actually using text area is a lot less stupid

pull/1120/head
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;
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;
}

View File

@ -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]);
if(isJSONClean(settings.results))
{
$('.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");
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 */

View File

@ -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>