comparison rlgterm.js @ 90:6c6a6e4f1e5b

RLG-Web client: distinguish playing and watching in UI. Don't show the keyboard when watching games, and display appropriate messages when playing or watching.
author John "Elwin" Edwards <elwin@sdf.org>
date Tue, 10 Jul 2012 13:53:38 -0700
parents 6145e1ea7ace
children e07f98799120
comparison
equal deleted inserted replaced
89:6145e1ea7ace 90:6c6a6e4f1e5b
660 termemu.reset(); 660 termemu.reset();
661 termemu.toAltBuf(); 661 termemu.toAltBuf();
662 setTitle("Watching"); 662 setTitle("Watching");
663 debug(1, "Watching with id " + session.id); 663 debug(1, "Watching with id " + session.id);
664 message("You are now watching."); 664 message("You are now watching.");
665 setmode("play"); 665 setmode("watch");
666 getData(); 666 getData();
667 } 667 }
668 else if (reply.t == 'E') { 668 else if (reply.t == 'E') {
669 debug(1, "Could not watch game " + gamenumber + ": " + reply.s); 669 debug(1, "Could not watch game " + gamenumber + ": " + reply.s);
670 message("The game could not be watched: " + reply.s); 670 message("The game could not be watched: " + reply.s);
723 723
724 function gameover() { 724 function gameover() {
725 if (session.id == null) 725 if (session.id == null)
726 return; 726 return;
727 /* TODO IFACE2 If the end was unexpected, tell player the game was saved. */ 727 /* TODO IFACE2 If the end was unexpected, tell player the game was saved. */
728 if (session.playing)
729 message("Finished playing.");
730 else
731 message("Finished watching.");
728 session.id = null; 732 session.id = null;
729 session.playing = false; 733 session.playing = false;
730 ajaxstate.clear(); 734 ajaxstate.clear();
731 setTitle("Game over."); 735 setTitle("Game over.");
732 termemu.toNormBuf(); 736 termemu.toNormBuf();
765 function setmode(mode, ev) { 769 function setmode(mode, ev) {
766 if (ev) 770 if (ev)
767 ev.preventDefault(); 771 ev.preventDefault();
768 if (mode == "play") { 772 if (mode == "play") {
769 document.getElementById("keyboard").style.display = "block"; 773 document.getElementById("keyboard").style.display = "block";
774 document.getElementById("playctl").style.display = "block";
770 document.getElementById("startgame").style.display = "none"; 775 document.getElementById("startgame").style.display = "none";
771 document.getElementById("login").style.display = "none"; 776 document.getElementById("login").style.display = "none";
772 document.getElementById("register").style.display = "none"; 777 document.getElementById("register").style.display = "none";
773 document.getElementById("current").style.display = "none"; 778 document.getElementById("current").style.display = "none";
774 } 779 }
775 if (mode == "choose") { 780 else if (mode == "watch") {
776 document.getElementById("keyboard").style.display = "none"; 781 document.getElementById("keyboard").style.display = "none";
782 document.getElementById("playctl").style.display = "block";
783 document.getElementById("startgame").style.display = "none";
784 document.getElementById("login").style.display = "none";
785 document.getElementById("register").style.display = "none";
786 document.getElementById("current").style.display = "none";
787 }
788 else if (mode == "choose") {
789 document.getElementById("keyboard").style.display = "none";
790 document.getElementById("playctl").style.display = "none";
777 document.getElementById("startgame").style.display = "block"; 791 document.getElementById("startgame").style.display = "block";
778 document.getElementById("login").style.display = "none"; 792 document.getElementById("login").style.display = "none";
779 document.getElementById("register").style.display = "none"; 793 document.getElementById("register").style.display = "none";
780 document.getElementById("current").style.display = "block"; 794 document.getElementById("current").style.display = "block";
781 getcurrent(); 795 getcurrent();
782 } 796 }
783 else if (mode == "login") { 797 else if (mode == "login") {
784 document.getElementById("keyboard").style.display = "none"; 798 document.getElementById("keyboard").style.display = "none";
799 document.getElementById("playctl").style.display = "none";
785 document.getElementById("startgame").style.display = "none"; 800 document.getElementById("startgame").style.display = "none";
786 document.getElementById("login").style.display = "block"; 801 document.getElementById("login").style.display = "block";
787 document.getElementById("register").style.display = "none"; 802 document.getElementById("register").style.display = "none";
788 document.getElementById("current").style.display = "block"; 803 document.getElementById("current").style.display = "block";
789 getcurrent(); 804 getcurrent();
790 } 805 }
791 else if (mode == "register") { 806 else if (mode == "register") {
792 document.getElementById("keyboard").style.display = "none"; 807 document.getElementById("keyboard").style.display = "none";
808 document.getElementById("playctl").style.display = "none";
793 document.getElementById("startgame").style.display = "none"; 809 document.getElementById("startgame").style.display = "none";
794 document.getElementById("login").style.display = "none"; 810 document.getElementById("login").style.display = "none";
795 document.getElementById("register").style.display = "block"; 811 document.getElementById("register").style.display = "block";
796 document.getElementById("current").style.display = "none"; 812 document.getElementById("current").style.display = "none";
797 } 813 }