Skip to content

Commit 7c81fe7

Browse files
committed
Added "admin_" prefix for ftp user names
Affected pages: Add/Edit Web entity for admin and user points
1 parent 0593df0 commit 7c81fe7

File tree

9 files changed

+2481
-1110
lines changed

9 files changed

+2481
-1110
lines changed

web/js/app.js

Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
/**
2+
* jQuery.browser.mobile (http://detectmobilebrowser.com/)
3+
*
4+
* jQuery.browser.mobile will be true if the browser is a mobile device
5+
*
6+
**/
7+
(function(a){(jQuery.browser=jQuery.browser||{}).mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);
8+
9+
/*! jQuery JSON plugin 2.4.0 | code.google.com/p/jquery-json */
10+
(function(jQuery){'use strict';var escape=/["\\\x00-\x1f\x7f-\x9f]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},hasOwn=Object.prototype.hasOwnProperty;jQuery.toJSON=typeof JSON==='object'&&JSON.stringify?JSON.stringify:function(o){if(o===null){return'null';}
11+
var pairs,k,name,val,type=jQuery.type(o);if(type==='undefined'){return undefined;}
12+
if(type==='number'||type==='boolean'){return String(o);}
13+
if(type==='string'){return jQuery.quoteString(o);}
14+
if(typeof o.toJSON==='function'){return jQuery.toJSON(o.toJSON());}
15+
if(type==='date'){var month=o.getUTCMonth()+1,day=o.getUTCDate(),year=o.getUTCFullYear(),hours=o.getUTCHours(),minutes=o.getUTCMinutes(),seconds=o.getUTCSeconds(),milli=o.getUTCMilliseconds();if(month<10){month='0'+month;}
16+
if(day<10){day='0'+day;}
17+
if(hours<10){hours='0'+hours;}
18+
if(minutes<10){minutes='0'+minutes;}
19+
if(seconds<10){seconds='0'+seconds;}
20+
if(milli<100){milli='0'+milli;}
21+
if(milli<10){milli='0'+milli;}
22+
return'"'+year+'-'+month+'-'+day+'T'+
23+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
24+
pairs=[];if(jQuery.isArray(o)){for(k=0;k<o.length;k++){pairs.push(jQuery.toJSON(o[k])||'null');}
25+
return'['+pairs.join(',')+']';}
26+
if(typeof o==='object'){for(k in o){if(hasOwn.call(o,k)){type=typeof k;if(type==='number'){name='"'+k+'"';}else if(type==='string'){name=jQuery.quoteString(k);}else{continue;}
27+
type=typeof o[k];if(type!=='function'&&type!=='undefined'){val=jQuery.toJSON(o[k]);pairs.push(name+':'+val);}}}
28+
return'{'+pairs.join(',')+'}';}};jQuery.evalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(str){return eval('('+str+')');};jQuery.secureEvalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(str){var filtered=str.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*jQuery/.test(filtered)){return eval('('+str+')');}
29+
throw new SyntaxError('Error parsing JSON, source is not valid.');};jQuery.quoteString=function(str){if(str.match(escape)){return'"'+str.replace(escape,function(a){var c=meta[a];if(typeof c==='string'){return c;}
30+
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
31+
return'"'+str+'"';};}(jQuery));
32+
33+
/**
34+
*
35+
* @author: Malishev Dmitry <dima.malishev@gmail.com>
36+
*/
37+
var _DEBUG = true;
38+
var _DEBUG_LEVEL = 'ALL';
39+
// possible levels: ALL, IMPORTANT
40+
var Error = {FATAL: 1, WARNING: 0, NORMAL: -1};
41+
42+
//
43+
// GLOBAL SETTINGS
44+
//
45+
GLOBAL = {};
46+
GLOBAL.FTP_USER_PREFIX = 'admin_';
47+
GLOBAL.AJAX_URL = '';
48+
49+
/**
50+
* Init debug, grabs console object if accessible, or makes dummy debugger
51+
*/
52+
var fb = _DEBUG && 'undefined' != typeof(console) ? console : {
53+
log : function(){},
54+
debug : function(){},
55+
info : function(){},
56+
warn : function(){},
57+
error : function(){},
58+
assert : function(){},
59+
dir : function(){},
60+
dirxml : function(){},
61+
trace : function(){},
62+
group : function(){},
63+
groupEnd : function(){},
64+
time : function(){},
65+
timeEnd : function(){},
66+
profile : function(){},
67+
profileEnd : function(){},
68+
count : function(){},
69+
msg : function(){}
70+
};
71+
72+
//
73+
var App = {
74+
// Main namespases for page specific functions
75+
// Core namespaces
76+
Ajax: { Busy: {} },
77+
Core: {},
78+
// Actions. More widly used funcs
79+
Actions: {
80+
WEB: {}
81+
},
82+
// Utilities
83+
Helpers: {},
84+
HTML: {Build: {}},
85+
Filters: {},
86+
Env: {
87+
lang: GLOBAL.lang,
88+
},
89+
i18n: {},
90+
Listeners: {
91+
WEB: {}
92+
},
93+
View:{
94+
HTML: {
95+
Build: {}
96+
},
97+
// pages related views
98+
},
99+
Cache: {
100+
clear: function(){} // TODO: stub method, will be used later
101+
},
102+
Ref: {},
103+
Tmp: {},
104+
Thread: {
105+
run: function(delay, ref){
106+
setTimeout(function(){
107+
ref();
108+
}, delay*10);
109+
}
110+
},
111+
Settings: { GLOBAL: {}, General: {}},
112+
Templates: {
113+
Templator: null,
114+
Tpl: {},
115+
_indexes: {}
116+
}
117+
};
118+
119+
// Internals
120+
Array.prototype.set = function(key, value){
121+
var index = this[0][key];
122+
this[1][index] = value;
123+
}
124+
Array.prototype.get = function(key){
125+
var index = this[0][key];
126+
return this[1][index];
127+
}
128+
Array.prototype.finalize = function(){
129+
this.shift();
130+
this[0] = this[0].join('');
131+
return this[0];
132+
}
133+
Array.prototype.done = function(){
134+
return this.join('');
135+
}
136+
137+
String.prototype.wrapperize = function(key, ns){
138+
var tpl = App.Templates.get(key, ns);
139+
tpl.set(':content', this);
140+
141+
return tpl.finalize();
142+
}
143+
144+
145+
146+
App.Ajax.request = function(method, data, callback, onError){
147+
// this will prevent multiple ajaxes on user clicks
148+
/*if (App.Helpers.isAjaxBusy(method, data)) {
149+
fb.warn('ajax request ['+method+'] is busy');
150+
return;
151+
}*/
152+
//App.Helpers.setAjaxBusy(method, data);
153+
data = data || {};
154+
155+
jQuery.ajax({
156+
url: GLOBAL.ajax_url,
157+
global: false,
158+
type: data.request_method || "GET",
159+
data: jQuery.extend(data, {'action': method}),
160+
dataType: "text boost",
161+
converters: {
162+
"text boost": function(value) {
163+
value = value.trim();
164+
return jsonParse(value);
165+
}},
166+
async: true,
167+
cache: false,
168+
error: function(jqXHR, textStatus, errorThrown)
169+
{
170+
onError && onError();
171+
if ('undefined' != typeof onError) {
172+
fb.error(textStatus);
173+
}
174+
},
175+
complete: function()
176+
{
177+
//App.Helpers.setAjaxFree(method, data);
178+
},
179+
success: function(reply)
180+
{
181+
//App.Helpers.setAjaxFree(method, data);
182+
try {
183+
callback && callback(reply);
184+
}
185+
catch(e) {
186+
alert('GENERAL ERROR: '+e);
187+
//App.Helpers.generalError();
188+
}
189+
}
190+
});
191+
}
192+
193+
jQuery.extend({
194+
keys: function(obj){
195+
if (!obj) {
196+
return [];
197+
}
198+
var a = [];
199+
jQuery.each(obj, function(k){ a.push(k) });
200+
return a;
201+
}
202+
})
203+
204+
205+
App.Core.create_hidden_form = function(action){
206+
var form = jQuery('<form>', {
207+
id : 'hidden-form',
208+
method : 'post',
209+
action : action
210+
});
211+
jQuery('body').append(form);
212+
213+
return form;
214+
};
215+
216+
App.Core.extend_from_json = function(elm, data, prefix){
217+
elm = jQuery(elm);
218+
var data = App.Core.flatten_json(data, prefix);
219+
var keys = jQuery.keys(data);
220+
for(var i=0, cnt=keys.length; i<cnt; i++)
221+
{
222+
elm.append(jQuery('<input>', {
223+
name : keys[i],
224+
value: data[keys[i]],
225+
type : 'hidden'
226+
}));
227+
}
228+
229+
return elm;
230+
}
231+
232+
App.Core.flatten_json = function(data, prefix){
233+
var keys = jQuery.keys(data);
234+
var result = {};
235+
236+
prefix || (prefix = '');
237+
238+
if(keys.length)
239+
{
240+
for(var i=0, cnt=keys.length; i<cnt; i++)
241+
{
242+
var value = data[keys[i]];
243+
switch(typeof(value))
244+
{
245+
case 'function': break;
246+
case 'object' : result = jQuery.extend(result, App.Core.flatten_json(value, prefix + '[' + keys[i] + ']')); break;
247+
default : result[prefix + '[' + keys[i] + ']'] = value;
248+
}
249+
}
250+
return result;
251+
}
252+
else
253+
{
254+
return false;
255+
}
256+
}
257+
258+
//
259+
// Cookies adapter
260+
// Allow to work old pages realisations of cookie requests
261+
//
262+
function createCookie(name, value, expire_days) {
263+
jQuery.cookie(name, value, { expires: expire_days});
264+
}
265+
266+
function readCookie(name) {
267+
jQuery.cookie(name);
268+
}
269+
270+
function eraseCookie(name) {
271+
jQuery.removeCookie(name);
272+
}
273+
274+
275+
/**
276+
* Timer for profiling
277+
*/
278+
var timer = {};
279+
timer.start = function()
280+
{
281+
timer.start_time = new Date();
282+
}
283+
284+
timer.stop = function( msg )
285+
{
286+
timer.stop_time = new Date();
287+
timer.print( msg );
288+
}
289+
290+
timer.print = function( msg )
291+
{
292+
var passed = timer.stop_time - timer.start_time;
293+
fb.info( msg || '' + passed / 1000 );
294+
}
295+
296+
297+
String.prototype.trim = function()
298+
{
299+
var str = this;
300+
str = str.replace(/^\s+/, '');
301+
for (var i = str.length - 1; i >= 0; i--) {
302+
if (/\S/.test(str.charAt(i))) {
303+
str = str.substring(0, i + 1);
304+
break;
305+
}
306+
}
307+
return str;
308+
}

web/js/pages/add.web.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
2+
if (hint.trim() == '') {
3+
$(elm).parent().find('.ftp_username_hint').html('');
4+
}
5+
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
6+
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
7+
}
8+
$(elm).parent().find('.ftp_username_hint').html(GLOBAL.FTP_USER_PREFIX + hint);
9+
}
10+
11+
App.Listeners.WEB.keypress_ftp_username = function() {
12+
$('input[name="v_ftp_user"]').bind('keypress', function(evt) {
13+
clearTimeout(window.frp_usr_tmt);
14+
window.frp_usr_tmt = setTimeout(function() {
15+
var elm = $(evt.target);
16+
App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
17+
}, 100);
18+
});
19+
}
20+
21+
//
22+
// Page entry point
23+
App.Listeners.WEB.keypress_ftp_username();

web/js/pages/edit.web.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
2+
if (hint.trim() == '') {
3+
$(elm).parent().find('.ftp_username_hint').html('');
4+
}
5+
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
6+
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
7+
}
8+
$(elm).parent().find('.ftp_username_hint').html(GLOBAL.FTP_USER_PREFIX + hint);
9+
}
10+
11+
App.Listeners.WEB.keypress_ftp_username = function() {
12+
$('input[name="v_ftp_user"]').bind('keypress', function(evt) {
13+
clearTimeout(window.frp_usr_tmt);
14+
window.frp_usr_tmt = setTimeout(function() {
15+
var elm = $(evt.target);
16+
App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
17+
}, 100);
18+
});
19+
}
20+
21+
//
22+
// Page entry point
23+
App.Listeners.WEB.keypress_ftp_username();

0 commit comments

Comments
 (0)