Pman.js
[Pman.Core] / Pman.js
1 //<script type="text/javascript">
2
3 /**
4  * 
5  * >>> Pman.layout.getRegion('center').tabs.stripWrap
6  * ==> tab.???
7  * var tbh = Pman.layout.getRegion('center').tabs.stripWrap.child('div').createChild(
8  * 
9  * {tag: 'div', style: 'display:block;position:absolute;top:2;left:300;width:100%;height:25px'});
10  * 
11  * 
12  *  CHANGES
13  *  - gtranslate moved to Pman.GoogleTranslate
14  * 
15  * 
16  */
17  
18 if (typeof(_T) == 'undefined') { _T={};}
19  
20
21
22   
23
24 Pman = new Roo.Document(
25 {
26    /// appVersion: '1.7', // fixme = needs to be removed - use Global AppVersion
27     subMenuItems : [],
28     topMenuItems : [],
29     rightNames: { }, /// register right names here - so they can be translated and rendered.
30     /**
31      * @property {Roo.menu.Menu} pulldownMenu - the 'add menu pulldown, you can use it to add items..
32      *
33      */
34     pulldownMenu : false, 
35     
36     
37     buildCompleted : false, // flag to say if we are building interface..
38     events : {
39         'beforeload' : true, // fired after page ready, before module building.
40         'load' : true, // fired after module building
41         'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
42     },
43     
44     listeners : {
45         'ready' : function()
46         {
47             // kludge to fix firebug debugger
48             if (typeof(console) == 'undefined') {
49                 console = { log : function() {  } };
50             }
51             
52             // remove loader..
53             if (Roo.get('loading')) {
54                 Roo.get('loading').remove();
55             }
56             
57             Roo.state.Manager.setProvider(new Roo.state.CookieProvider());
58             
59             // link errors...
60             
61             if (AppLinkError.length) {
62                 Roo.MessageBox.alert("Error", AppLinkError, function() {
63                     Pman.Login.onLoad();
64                 });
65                 return;
66             }
67             
68             
69             // reset password!!!!
70             if (showNewPass.length) {
71                 Pman.PasswordChange.show(  { passwordReset : showNewPass },
72                     function(data) {
73                         // fail and success we do  a load...
74                         Pman.Login.onLoad();
75                     }
76                 );
77                 return;
78             }
79              
80             Pman.Login.onLoad();
81             
82         },
83         'load' : function()
84         {
85             if (Roo.get('loading-logo-tile')) {
86                 Roo.get('loading-logo-tile').remove();
87             }
88             if (Roo.get('loading-logo-tile-top')) {
89                 Roo.get('loading-logo-tile-top').remove();
90             }
91             if (Roo.get('loading-logo-bottom')) {
92                 Roo.get('loading-logo-bottom').remove();
93             }
94             if (Roo.get('loading-logo-center')) {
95                 Roo.get('loading-logo-center').remove();
96             }
97         }   
98         
99     },
100    
101
102     
103     layout: false,
104     
105     onload: function() {
106         //this.fireEvent('beforeload',this);
107         
108         
109         
110         if (this.layout) {
111             return; // already loaded
112         } 
113         if (Roo.get('loading')) {
114             Roo.get('loading').remove();
115         }
116         if (Roo.get('loading-mask')) {
117             Roo.get('loading-mask').show();
118         }
119         
120         
121        
122         
123         /*
124         Roo.MessageBox.show({
125            title: "Please wait...",
126            msg: "Building Interface...",
127            width:340,
128            progress:true,
129            closable:false
130           
131         });
132         */
133         //Pman.onLoadBuild();
134         //Roo.get(document.body).mask("Building Interface");
135         //Pman.onLoadBuild.defer(100, Pman);
136        //Pman.onLoadBuild();
137                     
138    // },
139     //onLoadBuild : function() {
140         
141         var _this = this;
142         this.stime = new Date();
143         this.layout = new Roo.BorderLayout(document.body, {
144             north: {
145                 split:false,
146                 initialSize: 25,
147                 titlebar: false
148             },
149          
150              
151             center: {
152                 titlebar: false,
153                 autoScroll:false,
154                 closeOnTab: true,
155                 tabPosition: 'top',
156                 //resizeTabs: true,
157                 alwaysShowTabs: true,
158                 minTabWidth: 140
159             } ,
160             south: {
161                 collapsible : true,
162                 collapsed : true,
163                 split:false,
164                 height: 120,
165                 titlebar: false 
166             }
167             
168         });
169         
170         this.fireEvent('beforeload',this);
171         
172         
173         
174         this.layout.beginUpdate();
175         this.layout.add('north', new Roo.ContentPanel('title', 'North'));
176         var au = Pman.Login.authUser;
177         if (au.id > 0 && au.company_id_background_color && au.company_id_background_color.length) {
178             Roo.get('title').dom.style.backgroundColor = '#' + au.company_id_background_color;
179             Roo.get('headerInformation').dom.style.color = this.invertColor('#' + au.company_id_background_color);
180         }
181         if (au.id > 0 && au.company_id_logo_id * 1 > 0) {
182             Roo.get('headerInformation-company-logo').dom.src =  baseURL + 
183                 '/Images/' + au.company_id_logo_id + '/' + au.company_id_logo_id_filename;
184         } else {
185             Roo.get('headerInformation-company-logo').dom.src = Roo.BLANK_IMAGE_URL;
186         }
187         
188         Roo.get('headerInformation').dom.innerHTML = String.format(
189                 "You are Logged in as <b>{0} ({1})</b>", // to {4} v{3}", // for <b>{2}</b>",
190                 au.name, au.email, au.company_id_name, 
191                 AppVersion , appNameShort
192         );
193         
194         
195         document.title = appName + ' v' + AppVersion + ' - ' + au.company_id_name;
196         Roo.QuickTips.init(); 
197         if (Roo.isGecko) {
198            Roo.useShims = true;
199         }
200        
201         //this.mainLayout.beginUpdate();
202         //var maskDom = Roo.get(document.body)._maskMsg.dom
203         this.layout.beginUpdate();
204         
205         Pman.building = true;
206         
207         this.buildModules(this, 
208             function() {
209                 
210                 _this.layout.getRegion('center').showPanel(0);
211                 _this.layout.endUpdate(); 
212                 _this.addTopToolbar();  
213                 _this.finalize();
214                 _this.fireEvent('load',this);
215                 
216                 if (!_this.layout.getRegion('south').panels.length) {
217                     _this.layout.getRegion('south').hide();
218                 }
219                 
220                 
221             }
222         );
223         
224         
225      
226     },
227     
228     addTopToolbar : function()
229     {
230           //console.log( "t6:" + ((new Date())-stime));
231         //this.mainLayout.endUpdate();
232         // make a new tab to hold administration stuff...
233         
234        
235         //console.log( "t7:" + ((new Date())-stime));
236         var se = Pman.layout.getRegion('center').tabs.stripEl;
237         var tbh = se.createChild( 
238                 { tag: 'td', style: 'width:100%;'  });
239         
240         var lotb = new Roo.Toolbar(tbh);
241         
242         if (Roo.isSafari) {
243             var tbl = se.child('table', true);
244             tbl.setAttribute('width', '100%');
245         }
246         lotb.add(
247             new Roo.Toolbar.Fill(), 
248      
249             {
250                 text: "Change Password",
251                 cls: 'x-btn-text-icon',
252                 icon: rootURL + '/Pman/templates/images/change-password.gif',
253                 handler : function(){
254                     Pman.PasswordChange.show({});
255                 }
256             }, '-'
257         );
258          
259         
260         if (this.topMenuItems.length) {
261             
262             Roo.each(this.topMenuItems, function (mi) {
263                 lotb.add(mi);
264             });
265             lotb.add('-');
266         }
267         
268         
269         
270         if (this.subMenuItems.length) {
271             
272             this.subMenuItems.sort(function (a,b) {
273                 return a.seqid > b.seqid ? 1 : -1;
274             });
275             // chop off last seperator.
276             // since we always add it.. just chop of last item
277             this.subMenuItems.pop(); 
278             
279             this.pulldownMenu = new Roo.Toolbar.Button( 
280                 {
281                     text: "Add New Item",
282                     cls: 'x-btn-text-icon',
283                     icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
284                     menu : {
285                         items : this.subMenuItems
286                     }     
287                 }
288             );
289             lotb.add(this.pulldownMenu, '0');
290             
291         }
292        
293         lotb.add(
294             {
295                 text: "Logout",
296                 cls: 'x-btn-text-icon',
297                 icon: rootURL + '/Pman/templates/images/logout.gif',
298                 handler: function() {
299                     Pman.Login.logout();
300                 }
301                  
302             }
303         );
304       
305        // this.layout.endUpdate();
306     },
307     
308     
309     finalize : function() {
310         
311       
312        
313         window.onbeforeunload = function(e) { 
314             e = e || window.event;
315             var r = "Closing this window will loose changes, are you sure you want to do that?";
316
317             // For IE and Firefox
318             if (e) {
319                 e.returnValue = r;
320             }
321
322             // For Safari
323             return r;
324             
325         };
326         
327         Roo.MessageBox.hide();
328         if (Roo.get('loading-mask')) {
329            Roo.get('loading-mask').remove();
330         }
331         
332         
333         this.buildCompleted = true; // now we can force refreshes on everything..
334         
335         
336         // does the URL indicate we want to see a system..
337         if (AppTrackOnLoad * 1 > 0) {
338             this.onLoadTrack(AppTrackOnLoad,false);
339         }
340         
341         // Open system..
342         
343         var forceAdmin = function(data)
344         {
345             if (!data || !data.id) {
346                 //Roo.log("Force Admin");
347                 Pman.Dialog.PersonStaff.show( 
348                     { 
349                         id : 0, 
350                         company_id : Pman.Login.authUser.company_id_id * 1, 
351                         company_id_name : Pman.Login.authUser.company_id_name
352                     }, function(data) {
353                         forceAdmin(data);
354                     }
355                 );
356                 return;
357             }
358             Roo.state.Manager.set('Pman.Login.username', data.email),
359             window.onbeforeunload = false;
360             document.location = baseURL + '?ts=' + Math.random();
361         }
362         
363         var forceCompany = function(data) {
364             if (Pman.Login.authUser.company_id * 1 > 0) {
365                 forceAdmin();
366                 return;
367             }
368             if (!data || !data.id) {
369                 Pman.Dialog.Companies.show( { id : 0, isOwner : 1, comptype: 'OWNER' }, function(data) {
370                     forceCompany(data);
371                 });
372                 return;
373             }
374             Pman.Login.authUser.company_id_id  = data.id;
375             Pman.Login.authUser.company_id  = data.id;
376             Pman.Login.authUser.company_id_name  = data.name;
377             forceAdmin();
378         }
379         
380         if (Pman.Login.authUser.id < 0) {
381             // admin company has been created - create the user..
382             if (Pman.Login.authUser.company_id_id* 1 > 0) {
383                 forceAdmin();
384                 return;
385             }
386             
387             forceCompany();
388             /// create account..
389             
390             
391         }
392         
393
394     },
395     
396     
397     // REMOVE THESE 
398     
399      
400     onLoadTrack : function(id,cb) {
401         this.onLoadTrackCall(id, cb, 'DocumentsCirc_');
402     },
403     onLoadTrackEdit : function(id,cb) {
404         this.onLoadTrackCall(id, cb, 'Documents_');
405     },
406     
407     
408     /// ----------- FIXME -----
409     
410     
411     onLoadTrackCall : function(id,cb, cls) {
412         Roo.get(document.body).mask("Loading Document details");
413
414         Pman.request({
415             url: baseURL + '/Roo/Documents.html',  
416             params: {
417                 _id: id
418             },  
419             method: 'GET',  
420             success : function(data) {
421                 Roo.get(document.body).unmask();
422              
423                 
424                 switch(data.in_out) {
425                     case 'IN' : cls+='In';break;
426                     case 'OUT' : cls+='Out';break;
427                     case 'WIP' : cls+='Wip';break;
428                     default: 
429                         Roo.MessageBox.alert("Error", "invalid in_out");
430                         return;
431                 }
432                 Pman.Dialog[cls].show(data, cb ? cb : Pman.refreshActivePanel);
433             }, 
434             
435             failure: function() {
436                 Roo.get(document.body).unmask();
437                 //if (cb) {
438                 //    cb.call(false);
439                 //}
440                  
441            }
442         });
443           
444     },
445     
446     refreshActivePanel : function() {
447         var actpan = this.layout.getRegion('center').getActivePanel();
448         if (actpan.controller && actpan.controller.paging) {
449             actpan.controller.paging.onClick('refresh');
450             return;
451         }
452         
453         var agid = Pman.layout.getRegion('center').getActivePanel().id;
454         if (!agid) {
455             return;
456         }
457         Pman.Tab[agid].paging.onClick('refresh');
458     },
459     toCidV : function(data) {
460         return 'C' + data.in_out.substring(0,1) + data.cid;
461     },
462     
463     
464     /**
465      * eg. has Pman.hasPerm('Admin.Admin_Tab', 'S') == showlist..
466      * 
467      */
468     hasPerm: function(name, lvl) {
469         if (
470             (typeof(Pman.Login.authUser) != 'object')
471             ||
472             (typeof(Pman.Login.authUser.perms) != 'object')
473             ||
474             (typeof(Pman.Login.authUser.perms[name]) != 'string')
475             ) {
476                 return false;
477         }
478         
479         return Pman.Login.authUser.perms[name].indexOf(lvl) > -1;
480         
481     },
482     
483     
484     
485     
486     
487     
488     
489     
490     Readers : {},
491     ColModels : {},
492     Forms : {},
493     Tab : {},
494     Dialog : {},
495     
496     processResponse : function (response)
497     {
498         var res = '';
499         try {
500             res = Roo.decode(response.responseText);
501             // oops...
502             if (typeof(res) != 'object') {
503                 res = { success : false, errorMsg : res, errors : true };
504             }
505             if (typeof(res.success) == 'undefined') {
506                 res.success = false;
507             }
508             
509         } catch(e) {
510             res = { success : false,  errorMsg : response.responseText, errors : true };
511         }
512         return res;
513     },
514     genericDelete : function(tab,tbl) {
515         
516         var r = [];
517         
518             
519         var s = tab.grid.getSelectionModel().getSelections();
520         if (!s.length)  {
521             Roo.MessageBox.alert("Error", "Select at least one Row to delete" );
522             return '';
523         }
524         
525         for(var i = 0; i < s.length; i++) {
526             r.push(s[i].data.id);
527         }
528     
529         Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
530             function(btn) {
531                 if (btn != 'yes') {
532                     return;
533                 }
534                 // what about the toolbar??
535                 tab.grid.getView().mainWrap.mask("Deleting");
536                 Pman.request({
537                     url: baseURL + '/Roo/'+tbl+'.php',
538                     method: 'GET',
539                     params: {
540                         _delete : r.join(',')
541                     },
542                     success: function(response) {
543                         tab.grid.getView().mainWrap.unmask();
544                         if ( tab.paging ) {
545                             tab.paging.onClick('refresh');   
546                         } else if (tab.refresh) {
547                             tab.refresh();
548                         } else if (tab.grid.footer && tab.grid.footer.onClick) {
549                             // new xtype built grids
550                             tab.grid.footer.onClick('refresh');   
551                         } else {
552                             tab.grid.getDataSource().load();
553                         }
554                         
555                         
556                         
557                     },
558                     failure: function(act) {
559                         tab.grid.getView().mainWrap.unmask();
560                         Roo.MessageBox.alert("Error", "Error Deleting");
561                     }
562                     
563                 });
564             }
565             
566         );
567         return '';
568     },
569     
570     
571     standardActionFailed :  function(f, act, cb) {
572     
573         if (act.failureType == 'client') {
574             Roo.MessageBox.alert("Error", "Please Correct all the errors in red", cb);
575             return;
576         }
577         if (act.failureType == 'connect') {
578             Roo.MessageBox.alert("Error", "Problem Connecting to Server - please try again.", cb);
579             return;
580         }
581         
582         if (act.type == 'submit') {
583             
584             Roo.MessageBox.alert("Error", typeof(act.result.errorMsg) == 'string' ?
585                 String.format('{0}', act.result.errorMsg) : 
586                 "Saving failed = fix errors and try again", cb);
587             return;
588         }
589         
590         // what about load failing..
591         Roo.MessageBox.alert("Error", "Error loading details",cb); 
592     },
593     /**
594      * Depreciated - USE new Pman.Request
595     * 
596      * 
597      */
598     request : function(c) {
599         var r= new Roo.data.Connection({
600             timeout : typeof(c.timeout) == 'undefined' ?  30000 : c.timeout
601         });
602         r.request({
603             url: c.url,
604             method : c.method,
605             params: c.params,
606             xmlData : c.xmlData,
607             success:  function(response, opts)  {  // check successfull...
608                
609                 var res = Pman.processResponse(response);
610                 
611                 if (!res.success) { // error!
612                     if (c.failure) {
613                         if (true === c.failure.call(this,response, opts)) {
614                             return;
615                         }
616                     }
617                     Roo.MessageBox.hide();
618                     Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
619                     return;
620                 }
621                 
622                 c.success.call(this, res.data);
623                 
624                 return; 
625             },
626             failure :  function(response, opts)  {  // check successfull...
627                 
628                 if (c.failure) {
629                     if (true === c.failure.call(this,response, opts)) {
630                         return;
631                     }
632                 }
633                 Roo.MessageBox.hide();
634                 Roo.MessageBox.alert("Error", "Connection timed out sending");
635                 Roo.log(response);
636                 
637             },
638             scope: this
639             
640         });
641     },
642     
643     
644     // depreciated - use Pman.Download()
645     
646     download : function(c) {
647         
648         return new Pman.Download(c);
649     },
650     
651     // fixme - move to document manager...
652     downloadRevision : function(doc, rev)
653     {
654         this.download({
655             url: baseURL + '/Documents/Doc/DownloadRev/'+ doc.id + '/' + rev + '/' +
656                 doc.project_id_code + '-' + doc.cidV + '-' + rev  + '-' +  doc.filename
657         }); 
658                     
659     },
660     
661     
662     exportCSV : function(c) {
663         
664         for(var i=0;i < c.csvFormat.length;i++) {
665             c.params['csvCols['+i+']'] = c.csvFormat[i][0];
666             c.params['csvTitles['+i+']'] = c.csvFormat[i][1];
667         }
668         c.url +=  '?' + Roo.urlEncode(c.params);
669         this.download(c);
670
671     },
672     
673     
674     prettyDate : function (value) 
675     {
676         if (typeof(value) == 'string') {
677             var ds = Date.parseDate(value, 'Y-m-d H:i:s');
678             if (ds) {
679                 return this.prettyDate(ds);
680             }
681             ds = Date.parseDate(value, 'Y-m-d');
682             if (ds) {
683                 return this.prettyDate(ds);
684             }
685             return '';
686         }
687 // last 7 days...
688         if (!value) {
689             return '';
690         }
691         var td = new Date();
692         var daysSince = Math.floor(td.getElapsed(value) / (1000 * 60*60*24));
693         if (daysSince < 7) {
694             return value.dateFormat('D H:i');
695         }
696         
697         // same month
698         if (td.dateFormat('m') == value.dateFormat('m')) {
699             return value.dateFormat('dS D');
700         }
701         // same year?
702         if (td.dateFormat('Y') == value.dateFormat('Y')) {
703             return value.dateFormat('dS M');
704         }
705         return value.dateFormat('d M Y');
706     },
707     loadException : function(a,b,c,d)
708     {
709         if (d && d.authFailure) {
710             Pman.Login.show();
711             return;
712         }
713         Roo.MessageBox.alert("Problem Loading Data", a.message || c.statusText);
714     },
715     
716     
717     /**
718      * 
719      * Routine to flash alerts in the title bar..
720      * 
721      * 
722      */
723     
724     notifyActive : false,
725     
726     notifyTitle: function(msg)
727     {
728         if (this.notifyActive ) {
729             return;
730         }
731         var stop = false;
732         
733         var stopper = function() {
734             stop = true;
735              document.title = oldtitle;
736         };
737         
738         Roo.get(document.body).on('mousemove', stopper, this);
739         var oldtitle = document.title;
740         var s = 1;
741         var _this = this;
742         var ivl = window.setInterval(function() {
743             
744             if (stop) {
745                 Roo.get(document.body).un('mousemove', stopper, this);
746                 _this.notifyActive = false;
747                 document.title = oldtitle;
748                 window.clearInterval(ivl);
749                 return true;
750             }
751             s = !s;
752             document.title = s ? msg : oldtitle;
753             return false;     
754         }, 1000); // every 120 secs = 2mins..
755          document.title =   msg;
756         
757         
758         
759     },
760     
761     modules : false,
762     /**
763      * example:
764      * 
765      * Pman.register({
766           modKey : '00-admin-xxxx',
767           module : Pman.Tab.projectMgr,
768           moduleName : 'Pman.Tab.projectMgr',
769           region : 'center',
770           parent : Pman.layout
771         })
772      * 
773      */
774     register : function(obj)
775     {
776         
777         // ignore registration of objects which are disabled.
778         appDisabled = typeof(appDisabled) == 'undefined' ? [] : appDisabled;
779         
780         if ((typeof(obj.moduleName) != 'undefined')
781                 && appDisabled.indexOf(obj.moduleName) > -1)
782         {
783             return;
784         }
785         
786         if (!obj.parent) {
787             if (obj.parent === false) {
788                 //console.log('skip module (no parent)' + obj.modkey);
789                 return;
790             }
791             // this is an error condition - the parent does not exist..
792             // technically it should not happen..
793             console.log(obj);
794         }
795         if (!obj.parent.modules) {
796             obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.modKey });
797         }
798         
799         obj.parent.modules.add(obj);
800         
801     },
802     
803     buildModules : function(parent, onComplete) 
804     {
805         
806         var _this = this;
807         var cmp = function(a,b) {   
808             return String(a).toUpperCase() > String(b).toUpperCase() ? 1 : -1;
809             
810         };
811         if (!parent.modules) {
812             return;
813         }
814         parent.modules.keySort('ASC',  cmp );
815         var mods = [];
816         
817         
818         // add modules to their parents..
819         var addMod = function(m) {
820            // console.log(m.modKey);
821             
822             mods.push(m);
823             if (m.module.modules) {
824                 m.module.modules.keySort('ASC',  cmp );
825                 m.module.modules.each(addMod);
826             }
827             if (m.finalize) {
828                 m.finalize.name = m.name + " (clean up) ";
829                 mods.push(m.finalize);
830             }
831             
832         }
833  
834         parent.modules.each(addMod);
835         //this.allmods = mods;
836         //console.log(mods);
837         //return;
838         if (!mods.length) {
839             if (onComplete) onComplete();
840             return;
841         }
842         // flash it up as modal - so we store the mask!?
843         Roo.MessageBox.show({ title: 'loading' });
844         Roo.MessageBox.show({
845            title: "Please wait...",
846            msg: "Building Interface...",
847            width:450,
848            progress:true,
849            closable:false,
850            modal: false
851           
852         });
853         var n = 0;
854         var progressRun = function() {
855             
856             var mod = mods[n];
857             
858             
859             Roo.MessageBox.updateProgress(
860                 (n+1)/mods.length,  "Building Interface " + (n+1) + 
861                     " of " + mods.length + 
862                     (mod.name ? (' - ' + mod.name) : '')
863                     );
864             
865             
866             
867             if (typeof(mod) == 'function') {
868                 mod();
869                 
870             } else  if (mod.parent.layout && !mod.module.disabled) {
871                 // honour permname setings..
872                 if (mod.permname && mod.permname.length) {
873                     if (Pman.hasPerm(mod.permname, 'S')) {
874                         mod.module.add(mod.parent.layout, mod.region);    
875                     }
876                 } else {
877                     mod.module.add(mod.parent.layout, mod.region);    
878                 }
879                     
880                  
881             }
882             
883             
884             n++;
885             if (n >= mods.length) {
886                 onComplete();  
887                 return;
888             }
889                 
890             
891             progressRun.defer(10, Pman);    
892         }
893         progressRun.defer(1, Pman);
894      
895         
896         
897     },
898     
899     invertColor : function(c)
900     {
901         // read..
902         var ca = [];
903         for(var i = 0; i < 3; i++){
904             ca[i] = parseInt(c.charAt((i*2)+1) + c.charAt((i*2)+2), 16);
905         }
906             
907         // invert..
908         var col = '';
909         Roo.each(ca, function(hi) {
910             var h = parseInt(255-hi).toString(16);
911             if(h < 16){
912                 h = '0' + h;
913             }
914             col += h;
915         });
916         return '#' + col;
917         
918     }
919     
920     
921     
922     
923     
924     
925     
926 });
927