PageSourceSearch

https://synapsismail.com.ar/js/main.js

js synapsismail.com.ar collected 2026-10-04 17:01:44 UTC 32,109 bytes, 886 lines download raw bytes

1var deleteToken = function (toid) {
2    return $.ajax("./?tokens", {
3        type: "POST",
4        dataType: "json",
5        data: { action: "delete", toid: toid }
6    });
7}
8
9var removeTokenFromTable = function (toid) {
10    $("tr[data-toid='" + toid + "']").remove();
11}
12
13var saveTokens = function () {
14    var tokens = {};
15    $("tr[data-toid]").each(function () {
16        var toid = $(this).attr("data-toid");
17        var val = $(this).find("textarea").val();
18
19        tokens[toid] = val;
20    });
21
22    $.ajax("./?tokens", {
23        type: "POST",
24        dataType: "json",
25        data: { action: "update", tokens: tokens }
26    }).done(function () {
27        _alert("Los tokens han sido guardados son éxito", 'suss');
28    });
29}
30
31var createTokenListener = function () {
32    $('#tokenname').alphanumeric({ allow: "-_. " });
33}
34
35function sendError(error, file, line, funct) {
36    $.ajax({ type: "POST", url: "index.php?sendError", data: "error=" + error + "&file=" + file + "&line=" + line + "&funcion=" + funct });
37};
38function validateEmail(email) {
39    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
40    return re.test(email);
41}
42function checkUserDataLimits() {
43    TB_load();
44    $.ajax("index.php?checkUserDataLimits", { data: $('#usermanage').serialize(), type: "post", })
45        .done(function (txt) {
46            if (txt == 1) {
47                $('#usermanage').submit();
48            } else {
49                TB_remove();
50                _alert(txt, 'error');
51            }
52        });
53};
54function formatDate(date) {
55    var today = new Date(date);
56    c = date.split('-');
57    return c[2] + "/" + c[1] + "/" + c[0];
58}
59function fetchtext() {
60    texturl = $('#fetch_text').val();
61    if (texturl != "http://") {
62        TB_load();
63        $.post("index.php?fetchText", { url: texturl }, function (txt) {
64            $('#text_text').val(txt);
65            TB_remove();
66        });
67    }
68};
69function viewMessage(mid) {
70    //window.open('./?getMessageBody&mid='+mid+'&type=html', 'msgview', 'status=no,scrollbars=yes,height=600,width=800,location=n,menubar=noo');
71    window.speed = $.fn.speedoPopup({
72        href: './?getMessageBody&mid=' + mid + '&type=html',
73        width: 800,
74        height: 500,
75        useFrame: true,
76        unload: true,
77        theme: "default",
78        effectIn: "slideTop",
79        effectOut: "slideTop"
80    });
81}
82function loadSuscribersTable(npage, opciones) {
83    $("div#sustable").html('<table width="100%" height="142" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">' + nLang.js43 + '<br><img src="images/loading.gif"></td></tr></table>');
84    if (npage == false) npage = 0;
85    $("div#sustable").load("index.php?loadSuscribersTable", { page: npage, opcions: opciones });
86};
87function createMessage() {
88    from_name = $('#from_name').val();
89    from_mail = $('#from_mail').val();
90    subject = $('#subject').val();
91
92    TB_load();
93    if (from_name == "") {
94        TB_remove();
95        _alert(nLang.js03, "error");
96    } else if (from_mail == "") {
97        TB_remove();
98        _alert(nLang.js02, "error");
99    } else if (subject == "") {
100        TB_remove();
101        _alert(nLang.js15, "error");
102    } else {
103        $.post("index.php?checkCreateMessage", { email: from_mail }, function (txt) {
104            if (txt == 1) {
105                document.getElementById('message-form').action = './?previewMessage';
106                $('#message-form').submit();
107            } else {
108                TB_remove();
109                _alert(txt, 'error');
110            }
111        });
112    }
113};
114function addCredits() {
115    credits = $('#credits').val();
116    uid = $('#uid').val();
117
118    if (credits > 0) {
119        TB_load();
120        $.ajax({
121            type: "POST", url: "index.php?addCredits", dataType: "json", data: "uid=" + uid + "&credits=" + credits, success: function (data) {
122                TB_remove();
123                if (data.error) {
124                    _alert(data.error, 'error');
125                } else {
126                    $("#max_sends").val(data.totals);
127                    _alert(nLang.js46, 'suss');
128                }
129            }, error: function () {
130                TB_remove();
131                alert("error");
132            }
133        });
134    }
135};
136
137function checkQueue(mid, stoping, win) {
138    // if(stoping==true) stop=1;
139    // else stop=0;
140    // $.ajax({type: "POST", url: "index.php?checkQueue", dataType: "json", data: "id="+mid+"&stop="+stop,
141    // 		//error: function(jqXHR, textStatus, errorThrown){sendError("Error de AJAX ("+textStatus+")", "js/main.js", "", "checkQueue")},
142    // 		success: function(data){
143    // 			if(data.estado) {
144    // 				$('#nro_'+mid).html( data.procesados );
145    // 				$('#rest_'+mid).html( data.restantes );
146    // 				$('#enlapced_'+mid).html( data.enlapced );
147    // 				$('#state_'+mid).html( data.estado );
148    // 				$('#per_'+mid).html( data.per );
149    // 				document.getElementById('bar_bar_'+mid).style.width = data.barw+'px';
150    // 				if(data.active=="2") { // si esta detenido apago el boton de stop
151    // 					$('#stopbt_'+mid).attr("disabled","disabled").hide();
152    // 					$('#stats_'+mid).show(); 
153    // 				}
154    // 				if(data.active=="4") { // si esta detenido apago el boton de stop
155    // 					$('#stopbt_'+mid).attr("disabled","disabled").hide();
156    // 					//$('#stats_'+mid).show(); 
157    // 				}
158
159    // 			}
160    // }});
161}
162function loadReadsTable(xmid, npage, isort) {
163    $("div#readstable").html('<table width="100%" height="142" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">' + nLang.js43 + '<br><img src="images/loading.gif"></td></tr></table>');
164    if (npage == false) npage = 0;
165    if (isort == false) isort = 'email';
166    $("div#readstable").load("index.php?loadReadsTable", { mid: xmid, page: npage, sort: isort });
167};
168function loadNewSusTable(xmid, npage, isort) {
169    $("div#readstable").html('<table width="100%" height="142" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">' + nLang.js43 + '<br><img src="images/loading.gif"></td></tr></table>');
170    if (npage == false) npage = 0;
171    if (isort == false) isort = 'email';
172    $("div#readstable").load("index.php?loadNewSusTable", { mid: xmid, page: npage, sort: isort });
173};
174function loadTrackLinksTable(npage, liid, buscar) {
175    $("div#readstable").html('<table width="100%" height="142" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">' + nLang.js43 + '<br><img src="images/loading.gif"></td></tr></table>');
176    if (npage == false) npage = 0;
177    $("div#trackdetails").load("index.php?loadTrackLinksTable", { page: npage, liid: liid, search: buscar });
178};
179function loadBouncedTable(xmid, npage) {
180    $("div#bouncedtable").html('<table width="100%" height="142" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle">' + nLang.js43 + '<br><img src="images/loading.gif"></td></tr></table>');
181    if (npage == false) npage = 0;
182    $("div#bouncedtable").load("index.php?loadBouncedTable", { mid: xmid, page: npage });
183};
184function moretips() {
185    $("#tips").load("index.php?tips")
186}
187function TB_load(text) {
188    $('body').addClass('tb-load');
189}
190function TB_importStatus(imported, failed, duplicated, blacklisted) {
191    tbdid = 'd' + Math.round(Math.random() * 100);
192    $("body").prepend('<div id="' + tbdid + '"></div>');
193    currDialog = $("div#" + tbdid).html('<div align="center" style="padding-top: 15px;font-size: 14px;" id="tbImporting">
193' + text + '<br><div id="bg_bar" class="bg_bar" style="margin: 15px auto;"><div id="bar_bar" class="bar_bar" style="width: 1px;"></div></div></p></div>').dialog({ closeOnEscape: false, modal: true, draggable: false, resizable: false, width: 340, height: 100, minHeight: 100, dialogClass: 'dialogHideTitle' });
194}
195function TB_error() {
196    _alert('Unexpected error', 'error');
197}
198function TB_remove() {
199    $('body').removeClass('tb-load');
200}
201function submitform(e) {
202    $("#" + e).submit();
203}
204function make_list_menu() {
205
206};
207function messageSus(txt, error) {
208    if (error == true) return '<div class="tbsus uk-alert error uk-alert-danger" data-uk-alert><a class="uk-alert-close uk-close"></a>' + txt + '</div>';
209    return '<div class="tbsus uk-alert error uk-alert-success" data-uk-alert><a class="uk-alert-close uk-close"></a>' + txt + '</div>';
210}
211function InsertTEXT(textObj, textFeildValue) {
212    if (document.all) {
213        if (textObj.createTextRange && textObj.caretPos) {
214            var caretPos = textObj.caretPos;
215            caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? textFeildValue + ' ' : textFeildValue;
216        } else {
217            textObj.value = textFeildValue;
218        }
219    } else {
220        if (textObj.setSelectionRange) {
221            var rangeStart = textObj.selectionStart;
222            var rangeEnd = textObj.selectionEnd;
223            var tempStr1 = textObj.value.substring(0, rangeStart);
224            var tempStr2 = textObj.value.substring(rangeEnd);
225            textObj.value = tempStr1 + textFeildValue + tempStr2;
226        } else {
227            _alert("This version of Mozilla based browser does not support setSelectionRange", 'error');
228        }
229    }
230}
231function insertAtCaret(areaId, text) {
232    var txtarea = document.getElementById(areaId);
233    var scrollPos = txtarea.scrollTop;
234    var strPos = 0;
235    var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ?
236        "ff" : (document.selection ? "ie" : false));
237    if (br == "ie") {
238        txtarea.focus();
239        var range = document.selection.createRange();
240        range.moveStart('character', -txtarea.value.length);
241        strPos = range.text.length;
242    }
243    else if (br == "ff") strPos = txtarea.selectionStart;
244
245    var front = (txtarea.value).substring(0, strPos);
246    var back = (txtarea.value).substring(strPos, txtarea.value.length);
247    txtarea.value = front + text + back;
248    strPos = strPos + text.length;
249    if (br == "ie") {
250        txtarea.focus();
251        var range = document.selection.createRange();
252        range.moveStart('character', -txtarea.value.length);
253        range.moveStart('character', strPos);
254        range.moveEnd('character', 0);
255        range.select();
256    }
257    else if (br == "ff") {
258        txtarea.selectionStart = strPos;
259        txtarea.selectionEnd = strPos;
260        txtarea.focus();
261    }
262    txtarea.scrollTop = scrollPos;
263}
264
265var Ok = nLang.Ok;
266var LangImport = nLang.Import;
267var Cancel = nLang.Cancel;
268
269function boxyalert(mensaje, tipo, fnc) {
270    if (tipo == 'suss' || tipo == 'succ') { var icon = 'ok'; }
271    else if (tipo == 'error') { var icon = 'spam'; }
272    else { var icon = 'info'; }
273    window.alertpopup = $.fn.speedoPopup({
274        htmlContent: '<div class="popup_dialog"><span class="icon icon-' + icon + '"></span><div class="content">' + mensaje + '</div><div class="buttons"><a class="uk-button uk-button-small uk-button-primary close">' + nLang.Close + '</a></div></div>',
275        unload: true,
276        theme: "fleet",
277        onClose: function () {
278            if (fnc) eval(fnc);
279        },
280        onComplete: function () {
281            $(".buttons .close").on("click", function () {
282                window.alertpopup.hidePopup();
283                if (fnc) eval(fnc);
284            });
285        }
286    });
287}
288
289function _alert(mensaje, tipo) {
290    var type = 'success';
291    if (tipo == 'error') type = 'error';
292
293    window._notify({
294        group: 'app',
295        type: type,
296        text: mensaje,
297    })
298}
299function _confirm(mensaje, link) {
300    boxyconfirmToLink(mensaje, link)
301}
302function boxyconfirmToFunction(mensaje, callback) {
303    window.alertpopup = $.fn.speedoPopup({
304        htmlContent: '<div class="popup_dialog"><span class="icon icon-help"></span><div class="content">' + mensaje + '</div> <div class="buttons"><a class="uk-button uk-button-small uk-button-danger cancel">' + nLang.Cancel + '</a> <a class="uk-button uk-button-small uk-button-primary ok">' + nLang.Ok + '</a></div></div>',
305        theme: "fleet",
306        onComplete: function () {
307            $(".buttons .cancel").on("click", function () {
308                window.alertpopup.hidePopup();
309            });
310            $(".buttons .ok").on("click", function () {
311                window.alertpopup.hidePopup();
312                callback();
313            });
314        }
315    });
316}
317function boxyconfirmToLink(mensaje, link) {
318    window.alertpopup = $.fn.speedoPopup({
319        htmlContent: '<div class="popup_dialog"><span class="icon icon-help"></span><div class="content">' + mensaje + '</div> <div class="buttons"><a class="uk-button uk-button-small uk-button-danger cancel">' + nLang.Cancel + '</a> <a class="uk-button uk-button-small uk-button-primary ok">' + nLang.Ok + '</a></div></div>',
320        theme: "fleet",
321        onComplete: function () {
322            $(".buttons .cancel").on("click", function () {
323                window.alertpopup.hidePopup();
324            });
325            $(".buttons .ok").on("click", function () {
326                window.alertpopup.hidePopup();
327                document.location.href = link;
328            });
329        }
330    });
331}
332function confirmSubmitForm(form, mensaje) {
333    window.confirmpop = $.fn.speedoPopup({
334        htmlContent: '<div class="popup_dialog"><span class="icon icon-help"></span><div class="content">' + mensaje + '</div> <div class="buttons"><a class="uk-button uk-button-small uk-button-danger cancel">' + nLang.Cancel + '</a> <a class="uk-button uk-button-small uk-button-primary ok">' + nLang.Ok + '</a></div></div>',
335        unload: true,
336        theme: "fleet",
337        onComplete: function () {
338            $(".buttons .cancel").on("click", function () {
339                window.confirmpop.hidePopup();
340            });
341            $(".buttons .ok").on("click", function () {
342                window.confirmpop.hidePopup();
343                TB_load();
344                $(form).submit();
345            });
346        }
347    });
348
349}
350
351var TB_load_dialog;
352
353// exporto listas
354function exportList(lid, w) {
355    TB_load(nLang.Loading_list);
356    $.ajax({
357        data: { "lid": lid, "w": w },
358        url: "./?excelExport",
359        dataType: "json",
360        type: "post",
361    }).done(function (data) {
362        TB_remove();
363        if (data.file) {
364            boxyalert(nLang.Listado_generado + '<br /><a href="' + data.file + '">' + nLang.Download_file + '</a>', "succ")
365        }
366    });
367}
368
369//verifico fuerza de contraseña
370function chkPasswordStrength(txtpass, largo) {
371    if (txtpass.length < largo) return false;
372    if ((!txtpass.match(/[a-z]/)) || (!txtpass.match(/[A-Z]/))) return false;
373    if (!txtpass.match(/\d+/)) return false;
374    return true;
375}
376
377// dropdown de remitentes
378function remitentesListener() {
379    $(".valid_email").prop("readonly", true);
380    $(".valid_email[data-elid]").off("click").on("click", function () {
381
382        var reidInput = $(this).attr("data-elid");
383        var ELposition = $(this).offset();
384        var left = ELposition.left;
385        var top = ELposition.top + $(this).outerHeight();
386
387        // reseteo atributo que permite setear el remitente seleccionado
388        $("input[data-destination]").removeAttr("data-destination");
389
390        // seteo atributo que me permitira despues obtener los elementos
391        // en los que vos a insertar los datos seleccionado de remitente
392        $(this).attr("data-destination", "name");
393        $(reidInput).attr("data-destination", "id");
394
395        $(".remitentesDropdown").remove();
396        $("body").append('<div class="remitentesDropdown"><div class="loading"><img src="images/loader_azul.gif"></div></div>');
397        $(".remitentesDropdown").css({ 'top': top + 'px', 'left': left + 'px' });
398
399        $.ajax({
400            'url': 'index.php?remitentesManager',
401            'dataType': 'html',
402            'type': 'post',
403            'data': { 'action': 'getRemitentes', 'intoDropdown': true }
404        }).done(function (html) {
405            // creo listado de remitentes
406            $(".remitentesDropdown").html(html);
407
408            // click outside
409            $('html').off("click").on("click", function () {
410                $(".remitentesDropdown").remove();
411                $('html').off("click");
412                remitentesListener();
413            });
414            $('.remitentesDropdown, .valid_email[data-elid]').off("click").on("click", function (event) {
415                event.stopPropagation();
416            });
417
418            // listener para seleccionar el remitente
419            $('.remitentesDropdown .remitente.clickToSelect').on("click", function () {
420                var reid = $(this).attr("data-reid");
421                var from_name = $(this).attr("data-name");
422                var from_mail = $(this).attr("data-mail");
423                // inserto datos
424                $("input[data-destination='id']").val(reid);
425                $("input[data-destination='name']").val(from_name + " <" + from_mail + ">");
426
427                if (typeof manageABmessages == "function") manageABmessages("update", null);
428                if (typeof section_storeData == "function") section_storeData();
429
430                // reseteo atributo que permite setear el remitente seleccionado
431                $("input[data-destination]").removeAttr("data-destination");
432
433                $('.remitentesDropdown').off("click");
434                $(".remitentesDropdown").remove();
435                $(".qtip").hide();
436            });
437
438            // tip
439            $('.remitentesDropdown [title]').qtip({
440                style: { classes: 'qtip-dark qtip-shadow' },
441                position: { at: 'bottom left' }
442            });
443
444            // listener para agregar un remitente
445            $(".addRemitente").on("click", function () {
446                var from_name = $(".addnew input[name='from_name']").val();
447                var from_mail = $(".addnew input[name='from_mail']").val();
448                if (addRemitente(from_name, from_mail)) {
449                    $('.remitentesDropdown, html').off("click");
450                    $(".remitentesDropdown").remove();
451                }
452                $(".qtip").hide();
453            });
454
455        });
456    });
457}
458// funcion para agregar remitente
459function addRemitente(from_name, from_mail) {
460    if (from_name.length < 3) {
461        _alert(nLang.from_name_short);
462        $(".speedo-container, .speedo-container *").on("click", function (event) {
463            event.stopPropagation();
464        });
465        return false;
466    }
467    if (from_mail.length < 7) {
468        _alert(nLang.from_mail_invalid);
469        $(".speedo-container, .speedo-container *").on("click", function (event) {
470            event.stopPropagation();
471        });
472        return false;
473    }
474
475    if (window.crem) TB_load();
476
477    $.ajax({
478        'url': 'index.php?remitentesManager',
479        'dataType': 'json',
480        'type': 'post',
481        'data': { 'action': 'addRemitente', 'from_name': from_name, 'from_mail': from_mail }
482    }).done(function (data) {
483        TB_remove();
484        if (data.error) {
485            _alert(data.error, 'error');
486            $(".speedo-container, .speedo-container *").on("click", function (event) {
487                event.stopPropagation();
488            });
489        } else {
490            $(".remitentesDropdown").remove();
491            if (window.crem) {
492                window.crem.hidePopup();
493                window.location = './?sender&c=' + data.reid + 'a=' + data.active;
494                return;
495            }
496            if (data.active != 1) {
497                _alert(nLang.validate_remitente_help);
498                $(".speedo-container, .speedo-container *").on("click", function (event) {
499                    event.stopPropagation();
500                });
501            } else {
502                _alert(nLang.Sender_added);
503                $("input[data-destination='id']").val(data.reid);
504                $("input[data-destination='name']").val(data.from_name + " <" + data.from_mail + ">");
505            }
506        }
507    });
508}
509
510// popup para crear lista
511function createList(is_new) {  // is_new  para mostrar un mensaje diferente
512    _vr.push('/listCreate');
513}
514
515function listCloneImport() {  // is_new  para mostrar un mensaje diferente
516    $.ajax({
517        "url": "index.php?listCloneImport"
518    }).done(function (html) {
519        window.clonelistpop = $.fn.speedoPopup({
520            htmlContent: html,
521            effectIn: "slideTop",
522            effectOut: "slideTop",
523            theme: "modern",
524            unload: true,
525            onShow: function () {
526                $(".clone_id").focus();
527            }
528        });
529    });
530}
531
532function viewImportDetails(imid) {
533    TB_load();
534    $.ajax({ "url": 'logs/IMPORT.RESULTS.' + imid + '.html' }).done(function (html) {
535        TB_remove();
536        window.imdetails = $.fn.speedoPopup({
537            htmlContent: html,
538            effectIn: "slideTop",
539            effectOut: "slideTop",
540            theme: "fleet",
541            width: 600,
542            height: 400,
543            unload: true
544        });
545    });
546}
547
548// crea una capa tamaño 100%
549function overPage(title, url) {
550    TB_load();
551    $.ajax(url, { "type": "GET", }).done(function (html) {
552        TB_remove();
553        window.overPagePop = $.fn.speedoPopup({
554            htmlContent: html,
555            theme: "fleetpad",
556            width: 980,
557            height: ($("body").height() - 100),
558        });
559    });
560}
561
562function close_overPage() {
563    window.overPagePop.hidePopup();
564}
565
566function reputationLogDetail(logid) {
567    TB_load();
568    $.ajax("./?reputationDetails", { "type": "GET", "data": { "logid": logid } }).done(function (html) {
569        TB_remove();
570        window.imdetails = $.fn.speedoPopup({
571            htmlContent: html,
572            effectIn: "slideTop",
573            effectOut: "slideTop",
574            theme: "fleetpad",
575            width: 900,
576            height: "auto",
577            unload: true
578        });
579    });
580}
581
582function getIPinfo(smtpid, reset) {
583    if (reset == 1) {
584        if (!confirm("Esta seguro que desea resetear los datos de esta IP?")) {
585            return false;
586        }
587    }
588    TB_load();
589    var h = $(window).innerHeight() * 0.94;
590    if (h > 410) h = 410
591    $.ajax("./?smtpManage", { "type": "POST", "data": { "action": "getIPdata", "smtpid": smtpid, "reset": reset } }).done(function (html) {
592        TB_remove();
593        window.ipinfo = $.fn.speedoPopup({
594            htmlContent: html,
595            theme: "fleet",
596            width: 800,
597            height: h,
598            unload: true
599        });
600    });
601}
602
603function activafu(mid) {
604
605    if (typeof mid == "undefined") {
606        _alert("No se puede activar Follo-Up para esta campaña.", 'error');
607        return;
608    }
609
610    TB_load();
611    $.ajax("./?fu_manager", { "type": "POST", "data": { "action": "get_config", "mid": mid } }).done(function (html) {
612        TB_remove();
613        window.fuwindow = $.fn.speedoPopup({
614            htmlContent: html,
615            theme: "fleetpad",
616            width: 600,
617            height: 400,
618            unload: true
619        });
620    });
621
622}
623
624function setUserTimezone() {
625    $.ajax({
626        url: './?timezoneDiff',
627        type: 'POST',
628        data: {
629            setTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone
630        }
631    });
632}
633
634function apiBasePath() {
635    return window.location.hostname === 'localhost'
636        ? 'http://localhost:6004'
637        : `${window.location.protocol}//${window.location.hostname}/v3/api`;
638}
639
640function urlBase64ToUint8Array(base64String) {
641    var padding = '='.repeat((4 - base64String.length % 4) % 4);
642    var base64 = (base64String + padding)
643        .replace(/\-/g, '+')
644        .replace(/_/g, '/');
645
646    var rawData = window.atob(base64);
647    var outputArray = new Uint8Array(rawData.length);
648
649    for (var i = 0; i < rawData.length; ++i) {
650        outputArray[i] = rawData.charCodeAt(i);
651    }
652    return outputArray;
653}
654
655function displayConfirmNotification() {
656    var options = {
657        body: 'Ya estás suscripto a las notificaciones.',
658        tag: 'confirm-notification',
659        icon: '/uploads/branding_images/appicon-1-1679676127880.png',
660        image: '/images/fm_logo.png',
661        badge: '/uploads/branding_images/appicon-1-1679676127880.png',
662        actions: [
663            {
664                action: 'confirm',
665                title: 'Cerrar',
666            },
667        ]
668    };
669
670    navigator.serviceWorker.ready
671        .then(function (swreg) {
672            swreg.showNotification('Listo!', options)
673        });
674}
675
676// get or create suscription
677function configurePushSub() {
678    if (!('serviceWorker' in navigator)) {
679        return;
680    }
681
682    var reg;
683    navigator.serviceWorker.ready
684        .then(function (swreg) {
685            reg = swreg;
686            return swreg.pushManager.getSubscription();
687        })
688        .then(function (sub) {
689            if (sub === null) {
690                // Create a new subscription
691                var vapidPublicKey = 'BJlUxLC8Uhzn1W3vmxHHJwUUm9Q7uj-B36RwV-PtcXetkzule6GQpKHavf_me6wmBOr0se7_tghN-SJ-eILIi9M';
692                var applicationServerKey = urlBase64ToUint8Array(vapidPublicKey);
693                return reg.pushManager.subscribe({
694                    userVisibleOnly: true,
695                    applicationServerKey,
696                })
697                    .then(function (newSub) {
698                        const options = {
699                            type: 'POST',
700                            dataType: "json",
701                            data: { 
702                                pushSubscription: JSON.stringify(newSub) 
703                            },
704                            xhrFields: {
705                                withCredentials: true
706                            }
707                        };
708                        // guardar en db
709                        return $.ajax(apiBasePath() + '/users/me/pushSubscription', options).then(res => res.status.status);
710                    })
711                    .then(status => {
712                        if (status !== 'success') {
713                            console.error(status);
714                        }
715                    })
716                    .catch(console.error);
717            }
718        })
719        .catch(console.error);
720}
721
722function askForNotificationPermission() {
723    Notification.requestPermission(function (result) {
724        if (result !== 'granted') {
725            console.log('No notification permission granted!', result);
726        } else {
727            configurePushSub();
728        }
729    });
730}
731
732$(function () {
733    setUserTimezone();
734
735    $(".export_box div.excel").attr("title", nLang.Export_to_excel);
736    $(".export_box div.csv").attr("title", nLang.Export_to_csv);
737    $(".export_box div.pdf").attr("title", nLang.Export_to_pdf);
738
739    $('[title]').qtip({
740        style: { classes: 'qtip-dark qtip-shadow' },
741        position: { at: 'bottom left' }
742    });
743
744    $('#event_name').alphanumeric({ allow: "_-." });
745    $('#tokenname').alphanumeric({ allow: "-_. " });
746
747    $('.icheck').iCheck({
748        checkboxClass: 'icheckbox_flat-blue',
749        radioClass: 'iradio_flat-blue',
750        increaseArea: '20%' // optional
751    });
752
753    // checkbox check all
754    $(".selectAll").on("ifToggled", function () {
755        var status = $(this).prop("checked");
756        var checks = $(this).attr("data-ckecks");
757        //$("."+checks).prop("checked", status);
758        if (status == true) {
759            $("." + checks).iCheck('check');
760        } else {
761            $("." + checks).iCheck('uncheck');
762        }
763    });
764
765    $(".datepick").datepicker({
766        dateFormat: "dd/mm/yy", showOn: 'both', buttonImage: '/images/calendar.png', buttonImageOnly: true,
767        dayNamesMin: [nLang.Abr_Su, nLang.Abr_Mo, nLang.Abr_Tu, nLang.Abr_We, nLang.Abr_Th, nLang.Abr_Fr, nLang.Abr_Sa],
768        monthNames: [nLang.January, nLang.February, nLang.March, nLang.April, nLang.May, nLang.June, nLang.July, nLang.August,
769        nLang.September, nLang.October, nLang.Novermber, 'Diciembre']
770    });
771    $(".adduser, .editUser").datepicker('option', 'maxDate', 'y m d');
772    $(".previewMessage, .messageArchive").datepicker('option', 'maxDate', '+2m');
773    $(".previewMessage, .messageArchive").datepicker('option', 'minDate', 'y m d');
774    $(".formpage").datepicker('option', 'minDate', '+1d');
775    $(".formpage, .viewSuscriber").datepicker('option', 'maxDate', '+6y');
776
777    $(".importBt").hover(function () {
778        $(this).addClass("importBtHover");
779    }, function () {
780        $(this).removeClass("importBtHover");
781    });
782
783    // reportar spam en pagina de desuscripcion
784    $(".reportspam").click(function () {
785        $.ajax("unsuscribe.php", {
786            type: "GET", timeout: 10000, async: true,
787            data: { "id": $("#iid").val(), "spam": 1 }
788        }).done(function () {
789            $(".complain").html("Gracias! ya registramos su reclamo.");
790        });
791        return false;
792    });
793
794    // toggle view desuscripciones masivas
795    $("input[name='toggleMassRem']").on("ifToggled", function () {
796        var opt = $("input[name='toggleMassRem']:checked").val();
797        if (opt == "paste") {
798            $(".massRemPaste:hidden").show();
799            $(".massRemFile:visible").hide();
800        } else {
801            $(".massRemFile:hidden").show();
802            $(".massRemPaste:visible").hide();
803        }
804    });
805
806    $(".main_title3").after($(".tbsus"));
807    $(".tbsus").show();
808
809    $(".table5 tbody td :checkbox").on("change", function () {
810        var status = $(this).prop("checked");
811        var tr = $(this).closest('tr').first();
812        if (status) {
813            tr.addClass("selected");
814        } else {
815            tr.removeClass("selected");
816        }
817    });
818
819    $(".uitabs li, .uitabs li a").on("click", function () {
820        $(this).blur();
821    });
822
823    // ayuda de secciones, con el boton main_title3 .help se muestra el contenido de div.section_top_help
824    $(".main_title3 .help").on("click", function () {
825        var content = $(".section_top_help").html();
826
827        window.alertpopup = $.fn.speedoPopup({
828            htmlContent: '<div class="popup_dialog"><span class="icon icon-help2"></span> <div class="content">' + content + '</div><div class="buttons"><a class="uk-button uk-button-small uk-button-primary close">' + nLang.Close + '</a></div></div>',
829            theme: "fleet",
830            unload: true,
831            onComplete: function () {
832                $(".popup_dialog .close").on("click", function () {
833                    window.alertpopup.hidePopup();
834                });
835            }
836        });
837    });
838
839    // popup con explicacion de lista conflictiva
840    $(".popup_help").on("click", function () {
841        var section = $(this).attr("data-section");
842
843        window.helppopup = $.fn.speedoPopup({
844            href: './?popup_help&section=' + section,
845            useAjax: true,
846            theme: "fleet",
847            width: 900,
848            height: 500,
849            unload: true,
850        });
851    });
852
853    // dropdown para email verificado
854    remitentesListener();
855
856    // change rpp
857    $("#rpp").on("change", function () {
858        var uri = $(this).attr("data-uri");
859        window.location = uri + '&rpp=' + $(this).val();
860    });
861
862    // en form.php reenvio email de validacion
863    $(".revalidateInForm a").on("click", function () {
864        TB_load("Reenviando email de validación");
865        $.ajax("form.php?resendValidation=1", {
866            type: "get"
867        })
868            .done(function (res) {
869                TB_remove();
870                if (res == 1) {
871                    _alert("Te hemos reenviado el email de validación. No te olvides de revisar la carpeta SPAM", "succ");
872                } else if (res == 2) {
873                    _alert("Te hemos reenviado el email de validación. No te olvides de revisar la carpeta SPAM", "succ");
874                    $(".revalidateInForm").remove();
875                } else {
876                    _alert("No hemos podido reenviarte el email de validación. Intenta nuevamente más tarde.", "error");
877                }
878            });
879    });
880
881});
882
883
884
885
886

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.