antagonist 0.1.0.0 → 0.1.0.1
raw patch · 6 files changed
+116/−3 lines, 6 files
Files
- antagonist.cabal +2/−1
- home.htm +5/−0
- play.cass +30/−0
- play.htm +5/−0
- play.js +72/−0
- server/Web/Antagonist/Server.hs +2/−2
antagonist.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.0+version: 0.1.0.1 -- A short (one-line) description of the package. synopsis: A web interface to Antisplice dungeons.@@ -40,6 +40,7 @@ -- Extra files to be distributed with the package, such as examples or a -- README.+extra-source-files: home.htm, play.htm, play.cass, play.js -- Constraint on the version of Cabal needed to build this package. cabal-version: >=1.10
+ home.htm view
@@ -0,0 +1,5 @@+<h1>Hi, welcome to Antisplice-Web+<p>+ Feel free to start #+ <a href=@{SubsiteR PlayR}> playing+ \ ;)
+ play.cass view
@@ -0,0 +1,30 @@+*+ margin: 0px+ background-color: black+#cons+ background-color: black+ display: block;+ color: #909090+ margin: 0px+ padding: 0px+ overflow-y: scroll+ position: absolute+ left: 0px+ right: 0px+ bottom: 2em+ top: 0px+ font-family: monospace+#pw+ width: 100%+ position: fixed;+ bottom: 0px;+ left: 0px;+ font-family: monospace+#prom+ color: white+ vertical-align: center+ left: 0px+#inp+ background-color: white+.time+ color: #606060
+ play.htm view
@@ -0,0 +1,5 @@+<span #cons>+<span #pw>+ <span #prom>+ Loading...+ <input type=text #inp>
+ play.js view
@@ -0,0 +1,72 @@+function getNews()+{+ var req = mkRequestor();+ req.open("POST","@{toMaster NewsR}",true);+ req.setRequestHeader("Accept","application/json");+ req.send();+ window.setTimeout("getNews()",500);+}+getNews();+function postLine(line) {+ var req = mkRequestor();+ req.open("POST","@{toMaster PutR}",true);+ req.setRequestHeader("Accept","application/json");+ req.setRequestHeader("Content-type","application/x-www-form-urlencoded");+ req.send("line="+encodeURIComponent(line));+}+function mkRequestor() {+ var req;+ if (window.XMLHttpRequest)+ {+ req=new XMLHttpRequest();+ }+ else+ {+ req=new ActiveXObject("Microsoft.XMLHTTP");+ }+ req.onreadystatechange=function()+ {+ if (req.readyState==4 && req.status==200)+ {+ var res = eval("("+req.responseText+")");+ if (res.news != "") {+ var cons = document.getElementById("cons");+ cons.innerHTML+=res.news;+ cons.scrollTop = cons.scrollHeight;+ }+ document.getElementById("prom").textContent = res.prompt;+ fixwidth();+ }+ }+ return req;+}+var hist = new Array();+var histIdx = -1;+function keypress(e){+ if (!e) e = window.event;+ var keyCode = e.keyCode || e.which;+ var inp = document.getElementById("inp");+ if (keyCode == '13'){ // enter+ postLine(inp.value);+ if (inp.value != "" && (hist.length == 0 || hist[0] != inp.value))+ hist.unshift(inp.value);+ histIdx = -1;+ inp.value = "";+ } else if (keyCode == '38') { // up+ if ((histIdx+1) < hist.length) {+ histIdx++;+ inp.value = hist[histIdx];+ }+ } else if (keyCode == '40') { // down+ if (histIdx >= 0) {+ histIdx--;+ if (histIdx >= 0) inp.value = hist[histIdx];+ else inp.value = "";+ }+ }+}+document.getElementById("inp").onkeypress = keypress;+function fixwidth() {+ document.getElementById("inp").style.width = (window.innerWidth - document.getElementById("prom").offsetWidth - 12)+"px";+}+fixwidth();
server/Web/Antagonist/Server.hs view
@@ -77,8 +77,8 @@ lift $ defaultLayout $ do setTitle $ toHtml [lt| Session #{show ssid}|] toWidget $(hamletFile "play.htm")- toWidget $(cassiusFileReload "play.cass")- toWidget $(juliusFileReload "play.js")+ toWidget $(cassiusFile "play.cass")+ toWidget $(juliusFile "play.js") postNewsR :: Yesod master => HandlerT SingleUserSub (HandlerT master IO) Value postNewsR = do