phpBMS

Changeset 631 for trunk/phpbms/common

Show
Ignore:
Timestamp:
08/03/09 13:06:33 (3 years ago)
Author:
nate
Message:
  • Initial implementation of checking for new base module updates.
    • Send extra information does not work yet.
    • Only checks for base module, not yet other modules.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/common/javascript/common.js

    r422 r631  
    6666 
    6767        loadXMLDoc: function(url,readyStateFunction,async) { 
    68          
     68 
    6969                if(!readyStateFunction) 
    7070                        readyStateFunction= null; 
    71          
     71 
    7272                if(!async) 
    7373                        async = false; 
    74                  
     74 
    7575                // branch for native XMLHttpRequest object 
    7676                if (window.XMLHttpRequest) { 
     
    9090                } 
    9191        },//end function loadXMLDoc 
    92          
     92 
    9393    nameFunctions: function (namespace) { 
    9494        var base = namespace.NAME; 
     
    109109        } 
    110110    },//endfunction 
    111          
    112          
     111 
     112 
    113113        htmlDecode: function(string){ 
    114114 
     
    122122 
    123123        reportError: function(error){ 
    124                  
     124 
    125125                if(console){ 
    126126                        if(console.log) 
     
    128128                } else 
    129129                        alert(error); 
    130                  
     130 
    131131        }//end method - reportError 
    132132 
     
    145145 
    146146        var all = module.EXPORT; 
    147          
     147 
    148148    for (var i = 0; i < all.length; i++) { 
    149149        globals[all[i]] = module[all[i]]; 
     
    153153phpBMS.base.__new__ = function () { 
    154154        var m = this; 
    155          
     155 
    156156        m.nameFunctions(this); 
    157157} 
     
    167167 
    168168phpBMS.base.update(phpBMS.dom, { 
    169          
     169 
    170170        getObjectFromID: function(id){ 
    171171                var theObject; 
    172                  
     172 
    173173                if(document.getElementById) 
    174174                        theObject=document.getElementById(id); 
     
    177177                return theObject; 
    178178        },//end method 
    179          
    180          
     179 
     180 
    181181        getElementsByClassName: function(clsName){ 
    182182                var retVal = new Array(); 
     
    194194                } 
    195195                return retVal; 
    196         }//endMethod     
    197          
     196        }//endMethod 
     197 
    198198})//end update 
    199199 
     
    206206    this._document = document; 
    207207    this._window = win; 
    208          
     208 
    209209        m.nameFunctions(this); 
    210210} 
     
    228228 
    229229phpBMS.base.update(phpBMS.signal.e.prototype,{ 
    230          
     230 
    231231            src: function () { 
    232232        return this._src; 
     
    255255        return undefined; 
    256256    }, 
    257          
     257 
    258258    stop: function () { 
    259259        this.stopPropagation(); 
     
    276276        } 
    277277    } 
    278          
     278 
    279279})//end subclass 
    280280 
     
    288288                        if(observers[i][0] == obj && observers[i][1] == eventName) 
    289289                                return observers[i]; 
    290                          
     290 
    291291                return false; 
    292                  
     292 
    293293        },//end method 
    294294 
     
    297297                var self = phpBMS.signal; 
    298298        var observers = self._observers; 
    299          
     299 
    300300        for (var i = 0; i < observers.length; i++) { 
    301301            self._disconnect(observers[i]); 
    302302        } 
    303          
     303 
    304304        delete self._observers; 
    305          
     305 
    306306        try { 
    307307            window.onload = undefined; 
     
    315315            // pass 
    316316        } 
    317                  
     317 
    318318        },//end method 
    319319 
     
    321321        _listener: function(srcObj, func){ 
    322322        var E = phpBMS.signal.e; 
    323                  
     323 
    324324                if(!srcObj || !func){ 
    325                          
     325 
    326326                        reportError("ListnerError srcObj:" + srcObj + " func:" + func); 
    327327                        return false; 
    328                          
     328 
    329329                }//endif 
    330                          
     330 
    331331                return function (nativeEvent) { 
    332332                        return func.apply(srcObj, [new E(srcObj, nativeEvent)]); 
     
    336336 
    337337        connect: function(srcObj, eventName, func){ 
    338                  
     338 
    339339                if(!srcObj || !eventName || !func){ 
    340                          
     340 
    341341                        var err = "Invalid Entry for connect: srcObj:" + srcObj + " eventName:" + eventName + " func:" + func 
    342                         reportError(err);                        
    343                          
     342                        reportError(err); 
     343 
    344344                        return false; 
    345                          
    346                 }//endif  
    347                  
     345 
     346                }//endif 
     347 
    348348        var self = phpBMS.signal; 
    349                  
     349 
    350350                var listener = self._listener(srcObj, func); 
    351                  
     351 
    352352                if (srcObj.addEventListener) { 
    353353                        srcObj.addEventListener(eventName.substr(2), listener, false); 
     
    355355                        srcObj.attachEvent(eventName, listener); // useCapture unsupported 
    356356                }//end if 
    357                  
     357 
    358358        var ident = [srcObj, eventName, listener]; 
    359359        self._observers.push(ident); 
    360360        return ident; 
    361                  
     361 
    362362        }, 
    363363 
     
    373373        } else if (src.detachEvent) { 
    374374            src.detachEvent(sig, listener); // useCapture unsupported 
    375         }        
     375        } 
    376376        }, 
    377377 
     
    380380        var self = phpBMS.signal; 
    381381        var observers = self._observers; 
    382                  
     382 
    383383        for (var i = 0; i < observers.length; i++) { 
    384384            var pident = observers[i]; 
     
    395395 
    396396        trigger: function(src, sig){ 
    397                  
     397 
    398398        var self = phpBMS.signal; 
    399399        var observers = self._observers; 
     
    410410            }//endif 
    411411        }//endfor 
    412                  
     412 
    413413        }//end method - signal 
    414          
     414 
    415415})//end class 
    416416 
     
    446446// php equivilant to htmlEntitties 
    447447String.prototype.htmlEntities = function() 
    448 {        
     448{ 
    449449        newString = this; 
    450450        var chars = new Array(); 
     
    461461                        myRegExp = new RegExp(); 
    462462                        myRegExp.compile(chars[i],'g'); 
    463          
     463 
    464464                        newString = newString.replace (myRegExp, '&#' + chars[i].charCodeAt(0) + ';'); 
    465465                } 
    466          
     466 
    467467        return newString; 
    468468} 
     
    477477                offsetTrail = offsetTrail.offsetParent; 
    478478        } 
    479         if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined")  
     479        if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") 
    480480                offsetLeft += document.body.TopMargin; 
    481481        return offsetTop; 
     
    490490                offsetTrail = offsetTrail.offsetParent; 
    491491        } 
    492         if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined")  
     492        if (navigator.userAgent.indexOf("Mac") != -1 && typeof document.body.leftMargin != "undefined") 
    493493                offsetLeft += document.body.leftMargin; 
    494494        return offsetLeft; 
     
    502502                if(theObj.childNodes[i].offsetHeight) 
    503503                        totalHeight+=theObj.childNodes[i].offsetHeight; 
    504         return totalHeight;      
     504        return totalHeight; 
    505505} 
    506506 
     
    512512        } 
    513513        if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight; 
    514         if (document.body) return document.body.clientHeight;  
    515         return window.undefined;  
     514        if (document.body) return document.body.clientHeight; 
     515        return window.undefined; 
    516516} 
    517517function getViewportWidth() { 
     
    521521                //return i; 
    522522        } 
    523         if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;  
    524         if (document.body) return document.body.clientWidth;  
    525         return window.undefined;  
     523        if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
     524        if (document.body) return document.body.clientWidth; 
     525        return window.undefined; 
    526526} 
    527527 
     
    533533        tempButton=getObjectFromID("saveButton2"); 
    534534        if(tempButton) 
    535                 tempButton.disabled=true;                
    536 } 
    537  
    538  
    539 function setLoginRefresh(){      
     535                tempButton.disabled=true; 
     536} 
     537 
     538 
     539function setLoginRefresh(){ 
    540540        window.setInterval(doRefresh,(LOGIN_REFRESH*60*1000)); 
    541541} 
     
    623623        if(!format) format=DATE_FORMAT; 
    624624        var sdate=""; 
    625          
     625 
    626626        if(thedate){ 
    627627                var sep; 
     
    630630                switch(format){ 
    631631                        case "SQL": 
    632                                 sep="-";                         
     632                                sep="-"; 
    633633                                month=thedate.getMonth()+1; 
    634634                                if(month<10) month="0"+month; 
    635635                                day=thedate.getDate(); 
    636                                 if(day<10) day="0"+day;                                  
     636                                if(day<10) day="0"+day; 
    637637                                sdate= thedate.getFullYear()+sep+month+sep+day; 
    638638                        break; 
    639                          
     639 
    640640                        case "English, US": 
    641641                                sep="/"; 
     
    643643                                if(month<10) month="0"+month; 
    644644                                day=thedate.getDate(); 
    645                                 if(day<10) day="0"+day;                                  
     645                                if(day<10) day="0"+day; 
    646646                                sdate= month+sep+day+sep+thedate.getFullYear(); 
    647647                        break; 
    648                          
     648 
    649649                        case "English, UK": 
    650650                                sep="/"; 
     
    652652                                if(month<10) month="0"+month; 
    653653                                day=thedate.getDate(); 
    654                                 if(day<10) day="0"+day;                                  
     654                                if(day<10) day="0"+day; 
    655655                                sdate= day+sep+month+sep+thedate.getFullYear(); 
    656656                        break; 
    657                          
     657 
    658658                        case "Dutch, NL": 
    659659                                sep="-"; 
     
    661661                                if(month<10) month="0"+month; 
    662662                                day=thedate.getDate(); 
    663                                 if(day<10) day="0"+day;                                  
     663                                if(day<10) day="0"+day; 
    664664                                sdate= day+sep+month+sep+thedate.getFullYear(); 
    665665                        break; 
     
    680680                                        thetime=new Date(0,0,0,parseInt(timeArray[0],10),parseInt(timeArray[1],10),parseInt(timeArray[2],10)); 
    681681                        break; 
    682                          
     682 
    683683                        case "12 Hour": 
    684684                                timeadd=0; 
     
    690690                                if(timeArray.length==2){ 
    691691                                        var hour=parseInt(timeArray[0],10); 
    692                                         if(hour==12) hour=0;                                     
     692                                        if(hour==12) hour=0; 
    693693                                        hour=hour+timeadd; 
    694                                                          
    695                                         thetime=new Date(0,0,0,hour,parseInt(timeArray[1],10));                                          
     694 
     695                                        thetime=new Date(0,0,0,hour,parseInt(timeArray[1],10)); 
    696696                                } 
    697697                        break; 
     
    716716                                sTime=hours+sep+minutes+sep+seconds; 
    717717                        break; 
    718                          
     718 
    719719                        case "12 Hour": 
    720720                                var ampm=" AM"; 
     
    724724                                        hours=hours-12; 
    725725                                if (hours==0) hours=12; 
    726                                 if(minutes<10) minutes="0"+minutes;                              
     726                                if(minutes<10) minutes="0"+minutes; 
    727727                                sTime=""+hours+sep+minutes+ampm; 
    728728                        break; 
     
    734734/* ----------------------------------------------------------------------------- */ 
    735735function roundForCurrency(number){ 
    736          
     736 
    737737        return Math.round( number * Math.pow(10,CURRENCY_ACCURACY) ) /  Math.pow(10,CURRENCY_ACCURACY); 
    738          
     738 
    739739} 
    740740 
    741741 
    742742function numberToCurrency(number){ 
    743          
     743 
    744744        var currency=""; 
    745          
     745 
    746746        if(isNaN(parseFloat(number))) number=0; 
    747747 
     
    751751        number = Math.abs(number); 
    752752        currency += CURRENCY_SYM; 
    753          
     753 
    754754        if(number>0 && number <0) 
    755755                currency+="0"; 
     
    757757        var lessthanone = Math.round( (number-parseInt(number)) * (Math.pow(10,CURRENCY_ACCURACY)) ); 
    758758        number = parseInt(number); 
    759          
     759 
    760760        if(lessthanone >= Math.pow(10,CURRENCY_ACCURACY)){ 
    761761 
    762762                number++; 
    763                          
     763 
    764764                lessthanone -= Math.pow(10,CURRENCY_ACCURACY); 
    765                  
     765 
    766766        }//end if 
    767          
     767 
    768768        lessthanone = lessthanone.toString() 
    769          
     769 
    770770        while(lessthanone.length<CURRENCY_ACCURACY) 
    771                 lessthanone = "0" + lessthanone;                 
     771                lessthanone = "0" + lessthanone; 
    772772 
    773773        var withThousands = parseInt(number).toString(); 
     
    776776        while(objRegExp.test(withThousands)) 
    777777       withThousands = withThousands.replace(objRegExp, '$1'+THOUSANDS_SEPARATOR+'$2'); 
    778                  
     778 
    779779        currency+=withThousands; 
    780780 
    781781        if(CURRENCY_ACCURACY!=0) 
    782782                currency+=DECIMAL_SYMBOL+lessthanone; 
    783                  
     783 
    784784        return currency; 
    785          
     785 
    786786} 
    787787 
     
    820820        } 
    821821        showModal.box.width="400px"; 
    822          
     822 
    823823        var tempDiv=document.createElement("div"); 
    824824        tempDiv.id="modalTitle"; 
     
    840840        showModal.maskFade.setOpacity(0); 
    841841        document.body.appendChild(showModal.mask); 
    842          
     842 
    843843        showModal.boxFade.setOpacity(0); 
    844844        document.body.appendChild(showModal.box); 
    845          
     845 
    846846        showModal.maskFade.custom(0,0.7); 
    847                          
     847 
    848848        centerModal(); 
    849          
     849 
    850850        showModal.listeners =[ 
    851851                connect(window,"onresize",centerModal), 
    852                 connect(window,"onscroll",centerModal)             
     852                connect(window,"onscroll",centerModal) 
    853853        ] 
    854854} 
     
    863863        for(var i=0; i<showModal.listeners.length; i++) 
    864864                disconnect(showModal.listeners[i]) 
    865                  
     865 
    866866        document.body.removeChild(showModal.mask); 
    867867        document.body.removeChild(showModal.box); 
     
    870870 
    871871        delete showModal.mask; 
    872         delete showModal.box;    
     872        delete showModal.box; 
    873873} 
    874874 
     
    878878                var fullHeight = getViewportHeight(); 
    879879                var fullWidth = getViewportWidth(); 
    880          
     880 
    881881                var theBody = document.documentElement; 
    882          
     882 
    883883                var scTop = parseInt(theBody.scrollTop,10); 
    884884                var scLeft = parseInt(theBody.scrollLeft,10); 
    885          
     885 
    886886                showModal.mask.style.height = fullHeight + "px"; 
    887887                showModal.mask.style.width = fullWidth + "px"; 
     
    890890                if(window.innerHeight!=window.undefined){ 
    891891                if(showModal.mask.scrollWidth>fullWidth) 
    892                         showModal.mask.style.height=(fullHeight-20)+"px";        
     892                        showModal.mask.style.height=(fullHeight-20)+"px"; 
    893893                if(document.body.scrollHeight>fullHeight) 
    894894                        showModal.mask.style.width=(fullWidth-20)+"px"; 
     
    899899} 
    900900 
    901 function hideSelectBoxes() {     
     901function hideSelectBoxes() { 
    902902        if (typeof document.body.style.maxHeight == "undefined") { 
    903903                for(var i = 0; i < document.all.length; i++) { 
    904904                        if(document.all[i].tagName) 
    905                                 if(document.all[i].tagName == "SELECT")  
     905                                if(document.all[i].tagName == "SELECT") 
    906906                                        document.all[i].style.visibility="hidden"; 
    907907                } 
    908         }        
     908        } 
    909909} 
    910910function displaySelectBoxes() { 
     
    919919 
    920920function modalAlert(text){ 
    921          
     921 
    922922        text=""+text; 
    923923        text.replace("\n","<br />"); 
    924924        text+="<DIV align=\"right\"><button id=\"modalOK\" accesskey=\"o\" type=\"button\" class=\"Buttons\" onclick=\"closeModal()\" style=\"width:75px\"> ok </button></DIV>"; 
    925925        showModal(text,"Alert",250); 
    926          
     926 
    927927        var okButton = getObjectFromID("modalOK"); 
    928928        try{ 
     
    933933} 
    934934 
     935/* JS Equivalents to PHP Functions --------------------- */ 
     936/* ----------------------------------------------------- */ 
     937function dirname(path) { 
     938    // Returns the directory name component of the path 
     939    // 
     940    // version: 810.114 
     941    // discuss at: http://phpjs.org/functions/dirname 
     942    // +   original by: Ozh 
     943    // +   improved by: XoraX (http://www.xorax.info) 
     944    // *     example 1: dirname('/etc/passwd'); 
     945    // *     returns 1: '/etc' 
     946    // *     example 2: dirname('c:/Temp/x'); 
     947    // *     returns 2: 'c:/Temp' 
     948    // *     example 3: dirname('/dir/test/'); 
     949    // *     returns 3: '/dir' 
     950 
     951    return path.replace(/\\/g,'/').replace(/\/[^\/]*\/?$/, ''); 
     952} 
     953 
     954function basename(path, suffix) { 
     955    // Returns the filename component of the path 
     956    // 
     957    // version: 812.316 
     958    // discuss at: http://phpjs.org/functions/basename 
     959    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 
     960    // +   improved by: Ash Searle (http://hexmen.com/blog/) 
     961    // +   improved by: Lincoln Ramsay 
     962    // +   improved by: djmix 
     963    // *     example 1: basename('/www/site/home.htm', '.htm'); 
     964    // *     returns 1: 'home' 
     965    var b = path.replace(/^.*[\/\\]/g, ''); 
     966 
     967    if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) { 
     968        b = b.substr(0, b.length-suffix.length); 
     969    } 
     970 
     971    return b; 
     972} 
     973 
     974 
    935975/* Function Overloads and Extensions --------------------- */ 
    936976/* ------------------------------------------------------- */ 
     
    950990 
    951991        spinner = new Image; 
    952         spinner.src = APP_PATH+"common/image/spinner.gif";               
    953  
    954 } 
    955  
    956          
    957          
    958          
     992        spinner.src = APP_PATH+"common/image/spinner.gif"; 
     993 
     994} 
     995 
     996 
     997 
     998 
    959999})//end listner 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.