parent
106661712d
commit
fc5ec1922a
|
@ -13,28 +13,18 @@ $(document).ready(function () {
|
||||||
|
|
||||||
socket.on('settings', function (settings) {
|
socket.on('settings', function (settings) {
|
||||||
|
|
||||||
/* Check to make sure the JSON is clean before proceeding */
|
// (removed JSON validation, cause it's not JSON!)
|
||||||
if(isJSONClean(settings.results))
|
$('.settings').append(settings.results);
|
||||||
{
|
$('.settings').focus();
|
||||||
$('.settings').append(settings.results);
|
$('.settings').autosize();
|
||||||
$('.settings').focus();
|
|
||||||
$('.settings').autosize();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
alert("YOUR JSON IS BAD AND YOU SHOULD FEEL BAD");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* When the admin clicks save Settings check the JSON then send the JSON back to the server */
|
/* When the admin clicks save Settings check the JSON then send the JSON back to the server */
|
||||||
$('#saveSettings').on('click', function(){
|
$('#saveSettings').on('click', function(){
|
||||||
var editedSettings = $('.settings').val();
|
var editedSettings = $('.settings').val();
|
||||||
if(isJSONClean(editedSettings)){
|
// (removed JSON validation, cause it's not JSON!)
|
||||||
// JSON is clean so emit it to the server
|
// emit it to the server
|
||||||
socket.emit("saveSettings", $('.settings').val());
|
socket.emit("saveSettings", $('.settings').val());
|
||||||
}else{
|
|
||||||
alert("YOUR JSON IS BAD AND YOU SHOULD FEEL BAD")
|
|
||||||
$('.settings').focus();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Tell Etherpad Server to restart */
|
/* Tell Etherpad Server to restart */
|
||||||
|
@ -51,20 +41,3 @@ $(document).ready(function () {
|
||||||
socket.emit("load"); // Load the JSON from the server
|
socket.emit("load"); // Load the JSON from the server
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue