From 33c065c0984fc8417e07eae0cc14a4faa758ba76 Mon Sep 17 00:00:00 2001 From: Malishev Dima Date: Tue, 21 Jun 2011 18:23:59 +0300 Subject: [PATCH] Cleaned + Formatted + Partly-Commented up js code --- web/js/old/.svn/entries | 572 ------------------ .../old/.svn/text-base/__init__.js.svn-base | 18 - .../old/.svn/text-base/_settings.js.svn-base | 22 - web/js/old/.svn/text-base/actions.js.svn-base | 68 --- web/js/old/.svn/text-base/app.js.svn-base | 116 ---- web/js/old/.svn/text-base/bash.js.svn-base | 4 - web/js/old/.svn/text-base/console.js.svn-base | 7 - web/js/old/.svn/text-base/core.js.svn-base | 79 --- web/js/old/.svn/text-base/helpers.js.svn-base | 122 ---- web/js/old/.svn/text-base/html.js.svn-base | 186 ------ web/js/old/.svn/text-base/model.js.svn-base | 52 -- web/js/old/.svn/text-base/pages.js.svn-base | 103 ---- .../old/.svn/text-base/parsers.js.js.svn-base | 0 web/js/old/.svn/text-base/ref.js.svn-base | 4 - .../old/.svn/text-base/templates.js.svn-base | 295 --------- .../old/.svn/text-base/validators.js.svn-base | 13 - web/js/old/.svn/text-base/view.js.svn-base | 80 --- web/js/old/__init__.js | 18 - web/js/old/_settings.js | 22 - web/js/old/actions.js | 68 --- web/js/old/app.js | 116 ---- web/js/old/bash.js | 4 - web/js/old/console.js | 7 - web/js/old/core.js | 79 --- web/js/old/helpers.js | 122 ---- web/js/old/html.js | 186 ------ web/js/old/model.js | 52 -- web/js/old/pages.js | 103 ---- web/js/old/parsers.js.js | 0 web/js/old/ref.js | 4 - web/js/old/templates.js | 295 --------- web/js/old/validators.js | 13 - web/js/old/view.js | 80 --- web/js/tricks.js | 62 ++ 34 files changed, 62 insertions(+), 2910 deletions(-) delete mode 100644 web/js/old/.svn/entries delete mode 100644 web/js/old/.svn/text-base/__init__.js.svn-base delete mode 100644 web/js/old/.svn/text-base/_settings.js.svn-base delete mode 100644 web/js/old/.svn/text-base/actions.js.svn-base delete mode 100644 web/js/old/.svn/text-base/app.js.svn-base delete mode 100644 web/js/old/.svn/text-base/bash.js.svn-base delete mode 100644 web/js/old/.svn/text-base/console.js.svn-base delete mode 100644 web/js/old/.svn/text-base/core.js.svn-base delete mode 100644 web/js/old/.svn/text-base/helpers.js.svn-base delete mode 100644 web/js/old/.svn/text-base/html.js.svn-base delete mode 100644 web/js/old/.svn/text-base/model.js.svn-base delete mode 100644 web/js/old/.svn/text-base/pages.js.svn-base delete mode 100644 web/js/old/.svn/text-base/parsers.js.js.svn-base delete mode 100644 web/js/old/.svn/text-base/ref.js.svn-base delete mode 100644 web/js/old/.svn/text-base/templates.js.svn-base delete mode 100644 web/js/old/.svn/text-base/validators.js.svn-base delete mode 100644 web/js/old/.svn/text-base/view.js.svn-base delete mode 100644 web/js/old/__init__.js delete mode 100644 web/js/old/_settings.js delete mode 100644 web/js/old/actions.js delete mode 100644 web/js/old/app.js delete mode 100644 web/js/old/bash.js delete mode 100644 web/js/old/console.js delete mode 100644 web/js/old/core.js delete mode 100644 web/js/old/helpers.js delete mode 100644 web/js/old/html.js delete mode 100644 web/js/old/model.js delete mode 100644 web/js/old/pages.js delete mode 100644 web/js/old/parsers.js.js delete mode 100644 web/js/old/ref.js delete mode 100644 web/js/old/templates.js delete mode 100644 web/js/old/validators.js delete mode 100644 web/js/old/view.js create mode 100644 web/js/tricks.js diff --git a/web/js/old/.svn/entries b/web/js/old/.svn/entries deleted file mode 100644 index caa89407c..000000000 --- a/web/js/old/.svn/entries +++ /dev/null @@ -1,572 +0,0 @@ -10 - -dir -86 -svn://svn.vestacp.com/vesta/trunk/web/js/old -svn://svn.vestacp.com/vesta - - - -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - -32c52990-e6da-4f1f-8224-85171b9c7084 - -html.js -file - - - - -2011-05-21T09:49:42.000000Z -a8b4e2cf6b1924b2ae78745a3af73f41 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -5834 - -validators.js -file - - - - -2011-05-21T09:49:42.000000Z -9e501064573a57df29bbc3511cb46f32 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -207 - -view.js -file - - - - -2011-05-21T09:49:42.000000Z -66fda7fa58a7ea1490349bac3cf8a673 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -2307 - -ref.js -file - - - - -2011-05-21T09:49:42.000000Z -319d35f2c09ba860c63b5ae1c96e3baf -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -134 - -bash.js -file - - - - -2011-05-21T09:49:42.000000Z -b371668a5c21c10ca54388a4c99461ee -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -51 - -app.js -file - - - - -2011-05-21T09:49:42.000000Z -c6f8905f07a63fffd13dfd1c06331c34 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -2342 - -core.js -file - - - - -2011-05-21T09:49:42.000000Z -da707792a45bd518882aea03ff4d22b6 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -2402 - -parsers.js.js -file - - - - -2011-05-21T09:49:42.000000Z -d41d8cd98f00b204e9800998ecf8427e -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -0 - -templates.js -file - - - - -2011-05-21T09:49:42.000000Z -de7af99c9093d093485937c4d82151ae -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -16758 - -pages.js -file - - - - -2011-05-21T09:49:42.000000Z -6fd61d44fad269e9161388746b8e398b -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -2917 - -_settings.js -file - - - - -2011-05-21T09:49:42.000000Z -17c8540a4b10e60ee3e395aa8d511c33 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -711 - -__init__.js -file - - - - -2011-05-21T09:49:42.000000Z -eb2b5c743a71de5a9e6ff282a552ce86 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -280 - -model.js -file - - - - -2011-05-21T09:49:42.000000Z -fb84f0c6fcd6496bb49b6ae0b5cacbc7 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -1296 - -actions.js -file - - - - -2011-05-21T09:49:42.000000Z -ddb0654ab959b30bbaebf1b1d24a11f5 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -1985 - -helpers.js -file - - - - -2011-05-21T09:49:42.000000Z -92749d285ffc43d743cf732ee2f28634 -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -2680 - -console.js -file - - - - -2011-05-21T09:49:42.000000Z -7d7f042683f6369754dc1500e0d3f6fd -2011-05-21T11:21:12.984820Z -69 -twi - - - - - - - - - - - - - - - - - - - - - -147 - diff --git a/web/js/old/.svn/text-base/__init__.js.svn-base b/web/js/old/.svn/text-base/__init__.js.svn-base deleted file mode 100644 index b64a456c9..000000000 --- a/web/js/old/.svn/text-base/__init__.js.svn-base +++ /dev/null @@ -1,18 +0,0 @@ -$(document).ready(function(){ - try{ - App.Utils.detectBrowser(); - - App.Env.world = 'DNS'; - App.Pages.init(); - - App.Ref.init(); - - App.View.start(); - App.Core.listen(); - App.Core.initMenu(); - - }catch(e){ - fb.error(e); - } -}); - diff --git a/web/js/old/.svn/text-base/_settings.js.svn-base b/web/js/old/.svn/text-base/_settings.js.svn-base deleted file mode 100644 index 4fba19dae..000000000 --- a/web/js/old/.svn/text-base/_settings.js.svn-base +++ /dev/null @@ -1,22 +0,0 @@ -// Constants -App.Constants.IP_FORM_ID = 'ip-form'; -App.Constants.DNS_FORM_ID = 'dns-form'; - -App.Settings.ajax_url = 1; -App.Settings.uri = location.href.replace('index.html', ''); -App.Settings.popup_conf = { 'centered' : true, 'bgcolor' : '#FF0000', 'lightboxSpeed' : 'fast', 'destroyOnClose': true }; - -App.Constants.SUSPENDED_YES = 'yes'; - -App.Constants.IP = 'IP'; -App.Constants.DNS = 'DNS'; - -App.Constants.DNS_TEMPLATES = {'default': 'Default'}; - -App.Messages.total_dns_records = {single: 'total record', plural: 'total records'}; - -App.Messages.get = function(key, plural) { - if ('undefined' != typeof App.Messages[key]) { - return plural ? App.Messages[key].plural : App.Messages[key].single; - } -} \ No newline at end of file diff --git a/web/js/old/.svn/text-base/actions.js.svn-base b/web/js/old/.svn/text-base/actions.js.svn-base deleted file mode 100644 index f3ad225da..000000000 --- a/web/js/old/.svn/text-base/actions.js.svn-base +++ /dev/null @@ -1,68 +0,0 @@ -App.Actions.cancel_ip_form = function(){ - alert(1); -} - -/** - * Embeds new item form - * if exits custom method (App.Pages[ENVIRONMENT_NAME].newForm) - * custom method will be executes instead of default one - */ -App.Actions.newForm = function() { - if ('undefined' != typeof App.Pages[App.Env.world].newForm) { - App.Pages[App.Env.world].newForm(); - } else { - var form_id = App.Constants[App.Env.world + '_FORM_ID']; - $('#'+form_id).remove(); - var build_method = App.Env.getWorldName() + '_form'; - var tpl = App.HTML.Build[build_method]({}, form_id); - App.Ref.CONTENT.prepend(tpl); - App.Helpers.updateScreen(); - } -} - -// do_action_save -App.Actions.saveForm = function(evt) { - -} - -// do_action_edit -App.Actions.edit = function(evt) { - var elm = $(evt.target); - elm = elm.hasClass('row') ? elm : elm.parents('.row'); - App.Pages[App.Env.world].edit(elm); -} - -// do_cancel_form -App.Actions.cancelForm = function(evt, params) { - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - var form_id = App.Constants[App.Env.world + '_FORM_ID']; - if (elm.attr('id') == form_id) { - $('#' + form_id).remove(); - } - else { - var options = App.Helpers.evalJSON(elm.find('.source').val()); - var entry_name = App.Env.world.toLowerCase() + '_entry'; - var tpl = App.HTML.Build[entry_name](options); - elm.replaceWith(tpl); - } - App.Helpers.updateScreen(); -} - -// do_action_form_help -App.Actions.showFormHelp = function(evt) { - var tpl_name = App.Env.world + '_form'; - var tpl = App.Templates.get(tpl_name, 'help'); - App.View.popup(tpl.finalize()); -} - -// do_action_entry_help -App.Actions.showEntryHelp = function(evt) { - var tpl_name = App.Env.world + '_entry'; - var tpl = App.Templates.get(tpl_name, 'help'); - App.View.popup(tpl.finalize()); -} - -App.Actions.embedSubform = function(evt) { - var tpl = App.Templates.get('subform', App.Env.getWorldName()); -} diff --git a/web/js/old/.svn/text-base/app.js.svn-base b/web/js/old/.svn/text-base/app.js.svn-base deleted file mode 100644 index 2a5c3f2c0..000000000 --- a/web/js/old/.svn/text-base/app.js.svn-base +++ /dev/null @@ -1,116 +0,0 @@ -/** - * App namespace - */ -var App = { - Ajax: {}, - Env: { - BROWSER: { - type: 'unknown-type', - version: 'version', // prefixed with type will be "unknown-version" - os: 'unknown-os' - }, - getWorldName: function() { - return App.Env.world.toLowerCase(); - } - }, - Core: {}, - Bash: {}, - Console: {}, - Constants: {}, - Actions: {}, - Helpers: {}, - Filters: {}, - i18N: {}, - HTML: { - Build: {} - }, - View:{ - - // pages related views - Pages: { - USER: {}, - WEBDOMAIN: {}, - MAIL: {}, - DB: {}, - DNS: {}, - IP: {}, - CRON: {} - } - }, - Messages: {}, - Model: { - USER: {}, - WEBDOMAIN: {}, - MAIL: {}, - DB: {}, - DNS: {}, - IP: {}, - CRON: {} - }, - Cache: { - clear: function(){} // stub method, will be used later - }, - Pages: { - USER: {}, - WEBDOMAIN: {}, - MAIL: {}, - DB: {}, - DNS: {}, - IP: {}, - CRON: {} - }, - Ref: {}, - Tmp: {}, - Thread: { - run: function(delay, ref){ - setTimeout(function(){ - ref(); - }, delay*10); - } - }, - Settings: {}, - Templates: { - Templator: null, - Tpl: {}, - _indexes: {} - }, - Utils: {}, - Validate: {} -}; - -// -// AJAX global method -// -App.Ajax.request = function(jedi_method, data, callback){ - App.Helpers.beforeAjax(jedi_method); - $.ajax({ - url: function() { - var url_parts = location.href.split('/'); - if (url_parts[url_parts.length -1] == 'index.html') { - url_parts[url_parts.length -1] = 'dispatch.php'; - } - else { - url_parts.push('dispatch.php'); - } - return url_parts.join('/'); - }(), - global: false, - type: data.request_method || "POST", - data: $.extend(data, {'jedi_method': jedi_method}), - dataType: "json", - async:true, - success: function(reply){ - App.Helpers.afterAjax(); - callback && callback(reply); - }, - error: function() { - App.View.popup('error'); - } - }); -} - - - - - - diff --git a/web/js/old/.svn/text-base/bash.js.svn-base b/web/js/old/.svn/text-base/bash.js.svn-base deleted file mode 100644 index 034013b82..000000000 --- a/web/js/old/.svn/text-base/bash.js.svn-base +++ /dev/null @@ -1,4 +0,0 @@ -App.Bash.detectCommand = function(string){ - -} - diff --git a/web/js/old/.svn/text-base/console.js.svn-base b/web/js/old/.svn/text-base/console.js.svn-base deleted file mode 100644 index af2e0b0ad..000000000 --- a/web/js/old/.svn/text-base/console.js.svn-base +++ /dev/null @@ -1,7 +0,0 @@ -App.Console.init = function(){ - - App.Refs.CONSOLE_INPUT.bind('keydown', function(evt){ - App.Console.Bash.detectCommand(); - }); -} - diff --git a/web/js/old/.svn/text-base/core.js.svn-base b/web/js/old/.svn/text-base/core.js.svn-base deleted file mode 100644 index b3585dd33..000000000 --- a/web/js/old/.svn/text-base/core.js.svn-base +++ /dev/null @@ -1,79 +0,0 @@ -// -// REFLECTOR -// -App.Core.action_reflector = { - 'new_entry': App.Actions.newForm, - 'cancel_form': App.Actions.cancelForm, - 'save_form': App.Actions.saveForm,//App.Pages.IP.saveIpForm, - 'remove': App.Actions.remove,//App.Pages.IP.deleteIp, - - 'cancel_dns_form': App.Pages.DNS.closeForm, - 'save_dns_form': App.Pages.DNS.saveForm, - - 'edit': App.Actions.edit, - 'embed_subform': App.Actions.embedSubform, - - 'form_help': App.Actions.showFormHelp, - 'entry_help': App.Actions.showEntryHelp, - - 'close_popup': App.View.closePopup -}; -// -// CORE -// -App.Core.listen = function(){ - fb.log('start listening'); - $(document).bind('click', function(evt){ - //App.Pages.IP.customListen && App.Pages.IP.customListen(evt); - var elm = $(evt.target); - fb.log(elm); - var action = $(elm).attr('className').split('do_action_'); - if(action.length < 2){ - if (elm.hasClass('check-this')) { - var ref = $(elm).parents('.row'); - ref.hasClass('checked-row') ? ref.removeClass('checked-row') : ref.addClass('checked-row'); - } - - return; // no action found attached to the dom object - } - try{ - // retrieve the action itself - action_with_params = action[1].split(' '); - action = action_with_params[0]; - params = elm.find('.prm-'+action).value || null; - // TODO: filter params here - // Call the action - App.Core.__CALL__(evt, action, params); - }catch(e){ - fb.error(e) - } - }); -} - -/** - * Action caller - * if no action registered, execution will stop - */ -App.Core.__CALL__ = function(evt, action, params){ - if('undefined' == typeof App.Core.action_reflector[action]){ - return fb.warn('No action registered for: "'+action+'". Stop propagation'); - }else{ - return App.Core.action_reflector[action](evt, params); - } - - -} - -App.Core.initMenu = function(){ - $('.section').bind('click', function(evt){ - var elm = $(evt.target); - !elm.hasClass('section') ? elm = elm.parents('.section') : -1; - if(App.Env.world != elm.attr('id')){ - App.Env.world = elm.attr('id'); - App.Pages.init(); - fb.warn('Switch page to: ' + App.Env.world); - } - }); -} - - diff --git a/web/js/old/.svn/text-base/helpers.js.svn-base b/web/js/old/.svn/text-base/helpers.js.svn-base deleted file mode 100644 index a48f75c09..000000000 --- a/web/js/old/.svn/text-base/helpers.js.svn-base +++ /dev/null @@ -1,122 +0,0 @@ -App.Helpers.updateInitial = function(){ - $.each(App.Env.initialParams, function(key) { - var item = App.Env.initialParams[key]; - $.each(item, function (i, o) { - if (i.indexOf('total_') != -1) { - App.View.updateInitialInfo(i, o); - } - }); - }); -} - -App.Helpers.beforeAjax = function(jedi_method) { - switch(jedi_method) { - case 'DNS.getList': - App.Helpers.showLoading(); - break; - default: - break; - } -} - -App.Helpers.afterAjax = function() { - App.Helpers.removeLoading(); -} - -App.Helpers.removeLoading = function() { - var ref = $('#loading'); - if (ref.length > 0) { - ref.remove(); - } -} - -App.Helpers.showLoading = function() { - App.Helpers.removeLoading(); - var tpl = App.Templates.get('loading', 'general'); - $(document.body).append(tpl.finalize()); -} - -// todo: no iteration here -App.Helpers.getFirstValue = function(obj){ - var first = ''; - $.each(obj, function(key, i){ - return first = obj[key]; - }); - - return first; -} - -App.Helpers.evalJSON = function(string) { - return $.parseJSON(string); -} - -App.Helpers.toJSON = function(object) { - return ($.toJSON(object).replace(/'/gi, '')); -} - - -// -// Hints -// -App.Helpers.showConsoleHint = function(){ - // TODO: - } - - -// UTILS -App.Utils.generatePasswordHash = function(length){ - var length = length || 11; - var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!~."; - var pass = ""; - for(var x=0;x'+initial[key]+''; - }); - return opts.join(''); -} - -App.HTML.Build.ip_entry = function(o){ - var tpl = App.Templates.get('ENTRY', 'ip'); - tpl.set(':source',$.toJSON(o)); - tpl.set(':NETMASK', o.NETMASK); - tpl.set(':IP_ADDRESS', o.IP_ADDRESS); - tpl.set(':SYS_USERS', o.U_SYS_USERS); - tpl.set(':WEB_DOMAINS', o.U_WEB_DOMAINS); - tpl.set(':DATE', o.DATE); - tpl.set(':INTERFACE', o.INTERFACE); - tpl.set(':NAME', o.NAME); - tpl.set(':OWNER', o.OWNER); - tpl.set(':STATUS', o.STATUS); - tpl.set(':U_SYS_USERS', o.U_SYS_USERS); - tpl.set(':U_WEB_DOMAINS', o.U_WEB_DOMAINS); - - if (App.Constants.SUSPENDED_YES == o.SUSPENDED) { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'ip'); - } - else { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'ip'); - } - - tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); - - return tpl.finalize(); -} - -App.HTML.Build.dns_entry = function(o){ - var tpl = App.Templates.get('ENTRY', 'dns'); - tpl.set(':source', App.Helpers.toJSON(o)); - tpl.set(':DNS_DOMAIN', o.DNS_DOMAIN); - var ip = o.IP.split('.'); - tpl.set(':IP', ip.join('.')); - tpl.set(':TTL', o.TTL); - tpl.set(':TPL', o.TPL); - tpl.set(':SOA', o.SOA); - tpl.set(':TTL', o.TTL); - tpl.set(':DATE', o.DATE); - /*tpl.set(':NETMASK', o.NETMASK); - tpl.set(':IP_ADDRESS', o.IP_ADDRESS); - tpl.set(':SYS_USERS', o.U_SYS_USERS); - tpl.set(':WEB_DOMAINS', o.U_WEB_DOMAINS); - tpl.set(':DATE', o.DATE); - tpl.set(':INTERFACE', o.INTERFACE); - tpl.set(':NAME', o.NAME); - tpl.set(':OWNER', o.OWNER); - tpl.set(':STATUS', o.STATUS); - tpl.set(':U_SYS_USERS', o.U_SYS_USERS); - tpl.set(':U_WEB_DOMAINS', o.U_WEB_DOMAINS); - */ - if (App.Constants.SUSPENDED_YES == o.SUSPEND) { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'dns'); - } - else { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'dns'); - } - - tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); - - return tpl.finalize(); -} - diff --git a/web/js/old/.svn/text-base/model.js.svn-base b/web/js/old/.svn/text-base/model.js.svn-base deleted file mode 100644 index e67c79a9a..000000000 --- a/web/js/old/.svn/text-base/model.js.svn-base +++ /dev/null @@ -1,52 +0,0 @@ -App.Model.DNS.loadList = function(){ - App.Ajax.request('DNS.getList', {}, App.View.Pages.DNS.list); -} - -App.Model.DNS.update = function(values, source_json) { - App.Ajax.request('DNS.update', { - 'source': source_json, - 'target': App.Helpers.toJSON(values) - }, function(reply){ - if(!reply.result) { - App.Pages.DNS.notSaved(reply); - } - }); -} - -App.Model.IP.loadList = function(){ - App.Ajax.request('IP.getList', {}, App.View.Pages.IP.list); -} - -App.Model.IP.update = function(values, source_json) { - App.Ajax.request('IP.update', { - 'source': source_json, - 'target': App.Helpers.toJSON(values) - }, function(reply){ - if(!reply.result) { - App.Pages.IP.ipNotSaved(reply); - } - }); -} - -App.Model.IP.add = function(values) { - App.Ajax.request('IP.add', { - 'target': App.Helpers.toJSON(values) - }, function(reply){ - if(!reply.result) { - App.Helpers.alert(reply.message) - } - }); -} - -App.Model.IP.remove = function(values_json, elm) { - App.Ajax.request('IP.remove', { - 'target': values_json - }, function(reply){ - if(!reply.result) { - App.Helpers.alert(reply.message); - } - else { - elm.remove(); - } - }); -} diff --git a/web/js/old/.svn/text-base/pages.js.svn-base b/web/js/old/.svn/text-base/pages.js.svn-base deleted file mode 100644 index b0b1878e1..000000000 --- a/web/js/old/.svn/text-base/pages.js.svn-base +++ /dev/null @@ -1,103 +0,0 @@ -App.Pages.DNS.edit = function(elm) { - var options = elm.find('.source').val(); - fb.warn(elm); - fb.warn(options); - var tpl = App.HTML.Build.dns_form(options); - elm.replaceWith(tpl); -} - -App.Pages.init = function(){ - App.Ajax.request('MAIN.getInitialParams', {}, function(reply){ - App.Env.initialParams = reply.data; - App.Helpers.updateInitial(); - }); - - App.Pages[App.Env.world].prepareHTML && App.Pages[App.Env.world].prepareHTML(); - $('.section.active').removeClass('active'); - $('#'+App.Env.world).addClass('active'); -} - -// -// DNS -App.Pages.DNS.prepareHTML = function(){ - App.Model.DNS.loadList(); -} - -App.Pages.DNS.saveForm = function(evt, params){ - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - - if (elm.attr('id') == App.Constants.DNS_FORM_ID) { - var values = App.Helpers.getFormValues(elm); - if(App.Validate.dnsForm(values)) { - App.Model.DNS.update(values, source); - var tpl = App.HTML.Build.dns_entry(values); - $('#' + App.Constants.DNS_FORM_ID).replaceWith(tpl); - } - } - else { - var source = $(elm).find('.source').val(); - var values = App.Helpers.getFormValues(elm); - if(App.Validate.dnsForm(values)) { - App.Model.DNS.update(values, source); - var tpl = App.HTML.Build.dns_entry(values); - elm.replaceWith(tpl); - } - } - App.Helpers.updateScreen(); -} - -// -// IP -App.Pages.IP.prepareHTML = function(){ - App.Model.IP.loadList(); -} - -App.Pages.IP.saveForm = function(evt, params){ - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - - if (elm.attr('id') == App.Constants.IP_FORM_ID) { - var values = App.Helpers.getFormValues(elm); - if(App.Validate.ipForm(values)) { - App.Model.IP.update(values, source); - var tpl = App.HTML.Build.ip_entry(values); - $('#' + App.Constants.IP_FORM_ID).replaceWith(tpl); - } - } - else { - var source = $(elm).find('.source').val(); - var values = App.Helpers.getFormValues(elm); - if(App.Validate.ipForm(values)) { - App.Model.IP.update(values, source); - var tpl = App.HTML.Build.ip_entry(values); - elm.replaceWith(tpl); - } - } - App.Helpers.updateScreen(); -} - -/* -App.Pages.IP.edit = function(elm) { - var options = elm.find('.source').val(); - fb.warn(elm); - fb.warn(options); - var tpl = App.HTML.Build.ip_form(options); - elm.replaceWith(tpl); -} - -App.Pages.IP.ipNotSaved = function(reply) { - return App.Helpers.alert(reply.message); -} - -App.Pages.IP.remove = function(evt) { - var confirmed = confirm('Are you sure?'); - if (!confirmed) { - return; - } - var elm = $(evt.target); - elm.parents('.ip-details-row'); - var values = elm.find('.source').val(); - App.Model.IP.remove(values, elm); -} -*/ \ No newline at end of file diff --git a/web/js/old/.svn/text-base/parsers.js.js.svn-base b/web/js/old/.svn/text-base/parsers.js.js.svn-base deleted file mode 100644 index e69de29bb..000000000 diff --git a/web/js/old/.svn/text-base/ref.js.svn-base b/web/js/old/.svn/text-base/ref.js.svn-base deleted file mode 100644 index a3f020481..000000000 --- a/web/js/old/.svn/text-base/ref.js.svn-base +++ /dev/null @@ -1,4 +0,0 @@ -App.Ref.init = function(){ - App.Ref.CONSOLE_INPUT = $('#console').find('.b-console-field'); - App.Ref.CONTENT = $('#content'); -} diff --git a/web/js/old/.svn/text-base/templates.js.svn-base b/web/js/old/.svn/text-base/templates.js.svn-base deleted file mode 100644 index 997d55fc4..000000000 --- a/web/js/old/.svn/text-base/templates.js.svn-base +++ /dev/null @@ -1,295 +0,0 @@ -App.Templates.html = { - help: { - DNS_form: ['

