AB.newSplash();
AB.splashHtml ( `
<h1> Password only Websocket boxes </h1>
A version of Websocket boxes that only certain users can join. <br>
You enter a password. You only join with users who enter the same password (not with all users of the World). <br>
The first user to run the World can enter any password! But other users must know what password they will use.
<p>
Enter password:
<input style='width:25vw;' maxlength='2000' NAME="p" id="p" VALUE='' >
<button onclick='start();' class=ab-normbutton >Start</button>
<p>
<div id=errordiv name=errordiv> </div> ` );
//--- start Socket -----------------------------------------------------
function start() // user has entered a password
{
var password = jQuery("input#p").val();
password = password.trim();
if ( ! alphanumeric ( password ) )
{
$("#errordiv").html( "<font color=red> <B> Error: Password must be alphanumeric. </b></font> " );
return;
}
// else we have a password, start the socket run with this password
AB.socketStart ( password );
AB.removeSplash();
}
function alphanumeric ( str ) // return if string is just alphanumeric
{
var rc = str.match(/^[0-9a-zA-Z]+$/); // start of line "[0-9a-zA-Z]+" end of line
if ( rc ) return true;
else return false;
}