Mercurial > hg > rlgwebd
comparison rlgterm.js @ 92:a4d3ecf188b7
RLG-Web client: replace setTitle() with message().
Remove the title line, and make setTitle() add a message instead.
Also remove setTitle() from termemu.js, because shterm.js duplicates
the code.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Tue, 10 Jul 2012 18:39:36 -0700 |
parents | e07f98799120 |
children | 104409bf5f03 |
comparison
equal
deleted
inserted
replaced
91:e07f98799120 | 92:a4d3ecf188b7 |
---|---|
383 } | 383 } |
384 | 384 |
385 function setup() { | 385 function setup() { |
386 keyHexCodes.init(); | 386 keyHexCodes.init(); |
387 termemu.init("termwrap", 24, 80); | 387 termemu.init("termwrap", 24, 80); |
388 setTitle("Not connected."); | |
389 setmode("login"); | 388 setmode("login"); |
390 /* Set up the text size. */ | 389 /* Set up the text size. */ |
391 var cssSize = termemu.view.style.fontSize; | 390 var cssSize = termemu.view.style.fontSize; |
392 var match = cssSize.match(/\d*/); | 391 var match = cssSize.match(/\d*/); |
393 if (!match) { | 392 if (!match) { |
443 var reply = JSON.parse(req.responseText); | 442 var reply = JSON.parse(req.responseText); |
444 if (reply.t == 'l') { | 443 if (reply.t == 'l') { |
445 /* Success */ | 444 /* Success */ |
446 session.lcred = reply.k; | 445 session.lcred = reply.k; |
447 session.lname = reply.u; | 446 session.lname = reply.u; |
448 setTitle("Logged in as " + reply.u); | |
449 debug(0, "Logged in as " + reply.u + " with id " + reply.k); | 447 debug(0, "Logged in as " + reply.u + " with id " + reply.k); |
450 message("You are now logged in as " + reply.u + "."); | 448 message("You are now logged in as " + reply.u + "."); |
451 setmode("choose"); | 449 setmode("choose"); |
452 } | 450 } |
453 else if (reply.t == 'E') { | 451 else if (reply.t == 'E') { |
621 if (reply.t == 's') { | 619 if (reply.t == 's') { |
622 /* Success */ | 620 /* Success */ |
623 session.id = reply.id; | 621 session.id = reply.id; |
624 session.playing = true; | 622 session.playing = true; |
625 termemu.resize(reply.h, reply.w); | 623 termemu.resize(reply.h, reply.w); |
626 setTitle("Playing as " + session.lname); | |
627 debug(1, "Playing with id " + session.id); | 624 debug(1, "Playing with id " + session.id); |
628 message("You are now playing " + game.name + "."); | 625 message("You are now playing " + game.name + "."); |
629 setmode("play"); | 626 setmode("play"); |
630 getData(); | 627 getData(); |
631 } | 628 } |
657 session.id = reply.id; | 654 session.id = reply.id; |
658 session.playing = false; | 655 session.playing = false; |
659 termemu.resize(reply.h, reply.w); | 656 termemu.resize(reply.h, reply.w); |
660 termemu.reset(); | 657 termemu.reset(); |
661 termemu.toAltBuf(); | 658 termemu.toAltBuf(); |
662 setTitle("Watching"); | |
663 debug(1, "Watching with id " + session.id); | 659 debug(1, "Watching with id " + session.id); |
664 var pname = reply.p; | 660 var pname = reply.p; |
665 var gname = games[reply.g].name; | 661 var gname = games[reply.g].name; |
666 message("You are now watching " + pname + " play " + gname + "."); | 662 message("You are now watching " + pname + " play " + gname + "."); |
667 setmode("watch"); | 663 setmode("watch"); |
703 /* Success */ | 699 /* Success */ |
704 debug(1, "Registered account: " + reply.u); | 700 debug(1, "Registered account: " + reply.u); |
705 message("Welcome " + reply.u + ", you are now registered."); | 701 message("Welcome " + reply.u + ", you are now registered."); |
706 session.lcred = reply.k; | 702 session.lcred = reply.k; |
707 session.lname = reply.u; | 703 session.lname = reply.u; |
708 setTitle("Logged in as " + session.lname); | |
709 debug(1, "Logged in as " + session.lname + " with id " + session.lcred); | 704 debug(1, "Logged in as " + session.lname + " with id " + session.lcred); |
710 message("You are now logged in as " + reply.u + "."); | 705 message("You are now logged in as " + reply.u + "."); |
711 setmode("choose"); | 706 setmode("choose"); |
712 } | 707 } |
713 else if (reply.t == 'E') { | 708 else if (reply.t == 'E') { |
732 else | 727 else |
733 message("Finished watching."); | 728 message("Finished watching."); |
734 session.id = null; | 729 session.id = null; |
735 session.playing = false; | 730 session.playing = false; |
736 ajaxstate.clear(); | 731 ajaxstate.clear(); |
737 setTitle("Game over."); | |
738 termemu.toNormBuf(); | 732 termemu.toNormBuf(); |
739 nsend = 0; | 733 nsend = 0; |
740 nrecv = 0; | 734 nrecv = 0; |
741 msgQ = []; | 735 msgQ = []; |
742 if (session.lcred != null) | 736 if (session.lcred != null) |
839 var msgdiv = document.createElement("div"); | 833 var msgdiv = document.createElement("div"); |
840 var msgtext = document.createTextNode(msg); | 834 var msgtext = document.createTextNode(msg); |
841 msgdiv.appendChild(msgtext); | 835 msgdiv.appendChild(msgtext); |
842 document.getElementById("debug").appendChild(msgdiv); | 836 document.getElementById("debug").appendChild(msgdiv); |
843 return; | 837 return; |
838 } | |
839 | |
840 function setTitle(tstr) { | |
841 message(tstr); | |
844 } | 842 } |
845 | 843 |
846 function textsize(larger) { | 844 function textsize(larger) { |
847 var cssSize = termemu.view.style.fontSize; | 845 var cssSize = termemu.view.style.fontSize; |
848 if (!cssSize) { | 846 if (!cssSize) { |