Some Things You Just Can\'t Explain

\ -A farmer was sitting in the neighborhood bar getting drunk. A man came in and asked the farmer, "Hey, why are you sitting here on this beautiful day, getting drunk?" The farmer shook his head and replied, "Some things you just can\'t explain."\ -"So what happened that\'s so horrible?" the man asked as he sat down next to the farmer.\ -"Well," the farmer said, "today I was sitting by my cow, milking her. Just as I got the bucket full, she lifted her left leg and kicked over the bucket."\ -"Okay," said the man, "but that\'s not so bad." "Some things you just can\'t explain," the farmer replied. "So what happened then?" the man asked. The farmer said, "I took her left leg and tied it to the post on the left."\ -"And then?"\ -"Well, I sat back down and continued to milk her. Just as I got the bucket full, she took her right leg and kicked over the bucket."\ -The man laughed and said, "Again?" The farmer replied, "Some things you just can\'t explain." "So, what did you do then?" the man asked.\ -"I took her right leg this time and tied it to the post on the right."\ -"And then?"\ -"Well, I sat back down and began milking her again. Just as I got the bucket full, the stupid cow knocked over the bucket with her tail."\ -"Hmmm," the man said and nodded his head. "Some things you just can\'t explain," the farmer said.\ -"So, what did you do?" the man asked.\ -"Well," the farmer said, "I didn\'t have anymore rope, so I took off my belt and tied her tail to the rafter. In that moment, my pants fell down and my wife walked in ... Some things you just can\'t explain."'] - }, - general: { - loading: ['
\ -
Loading...
\ -
'], - popup: ['\ - '], - }, - popup: { - error: ['

