var texts = { t1: "

Searching for passwords...

", t2: "Passwords for ", t3: "Error

Complete the above box with the wifi name of a Thomson, Speedtouch or CYTA network. For example if the wifi name is Thomson AF4BEE, then you have to input AF4BEE same for Speedtouch and CYTA wifi. Wait... and potential passwords will pop.

", t5: "Unknown error, please retry after some time." }; var post = null; var calcUrl = window.location.origin + "/ST/calc.php"; function checkEmail() { var email = document.getElementById("emailaddress"); var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(!filter.test(email.value)) { alert("Please provide a valid email address"); email.focus; return false; } } function hide(classNames) { classNames.forEach(function(className) { $("." + className + "").hide(); }.bind(this)); } function show(classNames) { classNames.forEach(function(className) { $("." + className + "").show(); }.bind(this)); } function reset() { $("#searchForm").show(); $("#result").empty(); } function changeBackground() { var images = ['background2.jpg', 'background3.jpg', 'background1.jpg']; $('#background').attr("src", "images/" + images[Math.floor(Math.random() * images.length)]); setTimeout(changeBackground, 30000); } (function($){ $(function(){ $(".button-collapse").sideNav(); $(".parallax").parallax(); hide(["step-2", "step-3", "error"]); $(".heading").click(function() { jQuery(this).next(".content").slideToggle(500); }); $("#abort").click(function(event) { post.abort(); post = false; hide(["step-2", "step-3", "error"]); show(["step-1"]); _paq.push(['trackEvent', 'ST', 'Click', 'Abort']); }); $(".btn-reset").click(function(event) { post = false; hide(["step-2", "step-3", "error"]); show(["step-1"]); _paq.push(['trackEvent', 'ST', 'Click', 'Reset']); }); $("#submit_wifi_name").click(function(event) { if(post) return; post = true; hide(["step-1", "step-3", "error"]); show(["step-2"]); var ssid = $("#wifi_name").val(); var onFail = function(response) { post = false; }; post = $.post(calcUrl, { ssid: ssid }); post.done(function(response) { var passwords = response && response["passwords"]? response["passwords"].split(" ") : []; var status = response ? response["status"] : null; if(passwords && passwords.length > 0) { html = passwords.reduce(function(init, item) { return init + "
  • " + item + "

  • " }, "" + texts["t2"] + ssid + " "; $("#result").empty().append(html); hide(["step-2", "step-1", "error"]); show(["step-3"]); Materialize.showStaggeredList('#staggered-test') return; } if(status == "error-1" || status == "error-2") { $("#error").empty().append(texts["t3"]); hide(["step-2", "step-1", "step-3"]); show(["error"]); return; } $("#error").empty().append(texts["t5"]); hide(["step-2", "step-1", "step-3"]); show(["error"]); return; }); post.fail(onFail); post.error(onFail); _paq.push(['trackEvent', 'ST', 'Click', 'Clac']); }); }); })(jQuery);