apxtrib/setup/data/domain/apixpress/www/cdn/public/js/questio.js

51 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-01-22 09:53:09 +00:00
'use strict'
var md = md || {};
var $ = $ || jQuery;
md.u = 'http://maildigit.ndda.fr';
if (location.href.indexOf('https:')>-1){
md.u='https://maildigit.ndda.fr';
}
//survey.js doit être installé sur la page qui heberge les declencheurs
md.questio = function(quest,iduser){
function sendDataToServer(survey) {
console.log(survey)
$.ajax({url:md.u+'/questiodone',type: "POST", data:{'questio':survey.data,'quest':quest,'iduser':iduser}, cache: false,
success:function(e){
console.log(e.msg)
}
});
}
$.ajax({ url: md.u+"/questiotodo", type: "GET",
data:{quest:quest,iduser:iduser}, cache: false,
success: function(e) {
console.log(e);
if (e.surveyjson) {
console.log('survey')
console.log(e.surveyjson)
var survey = new Survey.Model(e.surveyjson);
$("#modalsurvey .survey").Survey({
model:survey,
onComplete:sendDataToServer
});
$('#modalsurvey').modal('show');
}
},
error: function(e) {
console.log(e);
},
});
}
$(document).ready(function(){
$('[data-tgsurvey][data-tgid]').on('click',function(){
console.log($(this).data('tgsurvey')+"-"+$(this).data('tgid'))
//pour tester enlever cette ligne pour la prod
var idt = $(this).data('tgid')
idt = $("input.testid").val()
md.questio($(this).data('tgsurvey'),idt);
});
$('[data-tgsurvey][data-tgid]').on('load',function(){
md.questio($(this).data('tgsurvey'),$(this).data('tgid'));
});
});