Important: An Error Has Occured.


    Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.
,    However, please notify us about the situation. It would be helpfull if you will write us approximate time the error occured and last actions you were performing. You send your petition on this email: BLABLA,

Sorry for inconvinience. (We recommend you to reload the page)
'] - }, - dates: { - 'lock_plan_date' : [''], - 'save_forecasted_date' : [''] - }, - dns: { - FORM: [ - '
\ - \ - \ -
~!:title~!
\ -
\ - \ - \ -
\ -
\ - \ -
\ - \ - \ -
\ -
\ -
\ - \ - \ - View template settings\ -
\ -
\ - \ - Cancel\ - Help\ -
\ -
' - ], - SUSPENDED_TPL_ENABLED : ['enabled\ - delete'], - SUSPENDED_TPL_DISABLED : ['suspended'], - ENTRIES_WRAPPER: ['
~!:content~!
'], - ENTRY: ['
\ - \ - \ -
\ -
\ -
\ - ~!:SUSPENDED_TPL~!\ - delete\ -
\ -
\ -
\ -
~!:DATE~!
\ -
\ -
\ -
\ -
\ - ~!:DNS_DOMAIN~!\ -
\ -
Show records
\ -
\ -
\ -
\ - ~!:IP~!\ - \ - template:\ - ~!:TPL~!\ - \ -
\ -
\ -
\ - \ - ttl:\ - ~!:TTL~!\ - \ - \ - soa:\ - ~!:SOA~!\ - \ -
\ -
\ -
'] - }, - ip: { - FORM: ['\ -
\ - \ -
~!:title~!
\ -
\ - \ - \ -
\ -
\ - \ - \ - \ -
\ -
\ - \ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ - \ -
\ -
\ - \ -
\ - \ -
\ -
\ -
\ - \ - Cancel\ - Help\ -
\ -
\ - '], - DOT: ['.'], - ENTRY: ['\ -
\ - \ - \ -
\ -
\ -
\ - ~!:SUSPENDED_TPL~!\ -
\ -
\ -
\ -
~!:DATE~!
\ -
\ -
\ -
\ -
\ - ~!:IP_ADDRESS~!\ -
\ - \ - netmask:\ - ~!:NETMASK~!\ - \ - \ - interface:\ - ~!:INTERFACE~!\ - \ - \ - name:\ - ~!:NAME~!\ - \ -
\ -
\ - \ - owner:\ - ~!:OWNER~!\ - \ - \ - status:\ - ~!:STATUS~!\ - \ -
\ -
\ - \ - sys users:\ - ~!:U_SYS_USERS~!\ - \ - \ - web domains:\ - ~!:U_WEB_DOMAINS~!\ - \ -
\ -
\ -
\ - '], - ENTRIES_WRAPPER: ['
~!:content~!
'], - SUSPENDED_TPL_ENABLED : ['enabled\ - delete'], - SUSPENDED_TPL_DISABLED : ['suspended'] - } -} - - - -// Internals -var Tpl = App.Templates; - -var Templator = function(){ - var init = function(){ - fb.info('Templator work'); - Templator.splitThemAll(); - Templator.freezeTplIndexes(); - }; - - - /** - * Split the tpl strings into arrays - */ - Templator.splitThemAll = function(){ - fb.info('splitting tpls'); - $.each(App.Templates.html, function(o){ - var tpls = App.Templates.html[o]; - $.each(tpls, function(t){ - tpls[t] = tpls[t][0].split('~!'); - }); - }); - }, - - /** - * Iterates tpls - */ - Templator.freezeTplIndexes = function(){ - fb.info('freezing tpl keys'); - $.each(App.Templates.html, Templator.cacheTplIndexes); - }, - - /** - * Grab the tpl group key and process it - */ - Templator.cacheTplIndexes = function(key){ - var tpls = App.Templates.html[key]; - - $.each(tpls, function(o){ - var tpl = tpls[o]; - Templator.catchIndex(key, o, tpl); - }); - }, - - /** - * Set the indexes - */ - Templator.catchIndex = function(key, ref_key, tpl){ - 'undefined' == typeof App.Templates._indexes[key] ? App.Templates._indexes[key] = {} : false; - 'undefined' == typeof App.Templates._indexes[key][ref_key] ? App.Templates._indexes[key][ref_key] = {} : false; - - $(tpl).each(function(index, o){ - if(':' == o.charAt(0)){ - App.Templates._indexes[key][ref_key][o.toString()] = index; - } - }); - } - - /** - * Get concrete templates - */ - init(); - return Templator; -}; -Templator.getTemplate = function(ns, key){ - return [ - App.Templates._indexes[ns][key], - App.Templates.html[ns][key].slice(0) - ]; -} -// init templator -Tpl.Templator = Templator(); - -Tpl.get = function(key, group){ - return Tpl.Templator.getTemplate(group, key); -} \ No newline at end of file diff --git a/web/js/old/.svn/text-base/validators.js.svn-base b/web/js/old/.svn/text-base/validators.js.svn-base deleted file mode 100644 index cd0974429..000000000 --- a/web/js/old/.svn/text-base/validators.js.svn-base +++ /dev/null @@ -1,13 +0,0 @@ -App.Validate.ipForm = function(values){ - if(values.IP_ADDRESS == '') { - return alert('Not correct ip'); - } - - return true; -} - -App.Validate.dnsForm = function(values){ - return true; -} - - diff --git a/web/js/old/.svn/text-base/view.js.svn-base b/web/js/old/.svn/text-base/view.js.svn-base deleted file mode 100644 index 712cc7f1a..000000000 --- a/web/js/old/.svn/text-base/view.js.svn-base +++ /dev/null @@ -1,80 +0,0 @@ -App.View.start = function(){ - -}; - -App.View.showDatabases = function(databases){ - var tpl = App.HTML.makeDatabases(databases); - $('#navigation').html(tpl.wrapperize('database_wrap', 'database')); -} - -App.View.openDatabase = function(data, ref, db_name){ - var tpl = App.HTML.makeDbTableList(data); - $('.databases .tables').remove(); - $('.databases .active').removeClass('active'); - $(ref).after(tpl.wrapperize('database_table_wrap', 'database')); - - $(ref).attr('className', 'active do.closeDatabase('+db_name+')"'); -} - -App.View.openTable = function(data, ref, table_name){ - var tpl = App.HTML.makeDbFieldsList(data); - $(ref).next('.fields').remove(); - $(ref).after(tpl.wrapperize('database_field_wrap', 'database')); - - $(ref).attr('className', 'active do.closeTable('+table_name+')"'); - - App.Helpers.updateScreen(); -} - -App.View.resultReturned = function(reply){ - if(reply.result){ - $('#results').text(reply.data); - }else{ - $('#results').text(reply.message); - } -} - -App.View.Pages.IP.list = function(reply){ - var acc = []; - $(reply.data).each(function(i, o){ - acc[acc.length++] = App.HTML.Build.ip_entry(o); - }); - - var html = acc.done().wrapperize('ENTRIES_WRAPPER', 'ip'); - App.Ref.CONTENT.html(html); - App.Helpers.updateScreen(); -} - -App.View.Pages.DNS.list = function(reply){ - var acc = []; - $(reply.data).each(function(i, o){ - acc[acc.length++] = App.HTML.Build.dns_entry(o); - }); - - var html = acc.done().wrapperize('ENTRIES_WRAPPER', 'dns'); - App.Ref.CONTENT.html(html); - App.Helpers.updateScreen(); -} - -App.View.popup = function(content) { - var tpl = App.Templates.get('popup', 'general'); - if ('undefined' != typeof App.Templates.html.popup[content]) { - var content = App.Templates.get(content, 'popup').finalize(); - } - - tpl.set(':content', content); - $('#popup-bg, #popup').remove(); - $(document.body).append(tpl.finalize()); -} - -App.View.closePopup = function(){ - $('.black_overlay').remove(); - $('.popup_content').remove(); -} - -App.View.updateInitialInfo = function(key, object) { - var expr = '.'+key; - var object = parseInt(object, 10); - var html = object + ' ' + App.Messages.get(key, (object > 1)); - $(expr).html(html); -} \ No newline at end of file diff --git a/web/js/old/__init__.js b/web/js/old/__init__.js deleted file mode 100644 index b64a456c9..000000000 --- a/web/js/old/__init__.js +++ /dev/null @@ -1,18 +0,0 @@ -$(document).ready(function(){ - try{ - App.Utils.detectBrowser(); - - App.Env.world = 'DNS'; - App.Pages.init(); - - App.Ref.init(); - - App.View.start(); - App.Core.listen(); - App.Core.initMenu(); - - }catch(e){ - fb.error(e); - } -}); - diff --git a/web/js/old/_settings.js b/web/js/old/_settings.js deleted file mode 100644 index 4fba19dae..000000000 --- a/web/js/old/_settings.js +++ /dev/null @@ -1,22 +0,0 @@ -// Constants -App.Constants.IP_FORM_ID = 'ip-form'; -App.Constants.DNS_FORM_ID = 'dns-form'; - -App.Settings.ajax_url = 1; -App.Settings.uri = location.href.replace('index.html', ''); -App.Settings.popup_conf = { 'centered' : true, 'bgcolor' : '#FF0000', 'lightboxSpeed' : 'fast', 'destroyOnClose': true }; - -App.Constants.SUSPENDED_YES = 'yes'; - -App.Constants.IP = 'IP'; -App.Constants.DNS = 'DNS'; - -App.Constants.DNS_TEMPLATES = {'default': 'Default'}; - -App.Messages.total_dns_records = {single: 'total record', plural: 'total records'}; - -App.Messages.get = function(key, plural) { - if ('undefined' != typeof App.Messages[key]) { - return plural ? App.Messages[key].plural : App.Messages[key].single; - } -} \ No newline at end of file diff --git a/web/js/old/actions.js b/web/js/old/actions.js deleted file mode 100644 index f3ad225da..000000000 --- a/web/js/old/actions.js +++ /dev/null @@ -1,68 +0,0 @@ -App.Actions.cancel_ip_form = function(){ - alert(1); -} - -/** - * Embeds new item form - * if exits custom method (App.Pages[ENVIRONMENT_NAME].newForm) - * custom method will be executes instead of default one - */ -App.Actions.newForm = function() { - if ('undefined' != typeof App.Pages[App.Env.world].newForm) { - App.Pages[App.Env.world].newForm(); - } else { - var form_id = App.Constants[App.Env.world + '_FORM_ID']; - $('#'+form_id).remove(); - var build_method = App.Env.getWorldName() + '_form'; - var tpl = App.HTML.Build[build_method]({}, form_id); - App.Ref.CONTENT.prepend(tpl); - App.Helpers.updateScreen(); - } -} - -// do_action_save -App.Actions.saveForm = function(evt) { - -} - -// do_action_edit -App.Actions.edit = function(evt) { - var elm = $(evt.target); - elm = elm.hasClass('row') ? elm : elm.parents('.row'); - App.Pages[App.Env.world].edit(elm); -} - -// do_cancel_form -App.Actions.cancelForm = function(evt, params) { - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - var form_id = App.Constants[App.Env.world + '_FORM_ID']; - if (elm.attr('id') == form_id) { - $('#' + form_id).remove(); - } - else { - var options = App.Helpers.evalJSON(elm.find('.source').val()); - var entry_name = App.Env.world.toLowerCase() + '_entry'; - var tpl = App.HTML.Build[entry_name](options); - elm.replaceWith(tpl); - } - App.Helpers.updateScreen(); -} - -// do_action_form_help -App.Actions.showFormHelp = function(evt) { - var tpl_name = App.Env.world + '_form'; - var tpl = App.Templates.get(tpl_name, 'help'); - App.View.popup(tpl.finalize()); -} - -// do_action_entry_help -App.Actions.showEntryHelp = function(evt) { - var tpl_name = App.Env.world + '_entry'; - var tpl = App.Templates.get(tpl_name, 'help'); - App.View.popup(tpl.finalize()); -} - -App.Actions.embedSubform = function(evt) { - var tpl = App.Templates.get('subform', App.Env.getWorldName()); -} diff --git a/web/js/old/app.js b/web/js/old/app.js deleted file mode 100644 index 2a5c3f2c0..000000000 --- a/web/js/old/app.js +++ /dev/null @@ -1,116 +0,0 @@ -/** - * App namespace - */ -var App = { - Ajax: {}, - Env: { - BROWSER: { - type: 'unknown-type', - version: 'version', // prefixed with type will be "unknown-version" - os: 'unknown-os' - }, - getWorldName: function() { - return App.Env.world.toLowerCase(); - } - }, - Core: {}, - Bash: {}, - Console: {}, - Constants: {}, - Actions: {}, - Helpers: {}, - Filters: {}, - i18N: {}, - HTML: { - Build: {} - }, - View:{ - - // pages related views - Pages: { - USER: {}, - WEBDOMAIN: {}, - MAIL: {}, - DB: {}, - DNS: {}, - IP: {}, - CRON: {} - } - }, - Messages: {}, - Model: { - USER: {}, - WEBDOMAIN: {}, - MAIL: {}, - DB: {}, - DNS: {}, - IP: {}, - CRON: {} - }, - Cache: { - clear: function(){} // stub method, will be used later - }, - Pages: { - USER: {}, - WEBDOMAIN: {}, - MAIL: {}, - DB: {}, - DNS: {}, - IP: {}, - CRON: {} - }, - Ref: {}, - Tmp: {}, - Thread: { - run: function(delay, ref){ - setTimeout(function(){ - ref(); - }, delay*10); - } - }, - Settings: {}, - Templates: { - Templator: null, - Tpl: {}, - _indexes: {} - }, - Utils: {}, - Validate: {} -}; - -// -// AJAX global method -// -App.Ajax.request = function(jedi_method, data, callback){ - App.Helpers.beforeAjax(jedi_method); - $.ajax({ - url: function() { - var url_parts = location.href.split('/'); - if (url_parts[url_parts.length -1] == 'index.html') { - url_parts[url_parts.length -1] = 'dispatch.php'; - } - else { - url_parts.push('dispatch.php'); - } - return url_parts.join('/'); - }(), - global: false, - type: data.request_method || "POST", - data: $.extend(data, {'jedi_method': jedi_method}), - dataType: "json", - async:true, - success: function(reply){ - App.Helpers.afterAjax(); - callback && callback(reply); - }, - error: function() { - App.View.popup('error'); - } - }); -} - - - - - - diff --git a/web/js/old/bash.js b/web/js/old/bash.js deleted file mode 100644 index 034013b82..000000000 --- a/web/js/old/bash.js +++ /dev/null @@ -1,4 +0,0 @@ -App.Bash.detectCommand = function(string){ - -} - diff --git a/web/js/old/console.js b/web/js/old/console.js deleted file mode 100644 index af2e0b0ad..000000000 --- a/web/js/old/console.js +++ /dev/null @@ -1,7 +0,0 @@ -App.Console.init = function(){ - - App.Refs.CONSOLE_INPUT.bind('keydown', function(evt){ - App.Console.Bash.detectCommand(); - }); -} - diff --git a/web/js/old/core.js b/web/js/old/core.js deleted file mode 100644 index b3585dd33..000000000 --- a/web/js/old/core.js +++ /dev/null @@ -1,79 +0,0 @@ -// -// REFLECTOR -// -App.Core.action_reflector = { - 'new_entry': App.Actions.newForm, - 'cancel_form': App.Actions.cancelForm, - 'save_form': App.Actions.saveForm,//App.Pages.IP.saveIpForm, - 'remove': App.Actions.remove,//App.Pages.IP.deleteIp, - - 'cancel_dns_form': App.Pages.DNS.closeForm, - 'save_dns_form': App.Pages.DNS.saveForm, - - 'edit': App.Actions.edit, - 'embed_subform': App.Actions.embedSubform, - - 'form_help': App.Actions.showFormHelp, - 'entry_help': App.Actions.showEntryHelp, - - 'close_popup': App.View.closePopup -}; -// -// CORE -// -App.Core.listen = function(){ - fb.log('start listening'); - $(document).bind('click', function(evt){ - //App.Pages.IP.customListen && App.Pages.IP.customListen(evt); - var elm = $(evt.target); - fb.log(elm); - var action = $(elm).attr('className').split('do_action_'); - if(action.length < 2){ - if (elm.hasClass('check-this')) { - var ref = $(elm).parents('.row'); - ref.hasClass('checked-row') ? ref.removeClass('checked-row') : ref.addClass('checked-row'); - } - - return; // no action found attached to the dom object - } - try{ - // retrieve the action itself - action_with_params = action[1].split(' '); - action = action_with_params[0]; - params = elm.find('.prm-'+action).value || null; - // TODO: filter params here - // Call the action - App.Core.__CALL__(evt, action, params); - }catch(e){ - fb.error(e) - } - }); -} - -/** - * Action caller - * if no action registered, execution will stop - */ -App.Core.__CALL__ = function(evt, action, params){ - if('undefined' == typeof App.Core.action_reflector[action]){ - return fb.warn('No action registered for: "'+action+'". Stop propagation'); - }else{ - return App.Core.action_reflector[action](evt, params); - } - - -} - -App.Core.initMenu = function(){ - $('.section').bind('click', function(evt){ - var elm = $(evt.target); - !elm.hasClass('section') ? elm = elm.parents('.section') : -1; - if(App.Env.world != elm.attr('id')){ - App.Env.world = elm.attr('id'); - App.Pages.init(); - fb.warn('Switch page to: ' + App.Env.world); - } - }); -} - - diff --git a/web/js/old/helpers.js b/web/js/old/helpers.js deleted file mode 100644 index a48f75c09..000000000 --- a/web/js/old/helpers.js +++ /dev/null @@ -1,122 +0,0 @@ -App.Helpers.updateInitial = function(){ - $.each(App.Env.initialParams, function(key) { - var item = App.Env.initialParams[key]; - $.each(item, function (i, o) { - if (i.indexOf('total_') != -1) { - App.View.updateInitialInfo(i, o); - } - }); - }); -} - -App.Helpers.beforeAjax = function(jedi_method) { - switch(jedi_method) { - case 'DNS.getList': - App.Helpers.showLoading(); - break; - default: - break; - } -} - -App.Helpers.afterAjax = function() { - App.Helpers.removeLoading(); -} - -App.Helpers.removeLoading = function() { - var ref = $('#loading'); - if (ref.length > 0) { - ref.remove(); - } -} - -App.Helpers.showLoading = function() { - App.Helpers.removeLoading(); - var tpl = App.Templates.get('loading', 'general'); - $(document.body).append(tpl.finalize()); -} - -// todo: no iteration here -App.Helpers.getFirstValue = function(obj){ - var first = ''; - $.each(obj, function(key, i){ - return first = obj[key]; - }); - - return first; -} - -App.Helpers.evalJSON = function(string) { - return $.parseJSON(string); -} - -App.Helpers.toJSON = function(object) { - return ($.toJSON(object).replace(/'/gi, '')); -} - - -// -// Hints -// -App.Helpers.showConsoleHint = function(){ - // TODO: - } - - -// UTILS -App.Utils.generatePasswordHash = function(length){ - var length = length || 11; - var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!~."; - var pass = ""; - for(var x=0;x'+initial[key]+''; - }); - return opts.join(''); -} - -App.HTML.Build.ip_entry = function(o){ - var tpl = App.Templates.get('ENTRY', 'ip'); - tpl.set(':source',$.toJSON(o)); - tpl.set(':NETMASK', o.NETMASK); - tpl.set(':IP_ADDRESS', o.IP_ADDRESS); - tpl.set(':SYS_USERS', o.U_SYS_USERS); - tpl.set(':WEB_DOMAINS', o.U_WEB_DOMAINS); - tpl.set(':DATE', o.DATE); - tpl.set(':INTERFACE', o.INTERFACE); - tpl.set(':NAME', o.NAME); - tpl.set(':OWNER', o.OWNER); - tpl.set(':STATUS', o.STATUS); - tpl.set(':U_SYS_USERS', o.U_SYS_USERS); - tpl.set(':U_WEB_DOMAINS', o.U_WEB_DOMAINS); - - if (App.Constants.SUSPENDED_YES == o.SUSPENDED) { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'ip'); - } - else { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'ip'); - } - - tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); - - return tpl.finalize(); -} - -App.HTML.Build.dns_entry = function(o){ - var tpl = App.Templates.get('ENTRY', 'dns'); - tpl.set(':source', App.Helpers.toJSON(o)); - tpl.set(':DNS_DOMAIN', o.DNS_DOMAIN); - var ip = o.IP.split('.'); - tpl.set(':IP', ip.join('.')); - tpl.set(':TTL', o.TTL); - tpl.set(':TPL', o.TPL); - tpl.set(':SOA', o.SOA); - tpl.set(':TTL', o.TTL); - tpl.set(':DATE', o.DATE); - /*tpl.set(':NETMASK', o.NETMASK); - tpl.set(':IP_ADDRESS', o.IP_ADDRESS); - tpl.set(':SYS_USERS', o.U_SYS_USERS); - tpl.set(':WEB_DOMAINS', o.U_WEB_DOMAINS); - tpl.set(':DATE', o.DATE); - tpl.set(':INTERFACE', o.INTERFACE); - tpl.set(':NAME', o.NAME); - tpl.set(':OWNER', o.OWNER); - tpl.set(':STATUS', o.STATUS); - tpl.set(':U_SYS_USERS', o.U_SYS_USERS); - tpl.set(':U_WEB_DOMAINS', o.U_WEB_DOMAINS); - */ - if (App.Constants.SUSPENDED_YES == o.SUSPEND) { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_ENABLED', 'dns'); - } - else { - var sub_tpl = App.Templates.get('SUSPENDED_TPL_DISABLED', 'dns'); - } - - tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); - - return tpl.finalize(); -} - diff --git a/web/js/old/model.js b/web/js/old/model.js deleted file mode 100644 index e67c79a9a..000000000 --- a/web/js/old/model.js +++ /dev/null @@ -1,52 +0,0 @@ -App.Model.DNS.loadList = function(){ - App.Ajax.request('DNS.getList', {}, App.View.Pages.DNS.list); -} - -App.Model.DNS.update = function(values, source_json) { - App.Ajax.request('DNS.update', { - 'source': source_json, - 'target': App.Helpers.toJSON(values) - }, function(reply){ - if(!reply.result) { - App.Pages.DNS.notSaved(reply); - } - }); -} - -App.Model.IP.loadList = function(){ - App.Ajax.request('IP.getList', {}, App.View.Pages.IP.list); -} - -App.Model.IP.update = function(values, source_json) { - App.Ajax.request('IP.update', { - 'source': source_json, - 'target': App.Helpers.toJSON(values) - }, function(reply){ - if(!reply.result) { - App.Pages.IP.ipNotSaved(reply); - } - }); -} - -App.Model.IP.add = function(values) { - App.Ajax.request('IP.add', { - 'target': App.Helpers.toJSON(values) - }, function(reply){ - if(!reply.result) { - App.Helpers.alert(reply.message) - } - }); -} - -App.Model.IP.remove = function(values_json, elm) { - App.Ajax.request('IP.remove', { - 'target': values_json - }, function(reply){ - if(!reply.result) { - App.Helpers.alert(reply.message); - } - else { - elm.remove(); - } - }); -} diff --git a/web/js/old/pages.js b/web/js/old/pages.js deleted file mode 100644 index b0b1878e1..000000000 --- a/web/js/old/pages.js +++ /dev/null @@ -1,103 +0,0 @@ -App.Pages.DNS.edit = function(elm) { - var options = elm.find('.source').val(); - fb.warn(elm); - fb.warn(options); - var tpl = App.HTML.Build.dns_form(options); - elm.replaceWith(tpl); -} - -App.Pages.init = function(){ - App.Ajax.request('MAIN.getInitialParams', {}, function(reply){ - App.Env.initialParams = reply.data; - App.Helpers.updateInitial(); - }); - - App.Pages[App.Env.world].prepareHTML && App.Pages[App.Env.world].prepareHTML(); - $('.section.active').removeClass('active'); - $('#'+App.Env.world).addClass('active'); -} - -// -// DNS -App.Pages.DNS.prepareHTML = function(){ - App.Model.DNS.loadList(); -} - -App.Pages.DNS.saveForm = function(evt, params){ - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - - if (elm.attr('id') == App.Constants.DNS_FORM_ID) { - var values = App.Helpers.getFormValues(elm); - if(App.Validate.dnsForm(values)) { - App.Model.DNS.update(values, source); - var tpl = App.HTML.Build.dns_entry(values); - $('#' + App.Constants.DNS_FORM_ID).replaceWith(tpl); - } - } - else { - var source = $(elm).find('.source').val(); - var values = App.Helpers.getFormValues(elm); - if(App.Validate.dnsForm(values)) { - App.Model.DNS.update(values, source); - var tpl = App.HTML.Build.dns_entry(values); - elm.replaceWith(tpl); - } - } - App.Helpers.updateScreen(); -} - -// -// IP -App.Pages.IP.prepareHTML = function(){ - App.Model.IP.loadList(); -} - -App.Pages.IP.saveForm = function(evt, params){ - var elm = $(evt.target); - elm = elm.parents('.b-new-entry'); - - if (elm.attr('id') == App.Constants.IP_FORM_ID) { - var values = App.Helpers.getFormValues(elm); - if(App.Validate.ipForm(values)) { - App.Model.IP.update(values, source); - var tpl = App.HTML.Build.ip_entry(values); - $('#' + App.Constants.IP_FORM_ID).replaceWith(tpl); - } - } - else { - var source = $(elm).find('.source').val(); - var values = App.Helpers.getFormValues(elm); - if(App.Validate.ipForm(values)) { - App.Model.IP.update(values, source); - var tpl = App.HTML.Build.ip_entry(values); - elm.replaceWith(tpl); - } - } - App.Helpers.updateScreen(); -} - -/* -App.Pages.IP.edit = function(elm) { - var options = elm.find('.source').val(); - fb.warn(elm); - fb.warn(options); - var tpl = App.HTML.Build.ip_form(options); - elm.replaceWith(tpl); -} - -App.Pages.IP.ipNotSaved = function(reply) { - return App.Helpers.alert(reply.message); -} - -App.Pages.IP.remove = function(evt) { - var confirmed = confirm('Are you sure?'); - if (!confirmed) { - return; - } - var elm = $(evt.target); - elm.parents('.ip-details-row'); - var values = elm.find('.source').val(); - App.Model.IP.remove(values, elm); -} -*/ \ No newline at end of file diff --git a/web/js/old/parsers.js.js b/web/js/old/parsers.js.js deleted file mode 100644 index e69de29bb..000000000 diff --git a/web/js/old/ref.js b/web/js/old/ref.js deleted file mode 100644 index a3f020481..000000000 --- a/web/js/old/ref.js +++ /dev/null @@ -1,4 +0,0 @@ -App.Ref.init = function(){ - App.Ref.CONSOLE_INPUT = $('#console').find('.b-console-field'); - App.Ref.CONTENT = $('#content'); -} diff --git a/web/js/old/templates.js b/web/js/old/templates.js deleted file mode 100644 index 997d55fc4..000000000 --- a/web/js/old/templates.js +++ /dev/null @@ -1,295 +0,0 @@ -App.Templates.html = { - help: { - DNS_form: ['

