diff --git a/web/LICENSE.txt b/web/LICENSE.txt index c77cede3e..fc62e9c13 100644 --- a/web/LICENSE.txt +++ b/web/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2005-2010, http://vestacp.com +Copyright (c) 2005-2010, http://www.vestacp.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/web/css/main.css b/web/css/main.css index 779f87c7f..158d46bf2 100644 --- a/web/css/main.css +++ b/web/css/main.css @@ -2428,3 +2428,4 @@ select{ font-size:14px; font-weight:bold; } + diff --git a/web/dispatch.php b/web/dispatch.php index e6a31cebd..6733f2d7a 100644 --- a/web/dispatch.php +++ b/web/dispatch.php @@ -1,6 +1,6 @@ diff --git a/web/images/form-bottom-bg.png b/web/images/form-bottom-bg.png index eb9be9030..85d9265b8 100644 Binary files a/web/images/form-bottom-bg.png and b/web/images/form-bottom-bg.png differ diff --git a/web/index.html b/web/index.html index f32a88a60..760a23058 100644 --- a/web/index.html +++ b/web/index.html @@ -204,6 +204,7 @@ + diff --git a/web/js/__init__.js b/web/js/__init__.js index 655eee055..c8bbeb61b 100644 --- a/web/js/__init__.js +++ b/web/js/__init__.js @@ -1,7 +1,21 @@ $(document).ready(function(){ try{ App.Utils.detectBrowser(); - App.Env.world = 'CRON'; + + if ('undefined' != typeof App.Tmp.loadTAB) { + App.Env.world = App.Tmp.loadTAB; + } + + if ('undefined' == typeof App.Tmp.loadTAB && cookieEnabled()) { + var tab = getCookie('tab'); + if (null != tab && $.inArray(tab, App.Constants.TABS)) { + App.Env.world = tab; + } + else { + App.Env.world = App.Constants.TABS[0]; + } + } + App.Pages.init(); App.Ref.init(); diff --git a/web/js/_settings.js b/web/js/_settings.js index a70b181f1..b2e51b288 100644 --- a/web/js/_settings.js +++ b/web/js/_settings.js @@ -8,34 +8,38 @@ App.i18n.getMessage = function(key) } - // Constants -App.Constants.IP_FORM_ID = 'ip-form'; -App.Constants.DNS_FORM_ID = 'dns-form'; -App.Constants.USER_FORM_ID = 'user-form'; -App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form'; -App.Constants.DB_FORM_ID = 'db-form'; -App.Constants.CRON_FORM_ID = 'cron-form'; +App.Constants.IP_FORM_ID = 'ip-form'; +App.Constants.DNS_FORM_ID = 'dns-form'; +App.Constants.USER_FORM_ID = 'user-form'; +App.Constants.WEB_DOMAIN_FORM_ID = 'web_domain-form'; +App.Constants.DB_FORM_ID = 'db-form'; +App.Constants.CRON_FORM_ID = 'cron-form'; +App.Constants.IP = 'IP'; +App.Constants.DNS = 'DNS'; +App.Constants.SUSPENDED_YES = 'yes'; +App.Constants.DNS_TEMPLATES = {'default': 'Default'}; -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 }; +// Settings +App.Settings.USER_VISIBLE_NS = 2; +App.Settings.NS_MIN = 2; +App.Settings.NS_MAX = 8; +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'}; +// Messages 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; } } +// Empty +App.Empty = {}; +App.Empty.USER = {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','LNAME':'', 'FNAME':'','NS1':'','NS2':'','NS3':'','NS4':'','NS5':'','NS6':'','NS7':'','NS8':''}; App.Settings.getMethodName = function(action) { diff --git a/web/js/actions.js b/web/js/actions.js index 299093f30..ef27f0f45 100644 --- a/web/js/actions.js +++ b/web/js/actions.js @@ -103,8 +103,7 @@ App.Actions.save_form = function(evt) { else { // OLD ITEM, UPDATING IT var source = $(elm).find('.source').val(); var values = App.Helpers.getFormValues(elm); - if(App.Validate.form(values, $('#'+elm_id))) { - App.Model.add(values, source); + if(App.Validate.form(values, $('#'+elm_id))) { App.Model.update(values, source, elm); } } @@ -146,12 +145,49 @@ App.Actions.cancel_form = function(evt, params) { App.Actions.suspend = function(evt) { - alert('Suspend?'); + var confirmed = confirm('Suspend?'); + if (!confirmed) { + return ; + } + var elm = $(evt.target); + var row = elm.parents('.row'); + + var options = row.find('.source').val(); + App.Ajax.request(App.Env.world+'.suspend', {spell: options}, function(reply) { + if (reply.result) { + //var tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general'); + //$(elm).replaceWith(tpl.finalize()); + App.Pages.prepareHTML(); + App.Helpers.updateScreen(); + } + else { + return App.Helpers.alert('Failed to suspend'); + } + }); } App.Actions.unsuspend = function(evt) { - alert('Unsuspend?'); + var confirmed = confirm('Unsuspend?'); + if (!confirmed) { + return ; + } + + var elm = $(evt.target); + var row = elm.parents('.row'); + + var options = row.find('.source').val(); + App.Ajax.request(App.Env.world+'.unsuspend', {spell: options}, function(reply) { + if (reply.result) { + //var tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general'); + //$(elm).replaceWith(tpl.finalize()); + App.Pages.prepareHTML(); + App.Helpers.updateScreen(); + } + else { + return App.Helpers.alert('Failed to suspend'); + } + }); } // do_action_form_help @@ -230,3 +266,56 @@ App.Actions.backup_db = function(evt) { alert('TODO'); } + +App.Actions.add_form_ns = function(evt) +{ + var elm = $(evt.target); + + form = elm.parents('.form:first'); + var total_nses = $(form).find('.ns-entry').length; + if (total_nses == App.Settings.NS_MAX) { + return App.Helpers.alert('Maximum number of NS cannot be more than ' + App.Settings.NS_MAX); + } + + var tpl = App.Templates.get('NS_INPUT', 'user'); + tpl.set(':NAME', ''); + tpl.set(':NS_LABEL', 'NS'); + elm.before(tpl.finalize()); + + if ((total_nses + 1) == App.Settings.NS_MAX ) { // added last NS + $('.additional-ns-add', form).addClass('hidden'); + } + + $(form).find('.ns-entry').each(function(i, o) + { + $(o).find('label').text('NS #' + (i + 1)); + $(o).find('input').attr('name', 'NS' + (i + 1)); + }); +} + +App.Actions.delete_ns = function(evt) +{ + var elm = $(evt.target); + + form = elm.parents('.form:first'); + var total_nses = $(form).find('.ns-entry').length; + if (total_nses == App.Settings.NS_MIN) { + return App.Helpers.alert('Minimum number of NS is ' + App.Settings.NS_MIN); + } + + var form = elm.parents('.form:first'); + $(elm).parents('.form:first').find('.additional-ns-add').removeClass('hidden'); + $(elm).parents('.ns-entry').remove(); + + $(form).find('.ns-entry').each(function(i, o) + { + $(o).find('label').text('NS #' + (i + 1)); + $(o).find('input').attr('name', 'NS' + (i + 1)); + }); +} + +App.Actions.view_full_ns_list = function(evt) +{ + var elm = $(evt.target); + App.Helpers.openInnerPopup(elm, $(elm).parents('.prop-box').find('.ns-full-list:first').html()); +} diff --git a/web/js/app.js b/web/js/app.js index aa7ac7061..373e403f3 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -78,7 +78,9 @@ var App = { Core: {}, Bash: {}, Console: {}, - Constants: {}, + Constants: { + TABS: ['USER','WEB_DOMAIN','MAIL','DB','DNS','IP','CRON'] + }, Actions: {}, Helpers: {}, Filters: {}, @@ -175,16 +177,7 @@ App.Ajax.request = function(jedi_method, data, callback) { App.Helpers.beforeAjax(jedi_method); $.ajax({ - url: function() { - var url_parts = location.href.replace('#', '').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('/'); - }(), + url: App.Helpers.getBackendUrl(), global: false, type: data.request_method || "POST", data: $.extend(data, {'jedi_method': jedi_method}), diff --git a/web/js/helpers.js b/web/js/helpers.js index 00d333795..547c583dc 100644 --- a/web/js/helpers.js +++ b/web/js/helpers.js @@ -264,3 +264,26 @@ App.Helpers.closeInnerPopup = function(evt) { $('#inner-popup').remove(); } + +App.Helpers.getBackendUrl = function() +{ + var url_parts = location.href.split('#'); + if (url_parts.length > 1) { + var tab = url_parts[url_parts.length - 1]; + if ($.inArray(tab, App.Constants.TABS) != -1) { + App.Tmp.loadTAB = tab; + } + } + + var url_parts = location.href.split('?', 1); + var url = url_parts[0]; + url_parts = url.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('/'); +} diff --git a/web/js/html.js b/web/js/html.js index 51e8c1071..64c440d2a 100644 --- a/web/js/html.js +++ b/web/js/html.js @@ -1,6 +1,6 @@ App.HTML.setTplKeys = function(tpl, o, empty) { - var empty = empty || '-'; + var empty = empty || ''; fb.log(empty); tpl.set(':source', $.toJSON(o).replace(/'/gi, "\\'")) $(o).each(function(i, object) @@ -12,7 +12,7 @@ App.HTML.setTplKeys = function(tpl, o, empty) tpl.set(':' + key, val || ''); } else { - tpl.set(':' + key, val || '-'); + tpl.set(':' + key, val || ''); } }); }); @@ -138,14 +138,14 @@ App.HTML.Build.ip_entry = function(o) var tpl = App.Templates.get('ENTRY', 'ip'); tpl = App.HTML.setTplKeys(tpl, o); - if (App.Constants.SUSPENDED_YES == o.SUSPENDED) { + /*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()); + tpl.set(':SUSPENDED_TPL', ''); return tpl.finalize(); } @@ -163,14 +163,14 @@ App.HTML.Build.dns_entry = function(o, is_new) tpl.set(':DATE', now.format("d.mm.yyyy")); } - if (App.Constants.SUSPENDED_YES == o.SUSPEND) { + /*if (App.Constants.SUSPENDED_YES == o.SUSPEND) { var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general'); } else { var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general'); - } + }*/ - tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); + tpl.set(':SUSPENDED_TPL', ''); return tpl.finalize(); } @@ -190,13 +190,41 @@ App.HTML.Build.user_entry = function(o, key) var tpl = App.Templates.get('ENTRY', 'user'); tpl = App.HTML.setTplKeys(tpl, o); - if (App.Constants.SUSPENDED_YES == o.SUSPENDED) { + /*if (App.Constants.SUSPENDED_YES == o.SUSPENDED) { var sub_tpl = App.Templates.get('SUSPENDED_TPL_SUSPENDED', 'general'); } else { var sub_tpl = App.Templates.get('SUSPENDED_TPL_NOT_SUSPENDED', 'general'); + }*/ + tpl.set(':SUSPENDED_TPL', '');//sub_tpl.finalize()); + + var ns = []; + var ns_full = []; + fb.info(o); + $([1,2,3,4,5,6,7,8]).each(function(i, index) + { + if (o['NS'+index].trim() != '') { + var tpl_ns = App.Templates.get('NS_RECORD', 'user'); + tpl_ns.set(':NAME', o['NS'+index]); + var tpl_finalized = tpl_ns.finalize(); + ns_full[ns_full.length++] = tpl_finalized; + if (i < App.Settings.USER_VISIBLE_NS) { + ns[ns.length++] = tpl_finalized; + } + } + }); + + if (ns_full.length <= App.Settings.USER_VISIBLE_NS) { + tpl.set(':NS', ns.done()); } - tpl.set(':SUSPENDED_TPL', sub_tpl.finalize()); + else { + var ns_custom = App.Templates.get('NS_MINIMIZED', 'user'); + ns_custom.set(':NS_MINI', ns.done()); + ns_custom.set(':NS_FULL', ns_full.done()); + ns_custom.set(':MORE_NUMBER', Math.abs(App.Settings.USER_VISIBLE_NS - ns_full.length)); + tpl.set(':NS', ns_custom.finalize()); + } + return tpl.finalize(); } @@ -220,7 +248,22 @@ App.HTML.Build.user_form = function(options, id) tpl.set(':save_button', 'SAVE'); } - options = !App.Helpers.isEmpty(options) ? options : {'CONTACT':'', 'PASSWORD':'','LOGIN_NAME':'','NS':''}; + options = !App.Helpers.isEmpty(options) ? options : App.Empty.USER; + + // NS + var ns = []; + $([3,4,5,6,7,8]).each(function(i, index) + {fb.warn(options); + if (options['NS'+index].trim() != '') { + var tpl_ns = App.Templates.get('NS_INPUT', 'user'); + tpl_ns.set(':NS_LABEL', 'NS #' + (index)); + tpl_ns.set(':NAME', options['NS'+index]); + ns[ns.length++] = tpl_ns.finalize(); + } + }); + ns[ns.length++] = App.Templates.get('PLUS_ONE_NS', 'user').finalize(); + + tpl.set(':NS', ns.done()); tpl = App.HTML.setTplKeys(tpl, options, true); tpl = App.HTML.Build.user_selects(tpl, options); @@ -491,7 +534,7 @@ App.HTML.Build.db_selects = function(tpl, options) App.HTML.Build.ip_selects = function(tpl, options) { // OWNER - var users = App.Env.initialParams.IP.SYS_USERS || ['Skid']; + var users = App.Env.initialParams.IP.SYS_USERS; var opts = App.HTML.Build.options(users, options.OWNER); tpl.set(':owner_options', opts); diff --git a/web/js/lib/cookie.js b/web/js/lib/cookie.js new file mode 100644 index 000000000..0b99f1259 --- /dev/null +++ b/web/js/lib/cookie.js @@ -0,0 +1,45 @@ +var today = new Date(); +var expiryyear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000); +var expirymonth = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000); +var expiryday = new Date(today.getTime() + 24 * 60 * 60 * 1000); + +function getCookie(name) +{ + var reg= new RegExp("; "+name+";|; "+name+"=([^;]*)"); + var matches=reg.exec('; '+document.cookie+';'); + if (matches) return ((matches[1])?unescape(matches[1]):''); + return null; +} + +function setCookie (name,value,expires,path,domain,secure) +{ + document.cookie = name + "=" + escape (value) + + ((expires) ? "; expires=" + expires.toGMTString() : "") + + ((path) ? "; path=" + path : "") + + ((domain) ? "; domain=" + domain : "") + + ((secure) ? "; secure" : ""); + + return getCookie(name)!=null?true:false; +} + +function deleteCookie (name,path,domain) +{ + if (getCookie(name)!=null) + { + document.cookie = name + "=" + + ((path) ? "; path=" + path : "") + + ((domain) ? "; domain=" + domain : "") + + "; expires=Thu, 01-Jan-1970 00:00:01 GMT"; + } +} + +function cookieEnabled() +{ + testCookieName="_testCookie_"; + if (setCookie(testCookieName,1)) + { + deleteCookie(testCookieName); + return true; + } + else return false; +} \ No newline at end of file diff --git a/web/js/model.js b/web/js/model.js index d4c2541e8..c97828cec 100644 --- a/web/js/model.js +++ b/web/js/model.js @@ -72,10 +72,12 @@ App.Model.add = function(values, source_json) App.Helpers.Warn('Changes were not applied'); } else { - var build_method = App.Env.getWorldName() + '_entry'; + /*var build_method = App.Env.getWorldName() + '_entry'; var tpl = App.HTML.Build[build_method](values, 'new'); - App.Ref.CONTENT..replaceWith(tpl); + App.Ref.CONTENT..replaceWith(tpl);*/ // todo: reply.data; + App.Pages.prepareHTML(); + App.Helpers.updateScreen(); } }); } @@ -113,8 +115,11 @@ App.Model.update = function(values, source_json, elm) App.Helpers.Warn('Changes were not applied'); } else { - var tpl = App.HTML.Build[build_method](reply.data); + /*var tpl = App.HTML.Build[build_method](reply.data); $(elm).replaceWith(tpl); + App.Helpers.updateScreen();*/ + // todo: reply.data; + App.Pages.prepareHTML(); App.Helpers.updateScreen(); } // TODO: ! diff --git a/web/js/pages.js b/web/js/pages.js index 63089ff5d..631f36063 100644 --- a/web/js/pages.js +++ b/web/js/pages.js @@ -8,6 +8,10 @@ App.Pages.init = function(){ $('.section.active').removeClass('active'); $('#'+App.Env.world).addClass('active'); + + if (cookieEnabled()) { + setCookie('tab', App.Env.world); + } } App.Pages.prepareHTML = function() diff --git a/web/js/templates.js b/web/js/templates.js index a81012000..a69f585a4 100644 --- a/web/js/templates.js +++ b/web/js/templates.js @@ -32,7 +32,7 @@ App.Templates.html = { select_option: [''], error_elm: ['
~!:ERROR~!
'], SUSPENDED_TPL_NOT_SUSPENDED : ['enabled'], - SUSPENDED_TPL_SUSPENDED : ['disabled'] + SUSPENDED_TPL_SUSPENDED : ['suspended'] }, 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)
'] @@ -47,17 +47,17 @@ App.Templates.html = { \ \
~!:title~!
\ -
\ + \
\ \ \ - \ + \
\
\ \
\ - \ + \  \
\
\ @@ -71,11 +71,11 @@ App.Templates.html = {
\
\ \ - \ + \
\
\ \ - \ + \
\
\ \ @@ -171,11 +171,11 @@ App.Templates.html = { \ \
~!:title~!
\ -
\ + \
\ \ - \ + \
\
\ \ @@ -192,7 +192,7 @@ App.Templates.html = {
\
\ \ - \ + \
\
\ \ @@ -276,20 +276,32 @@ App.Templates.html = { SUSPENDED_TPL_DISABLED : ['suspended'] }, user: { + NS_MINIMIZED: ['~!:NS_MINI~!\ + \ + ~!:MORE_NUMBER~! more\ + '], + /*NS_RECORD_POPUP_WRAP: ['
    ~!:CONTENT~!
'], + NS_RECORD_POPUP: ['
  • ~!:NAME~!
  • '],*/ + NS_RECORD: ['~!:NAME~!'], + NS_INPUT: ['
    \ + \ + \ +
    '], + PLUS_ONE_NS: [''], ENTRIES_WRAPPER: ['
    ~!:content~!
    '], - FORM: ['
    \ + FORM: ['
    \ \ \
    ~!:title~!
    \ -
    \ + \
    \ \ - \ + \
    \
    \ \ - \ + \ Generate\
    \
    \ @@ -298,7 +310,7 @@ App.Templates.html = { ~!:PACKAGE_OPTIONS~!\ \
    \ -
    \ + \
    \ \ \
    \ -
    \ - \ - \ +
    \ + \ + \
    \ - \ +
    \ + \ + \ +
    \ +
    \ + \ + \ +
    \ +
    \ + \ + \ +
    \ + ~!:NS~!\
    \ \ Cancel\ @@ -357,6 +378,7 @@ App.Templates.html = {
    \ \ ~!:LOGIN_NAME~!\ + \ (~!:ROLE~!)\ \ \ @@ -463,7 +485,8 @@ App.Templates.html = { \ \ ns list:\ - ~!:NS~!\ + \ + ~!:NS~!\ \
    \
    \ @@ -767,48 +790,48 @@ App.Templates.html = { \ \
    ~!:title~!
    \ -
    \ + \
    \ run at:\
    \ - \ + \
    \ - \ + \
    \
    \
    \ \
    \ - \ + \
    \
    \
    \ \
    \ - \ + \
    \
    \
    \ \
    \ - \ + \
    \
    \
    \ \
    \ - \ + \
    \
    \
    \
    \ \ - \ + \
    \ -
    \ + \ @@ -858,7 +881,7 @@ App.Templates.html = {
    \ ~!:CMD~!\
    \ -
    \ +