Created
September 5, 2017 19:03
-
-
Save Pikachu920/6f4d4141c40555e65d2cfc10e10f459d 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> | |
!! <input type="text" name="message" placeholder="Message"><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 with path "/chat": | |
send back header "Content-type" with value "text/html" | |
send back join "<ul style=""list-style-type: none;"">", {chat::*} and "</ul>" with "" | |
stop request | |
on web request: | |
set {_post::*} to post vars | |
if {_post::*} is set: | |
if {_post::message} is set: | |
add getList("<li style=""list-style-type: none;"">%join ""<"" and ""b>"" with """"%%check [{_post::author} is """"] ? ""Anon"" : htmlEsc({_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