Mercurial > hg > rlgwebd
comparison rlgterm.js @ 97:8a748eac7c11
rlgterm.js: remove unnecessary debugging messages.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Wed, 11 Jul 2012 15:45:22 -0700 |
parents | 7bb634f6995c |
children | 3dbfdaf62623 |
comparison
equal
deleted
inserted
replaced
96:7bb634f6995c | 97:8a748eac7c11 |
---|---|
259 return; | 259 return; |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 function errHandler() { | 263 function errHandler() { |
264 //debug(1, "Server unavailable?"); | |
265 message("Unable to connect to the server.", "warn"); | 264 message("Unable to connect to the server.", "warn"); |
266 } | 265 } |
267 | 266 |
268 function sendback(str) { | 267 function sendback(str) { |
269 /* For responding to terminal queries. */ | 268 /* For responding to terminal queries. */ |
442 var reply = JSON.parse(req.responseText); | 441 var reply = JSON.parse(req.responseText); |
443 if (reply.t == 'l') { | 442 if (reply.t == 'l') { |
444 /* Success */ | 443 /* Success */ |
445 session.lcred = reply.k; | 444 session.lcred = reply.k; |
446 session.lname = reply.u; | 445 session.lname = reply.u; |
447 debug(0, "Logged in as " + reply.u + " with id " + reply.k); | |
448 message("You are now logged in as " + reply.u + "."); | 446 message("You are now logged in as " + reply.u + "."); |
449 setmode("choose"); | 447 setmode("choose"); |
450 } | 448 } |
451 else if (reply.t == 'E') { | 449 else if (reply.t == 'E') { |
452 debug(0, "Could not log in: " + reply.s); | |
453 var failmsg = "Logging in failed. "; | 450 var failmsg = "Logging in failed. "; |
454 if (reply.c == 2) | 451 if (reply.c == 2) |
455 failmsg += reply.s.match(/Invalid data: (.*)/)[1]; | 452 failmsg += reply.s.match(/Invalid data: (.*)/)[1]; |
456 else if (reply.c == 3) | 453 else if (reply.c == 3) |
457 failmsg += "The username or password was incorrect."; | 454 failmsg += "The username or password was incorrect."; |
626 if (reply.t == 's') { | 623 if (reply.t == 's') { |
627 /* Success */ | 624 /* Success */ |
628 session.id = reply.id; | 625 session.id = reply.id; |
629 session.playing = true; | 626 session.playing = true; |
630 termemu.resize(reply.h, reply.w); | 627 termemu.resize(reply.h, reply.w); |
631 debug(1, "Playing with id " + session.id); | |
632 message("You are now playing " + game.name + "."); | 628 message("You are now playing " + game.name + "."); |
633 setmode("play"); | 629 setmode("play"); |
634 getData(); | 630 getData(); |
635 } | 631 } |
636 else if (reply.t == 'E') { | 632 else if (reply.t == 'E') { |
637 debug(1, "Could not start game: " + reply.s); | |
638 if (reply.c == 1) { | 633 if (reply.c == 1) { |
639 logout(); | 634 logout(); |
640 message("The server forgot about you, please log in again.", "warn"); | 635 message("The server forgot about you, please log in again.", "warn"); |
641 } | 636 } |
642 else if (reply.c == 4) { | 637 else if (reply.c == 4) { |
672 session.id = reply.id; | 667 session.id = reply.id; |
673 session.playing = false; | 668 session.playing = false; |
674 termemu.resize(reply.h, reply.w); | 669 termemu.resize(reply.h, reply.w); |
675 termemu.reset(); | 670 termemu.reset(); |
676 termemu.toAltBuf(); | 671 termemu.toAltBuf(); |
677 debug(1, "Watching with id " + session.id); | |
678 var pname = reply.p; | 672 var pname = reply.p; |
679 var gname = games[reply.g].name; | 673 var gname = games[reply.g].name; |
680 message("You are now watching " + pname + " play " + gname + "."); | 674 message("You are now watching " + pname + " play " + gname + "."); |
681 setmode("watch"); | 675 setmode("watch"); |
682 getData(); | 676 getData(); |
683 } | 677 } |
684 else if (reply.t == 'E') { | 678 else if (reply.t == 'E') { |
685 debug(1, "Could not watch game " + gamenumber + ": " + reply.s); | |
686 message("The game could not be watched: " + reply.s, "warn"); | 679 message("The game could not be watched: " + reply.s, "warn"); |
687 getcurrent(); | 680 getcurrent(); |
688 } | 681 } |
689 }; | 682 }; |
690 req.open('POST', '/watch', true); | 683 req.open('POST', '/watch', true); |
713 if (req.readyState != 4 || req.status != 200) | 706 if (req.readyState != 4 || req.status != 200) |
714 return; | 707 return; |
715 var reply = JSON.parse(req.responseText); | 708 var reply = JSON.parse(req.responseText); |
716 if (reply.t == 'r') { | 709 if (reply.t == 'r') { |
717 /* Success */ | 710 /* Success */ |
718 debug(1, "Registered account: " + reply.u); | |
719 message("Welcome " + reply.u + ", you are now registered."); | 711 message("Welcome " + reply.u + ", you are now registered."); |
720 session.lcred = reply.k; | 712 session.lcred = reply.k; |
721 session.lname = reply.u; | 713 session.lname = reply.u; |
722 debug(1, "Logged in as " + session.lname + " with id " + session.lcred); | |
723 message("You are now logged in as " + reply.u + "."); | 714 message("You are now logged in as " + reply.u + "."); |
724 setmode("choose"); | 715 setmode("choose"); |
725 } | 716 } |
726 else if (reply.t == 'E') { | 717 else if (reply.t == 'E') { |
727 debug(1, "Could not register: " + reply.s); | |
728 var failmsg = "Registration failed."; | 718 var failmsg = "Registration failed."; |
729 if (reply.c == 2) { | 719 if (reply.c == 2) { |
730 var errdesc = reply.s.match(/Invalid data: (.*)/)[1]; | 720 var errdesc = reply.s.match(/Invalid data: (.*)/)[1]; |
731 if (errdesc.match(/No name/)) | 721 if (errdesc.match(/No name/)) |
732 failmsg += " You need to choose a name."; | 722 failmsg += " You need to choose a name."; |