Skip to content

Commit b472a36

Browse files
committed
JSON parser improved. Fixed problem with parsing special symbols
1 parent c80f12e commit b472a36

File tree

6 files changed

+107
-11
lines changed

6 files changed

+107
-11
lines changed

web/js/_settings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ App.Constants.DNS_FORM_ID = 'dns-form';
1515
App.Constants.USER_FORM_ID = 'user-form';
1616
App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form';
1717
App.Constants.DB_FORM_ID = 'db-form';
18+
App.Constants.CRON_FORM_ID = 'cron-form';
1819

1920
App.Settings.ajax_url = 1;
2021
App.Settings.uri = location.href.replace('index.html', '');

web/js/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ App.Actions.cancel_form = function(evt, params) {
135135
$('#' + form_id).remove();
136136
}
137137
else {
138+
fb.warn(elm.find('.source').val());
138139
var options = App.Helpers.evalJSON(elm.find('.source').val());
139140
var entry_name = App.Env.world.toLowerCase() + '_entry';
140141
var tpl = App.HTML.Build[entry_name](options);

web/js/app.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,15 @@ App.Ajax.request = function(jedi_method, data, callback)
189189
type: data.request_method || "POST",
190190
data: $.extend(data, {'jedi_method': jedi_method}),
191191
dataType: "text",
192-
async:true,
192+
async: true,
193193
success: function(reply)
194194
{
195-
timer.start();
195+
reply = reply.replace(/\\'/gi, '');
196+
reply = reply.replace(/\'/gi, '');
197+
//timer.start();
196198
callback && callback(jsonParse(reply));
197199
App.Helpers.afterAjax();
198-
timer.stop(jedi_method);
200+
//timer.stop(jedi_method);
199201
},
200202
error: function()
201203
{

web/js/helpers.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,17 @@ App.Helpers.getFirstValue = function(obj)
123123
return first;
124124
}
125125

126-
App.Helpers.evalJSON = function(string)
126+
App.Helpers.evalJSON = function(str)
127127
{
128-
return $.parseJSON(string);
128+
/*str = str.replace(/\\'/gi, '');
129+
str = str.replace(/\'/gi, '');
130+
fb.warn(str);*/
131+
return $.parseJSON(str);
129132
}
130133

131134
App.Helpers.toJSON = function(object)
132-
{
133-
return ($.toJSON(object).replace(/'/gi, ''));
135+
{
136+
return ($.toJSON(object).replace(/\\'/gi, ''));
134137
}
135138

136139

web/js/html.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,38 @@ App.HTML.Build.cron_entry = function(o, key)
357357

358358
return tpl.finalize();
359359
}
360+
361+
362+
App.HTML.Build.cron_form = function(options, id)
363+
{try{
364+
if('undefined' == typeof App.Env.initialParams) {
365+
return alert('PLease wait a bit. Some background processes are not yet executed. Thank you for patience.');
366+
}
367+
var tpl = App.Templates.get('FORM', 'cron');
368+
tpl.set(':source', options);
369+
370+
options = App.Helpers.evalJSON(options) || {};
371+
if (App.Helpers.isEmpty(options)) {
372+
tpl.set(':title', 'New cron entry');
373+
tpl.set(':save_button', 'ADD');
374+
}
375+
else {
376+
tpl.set(':title', 'Edit cron entry');
377+
tpl.set(':save_button', 'SAVE');
378+
}
379+
380+
options = !App.Helpers.isEmpty(options) ? options : {DAY:'', MONTH: '', WDAY:'',HOUR:'',CMD:'',MIN:''};
381+
tpl = App.HTML.setTplKeys(tpl, options);
382+
383+
/*tpl.set(':id', id || '');
384+
tpl.set(':IP_ADDRESS', options.IP_ADDRESS || '');
385+
tpl.set(':NETMASK', options.NETMASK || '');
386+
tpl.set(':NAME', options.NAME || '');*/
387+
388+
//tpl = App.HTML.Build.ip_selects(tpl, options);
389+
}catch(e){fb.error(e);}
390+
return tpl.finalize();
391+
}
360392

361393

362394
App.HTML.Build.dns_records = function(records)

web/js/templates.js

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ App.Templates.html = {
4444
dns: {
4545
FORM: [
4646
'<div style="margin-top: 25px;" class="b-new-entry b-new-entry_dns" id="~!:id~!">\
47-
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
47+
<input type="hidden" name="source" class="source" value=~!:source~!>\
4848
<input type="hidden" name="target" class="target" value=\'\'>\
4949
<div class="entry-header">~!:title~!</div>\
5050
<div class="errors">\
@@ -86,8 +86,8 @@ App.Templates.html = {
8686
],
8787
ENTRIES_WRAPPER: ['<div class="dns-list items-list">~!:content~!</div>'],
8888
ENTRY: ['<div class="row dns-details-row ~!:CHECKED~!">\
89-
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
90-
<input type="hidden" class="target" name="target" value="" />\
89+
<input type="hidden" name="source" class="source" value=~!:source~! />\
90+
<input type="hidden" class="target" name="target" value=\'\' />\
9191
<div class="row-actions-box cc">\
9292
<div class="check-this check-control"></div>\
9393
<div class="row-operations">\
@@ -763,9 +763,66 @@ App.Templates.html = {
763763
</div>']
764764
},
765765
cron: {
766+
FORM: ['<div class="b-new-entry b-new-entry_cron">\
767+
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
768+
<input type="hidden" name="target" class="target" value=\'\'>\
769+
<div class="entry-header">~!:title~!</div>\
770+
<div class="form-error">\
771+
<div class="error-box">\
772+
</div>\
773+
</div>\
774+
<div class="form-row form-row-line run-at-box cc">\
775+
<span class="row-header">run at:</span>\
776+
<div class="field-box cron-minute-box">\
777+
<label for="#" class="field-label">minute:<br>(0&mdash;59)</label>\
778+
<div class="field-box-inner cc">\
779+
<input type="text" value="~!:MIN~!" name="MIN" class="text-field">\
780+
</div>\
781+
</div>\
782+
<div class="field-box cron-hour-box">\
783+
<label for="#" class="field-label">hour:<br>(0&mdash;23)</label>\
784+
<div class="field-box-inner cc">\
785+
<input type="text" value="~!:HOUR~!" name="HOUR" class="text-field">\
786+
</div>\
787+
</div>\
788+
<div class="field-box cron-day-box">\
789+
<label for="#" class="field-label">day of Month:<br>(1&mdash;31)</label>\
790+
<div class="field-box-inner cc">\
791+
<input type="text" value="~!:DAY~!" name="DAY" class="text-field">\
792+
</div>\
793+
</div>\
794+
<div class="field-box cron-month-box">\
795+
<label for="#" class="field-label">Month:<br>(1&mdash;12)(Jan&mdash;Dec)</label>\
796+
<div class="field-box-inner cc">\
797+
<input type="text" value="~!:MONTH~!" name="MONTH" class="text-field">\
798+
</div>\
799+
</div>\
800+
<div class="field-box cron-week-box">\
801+
<label for="#" class="field-label">day of Week:<br>(1&mdash;7)(Sun&mdash;Sat)</label>\
802+
<div class="field-box-inner cc">\
803+
<input type="text" value="~!:WDAY~!" name="WDAY" class="text-field">\
804+
</div>\
805+
</div>\
806+
</div>\
807+
<div class="form-row cc">\
808+
<label for="#" class="field-label">command:</label>\
809+
<textarea class="textarea" name="CMD">~!:CMD~!</textarea>\
810+
</div>\
811+
<div class="form-row cc">\
812+
<label for="#" class="field-label">report to: <span class="remark">(devide by comma ",")</span></label>\
813+
<textarea class="textarea"></textarea>\
814+
</div>\
815+
<div class="form-row buttons-row cc">\
816+
<input type="submit" value="~!:save_button~!" class="add-entry-btn">\
817+
<span class="cancel-btn do_action_cancel_form">Cancel</span>\
818+
<a target="_blank" href="http://vestacp.com/docs/cron/" class="help-btn">Help</a>\
819+
</div>\
820+
</div>'],
766821
ENTRIES_WRAPPER: ['<div class="db-list">~!:content~!</div>'],
767822
ENTRY: ['<div class="row first-row cron-details-row">\
768-
<div class="row-actions-box cc">\
823+
<input type="hidden" name="source" class="source" value=\'~!:source~!\'>\
824+
<input type="hidden" name="target" class="target" value=\'\'>\
825+
<div class="row-actions-box cc">\
769826
<div class="check-this check-control"></div>\
770827
<div class="row-operations">\
771828
~!:SUSPENDED_TPL~!\

0 commit comments

Comments
 (0)