mirror of
https://github.com/myvesta/vesta
synced 2025-07-16 10:03:23 -07:00
JSON parser improved. Fixed problem with parsing special symbols
This commit is contained in:
parent
c80f12eaa4
commit
b472a367d5
6 changed files with 107 additions and 11 deletions
|
@ -15,6 +15,7 @@ App.Constants.DNS_FORM_ID = 'dns-form';
|
||||||
App.Constants.USER_FORM_ID = 'user-form';
|
App.Constants.USER_FORM_ID = 'user-form';
|
||||||
App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form';
|
App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form';
|
||||||
App.Constants.DB_FORM_ID = 'db-form';
|
App.Constants.DB_FORM_ID = 'db-form';
|
||||||
|
App.Constants.CRON_FORM_ID = 'cron-form';
|
||||||
|
|
||||||
App.Settings.ajax_url = 1;
|
App.Settings.ajax_url = 1;
|
||||||
App.Settings.uri = location.href.replace('index.html', '');
|
App.Settings.uri = location.href.replace('index.html', '');
|
||||||
|
|
|
@ -135,6 +135,7 @@ App.Actions.cancel_form = function(evt, params) {
|
||||||
$('#' + form_id).remove();
|
$('#' + form_id).remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
fb.warn(elm.find('.source').val());
|
||||||
var options = App.Helpers.evalJSON(elm.find('.source').val());
|
var options = App.Helpers.evalJSON(elm.find('.source').val());
|
||||||
var entry_name = App.Env.world.toLowerCase() + '_entry';
|
var entry_name = App.Env.world.toLowerCase() + '_entry';
|
||||||
var tpl = App.HTML.Build[entry_name](options);
|
var tpl = App.HTML.Build[entry_name](options);
|
||||||
|
|
|
@ -189,13 +189,15 @@ App.Ajax.request = function(jedi_method, data, callback)
|
||||||
type: data.request_method || "POST",
|
type: data.request_method || "POST",
|
||||||
data: $.extend(data, {'jedi_method': jedi_method}),
|
data: $.extend(data, {'jedi_method': jedi_method}),
|
||||||
dataType: "text",
|
dataType: "text",
|
||||||
async:true,
|
async: true,
|
||||||
success: function(reply)
|
success: function(reply)
|
||||||
{
|
{
|
||||||
timer.start();
|
reply = reply.replace(/\\'/gi, '');
|
||||||
|
reply = reply.replace(/\'/gi, '');
|
||||||
|
//timer.start();
|
||||||
callback && callback(jsonParse(reply));
|
callback && callback(jsonParse(reply));
|
||||||
App.Helpers.afterAjax();
|
App.Helpers.afterAjax();
|
||||||
timer.stop(jedi_method);
|
//timer.stop(jedi_method);
|
||||||
},
|
},
|
||||||
error: function()
|
error: function()
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,14 +123,17 @@ App.Helpers.getFirstValue = function(obj)
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Helpers.evalJSON = function(string)
|
App.Helpers.evalJSON = function(str)
|
||||||
{
|
{
|
||||||
return $.parseJSON(string);
|
/*str = str.replace(/\\'/gi, '');
|
||||||
|
str = str.replace(/\'/gi, '');
|
||||||
|
fb.warn(str);*/
|
||||||
|
return $.parseJSON(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Helpers.toJSON = function(object)
|
App.Helpers.toJSON = function(object)
|
||||||
{
|
{
|
||||||
return ($.toJSON(object).replace(/'/gi, ''));
|
return ($.toJSON(object).replace(/\\'/gi, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -357,6 +357,38 @@ App.HTML.Build.cron_entry = function(o, key)
|
||||||
|
|
||||||
return tpl.finalize();
|
return tpl.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
App.HTML.Build.cron_form = function(options, id)
|
||||||
|
{try{
|
||||||
|
if('undefined' == typeof App.Env.initialParams) {
|
||||||
|
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
|
||||||
|
}
|
||||||
|
var tpl = App.Templates.get('FORM', 'cron');
|
||||||
|
tpl.set(':source', options);
|
||||||
|
|
||||||
|
options = App.Helpers.evalJSON(options) || {};
|
||||||
|
if (App.Helpers.isEmpty(options)) {
|
||||||
|
tpl.set(':title', 'New cron entry');
|
||||||
|
tpl.set(':save_button', 'ADD');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tpl.set(':title', 'Edit cron entry');
|
||||||
|
tpl.set(':save_button', 'SAVE');
|
||||||
|
}
|
||||||
|
|
||||||
|
options = !App.Helpers.isEmpty(options) ? options : {DAY:'', MONTH: '', WDAY:'',HOUR:'',CMD:'',MIN:''};
|
||||||
|
tpl = App.HTML.setTplKeys(tpl, options);
|
||||||
|
|
||||||
|
/*tpl.set(':id', id || '');
|
||||||
|
tpl.set(':IP_ADDRESS', options.IP_ADDRESS || '');
|
||||||
|
tpl.set(':NETMASK', options.NETMASK || '');
|
||||||
|
tpl.set(':NAME', options.NAME || '');*/
|
||||||
|
|
||||||
|
//tpl = App.HTML.Build.ip_selects(tpl, options);
|
||||||
|
}catch(e){fb.error(e);}
|
||||||
|
return tpl.finalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
App.HTML.Build.dns_records = function(records)
|
App.HTML.Build.dns_records = function(records)
|
||||||
|
|
|
@ -44,7 +44,7 @@ App.Templates.html = {
|
||||||
dns: {
|
dns: {
|
||||||
FORM: [
|
FORM: [
|
||||||
'<div style="margin-top: 25px;" class="b-new-entry b-new-entry_dns" id="~!:id~!">\
|
'<div style="margin-top: 25px;" class="b-new-entry b-new-entry_dns" id="~!:id~!">\
|
||||||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
<input type="hidden" name="source" class="source" value=~!:source~!>\
|
||||||
<input type="hidden" name="target" class="target" value=\'\'>\
|
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||||
<div class="entry-header">~!:title~!</div>\
|
<div class="entry-header">~!:title~!</div>\
|
||||||
<div class="errors">\
|
<div class="errors">\
|
||||||
|
@ -86,8 +86,8 @@ App.Templates.html = {
|
||||||
],
|
],
|
||||||
ENTRIES_WRAPPER: ['<div class="dns-list items-list">~!:content~!</div>'],
|
ENTRIES_WRAPPER: ['<div class="dns-list items-list">~!:content~!</div>'],
|
||||||
ENTRY: ['<div class="row dns-details-row ~!:CHECKED~!">\
|
ENTRY: ['<div class="row dns-details-row ~!:CHECKED~!">\
|
||||||
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
<input type="hidden" name="source" class="source" value=~!:source~! />\
|
||||||
<input type="hidden" class="target" name="target" value="" />\
|
<input type="hidden" class="target" name="target" value=\'\' />\
|
||||||
<div class="row-actions-box cc">\
|
<div class="row-actions-box cc">\
|
||||||
<div class="check-this check-control"></div>\
|
<div class="check-this check-control"></div>\
|
||||||
<div class="row-operations">\
|
<div class="row-operations">\
|
||||||
|
@ -763,9 +763,66 @@ App.Templates.html = {
|
||||||
</div>']
|
</div>']
|
||||||
},
|
},
|
||||||
cron: {
|
cron: {
|
||||||
|
FORM: ['<div class="b-new-entry b-new-entry_cron">\
|
||||||
|
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||||
|
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||||
|
<div class="entry-header">~!:title~!</div>\
|
||||||
|
<div class="form-error">\
|
||||||
|
<div class="error-box">\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="form-row form-row-line run-at-box cc">\
|
||||||
|
<span class="row-header">run at:</span>\
|
||||||
|
<div class="field-box cron-minute-box">\
|
||||||
|
<label for="#" class="field-label">minute:<br>(0—59)</label>\
|
||||||
|
<div class="field-box-inner cc">\
|
||||||
|
<input type="text" value="~!:MIN~!" name="MIN" class="text-field">\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="field-box cron-hour-box">\
|
||||||
|
<label for="#" class="field-label">hour:<br>(0—23)</label>\
|
||||||
|
<div class="field-box-inner cc">\
|
||||||
|
<input type="text" value="~!:HOUR~!" name="HOUR" class="text-field">\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="field-box cron-day-box">\
|
||||||
|
<label for="#" class="field-label">day of Month:<br>(1—31)</label>\
|
||||||
|
<div class="field-box-inner cc">\
|
||||||
|
<input type="text" value="~!:DAY~!" name="DAY" class="text-field">\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="field-box cron-month-box">\
|
||||||
|
<label for="#" class="field-label">Month:<br>(1—12)(Jan—Dec)</label>\
|
||||||
|
<div class="field-box-inner cc">\
|
||||||
|
<input type="text" value="~!:MONTH~!" name="MONTH" class="text-field">\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="field-box cron-week-box">\
|
||||||
|
<label for="#" class="field-label">day of Week:<br>(1—7)(Sun—Sat)</label>\
|
||||||
|
<div class="field-box-inner cc">\
|
||||||
|
<input type="text" value="~!:WDAY~!" name="WDAY" class="text-field">\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="form-row cc">\
|
||||||
|
<label for="#" class="field-label">command:</label>\
|
||||||
|
<textarea class="textarea" name="CMD">~!:CMD~!</textarea>\
|
||||||
|
</div>\
|
||||||
|
<div class="form-row cc">\
|
||||||
|
<label for="#" class="field-label">report to: <span class="remark">(devide by comma ",")</span></label>\
|
||||||
|
<textarea class="textarea"></textarea>\
|
||||||
|
</div>\
|
||||||
|
<div class="form-row buttons-row cc">\
|
||||||
|
<input type="submit" value="~!:save_button~!" class="add-entry-btn">\
|
||||||
|
<span class="cancel-btn do_action_cancel_form">Cancel</span>\
|
||||||
|
<a target="_blank" href="http://vestacp.com/docs/cron/" class="help-btn">Help</a>\
|
||||||
|
</div>\
|
||||||
|
</div>'],
|
||||||
ENTRIES_WRAPPER: ['<div class="db-list">~!:content~!</div>'],
|
ENTRIES_WRAPPER: ['<div class="db-list">~!:content~!</div>'],
|
||||||
ENTRY: ['<div class="row first-row cron-details-row">\
|
ENTRY: ['<div class="row first-row cron-details-row">\
|
||||||
<div class="row-actions-box cc">\
|
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
|
||||||
|
<input type="hidden" name="target" class="target" value=\'\'>\
|
||||||
|
<div class="row-actions-box cc">\
|
||||||
<div class="check-this check-control"></div>\
|
<div class="check-this check-control"></div>\
|
||||||
<div class="row-operations">\
|
<div class="row-operations">\
|
||||||
~!:SUSPENDED_TPL~!\
|
~!:SUSPENDED_TPL~!\
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue