Files
vgstation13/code/modules/html_interface/html_interface.js
NullQuery 9b9ee3d5f9 Revert Revert "HTML interface module (ported from old Hypatia Station branch)"
Code style: Modified the amount of indentation for lists as suggested by wild-billy.
2015-01-05 19:23:54 +01:00

45 lines
1.2 KiB
JavaScript

var is_loading = false;
var load_count = 0;
function onload()
{
if (!is_loading)
{
var count = ++load_count;
is_loading = true;
$("body").html("");
window.location.href = "byond://?src=" + hSrc + "&html_interface_action=onload";
// The request may fail which would prevent the player from refreshing the screen again. Try to detect this retry.
setTimeout(function()
{
if (count == load_count && is_loading && $("body").html() == "")
{
is_loading = false;
onload();
}
}, 500);
}
}
$(document).ready(function()
{
$(document).on("keydown", function(e)
{
if (!e.ctrlKey && e.which == 116)
{
e.preventDefault();
onload();
}
});
onload();
});
function fixText(text) { return text.replace(/ÿ/g, ""); }
function setTitle(new_title) { $("title").html(fixText(new_title)); $(window).trigger("onUpdateTitle"); }
function updateLayout(new_html) { $("body").html(fixText(new_html)); $(window).trigger("onUpdateLayout"); setTimeout(function(){ is_loading = false; }, 200); }
function updateContent(id, new_html) { $("#" + id).html(fixText(new_html)); $(window).trigger("onUpdateContent"); }