dynamic css loading

This commit is contained in:
Igor Shymko
2014-09-15 22:21:44 +03:00
parent 76bf5bcd5f
commit 2b6034b5c1
2 changed files with 22 additions and 3 deletions

View File

@@ -21,11 +21,18 @@
console.log('Code: ' + event.code + ' reason: ' + event.reason);
};
socket.onmessage = function(event) {
$("#markdown-body").html(event.data);
loadCSS($(event.data).find("#style").text());
$("#markdown-body").html($(event.data).find("#content").html());
};
socket.onerror = function(error) {
alert("Error: " + error.message);
};
loadCSS = function(href) {
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
$("link[type='text/css']").remove();
$("head").append(cssLink);
};
})(jQuery);
</script>
</head>