From 432ee7bc30be4c3310977288760515bb4d170cb7 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 12 Dec 2015 16:49:40 -0800 Subject: [PATCH] Add warning for inline CSS too large (fixes #538) --- www/js/ui.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/www/js/ui.js b/www/js/ui.js index 9b6aff0a..ccc62dfe 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -847,3 +847,25 @@ $("#fullscreenbtn").click(function () { fn.call(elem); } }); + +function handleCSSJSTooLarge(selector) { + if (this.value.length > 20000) { + var warning = $(selector); + if (warning.length > 0) { + return; + } + + warning = makeAlert("Maximum Size Exceeded", "Inline CSS and JavaScript are " + + "limited to 20,000 characters or less. If you need more room, you " + + "need to use the external CSS or JavaScript option.", "alert-danger") + .attr("id", selector.replace(/#/, "")); + warning.insertBefore(this); + } else { + $(selector).remove(); + } +} + +$("#cs-csstext").bind("input", handleCSSJSTooLarge.bind($("#cs-csstext")[0], + "#cs-csstext-too-big")); +$("#cs-jstext").bind("input", handleCSSJSTooLarge.bind($("#cs-jstext")[0], + "#cs-jstext-too-big"));