Created
September 5, 2017 04:30
-
-
Save Pikachu920/81421b7472c4675b989f14cde11c1150 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function htmlEsc(html: string) :: string: | |
return "%{HtmlEscapers}.htmlEscaper().escape({_html})%" | |
on script load: | |
start web server on port 80 if not already started | |
function getList(string: string) :: string: | |
return "<li style=""list-style-type: none;"">%{_string}%</li>" | |
on web request: | |
if requested path is "/" or "/action_page.php": | |
send back header "Content-type" with value "text/html" | |
!! <center><b>Skript Chat Room</b></center> | |
!! <form action="/action_page.php"> | |
!! Username: <br> | |
!! <input type="text" name="author" placeholder="Anon"><br> | |
!! <br> | |
!! <input type="text" name="message" placeholder="Message"><br><br> | |
!! <input type="submit" value="Send"> | |
!! </form> | |
!! <iframe id="chat" src="/chat" width="100%%" height="100%%"></iframe> | |
!! <script>setInterval(function(){document.getElementById('chat').contentWindow.location.reload(true);}, 2000)</script> | |
send back multiline string | |
stop request | |
on web request: | |
if requested path is "/chat": | |
send back header "Content-type" with value "text/html" | |
!! <ul style="list-style-type: none;"> | |
add multiline string to {_r::*} | |
loop {chat::*}: | |
add loop-value to {_r::*} | |
send back join {_r::*} and "</ul>" with "" | |
stop request | |
on web request: | |
set {_post::*} to post vars | |
if {_post::*} is set: | |
if {_post::message} is set: | |
add getList("%join ""<"" and ""b>"" with """"%%check [{_post::author} is """"] ? ""Anon"" : {_post::author}%:</b> %htmlEsc({_post::message})%<br>") to {chat::*} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment