actually using text area is a lot less stupid

This commit is contained in:
johnyma22 2012-11-02 14:31:52 +00:00
parent 89e38ed4c2
commit f6fa897a4e
3 changed files with 52 additions and 41 deletions

View file

@ -120,10 +120,9 @@ td, th {
padding: 2px; padding: 2px;
overflow: auto; overflow: auto;
} }
.settings pre{ .settings {
white-space: pre-wrap; margin-top:10px;
white-space: -moz-pre-wrap; width:100%;
white-space: -pre-wrap; min-height:600px;
white-space: -o-pre-wrap;
word-wrap: break-word;
} }

View file

@ -123,44 +123,52 @@ $(document).ready(function () {
}); });
*/ */
socket.on('settings', function (data) { socket.on('settings', function (settings) {
$('.settings').append(data.results);
$('.settings').sloppyForm(); // Turn JSON into Form
/* $("#installed-plugins *").remove(); /* Check to make sure the JSON is clean before proceeding */
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();
for (attr in plugin.package) { if(isJSONClean(settings.results))
row.find("." + attr).html(plugin.package[attr]); {
$('.settings').append(settings.results);
} }
$("#installed-plugins").append(row); else{
alert("YOUR JSON IS BAD AND YOU SHOULD FEEL BAD")
} }
updateHandlers();
*/ $('#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"); socket.emit("load");
search(); search();
}); });
function isJSONClean(data){
/* A jQuery plugin to turn JSON strings into forms */ var cleanSettings = JSON.minify(data);
(function($){ try{
$.fn.sloppyForm = function() { var response = jQuery.parseJSON(cleanSettings);
return this.each(function() { }
// Firstly get a clean object with comments stripped out catch(e){
var settings = ($.parseJSON(JSON.minify($(this).text()))); return false; // the JSON failed to be parsed
}
// For each create form bla bla if(typeof response !== 'object'){
return false;
}); }else{
}; return true;
})(jQuery); }
}
/* Strip crap out of JSON */ /* Strip crap out of JSON */

View file

@ -20,7 +20,11 @@
<h1>Etherpad Lite Settings</h1> <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> </div>
</body> </body>
</html> </html>