diff options
author | johnyma22 <john@mclear.co.uk> | 2012-11-02 14:31:52 +0000 |
---|---|---|
committer | johnyma22 <john@mclear.co.uk> | 2012-11-02 14:31:52 +0000 |
commit | f6fa897a4eac1a98f6979965a1eab4a12a37c653 (patch) | |
tree | 122c47b3b2a2f60ef98514b2d3a802de968b23dc /src | |
parent | 89e38ed4c240d826e32eddc9f2b5794731b804ea (diff) | |
download | etherpad-lite-f6fa897a4eac1a98f6979965a1eab4a12a37c653.zip |
actually using text area is a lot less stupid
Diffstat (limited to 'src')
-rw-r--r-- | src/static/css/admin.css | 11 | ||||
-rw-r--r-- | src/static/js/admin/settings.js | 76 | ||||
-rw-r--r-- | src/templates/admin/settings.html | 6 |
3 files changed, 52 insertions, 41 deletions
diff --git a/src/static/css/admin.css b/src/static/css/admin.css index 45dae727..1c9e490a 100644 --- a/src/static/css/admin.css +++ b/src/static/css/admin.css @@ -120,10 +120,9 @@ td, th { padding: 2px;
overflow: auto;
}
-.settings pre{
- white-space: pre-wrap;
- white-space: -moz-pre-wrap;
- white-space: -pre-wrap;
- white-space: -o-pre-wrap;
- word-wrap: break-word;
+.settings {
+ margin-top:10px;
+ width:100%;
+ min-height:600px;
}
+
diff --git a/src/static/js/admin/settings.js b/src/static/js/admin/settings.js index 136b3a08..af5ec46f 100644 --- a/src/static/js/admin/settings.js +++ b/src/static/js/admin/settings.js @@ -123,44 +123,52 @@ $(document).ready(function () { }); */ - socket.on('settings', function (data) { - $('.settings').append(data.results); - $('.settings').sloppyForm(); // Turn JSON into Form + socket.on('settings', function (settings) { -/* $("#installed-plugins *").remove(); - for (plugin_name in data.results) { - if (plugin_name == "ep_etherpad-lite") continue; // Hack... - var plugin = data.results[plugin_name]; - var row = $("#installed-plugin-template").clone(); + /* Check to make sure the JSON is clean before proceeding */ - for (attr in plugin.package) { - row.find("." + attr).html(plugin.package[attr]); - } - $("#installed-plugins").append(row); + if(isJSONClean(settings.results)) + { + $('.settings').append(settings.results); } - updateHandlers(); -*/ + else{ + alert("YOUR JSON IS BAD AND YOU SHOULD FEEL BAD") + } + + $('#saveSettings').on('click', function(){ + var editedSettings = $('.settings').val(); + if(isJSONClean(editedSettings)){ + // JSON is clean so emit it to the server + }else{ + alert("YOUR JSON IS BAD AND YOU SHOULD FEEL BAD") + } + }); + + $('#restartEtherpad').on('click', function(){ + + }); + + }); socket.emit("load"); search(); }); - -/* A jQuery plugin to turn JSON strings into forms */ -(function($){ - $.fn.sloppyForm = function() { - return this.each(function() { - // Firstly get a clean object with comments stripped out - var settings = ($.parseJSON(JSON.minify($(this).text()))); - - // For each create form bla bla - - }); - }; -})(jQuery); - - +function isJSONClean(data){ + var cleanSettings = JSON.minify(data); + try{ + var response = jQuery.parseJSON(cleanSettings); + } + catch(e){ + return false; // the JSON failed to be parsed + } + if(typeof response !== 'object'){ + return false; + }else{ + return true; + } +} /* Strip crap out of JSON */ @@ -174,18 +182,18 @@ $(document).ready(function () { if (typeof global.JSON == "undefined" || !global.JSON) { global.JSON = {}; } - + global.JSON.minify = function(json) { - + var tokenizer = /"|(\/\*)|(\*\/)|(\/\/)|\n|\r/g, in_string = false, in_multiline_comment = false, in_singleline_comment = false, tmp, tmp2, new_str = [], ns = 0, from = 0, lc, rc ; - + tokenizer.lastIndex = 0; - + while (tmp = tokenizer.exec(json)) { lc = RegExp.leftContext; rc = RegExp.rightContext; @@ -197,7 +205,7 @@ $(document).ready(function () { new_str[ns++] = tmp2; } from = tokenizer.lastIndex; - + if (tmp[0] == "\"" && !in_multiline_comment && !in_singleline_comment) { tmp2 = lc.match(/(\\)*$/); if (!in_string || !tmp2 || (tmp2[0].length % 2) == 0) { // start of string with ", or unescaped " character found to end string diff --git a/src/templates/admin/settings.html b/src/templates/admin/settings.html index b3d6b32a..7a7cc6d6 100644 --- a/src/templates/admin/settings.html +++ b/src/templates/admin/settings.html @@ -20,7 +20,11 @@ <h1>Etherpad Lite Settings</h1>
- <div class="settings"></div>
+ <a href=''>Example production settings template</a>
+ <a href=''>Example development settings template</a>
+ <textarea class="settings"></textarea>
+ <input type="button" class="settingsButton" id="saveSettings" value="Save Settings">
+ <input type="button" class="settingsButton" id="restartEtherpad" value="Restart Etherpad">
</div>
</body>
</html>
|