Last active
February 9, 2019 15:28
-
-
Save sellmair/7396432e3687a6037de07dc6359a0108 to your computer and use it in GitHub Desktop.
HEEELP
This file contains hidden or 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
if (typeof kotlin === 'undefined') { | |
throw new Error("Error loading module 'output'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'output'."); | |
} | |
var output = function (_, Kotlin) { | |
'use strict'; | |
var throwUPAE = Kotlin.throwUPAE; | |
var Unit = Kotlin.kotlin.Unit; | |
var IllegalStateException_init = Kotlin.kotlin.IllegalStateException_init; | |
var toString = Kotlin.toString; | |
var println = Kotlin.kotlin.io.println_s8jyv4$; | |
var equals = Kotlin.equals; | |
var messageElement; | |
function get_messageElement() { | |
if (messageElement == null) | |
return throwUPAE('messageElement'); | |
return messageElement; | |
} | |
function set_messageElement(messageElement_0) { | |
messageElement = messageElement_0; | |
} | |
function main$lambda(it) { | |
setupElements(); | |
queryMessage(); | |
return Unit; | |
} | |
function main() { | |
window.onload = main$lambda; | |
} | |
function setupElements() { | |
var tmp$; | |
tmp$ = document.getElementById('message'); | |
if (tmp$ == null) { | |
throw IllegalStateException_init(); | |
} | |
set_messageElement(tmp$); | |
} | |
function queryMessage$lambda$lambda() { | |
queryMessage(); | |
return Unit; | |
} | |
function queryMessage$lambda(closure$xhttp) { | |
return function () { | |
println('ready state: ' + toString(closure$xhttp.readyState)); | |
println(closure$xhttp.status); | |
println(closure$xhttp.responseText); | |
if (closure$xhttp.status == 200 && closure$xhttp.readyState == 4 || closure$xhttp.readyState == '4') { | |
onMessageText(closure$xhttp.responseText); | |
} | |
window.setTimeout(queryMessage$lambda$lambda, 5000); | |
}; | |
} | |
function queryMessage() { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.open('GET', 'http://localhost:8080/message', true); | |
xhttp.onreadystatechange = queryMessage$lambda(xhttp); | |
xhttp.send(); | |
} | |
function onMessageText(text) { | |
var tmp$; | |
var textBefore = (tmp$ = get_messageElement().textContent) != null ? tmp$ : ''; | |
get_messageElement().textContent = text; | |
if (!equals(textBefore, text)) { | |
playSound(); | |
} | |
} | |
function playSound() { | |
(new Audio('bell.mp3')).play(); | |
} | |
var package$io = _.io || (_.io = {}); | |
var package$sellmair = package$io.sellmair || (package$io.sellmair = {}); | |
var package$allediewas = package$sellmair.allediewas || (package$sellmair.allediewas = {}); | |
var package$display = package$allediewas.display || (package$allediewas.display = {}); | |
Object.defineProperty(package$display, 'messageElement', { | |
get: get_messageElement, | |
set: set_messageElement | |
}); | |
package$display.main = main; | |
main(); | |
Kotlin.defineModule('output', _); | |
return _; | |
}(typeof output === 'undefined' ? {} : output, kotlin); | |
//# sourceMappingURL=output.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment