1+
2+
3+ App . Helpers . getMbHumanMeasure = function ( val )
4+ {
5+ return App . Helpers . getMbHuman ( val , true ) ;
6+ }
7+
8+ /**
9+ * Currently no bytes are used, minimal value is in MB
10+ * uncomment in case we will use bytes instead
11+ */
12+ App . Helpers . getMbHuman = function ( val , only_measure )
13+ {
14+ var bytes = val * 1024 * 1024 ;
15+ var kilobyte = 1024 ;
16+ var megabyte = kilobyte * 1024 ;
17+ var gigabyte = megabyte * 1024 ;
18+ var terabyte = gigabyte * 1024 ;
19+ var precision = 0 ;
20+
21+ /*if ((bytes >= 0) && (bytes < kilobyte)) {
22+ return bytes + ' B';
23+
24+ } else if ((bytes >= kilobyte) && (bytes < megabyte)) {
25+ return (bytes / kilobyte).toFixed(precision) + ' KB';
26+
27+ } else */
28+ if ( ( bytes >= megabyte ) && ( bytes < gigabyte ) ) {
29+ return only_measure ? 'MB' : ( bytes / megabyte ) . toFixed ( precision ) ;
30+
31+ } else if ( ( bytes >= gigabyte ) && ( bytes < terabyte ) ) {
32+ return only_measure ? 'GB' : ( bytes / gigabyte ) . toFixed ( precision ) ;
33+
34+ } else if ( bytes >= terabyte ) {
35+ return only_measure ? 'TB' : ( bytes / terabyte ) . toFixed ( precision ) ;
36+
37+ } else {
38+ return only_measure ? 'MB' : bytes ;
39+ }
40+ }
41+
142App . Helpers . getFirst = function ( obj )
243{
344 try { // TODO: remove try / catch
@@ -101,22 +142,6 @@ App.Helpers.showConsoleHint = function()
101142 // TODO:
102143}
103144
104-
105- // UTILS
106- App . Utils . generatePasswordHash = function ( length )
107- {
108- var length = length || 11 ;
109- var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!~." ;
110- var pass = "" ;
111- for ( var x = 0 ; x < length ; x ++ )
112- {
113- var i = Math . floor ( Math . random ( ) * 62 ) ;
114- pass += chars . charAt ( i ) ;
115- }
116-
117- return pass ;
118- }
119-
120145App . Helpers . markBrowserDetails = function ( )
121146{
122147 var b = App . Env . BROWSER ;
@@ -194,12 +219,12 @@ App.Helpers.liveValidate = function()
194219
195220App . Helpers . generatePassword = function ( )
196221{
197- var length = 12 ;
198- var chars = "abcdefghijklmn.-%$#&-opqrstuvwxyz.-%$#&-ABCDEFGHIJKLMNOPQRSTUV.-%$#&-WXYZ1234567890.-%$#&- " ;
222+ var length = 8 ;
223+ var chars = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789 " ;
199224 var pass = "" ;
200225
201226 for ( x = 0 ; x < length ; x ++ ) {
202- var i = Math . floor ( Math . random ( ) * 62 ) ;
227+ var i = Math . floor ( Math . random ( ) * chars . length ) ;
203228 pass += chars . charAt ( i ) ;
204229 }
205230
@@ -210,3 +235,21 @@ App.Helpers.Warn = function(msg)
210235{
211236 alert ( msg ) ;
212237}
238+
239+ App . Helpers . openInnerPopup = function ( elm , html )
240+ {
241+ App . Helpers . closeInnerPopup ( ) ;
242+
243+ var offset = $ ( elm ) . offset ( ) ;
244+ var tpl = App . Templates . get ( 'inner_popup' , 'general' ) ;
245+ tpl . set ( ':CONTENT' , html ) ;
246+ tpl . set ( ':LEFT' , offset . left ) ;
247+ tpl . set ( ':TOP' , offset . top ) ;
248+
249+ $ ( document . body ) . append ( tpl . finalize ( ) ) ;
250+ }
251+
252+ App . Helpers . closeInnerPopup = function ( evt )
253+ {
254+ $ ( '#inner-popup' ) . remove ( ) ;
255+ }
0 commit comments