var MyCFD = MyCFD || {}; MyCFD.User = function User(jsO) { var properties = [ "email", "password", "lastName", "firstName", "cellPhone", "firmPhone", "firmName", "firmAddress", "job", "register_date" ]; if('undefined' === typeof(jsO) || jsO === null) jsO = { email: null, password: null, lastName: null, firstName: null, cellPhone: null, firmPhone: null, firmName: null, firmAddress: ", , , ", job: null, register_date: null }; for(var property of properties) this[property] = jsO[property]; }; MyCFD.User.prototype.toString = function(){ return JSON.stringify(this) } var addressFromArray = a => a[0] + ", " + a[1] + ", " + a[2] + " "+ a[3] + ", " + a[4]; var addressToArray = a => /(.*), (.*), (\d*) (.*), (.*)/.exec(a).slice(1); function addressPartUpdater(address, part, newValue){ var t = addressToArray(address); t[part] = newValue; return addressFromArray(t); } /* Include my personnal Library */ if( !('remove' in Element.prototype) ) Element.prototype.remove = function() { this.parentElement.removeChild(this); } if( !('remove' in NodeList.prototype) ) NodeList.prototype.remove = HTMLCollection.prototype.remove = function() { for(var i = this.length - 1; i >= 0; i--) if(this[i] && this[i].parentElement) this[i].parentElement.removeChild(this[i]); } if( !('hasClass' in Element.prototype) ) Element.prototype.hasClass = function(wantedClass) { return this.className.match(new RegExp( "[^|\\s]?(" + wantedClass + ")[!\\S]?", '' )) ? true : false; } if( !('addClass' in Element.prototype) ) Element.prototype.addClass = function(wantedClass) { if(!this.hasClass(wantedClass)) this.className += " " + wantedClass; } if( !('addClass' in NodeList.prototype) ) NodeList.prototype.addClass = function(wantedClass) { for(var i = this.length - 1; i >= 0; i--) if(!this[i].hasClass(wantedClass)) this[i].addClass(wantedClass); } if( !('removeClass' in Element.prototype) ) Element.prototype.removeClass = function(wantedClass) { if(this.hasClass(wantedClass)) this.className = this.className.replace(new RegExp( "[^|\\s]?(" + wantedClass + ")[!\\S]?", 'g' ), '').replace(new RegExp( "(^\\s)", '' ), ''); } if( !('removeClass' in NodeList.prototype) ) NodeList.prototype.removeClass = function(wantedClass) { for(var i = this.length - 1; i >= 0; i--) if(this[i].hasClass(wantedClass)) this[i].removeClass(wantedClass); } if( !('toggleClass' in Element.prototype) ) Element.prototype.toggleClass = function(wantedClass) { this.hasClass(wantedClass) ? this.removeClass(wantedClass) : this.addClass(wantedClass); } if( !('toggleClass' in NodeList.prototype) ) NodeList.prototype.toggleClass = function(wantedClass) { for(var i = this.length - 1; i >= 0; i--) this[i].hasClass(wantedClass) ? this[i].removeClass(wantedClass) : this[i].addClass(wantedClass); } if( !('addEventListener' in Element.prototype) ) Element.prototype.addEventListener = function(e, f, p) { document.body[ window.addEventListener ? 'addEventListener' : 'attachEvent' ]( window.addEventListener ? e : "on" + e //TODO: improve ... (not fully compatible, some event names change , f, p); } if( !('Event4ie' in window) ) window.Event4ie = function(e, p) { p = p || { bubbles: false, cancelable: false, detail: undefined }; var evt = document.createEvent('CustomEvent'); evt.initCustomEvent(e, p.bubbles, p.cancelable, p.detail ); return evt; }, window.Event4ie.prototype = window.Event.prototype; function navigatorIs(name){ return navigator.userAgent.toLowerCase().indexOf('undefined' === typeof(name) ? "none" : name.toLowerCase()) > -1; } function isInt(v){ return !isNaN(v) && (function(x) { return (x | 0) === x; })(parseFloat(v)) } var Notification = window.Notification || window.mozNotification || window.webkitNotification;