PageSourceSearch

https://membres.oiq.qc.ca/OIQ/Areas/OIQ/Common/commonService.js

js oiq.qc.ca collected 2026-10-02 03:34:21 UTC 12,886 bytes, 1 lines download raw bytes

1var CommonService=function(){function CommonService(){}return CommonService.debounce=function(a,b){return function(c,d,e){var f,g=b.defer();return function(){var h=this,i=arguments,j=function(){f=null,e||(g.resolve(c.apply(h,i)),g=b.defer())},k=e&&!f;return f&&a.cancel(f),f=a(j,d),k&&(g.resolve(c.apply(h,i)),g=b.defer()),g.promise}}},CommonService.getLangue=function(){var a=jQuery("select[name$='$CultureDropDownList']").val();return a?a:"fr"},CommonService.getLangueCourt=function(){var a=jQuery("select[name$='$CultureDropDownList']").val();return a?a.substring(0,2).toLowerCase():"fr"},CommonService.getValeurPropriete=function(a,b){for(var c=0;c<a.length;c++)if(a[c].Name.toLowerCase()===b.toLowerCase())return a[c].Value;return null},CommonService.setValeurPropriete=function(a,b,c,d){for(var e=0;e<a.length;e++)if(a[e].Name.toLowerCase()===b.toLowerCase())return void(d?a[e].Value.$value=c:a[e].Value=c)},CommonService.writeCookie=function(a,b,c){document.cookie=a+"="+b+"; expires="+c.toUTCString()+"; path=/"},CommonService.readCookie=function(a){var b=document.cookie.match("(^|[^;]+)\\s*"+a+"\\s*=\\s*([^;]+)");return b?b.pop():""},CommonService.toSimpleObject=function(a,b,c,d){if(!a||!a.Properties||!a.Properties.$values)return null;var e=a.Properties.$values,f={};if(f._ref=a,d){var g=CommonService.getValeurPropriete(e,b),h=CommonService.getValeurPropriete(e,c);f.Description="en"===d&&h?h:g}return CommonService.defineObject(a.Properties,f),f},CommonService.defineObject=function(a,b){for(var c=a.$values,d=function(a,b){Object.defineProperty(b,a.Name,{get:function(){var b=CommonService.getValeurPropriete(c,a.Name);return null!=b&&null!=b.$value?b.$value:b},set:function(b){var d=CommonService.getValeurPropriete(c,a.Name);return null!=d&&null!=d.$type?void CommonService.setValeurPropriete(c,a.Name,b,!0):("boolean"==typeof b&&(b={$type:"System.Boolean",$value:b}),"number"==typeof b&&(b={$type:"System.Double",$value:b}),void CommonService.setValeurPropriete(c,a.Name,b,!1))},enumerable:!0,configurable:!0})},e=0;e<c.length;e++)d(c[e],b)},CommonService.toSimpleObjects=function(a,b,c,d){var e=[];if(!a||!a.Items||!a.Items.$values)return e;for(var f=0;f<a.Items.$values.length;f++)e.push(CommonService.toSimpleObject(a.Items.$values[f],b,c,d));return e},CommonService.toSimpleObjectsFromValues=function(a,b,c,d){var e=[];if(!a)return e;for(var f=0;f<a.length;f++)e.push(CommonService.toSimpleObject(a[f],b,c,d));return e},CommonService.getToken=function(){var a=JSON.parse(jQuery("#__ClientContext").val());return a.isAnonymous?"":jQuery("#__RequestVerificationToken").val()},CommonService.getConnectedUserId=function(){var a=JSON.parse(jQuery("#__ClientContext").val());return a.loggedInPartyId},CommonService.attendreElementDansPage=function($q,selecteur,nombreTentativeMax,delaiEntreTentative,$source,isIframe,cpt){var self=this,isAngular=null!=$q,deferred=isAngular?$q.defer():jQuery.Deferred();nombreTentativeMax=nombreTentativeMax?nombreTentativeMax:100,delaiEntreTentative=delaiEntreTentative?delaiEntreTentative:100,$source=$source?$source:jQuery(document),isIframe=isIframe?isIframe:!1,cpt=cpt?cpt+1:1;var $element=eval(selecteur);return $element.length?deferred.resolve($element):(cpt===nombreTentativeMax&&deferred.resolve(null),setTimeout(function(){self.attendreElementDansPage($q,selecteur,nombreTentativeMax,delaiEntreTentative,$source,isIframe,cpt).then(function(a){deferred.resolve(a)})},delaiEntreTentative)),isAngular?deferred.promise:deferred.promise()},CommonService.ajouterOverlay=function(){if(0===jQuery("#overlay-oiq").length){var a=jQuery("<div>").attr("id","overlay-oiq").css("display","none"),b=jQuery("<i>").addClass("fas fa-spinner fa-spin fa-5x");a.append(b),jQuery("body").append(a)}},CommonService.afficherOverlay=function(a){a?(CommonService.ajouterOverlay(),jQuery("#overlay-oiq").show()):jQuery("#overlay-oiq").hide()},CommonService.getAPI=function(a,b){return jQuery.ajax(CommonService.getUrlBase()+"api/"+a,{type:"GET",contentType:"application/json",headers:{RequestVerificationToken:document.getElementById("__RequestVerificationToken").value},data:b}).done(function(a){return a})},CommonService.putAPI=function(a,b){return jQuery.ajax(CommonService.getUrlBase()+"api/"+a,{type:"PUT",contentType:"application/json",data:JSON.stringify(b),headers:{RequestVerificationToken:document.getElementById("__RequestVerificationToken").value}}).done(function(a){return a})},CommonService.postAPI=function(a,b){return jQuery.ajax(CommonService.getUrlBase()+"api/"+a,{type:"POST",contentType:"application/json",data:JSON.stringify(b),headers:{RequestVerificationToken:document.getElementById("__RequestVerificationToken").value}}).done(function(a){return a})},CommonService.format=function(a,b){return jQuery.each(b,function(b,c){a=a.replace(new RegExp("\\{"+b+"\\}","g"),c)}),a},CommonService.getTexte=function(a,b,c){if(!b)return"";for(var d=b.toLowerCase(),e=c.toLowerCase(),f=0;f<a.length;f++)if(a[f].nom.toLowerCase()===d)return"en"===e?a[f].en:a[f].fr;return""},CommonService.getUrlParameterByName=function(a,b){b||(b=window.location.href),a=a.replace(/[\[\]]/g,"\\$&");var c=new RegExp("[?&]"+a+"(=([^&#]*)|&|#|$)"),d=c.exec(b);
1return d?d[2]?decodeURIComponent(d[2].replace(/\+/g," ")):"":null},CommonService.addUpdateUrlParameter=function(a,b,c){a=encodeURIComponent(a),b=encodeURIComponent(b);var d=a+"="+b;if(c.indexOf(a+"=")>0){var e=new RegExp("(&|\\?)"+a+"=[^&]*");c=c.replace(e,"$1"+d)}else c=-1===c.indexOf("?")?c+"?"+d:c+"&"+d;return c},CommonService.removeUrlParameter=function(a,b){var c=b.split("?");if(c.length>=2){for(var d=encodeURIComponent(a)+"=",e=c[1].split(/[&;]/g),f=e.length;f-->0;)-1!==e[f].lastIndexOf(d,0)&&e.splice(f,1);return c[0]+(e.length>0?"?"+e.join("&"):"")}return b},CommonService.getIMISWebsiteKey=function(a){return this.getUrlParameterByName("WebsiteKey",a)},CommonService.assignCurrentIMISWebsiteKeyToUrl=function(a){var b=this.getIMISWebsiteKey();return b?this.addUpdateUrlParameter("WebsiteKey",b,a):a},CommonService.removeIMISWebsiteKeyFromUrl=function(a){return this.removeIMISWebsiteKeyFromUrl(a)},CommonService.replaceAll=function(a,b,c){return a?a.replace(new RegExp(b,"g"),c):""},CommonService.setCacheObject=function(a,b,c){c=null!==c&&void 0!==c?c:30;var d=new Date;d.setTime(d.getTime()+1e3*c);var e={data:b,expiringDate:d};localStorage.setItem(a,JSON.stringify(e))},CommonService.getCachedObject=function(a){var b=localStorage.getItem(a);if(!b)return null;var c=JSON.parse(b);return c.expiringDate<new Date?(localStorage.removeItem(a),null):c.data},CommonService.getUrlParameter=function(a,b){for(var c,d=b?b:decodeURIComponent(window.location.search.substring(1)),e=d.split("&"),f=0;f<e.length;f++)if(c=e[f].split("="),c[0].toLowerCase()===a.toLowerCase())return void 0===c[1]?!0:c[1]},CommonService.getUrlBase=function(){var a=JSON.parse(angular.element(document.querySelector("#__ClientContext")).val());return window.location.protocol+"//"+window.location.host+a.baseUrl},CommonService.getOIQCombinedUrlFromBase=function(a){if(!a||0===a.indexOf("http"))return a;var b=CommonService.getUrlBase();return-1===b.lastIndexOf("/",b.length-1)&&(b+="/"),0===a.indexOf("/OIQ/")?b+a.substring(4):a.indexOf("/")?b+a:b+a.substring(1)},CommonService.getContactId=function(){var a=JSON.parse(angular.element(document.querySelector("#__ClientContext")).val()),b=CommonService.getUrlParameter("ID");return b||a.selectedPartyId},CommonService.getParty=function(a){return CommonService.getAPI("Party/"+a).then(function(a){return a.BoAdditionnalAttributes={},CommonService.defineObject(a.AdditionalAttributes,a.BoAdditionnalAttributes),a})},CommonService.getProfil=function(a){return CommonService.getAPI("OIQ_PROFIL?PartyId="+a).then(function(a){return a})},CommonService}(),BaseDataService=function(){function a(a,b,c,d,e,f){var g=this;this.actionRetry=3,this.getSettings=function(a,b){var c=g;return c.getApi("ContentItem",{contentKey:a,contentItemKey:b}).then(function(a){return a&&a.Settings?a.Settings:{}})},this.getProfil=function(a){return CommonService.getProfil(a)},this.getParty=function(a){return CommonService.getParty(a)},this.getCurrentParty=function(){return g.getParty(CommonService.getContactId())},this.setParty=function(a){return g.putApi("Party/"+a.Id,a).then(function(a){return a})},this.pCommandes={},this.lancerCommandeAvecCache=function(a,b,c){if(!c&&g.pCommandes[a])return g.pCommandes[a];var d={langue:g.langue};return b&&jQuery.extend(d,b),g.pCommandes[a]=g.executerCommande(a,d).then(function(a){return a.Requete_Resultat?JSON.parse(a.Requete_Resultat):null}),g.pCommandes[a]},this.lancerCommande=function(a,b){return g.lancerCommandeAvecCache(a,b,!0)},this.$q=a,this.$http=b,this.requestVerificationToken=c,this.urlBase=d,this.langue=e,this.contactId=f}return a.prototype.getApi=function(a,b){var c=this,d={headers:{RequestVerificationToken:this.requestVerificationToken},params:null,transformResponse:this.$http.defaults.transformResponse[0]};b&&(d.params=b);var e=0,f=this.$q.defer(),g=function(){c.$http.get(c.urlBase+"api/"+a,d).then(function(a){f.resolve(a.data)},function(b){if(!(e<=c.actionRetry))throw{message:"GET: Erreur lors de l'appel de l'URL: "+a,data:b};g(),e++})};return g(),f.promise},a.prototype.deleteAPI=function(a){var b=this,c={headers:{RequestVerificationToken:this.requestVerificationToken},params:null,transformResponse:this.$http.defaults.transformResponse[0]},d=0,e=this.$q.defer(),f=function(){b.$http["delete"](b.urlBase+"api/"+a,c).then(function(a){e.resolve()},function(c){if(!(d<=b.actionRetry))throw{message:"GET: Erreur lors de l'appel de l'URL: "+a,data:c};f(),d++})};return f(),e.promise},a.prototype.postPushApi=function(a,b,c){function d(){var j=this;g(e.urlBase+"api/"+a,JSON.stringify(b),f).then(function(a){i.resolve(a.data)},function(b){if(!(h<=j.actionRetry))throw{message:(c?"PUT":"POST")+": Erreur lors de l'appel de l'URL: "+a,data:b};d(),h++})}var e=this,f={headers:{RequestVerificationToken:this.requestVerificationToken},transformResponse:this.$http.defaults.transformResponse[0]},g=c?e.$http.put:e.$http.post,h=0,i=this.$q.defer();return d(),i.promise},a.prototype.postApi=function(a,b){var c=this;return c.postPushApi(a,b,!1)},a.prototype.putApi=function(a,b){var c=this;return c.postPushApi(a,b,!0)},a.prototype.getConfigGestionDocumentaire=function(){var a=this,b=a.getApi("oiq_b_configuration?cd_config=TAILLE_MAX_GED").then(function(a){if
1(!a||!a.Items||!a.Items.$values||0===a.Items.$values.length)return 10;var b=a.Items.$values[0].Properties.$values,c=CommonService.getValeurPropriete(b,"Val_Int").$value;return c?c:10}),c=a.getApi("oiq_b_configuration?cd_config=FICHIER_ACCEPTE_GED").then(function(a){if(!a||!a.Items||!a.Items.$values||0===a.Items.$values.length)return"pdf,doc,docx,xls,xlsx,ppt,pptx,gif,jpg,jpeg,png,bmp,zip,7z";var b=a.Items.$values[0].Properties.$values,c=CommonService.getValeurPropriete(b,"Val_Char");return c?c:"pdf,doc,docx,xls,xlsx,ppt,pptx,gif,jpg,jpeg,png,bmp,zip,7z"});return a.$q.all([b,c]).then(function(a){return{tailleMaximale:a[0],extensionAcceptes:a[1].split(",")}})},a.prototype.executerCommande=function(a,b){var c=this,d=this.getNomObjetCommande(),e=this.getNouvelleCommande(d,a,b?JSON.stringify(b):null);return this.postApi(d,e._ref).then(function(b){var e=CommonService.toSimpleObject(b);if(e.SEQN>0)return c.getApi(d+"/~"+e.ID+"|"+e.SEQN).then(function(a){return CommonService.toSimpleObject(a)});throw{message:"GET: Erreur lors de l'obtention des données d'exécution de la commande "+a+"."}})},a.prototype.getNomObjetCommande=function(){var a=Math.floor(9*Math.random())+1;return"oiq_b_commandes"+a},a.prototype.getNouvelleCommande=function(a,b,c){var d={$type:"Asi.Soa.Core.DataContracts.GenericEntityData, Asi.Contracts",EntityTypeName:a,PrimaryParentEntityTypeName:"Party",Identity:{$type:"Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts",EntityTypeName:a},PrimaryParentIdentity:{$type:"Asi.Soa.Core.DataContracts.IdentityData, Asi.Contracts",EntityTypeName:"Party",IdentityElements:{$type:"System.Collections.ObjectModel.Collection`1[[System.String, mscorlib]], mscorlib",$values:[this.contactId]}},Properties:{$type:"Asi.Soa.Core.DataContracts.GenericPropertyDataCollection, Asi.Contracts",$values:[{$type:"Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",Name:"ID",Value:this.contactId},{$type:"Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",Name:"SEQN",Value:{$type:"System.Int32",$value:0}},{$type:"Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",Name:"Requete_Path",Value:b},{$type:"Asi.Soa.Core.DataContracts.GenericPropertyData, Asi.Contracts",Name:"Requete_Params",Value:c||""}]}};return CommonService.toSimpleObject(d)},a}(),BaseLocalizationService=function(){function a(a){var b=this;this.getTexte=function(a){return CommonService.getTexte(b.dico,a,b.langue)},this.langue=a.toLowerCase()}return a}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.