Commit 1cf21822 authored by Clément Damiens's avatar Clément Damiens

up refactor co2 ajaxPost

parent d3351f03
......@@ -112,7 +112,7 @@ function autoCompleteSearch(name, locality, indexMin, indexMax){
$(".responsive-calendar").hide();
$.ajax({
$.Oldajax({
type: "POST",
url: baseUrl+"/" + moduleId + "/search/globalautocomplete",
data: data,
......@@ -380,7 +380,7 @@ function autoCompleteSearch(name, locality, indexMin, indexMax){
mylog.log(formData);
if ($(this).attr("data-ownerlink")=="participate"){
formData.connectType = "attendee";
$.ajax({
$.Oldajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/link/connect",
data: formData,
......@@ -402,7 +402,7 @@ function autoCompleteSearch(name, locality, indexMin, indexMax){
} else if ($(this).attr("data-ownerlink")=="unparticipate"){
formData.connectType = "attendees";
mylog.log(formData);
$.ajax({
$.Oldajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/link/disconnect",
data : formData,
......
......@@ -103,7 +103,7 @@ function runEventFormValidation(el) {
mylog.dir(newEvent);
$.blockUI( { message : '<span class="homestead"><i class="fa fa-spinner fa-circle-o-noch"></i> Save Processing ...</span>' });
$.ajax(
$.oooooooooooajax(
{
type: "POST",
url: baseUrl+"/"+moduleId+'/event/save',
......@@ -218,7 +218,7 @@ function runProjectFormValidation(el) {
$.blockUI({
message : '<span class="homestead"><i class="fa fa-spinner fa-circle-o-noch"></i> <?php echo Yii::t("common","Save Processing") ?> ...</span>'
});
$.ajax({
$.oooooooooooajax({
type: "POST",
url: baseUrl+"/"+moduleId+'/project/save',
dataType: "json",
......
......@@ -99,7 +99,7 @@ $(document).ready(function() {
function loadCalendar(typeElt, id) {
mylog.log("loadCalendar",typeElt, id);
$.ajax({
$.OldAjax({
type: "POST",
url: baseUrl+'/co2/element/getdatadetail/type/'+typeElt+'/id/'+id+'/dataName/events/sub/2',
data: {},
......@@ -302,7 +302,7 @@ function selectProject(){
$('.customTab').hide().removeClass('active');
$('.customTabTrigger').removeClass('active');
$.ajax({
$.OldAjax({
type: "POST",
url: baseUrl+'/co2/element/get/id/'+key+'/type/'+col,
data: {},
......@@ -466,7 +466,7 @@ function loadGallery(dir, key, folderId){
function(){
$("#header-gallery .nav-pills").hide();
},"html");
});
}
function loadMyStream(typeElt, id){
......@@ -482,7 +482,7 @@ function loadMyStream(typeElt, id){
},
function(){
// loadLiveNow();
},"html");
});
}, 700);
}
function changeMobileBtnMenu(){
......
......@@ -134,7 +134,7 @@ function loadStream(indexMin, indexMax){ console.log("load stream media");
coInterface.scrollTo("#content-media");
}
$.ajax({
$OOOO.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/app/media",
data: { indexMin: indexMin,
......
function removeExplainations(){
$(".removeExplanation").replaceWith("<i class='fa fa-spin fa-circle-o-notch text-azure'></i>");
$.ajax({
ajaxPost(
null,
baseUrl+"/"+moduleId+"/slug/check",
{slug:slug},
function(data){
if (!data.result)
window.location.reload();
else{
if(location.hash.indexOf("#page") >= 0)
window.location.reload();
else
window.location.reload();
}
},
function(data) {
mylog.log("error"); mylog.dir(data)
}
);
$.OLLLLLDajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/person/updatesettings",
dataType: "json",
......
......@@ -276,7 +276,7 @@
$("#dropdown_geo").css({"display" : "block" });
//requête auprès du service Nominatim
$.ajax({
$.OOOLDajax({
url: "http://nominatim.openstreetmap.org/search?" + request + "&format=json&polygon=0&addressdetails=1",
type: 'POST',
complete: function () { },
......
......@@ -22,7 +22,7 @@ var loadStream = function(indexMin, indexMax, type, id){ mylog.log("loadStream")
//isLive = isLiveBool==true ? "/isLive/true" : "";
var url = "news/index/type/"+type+"/id/"+id+isLiveNews+"/date/"+dateLimit+"?tpl=co2&renderPartial=true";
$.ajax({
$.OOOajax({
type: "POST",
url: baseUrl+"/"+moduleId+'/'+url,
data: { indexMin: indexMin,
......@@ -106,7 +106,7 @@ var loadStream = function(indexMin, indexMax, type, id){ mylog.log("loadStream")
$(".search-loader-news").html('<i class="fa fa-spin fa-circle-o-notch"></i>');
if(typeof(dateLimit)!="undefined"){
$.ajax({
$.OOOajax({({
type: "POST",
url: baseUrl+"/"+moduleId+"/news/index/type/"+contextParentType+thisParentId+"/date/"+dateLimit+simpleUserData,
dataType: "json",
......@@ -461,7 +461,7 @@ function modifyNews(idNews,typeNews){
newNews = getNewsObject("#form-news-update", "update");// new Object;
newNews.idNews = idNews;
newNews=mentionsInit.beforeSave(newNews, '.newsTextUpdate');
$.ajax({
$.OOOajax({({
type: "POST",
url: baseUrl+"/"+moduleId+"/news/update?tpl=co2",
data: newNews,
......@@ -591,7 +591,7 @@ function deleteNews(id, type, $this){
deleteImage(imageId,"",true,true);
}
$.ajax({
$.OOOajax({({
type: "POST",
url: baseUrl+"/"+moduleId+"/news/delete/id/"+id,
//dataType: "json",
......@@ -933,7 +933,7 @@ function saveNews(){
}else{
newNews=getNewsObject("#form-news");
newNews=mentionsInit.beforeSave(newNews, 'textarea.mention');
$.ajax({
$.OOOajax({({
type: "POST",
url: baseUrl+"/"+moduleId+"/news/save?tpl=co2",
//dataType: "json",
......@@ -1052,7 +1052,7 @@ function initFormImages(){
contextParentType = "citoyens";
contextParentId = idSession;
}
$.ajax({
$.OOOajax({({
url : baseUrl+"/"+moduleId+"/document/uploadSave/dir/communecter/folder/"+contextParentType+"/ownerId/"+contextParentId+"/input/newsImage/docType/image/contentKey/slider",
type: "POST",
data: new FormData(this),
......@@ -1245,7 +1245,7 @@ function deleteImage(id,name,hideMsg,communevent){
path="communevent";
else
path="communecter";
$.ajax({
$.OOOajax({({
url : baseUrl+"/"+moduleId+"/document/delete/"+id,
type: "POST",
data: {"name": name, "parentId": contextParentId, "parentType": contextParentType, "path" : path},
......
......@@ -607,7 +607,7 @@ function builHtmlAuthorImageObject(obj){ //mylog.log("[[[[[[[[[[[[[[[[[[[[[[[[[[
params.unset=method;
}
mylog.log(params);
$.ajax({
$.OOOajax({({
url: baseUrl+'/'+moduleId+"/action/addaction/",
data: params,
type: 'post',
......
......@@ -151,7 +151,7 @@ function callGeoWebService(providerName, requestPart, countryCode, success, erro
mylog.log("calling : " + url);
if(url != ""){
if(providerName != "communecter"){
$.ajax({
$.oooooajax({
url: url,
type: 'GET',
dataType: 'json',
......@@ -166,7 +166,7 @@ function callGeoWebService(providerName, requestPart, countryCode, success, erro
}
});
}else{
$.ajax({
$.oooooajax({
url: url,
type: 'POST',
dataType: 'json',
......@@ -432,7 +432,7 @@ function checkCityExists(addressData, btn){
mylog.log("start verify city exists : " + data);
$.ajax({
$.oooooajax({
url: baseUrl+"/"+moduleId+"/city/cityExists",
type: 'POST',
data: data,
......
......@@ -115,7 +115,7 @@
showLoadingMsg("Recherche de la position en cours");
$("#iconeChargement").css("display", "inline-block");
$.ajax({
$.oooooooajaxoooooooooooo({
url: "//nominatim.openstreetmap.org/search?q=" + requestPart + "&format=json&polygon=0&addressdetails=1",
type: 'POST',
dataType: 'json',
......@@ -148,7 +148,7 @@
showLoadingMsg("Recherche de la position en cours");
$("#iconeChargement").css("display", "inline-block");
$.ajax({
$.oooooooajaxoooooooooooo({
url: baseUrl+"/"+moduleId+"/sig/getlatlngbyinsee",
type: 'POST',
data: "insee="+codeInsee+"&postalCode="+postalCode,
......@@ -179,7 +179,7 @@
function showDataByInsee(insee){
//toastr.success('recherche des éléments de la ville');
$.ajax({
$.oooooooajaxoooooooooooo({
url: baseUrl+"/"+moduleId+"/city/getcityjsondata",
type: 'POST',
data: "insee="+insee,
......@@ -223,7 +223,7 @@
function updateCitiesGeoFormat(){
showLoadingMsg("Mise à jour de la bdd en cours");
$.ajax({
$.oooooooajaxoooooooooooo({
url: baseUrl+"/"+moduleId+"/city/updatecitiesgeoformat",
type: 'POST',
async:false,
......@@ -249,7 +249,7 @@
var objnominatim = {} ;
mylog.log('findGeoposByGoogleMaps',"https://maps.googleapis.com/maps/api/geocode/json?address=" + requestPart); // + "&key="+keyApp);
showLoadingMsg("Recherche de la position en cours");
$.ajax({
$.oooooooajaxoooooooooooo({
url: "//maps.googleapis.com/maps/api/geocode/json?address=" + requestPart,// + "&key="+keyApp,
type: 'POST',
dataType: 'json',
......@@ -270,7 +270,7 @@
function findGeoposByDataGouv(requestPart){
var objDataGouv = {} ;
$.ajax({
$.oooooooajaxoooooooooooo({
url: "//api-adresse.data.gouv.fr/search/?q=" + requestPart ,
dataType: 'json',
async:false,
......
......@@ -92,7 +92,7 @@ function getCityInseeByGeoPos(coords){
// };
// mylog.log("getCityInseeByGeoPos !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
// mylog.log(coords);
$.ajax({
$.oooooooooajaxppppppp({
url: baseUrl + "/" + moduleId+"/sig/getinseebylatlng",
type: 'POST',
dataType: 'json',
......@@ -179,7 +179,7 @@ function getCityInseeByGeoPos(coords){
function getCityByLatLngNominatim(latitude, longitude){
mylog.log(latitude, longitude);
toastr.info("<i class='fa fa-circle-o-notch fa-spin'></i> Recherche approfondie");
$.ajax({
$.oooooooooajaxppppppp({
url: "//nominatim.openstreetmap.org/reverse?lat=" + latitude + "&lon=" + longitude + "&format=json&addressdetails=1",
type: 'POST',
dataType: 'json',
......@@ -198,7 +198,7 @@ function getCityByLatLngNominatim(latitude, longitude){
function getInseeByCityName(cityName){
toastr.info("<i class='fa fa-circle-o-notch fa-spin'></i> Merci de patienter ...");
$.ajax({
$.oooooooooajaxppppppp({
url: baseUrl + "/" + moduleId+"/sig/getcodeinseebycityname",
type: 'POST',
dataType: 'json',
......
......@@ -88,7 +88,7 @@ SigLoader.getSigFindPlace = function (Sig){
}
var urlRequest = this.getNominatimRequest(nbTentative);
//mylog.log(urlRequest);
$.ajax({
$.oooooooajax({
//url: "http://nominatim.openstreetmap.org/search?q=" + address + "&format=json&polygon=0&addressdetails=1",
url: "//nominatim.openstreetmap.org/search" + urlRequest + "&format=json&polygon=1&addressdetails=1",
type: 'POST',
......@@ -374,7 +374,7 @@ SigLoader.getSigFindPlace = function (Sig){
+geoShape.getEast()+","+geoShape.getSouth();
}
mylog.log("urlRequest", urlRequest);
$.ajax({
$.oooooooajax({
url: "//nominatim.openstreetmap.org/search" + urlRequest + "&format=json&polygon=1&addressdetails=1",
type: 'POST',
dataType: 'json',
......@@ -668,7 +668,7 @@ SigLoader.getSigFindPlace = function (Sig){
clearTimeout(Sig.timerbounce);
$("#lbl-loading-saving").removeClass("hidden");
$("#lbl-loading-saving").html("<center><i class='fa fa-refresh fa-2x center fa-spin'></i></br>Enregistrement de la nouvelle position...<br>Merci de patienter...</center>");
$.ajax({
$.oooooooajax({
url: baseUrl+"/"+moduleId+"/sig/updateentitygeoposition",
type: 'POST',
data: "entityType="+entityType+"&entityId="+entityId+"&latitude="+latitude+"&longitude="+longitude,
......
......@@ -462,7 +462,7 @@
//initialise le bouton home
var thisSig = this;
if(this.initParameters.useHomeButton){ //mylog.log("init btn home " + baseUrl + "/" + moduleId);
$.ajax({
$.ooooooooooajax({
url: baseUrl+"/"+moduleId+"/sig/getmyposition",
type: "POST",
dataType : "json",
......
......@@ -2,19 +2,19 @@ function actionRoomDelete(id, $this, parentId){
bootbox.confirm(trad["suretodeletediscuss"],
function(result) {
if (result) {
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/rooms/deleteroom/id/"+id,
dataType: "json",
success: function(data){
if (data.result) {
toastr.success(data.msg);
showRoom('all', parentId);
} else {
toastr.error(data.msg);
}
ajaxPost(
null,
baseUrl+"/" + moduleId + "/rooms/deleteroom/id/"+id,
null,
function(data){
if (data.result) {
toastr.success(data.msg);
showRoom('all', parentId);
} else {
toastr.error(data.msg);
}
});
}
);
}
}
)
......
......@@ -222,47 +222,7 @@ DropDown.prototype = {
return this.index;
}
}
/* DEPRACATED [06/05/2019] TODO : clean if not used
function openModal(key,collection,id,tpl,savePath,isSub){
$.ajax({
type: "POST",
url: baseUrl+"/common/GetMicroformat/key/"+key,
data: { "key" : key,
"template" : tpl,
"collection" : collection,
"id" : id,
"savePath" : savePath,
"isSub" : isSub },
success: function(data){
$("#flashInfoLabel").html(data.title);
$("#flashInfoContent").html(data.content);
$("#flashInfoSaveBtn").html('<a class="btn btn-warning " href="javascript:;" onclick="$(\'#flashForm\').submit(); return false;" >Enregistrer</a>');
},
dataType: "json"
});
}
*/
/* DEPRACATED [06/05/2019] TODO : clean if not used
function updateField(type,id,name,value,reload, useToastr){
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/"+type+"/updatefield",
data: { "pk" : id ,"name" : name, "value" : value },
success: function(data){
if(data.result) {
if(useToastr==null)
toastr.success(data.msg);
if(reload)
urlCtrl.loadByHash(location.hash);
}
else
toastr.error(data.msg);
},
dataType: "json"
});
}*/
function addslashes(str) {
// discuss at: http://phpjs.org/functions/addslashes/
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
......@@ -358,7 +318,7 @@ function loadSettings(hash){
showLoader('#modal-settings');
ajaxPost('#modal-settings', baseUrl+'/'+moduleId+'/'+url,
null,
function(){},"html");
function(){});
}
var CoAllReadyLoad = false;
......@@ -760,18 +720,17 @@ var coInterface = {
value : lang,
pk : userId
};
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/element/updatefields/type/citoyens",
data: param,
dataType: "json",
success: function(data){
if(data.result){
toastr.success(data.msg);
location.reload();
}
}
});
ajaxPost(
null,
baseUrl+"/" + moduleId + "/element/updatefields/type/citoyens",
param,
function(data){
if(data.result){
toastr.success(data.msg);
location.reload();
}
}
);
}else{
location.reload();
}
......@@ -1168,12 +1127,12 @@ var urlCtrl = {
slug=hashT;
else
slug=hashT[0];
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/slug/getinfo/key/"+slug,
dataType: "json",
success: function(data){
if(data.result){
ajaxPost(
null,
baseUrl+"/" + moduleId + "/slug/getinfo/key/"+slug,
param,
function(data){
if(data.result){
viewPage="";
if(hashT.length > 1){
hashT.shift();
......@@ -1190,8 +1149,8 @@ var urlCtrl = {
callback('page/type/'+data.contextType+'/id/'+data.contextId+viewPage+get);
}else
callback(result);
}
});
}
);
}else
callback(result);
}
......@@ -1298,12 +1257,12 @@ var urlCtrl = {
slug=hashT;
else
slug=hashT[0];
$.ajax({
type: "POST",
url: baseUrl+"/"+moduleId+"/slug/getinfo/key/"+slug,
dataType: "json",
success: function(data){
if(data.result){
ajaxPost(
null,
baseUrl+"/" + moduleId + "/slug/getinfo/key/"+slug,
null,
function(data){
if(data.result){
viewPage="";
if(hashT.length > 1){
hashT.shift();
......@@ -1333,8 +1292,8 @@ var urlCtrl = {
coInterface.menu.set("");
showAjaxPanel( baseUrl+'/'+ moduleId + '/app/index', 'Home','home' );
}
}
} );
}
);
}else{
coInterface.menu.set("");
showAjaxPanel( baseUrl+'/'+ moduleId + '/app/index', 'Home','home' );
......@@ -1516,17 +1475,16 @@ var urlCtrl = {
urlPreview+=(res.indexOf("#") == 0 ) ? "app/"+ urlCtrl.convertToPath(res) : "app/"+ res;
//urlCtopenPreviewElement( baseUrl+'/'+moduleId+"/"+url);
$("#modal-preview-coop").show(200);
$.ajax({
type: "POST",
url: urlPreview,
data: {"preview" : true},
success: function(html){
$("#modal-preview-coop").html(html);
urlCtrl.bindModalPreview();
ajaxPost(
"#modal-preview-coop",
urlPreview,
{"preview" : true},