Some Things You Just Can\'t Explain

\ -A farmer was sitting in the neighborhood bar getting drunk. A man came in and asked the farmer, "Hey, why are you sitting here on this beautiful day, getting drunk?" The farmer shook his head and replied, "Some things you just can\'t explain."\ -"So what happened that\'s so horrible?" the man asked as he sat down next to the farmer.\ -"Well," the farmer said, "today I was sitting by my cow, milking her. Just as I got the bucket full, she lifted her left leg and kicked over the bucket."\ -"Okay," said the man, "but that\'s not so bad." "Some things you just can\'t explain," the farmer replied. "So what happened then?" the man asked. The farmer said, "I took her left leg and tied it to the post on the left."\ -"And then?"\ -"Well, I sat back down and continued to milk her. Just as I got the bucket full, she took her right leg and kicked over the bucket."\ -The man laughed and said, "Again?" The farmer replied, "Some things you just can\'t explain." "So, what did you do then?" the man asked.\ -"I took her right leg this time and tied it to the post on the right."\ -"And then?"\ -"Well, I sat back down and began milking her again. Just as I got the bucket full, the stupid cow knocked over the bucket with her tail."\ -"Hmmm," the man said and nodded his head. "Some things you just can\'t explain," the farmer said.\ -"So, what did you do?" the man asked.\ -"Well," the farmer said, "I didn\'t have anymore rope, so I took off my belt and tied her tail to the rafter. In that moment, my pants fell down and my wife walked in ... Some things you just can\'t explain."'] - }, - general: { - loading: ['
\ -
Loading...
\ -
'], - popup: ['\ - '], - }, - popup: { - error: ['

