App.HTML.setTplKeys = function(tpl, o, empty) { var empty = empty || '-'; fb.log(empty); tpl.set(':source', $.toJSON(o).replace(/'/gi, "\\'")) $(o).each(function(i, object) { $.each(o, function(key) { var val = o[key]; if (empty == true) { tpl.set(':' + key, val || ''); } else { tpl.set(':' + key, val || '-'); } }); }); return tpl; } App.HTML.makeDatabases = function(databases) { var acc = []; $(databases).each(function(i, o) { var tpl = App.Templates.get('database', 'database'); tpl.set(':name', o.Database); tpl.set(':db_name', o.Database); acc[acc.length++] = tpl.finalize(); }); return acc.done(); } App.HTML.makeDbTableList = function(data) { var acc = []; $(data).each(function(i, o) { var name = App.Helpers.getFirstValue(o); var tpl = App.Templates.get('database_table', 'database'); tpl.set(':name', name); tpl.set(':table_name', name); acc[acc.length++] = tpl.finalize(); }); return acc.done(); } App.HTML.makeDbFieldsList = function(data) { var acc = []; $(data).each(function(i, o) { var details = [o['Type'], o['Null'], o['Key'], o['Default'], o['Extra']].join(' '); var tpl = App.Templates.get('database_field', 'database'); tpl.set(':name', o.Field); tpl.set(':details', details); acc[acc.length++] = tpl.finalize(); }); return acc.done(); } App.HTML.Build.dns_form = function(options, id) { 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', 'dns'); tpl.set(':source', options); options = App.Helpers.evalJSON(options) || {}; if (App.Helpers.isEmpty(options)) { tpl.set(':title', 'New dns record'); tpl.set(':save_button', 'ADD'); } else { tpl.set(':title', 'Edit dns record'); tpl.set(':save_button', 'SAVE'); } tpl.set(':id', id || ''); tpl.set(':DNS_DOMAIN', options.DNS_DOMAIN || ''); tpl.set(':IP', options.IP || ''); tpl.set(':TTL', options.TTL || ''); tpl.set(':SOA', options.SOA || ''); tpl.set(':DATE', options.DATE || ''); tpl = App.HTML.Build.dns_selects(tpl, options); return tpl.finalize(); } App.HTML.Build.ip_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', 'ip'); tpl.set(':source', options); options = App.Helpers.evalJSON(options) || {}; if (App.Helpers.isEmpty(options)) { tpl.set(':title', 'New ip address'); tpl.set(':save_button', 'ADD'); } else { tpl.set(':title', 'Edit ip address'); tpl.set(':save_button', 'SAVE'); } 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.options = function(initial, default_value) { var opts = []; $.each(initial, function(key){ var selected = key == default_value ? 'selected="selected"' : ''; opts[opts.length++] = '