// metodo SolSslCheck function SolSslCheck(config) { var _p = {}; var pub = this; var COOKIE_NAME = "sslcookie"; // Libreria per la creazione e lettura dei cookie var lib = { // scrivo il cookie writePersistentCookie : function(_name, _value){ var expireDate = new Date(); var offset = 2 * 60 * 60 * 1000; expireDate.setTime(expireDate.getTime() + offset); var cookie_string = escape(_name) + "=" + escape(_value) + "; expires=" + expireDate.toGMTString() + "; path=/"; document.cookie = cookie_string; }, // leggo il cookie getCookieValue : function(_name) { var exp = new RegExp (escape(_name) + "=([^;]+)"); if (exp.test (document.cookie + ";")) { exp.exec (document.cookie + ";"); return unescape(RegExp.$1); } else return false; } } _p.debug = true; _p.$ = config.jQuery; /* _p.window = config.window; _p.message = config.message; _p.loginButtonId = config.loginButtonId; _p.loginFormId= config.loginFormId; _p.cms_enable_https = config.cms_enable_https; */ _p.console = { log : function() {} }; if (_p.debug) { if (typeof console != "undefined") { _p.console = console; } } for(var e in config) { // _p.console.log(e); _p[e] = config[e]; } // verifico se SSL è disponibile nel browser pub.isSSLEnabled = function(){ // Se non è abilitato l'https facciamo finta che lo sia per l'ambiente di dev if (_p.cms_enable_https === false) return true; if(!_p.window.sol_sslcheck){ //_p.console.log("sol_sslcheck non esiste, https è disabilitato"); return false; // false per debug } return true; }; // Chiamata ajax al server per informarlo dello stato del browser corrente pub.notifyBrowserStatus = function() { var settings = { async: true, url: _p.save_session_status_url, dataType: 'json', data : { v : 1, https_disabled : (typeof _p.window.sol_sslcheck == "undefined") }, success : function(_r) { //_p.console.log(JSON.stringify(_r)); } }; _p.$.ajax(settings); }; pub.findAllAnchors = function() { _p.$( "a" ).click(function( event ) { if (this.protocol == 'https:') { event.preventDefault(); pub.showMessage(); return false; } }); } pub.showModal = function() { var a = document.createElement("a"); a.href = '/notify-box-noauth?notify=1'; if (_p.hs && _p.hs.htmlExpand) return _p.hs.htmlExpand(a, { "objectType":"iframe", "width":670, "wrapperClassName":"sslcheckModal", "height":420, "objectLoadTime":"after" }); return false; }; _p.handleLoginButton = function() { if (!pub.isSSLEnabled()) { return pub.showModal(); } else { _p.$(_p.loginFormId).submit(); } }; pub.handleEvents = function() { // form login homepage _p.$(_p.loginButtonId).click(_p.handleLoginButton); }; // Mostra il banner con il messaggio di cortesia pub.showMessage = function(){ // Genero HTML per l'alert e lo appendo al body var html_alert = '
'; html_alert += '
'; html_alert += ''; html_alert += _p.message; html_alert += '
×
'; html_alert += '
'; html_alert += '
'; _p.$('body').append(html_alert); // Chiudo il messaggio e creo il cookie _p.$( "#buorgclose" ).click(function( event ) { _p.$( "#buorg" ).fadeOut(); lib.writePersistentCookie(COOKIE_NAME, '1'); }); }; pub.init = function() { if (!pub.isSSLEnabled()) { // Se il cookie non è più valido appendo l'alert if(!lib.getCookieValue(COOKIE_NAME)){ pub.showMessage(); } pub.findAllAnchors(); } pub.notifyBrowserStatus(); pub.handleEvents(); }; // Nelle jump mostrami direttamente la modale function showModalReady(value, array) { if(!pub.isSSLEnabled() && array.indexOf(value) > -1) { return pub.showModal(); } } showModalReady(config.ctr, ["crea-sito-web", "crea-sito-gratis", "sito-web-avvocato", "sito-architetto", "sito-agriturismo", "sito-fotografi", "sito-fidal"]); };