Important: An Error Has Occured.


    Something went wrong and some of your actions can be not saved in system. Mostly, it happens when you have network connection errors.
,    However, please notify us about the situation. It would be helpfull if you will write us approximate time the error occured and last actions you were performing. You send your petition on this email: BLABLA,

Sorry for inconvinience. (We recommend you to reload the page)
'] - }, - dates: { - 'lock_plan_date' : [''], - 'save_forecasted_date' : [''] - }, - dns: { - FORM: [ - '
\ - \ - \ -
~!:title~!
\ -
\ - \ - \ -
\ -
\ - \ -
\ - \ - \ -
\ -
\ -
\ - \ - \ - View template settings\ -
\ -
\ - \ - Cancel\ - Help\ -
\ -
' - ], - SUSPENDED_TPL_ENABLED : ['enabled\ - delete'], - SUSPENDED_TPL_DISABLED : ['suspended'], - ENTRIES_WRAPPER: ['
~!:content~!
'], - ENTRY: ['
\ - \ - \ -
\ -
\ -
\ - ~!:SUSPENDED_TPL~!\ - delete\ -
\ -
\ -
\ -
~!:DATE~!
\ -
\ -
\ -
\ -
\ - ~!:DNS_DOMAIN~!\ -
\ -
Show records
\ -
\ -
\ -
\ - ~!:IP~!\ - \ - template:\ - ~!:TPL~!\ - \ -
\ -
\ -
\ - \ - ttl:\ - ~!:TTL~!\ - \ - \ - soa:\ - ~!:SOA~!\ - \ -
\ -
\ -
'] - }, - ip: { - FORM: ['\ -
\ - \ -
~!:title~!
\ -
\ - \ - \ -
\ -
\ - \ - \ - \ -
\ -
\ - \ - \ - \ -
\ -
\ - \ - \ -
\ -
\ - \ - \ - \ -
\ -
\ - \ -
\ - \ -
\ -
\ -
\ - \ - Cancel\ - Help\ -
\ -
\ - '], - DOT: ['.'], - ENTRY: ['\ -
\ - \ - \ -
\ -
\ -
\ - ~!:SUSPENDED_TPL~!\ -
\ -
\ -
\ -
~!:DATE~!
\ -
\ -
\ -
\ -
\ - ~!:IP_ADDRESS~!\ -
\ - \ - netmask:\ - ~!:NETMASK~!\ - \ - \ - interface:\ - ~!:INTERFACE~!\ - \ - \ - name:\ - ~!:NAME~!\ - \ -
\ -
\ - \ - owner:\ - ~!:OWNER~!\ - \ - \ - status:\ - ~!:STATUS~!\ - \ -
\ -
\ - \ - sys users:\ - ~!:U_SYS_USERS~!\ - \ - \ - web domains:\ - ~!:U_WEB_DOMAINS~!\ - \ -
\ -
\ -
\ - '], - ENTRIES_WRAPPER: ['
~!:content~!
'], - SUSPENDED_TPL_ENABLED : ['enabled\ - delete'], - SUSPENDED_TPL_DISABLED : ['suspended'] - } -} - - - -// Internals -var Tpl = App.Templates; - -var Templator = function(){ - var init = function(){ - fb.info('Templator work'); - Templator.splitThemAll(); - Templator.freezeTplIndexes(); - }; - - - /** - * Split the tpl strings into arrays - */ - Templator.splitThemAll = function(){ - fb.info('splitting tpls'); - $.each(App.Templates.html, function(o){ - var tpls = App.Templates.html[o]; - $.each(tpls, function(t){ - tpls[t] = tpls[t][0].split('~!'); - }); - }); - }, - - /** - * Iterates tpls - */ - Templator.freezeTplIndexes = function(){ - fb.info('freezing tpl keys'); - $.each(App.Templates.html, Templator.cacheTplIndexes); - }, - - /** - * Grab the tpl group key and process it - */ - Templator.cacheTplIndexes = function(key){ - var tpls = App.Templates.html[key]; - - $.each(tpls, function(o){ - var tpl = tpls[o]; - Templator.catchIndex(key, o, tpl); - }); - }, - - /** - * Set the indexes - */ - Templator.catchIndex = function(key, ref_key, tpl){ - 'undefined' == typeof App.Templates._indexes[key] ? App.Templates._indexes[key] = {} : false; - 'undefined' == typeof App.Templates._indexes[key][ref_key] ? App.Templates._indexes[key][ref_key] = {} : false; - - $(tpl).each(function(index, o){ - if(':' == o.charAt(0)){ - App.Templates._indexes[key][ref_key][o.toString()] = index; - } - }); - } - - /** - * Get concrete templates - */ - init(); - return Templator; -}; -Templator.getTemplate = function(ns, key){ - return [ - App.Templates._indexes[ns][key], - App.Templates.html[ns][key].slice(0) - ]; -} -// init templator -Tpl.Templator = Templator(); - -Tpl.get = function(key, group){ - return Tpl.Templator.getTemplate(group, key); -} \ No newline at end of file diff --git a/web/js/old/validators.js b/web/js/old/validators.js deleted file mode 100644 index cd0974429..000000000 --- a/web/js/old/validators.js +++ /dev/null @@ -1,13 +0,0 @@ -App.Validate.ipForm = function(values){ - if(values.IP_ADDRESS == '') { - return alert('Not correct ip'); - } - - return true; -} - -App.Validate.dnsForm = function(values){ - return true; -} - - diff --git a/web/js/old/view.js b/web/js/old/view.js deleted file mode 100644 index 712cc7f1a..000000000 --- a/web/js/old/view.js +++ /dev/null @@ -1,80 +0,0 @@ -App.View.start = function(){ - -}; - -App.View.showDatabases = function(databases){ - var tpl = App.HTML.makeDatabases(databases); - $('#navigation').html(tpl.wrapperize('database_wrap', 'database')); -} - -App.View.openDatabase = function(data, ref, db_name){ - var tpl = App.HTML.makeDbTableList(data); - $('.databases .tables').remove(); - $('.databases .active').removeClass('active'); - $(ref).after(tpl.wrapperize('database_table_wrap', 'database')); - - $(ref).attr('className', 'active do.closeDatabase('+db_name+')"'); -} - -App.View.openTable = function(data, ref, table_name){ - var tpl = App.HTML.makeDbFieldsList(data); - $(ref).next('.fields').remove(); - $(ref).after(tpl.wrapperize('database_field_wrap', 'database')); - - $(ref).attr('className', 'active do.closeTable('+table_name+')"'); - - App.Helpers.updateScreen(); -} - -App.View.resultReturned = function(reply){ - if(reply.result){ - $('#results').text(reply.data); - }else{ - $('#results').text(reply.message); - } -} - -App.View.Pages.IP.list = function(reply){ - var acc = []; - $(reply.data).each(function(i, o){ - acc[acc.length++] = App.HTML.Build.ip_entry(o); - }); - - var html = acc.done().wrapperize('ENTRIES_WRAPPER', 'ip'); - App.Ref.CONTENT.html(html); - App.Helpers.updateScreen(); -} - -App.View.Pages.DNS.list = function(reply){ - var acc = []; - $(reply.data).each(function(i, o){ - acc[acc.length++] = App.HTML.Build.dns_entry(o); - }); - - var html = acc.done().wrapperize('ENTRIES_WRAPPER', 'dns'); - App.Ref.CONTENT.html(html); - App.Helpers.updateScreen(); -} - -App.View.popup = function(content) { - var tpl = App.Templates.get('popup', 'general'); - if ('undefined' != typeof App.Templates.html.popup[content]) { - var content = App.Templates.get(content, 'popup').finalize(); - } - - tpl.set(':content', content); - $('#popup-bg, #popup').remove(); - $(document.body).append(tpl.finalize()); -} - -App.View.closePopup = function(){ - $('.black_overlay').remove(); - $('.popup_content').remove(); -} - -App.View.updateInitialInfo = function(key, object) { - var expr = '.'+key; - var object = parseInt(object, 10); - var html = object + ' ' + App.Messages.get(key, (object > 1)); - $(expr).html(html); -} \ No newline at end of file diff --git a/web/js/tricks.js b/web/js/tricks.js new file mode 100644 index 000000000..fc52b139c --- /dev/null +++ b/web/js/tricks.js @@ -0,0 +1,62 @@ +/** + * Usefull tricks conteiner + * + * @author Malishev Dima + * @author vesta, http://vestacp.com/ + * @copyright vesta 2010-2011 + */ + + +/** + * Init debug, grabs console object if accessible, or makes dummy debugger + */ +var fb = _DEBUG && 'undefined' != typeof(console) ? console : { + log : function(){}, + debug : function(){}, + info : function(){}, + warn : function(){}, + error : function(){}, + assert : function(){}, + dir : function(){}, + dirxml : function(){}, + trace : function(){}, + group : function(){}, + groupEnd : function(){}, + time : function(){}, + timeEnd : function(){}, + profile : function(){}, + profileEnd : function(){}, + count : function(){}, + msg : function(){} +}; + +(function($){$.toJSON=function(o) +{if(typeof(JSON)=='object'&&JSON.stringify) +return JSON.stringify(o);var type=typeof(o);if(o===null) +return"null";if(type=="undefined") +return undefined;if(type=="number"||type=="boolean") +return o+"";if(type=="string") +return $.quoteString(o);if(type=='object') +{if(typeof o.toJSON=="function") +return $.toJSON(o.toJSON());if(o.constructor===Date) +{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+ +hours+':'+minutes+':'+seconds+'.'+milli+'Z"';} +if(o.constructor===Array) +{var ret=[];for(var i=0;i