From d435f6b4fdd62a1cb08e5ac8d20309e0540b8c66 Mon Sep 17 00:00:00 2001 From: tschaub Date: Thu, 5 Jul 2012 13:55:24 -0600 Subject: [PATCH] Simplifying the loader. Plovr checks the referrer for query string parameters (like mode), so we don't need any of this query string parsing (thanks @elemoine for the tip). The reason we still dynamically generate the script tag is to work on other domains (e.g. testing on a VM or mobile device). In this case, we make use of the `window.location.hostname`. --- demo/loader.js | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/demo/loader.js b/demo/loader.js index 0b9230f5a5..8b01bc2322 100644 --- a/demo/loader.js +++ b/demo/loader.js @@ -1,36 +1,7 @@ /** - Adds the plovr generated script to the document. The following default - values may be overridden with query string parameters: - - * hostname - localhost - * port - 9810 - * mode - SIMPLE - * id - ol + Adds the plovr generated script to the document. */ (function() { - var search = window.location.search.substring(1); - var params = { - hostname: "localhost", - port: "9810", - mode: "SIMPLE", - id: "ol" - }; - var chunks = search.split("&"); - var pair; - for (var i=chunks.length-1; i>=0; --i) { - pair = chunks[i].split("="); - params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); - } - - var host = params.hostname + ":" + params.port; - delete params.hostname; - delete params.port; - - var pairs = []; - for (var key in params) { - pairs.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key])); - } - - var url = "http://" + host + "/compile?" + pairs.join("&"); + var url = "http://" + window.location.hostname + ":9810/compile?id=ol"; document.write(""); })();