'; var pending = 0; var results = { v4_support: 0, v6_support: 0, v6_native: 0, v6_no_slaac: 0, v6_hostname: 0, br_default_v6: 0, br_fallback: 0, dns_n4i6: 0, dns_n6i4: 0, dns_n6i6: 0, }; function test_started() { pending++; } function test_finished() { if (--pending === 0) { update_score(); } } function test_v4_conn() { var $p = $("#v4_conn"); $p.find(".proto_supported").html(progress_bar).find(".progress-bar").css("width", "100%"); $p.find(".proto_address, .proto_hostname, .proto_isp").empty(); test_started(); $.ajax({ url: "//v4.ipv6-test.com/json/addrinfo.php?PHPSESSID=bfg5pfbu27t2njo245e6n1lql5", dataType: "jsonp", timeout: 15000, success: function(resp) { $p.find(".proto_supported").html("Supported"); $p.find(".proto_address").html("" + resp.address + ""); $p.find(".proto_hostname").html(resp.hostname ? resp.hostname : "None"); $p.find(".proto_isp").html(resp.isp_name + " "); results.v4_support = 1; }, error: function(xopt, err) { $p.find(".proto_supported").html("Not supported"); results.v4_support = 0; }, complete: test_finished, }); } function test_v6_conn() { var $p = $("#v6_conn"); $p.find(".proto_supported").html(progress_bar).find(".progress-bar").css("width", "100%"); $p.find(".proto_address, .proto_type, .proto_tunnel_server, .proto_tunnel_server_type, .proto_tunnel_client, .proto_slaac, .proto_mac_addr, .proto_mac_vendor, .proto_hostname, .proto_isp, .proto_icmp").empty(); test_started(); $.ajax({ url: "//v6.ipv6-test.com/json/addrinfo.php?PHPSESSID=bfg5pfbu27t2njo245e6n1lql5", dataType: "jsonp", timeout: 15000, success: function(resp) { $p.find(".proto_supported").html("Supported"); $p.find(".proto_address").html("" + resp.address + ""); $p.find(".proto_type").html("" + resp.ip6_type + ""); if (resp.ip6_6to4) { $p.find(".proto_tunnel_server").html("" + resp.ip6_6to4 + ""); $p.find(".proto_tunnel_server_type").text("6to4"); $p.find(".proto_has_tunnel_server").show(); results.v6_native = 0; } else if (resp.ip6_teredo_server) { $p.find(".proto_tunnel_server").html("" + resp.ip6_teredo_server + ""); $p.find(".proto_tunnel_client").html("" + resp.ip6_teredo_client_host + ":" + resp.ip6_teredo_client_port); $p.find(".proto_tunnel_server_type").text("Teredo"); $p.find(".proto_has_tunnel_server, .proto_has_tunnel_client").show(); results.v6_native = 0; } else { $p.find(".proto_has_tunnel_server, .proto_has_tunnel_client").hide(); results.v6_native = 1; } $p.find(".proto_slaac").html(resp.ip6_stateless ? "Yes" : "No"); if (resp.ip6_stateless) { $p.find(".proto_mac_addr").text(resp.ip6_mac); $p.find(".proto_mac_vendor").text(resp.ip6_mac_vendor); $p.find(".proto_has_slaac").show(); results.v6_no_slaac = 0; } else { $p.find(".proto_has_slaac").hide(); results.v6_no_slaac = 1; } if (resp.hostname) { $p.find(".proto_hostname").html(resp.hostname); results.v6_rdns_ok = 1; results.v6_hostname = 1; } else { if (resp.rdns_fail) { $p.find(".proto_hostname").html("SERVFAIL"); results.v6_rdns_ok = 0; } else { $p.find(".proto_hostname").html("None"); results.v6_rdns_ok = 1; } results.v6_hostname = 0; } $p.find(".proto_isp").html(resp.isp_name + " "); results.v6_support = 1; $p.find(".proto_icmp").html(progress_bar).find(".progress-bar").css("width", "100%"); test_started(); $.ajax({ url: "https:\/\/v6.ipv6-test.com:8443", dataType: "jsonp", timeout: 5000, success: function(resp) { if (resp.status === "ok") { $p.find(".proto_icmp").html("Reachable"); results.v6_icmp = 1; test_finished(); } else { // retry once $.ajax({ url: "https:\/\/v6.ipv6-test.com:8443", dataType: "jsonp", timeout: 5000, success: function(resp) { if (resp.status === "ok") { $p.find(".proto_icmp").html("Reachable"); results.v6_icmp = 1; } else { $p.find(".proto_icmp").html("Filtered"); results.v6_icmp = 0; } }, error: function(xopt, err) { $p.find(".proto_icmp").html("Not tested"); results.v6_icmp = 0; }, complete: test_finished, }); } }, error: function(xopt, err) { $p.find(".proto_icmp").html("Not tested"); results.v6_icmp = 0; test_finished(); }, }); }, error: function(xopt, err) { $p.find(".proto_supported").html("Not supported"); results.v6_support = 0; results.v6_native = 0; results.v6_no_slaac = 0; results.v6_hostname = 0; }, complete: test_finished, }); } function test_browser() { var $p = $("#browser"); $p.find(".browser_default").html(progress_bar).find(".progress-bar").css("width", "100%"); $p.find(".browser_fallback").empty(); test_started(); $.ajax({ url: "//v4v6.ipv6-test.com/json/defaultproto.php?PHPSESSID=bfg5pfbu27t2njo245e6n1lql5", dataType: "jsonp", timeout: 15000, success: function(resp) { $p.find(".browser_default").html("IPv" + resp.protocol + ""); $p.find(".browser_fallback").html(progress_bar).find(".progress-bar").css("width", "100%"); var fb_start = (new Date()).getTime(); test_started(); $.ajax({ url: "//fallback-v" + resp.protocol + ".ipv6-test.com/json/proto.php", dataType: "jsonp", timeout: 15000, success: function(resp2) { var fb_time = Math.round(((new Date()).getTime() - fb_start) / 1000); var label = fb_time + " seconds"; var lclass = "success"; results.br_fallback = 1; results.br_fallback_tm = 1; if (fb_time > 5) { lclass = "warning"; results.br_fallback_tm = 0; } else if (fb_time === 1) { label = "1 second"; } else { label = "< 1 second"; } $p.find(".browser_fallback").html("to IPv" + resp2.protocol + " in " + label + ""); }, error: function(xopt, err) { $p.find(".browser_fallback").html("No"); results.br_fallback = 0; results.br_fallback_tm = 0; }, complete: test_finished, }); if (resp.protocol === "6") { results.br_default_v6 = 1; } else { results.br_default_v6 = 0; } }, error: function(xopt, err) { $p.find(".browser_default").html("Test failed"); results.br_default_v6 = 0; results.br_fallback = 0; results.br_fallback_tm = 0; }, complete: test_finished, }); } function test_dns() { var $p = $("#dns"); $p.find(".dns_dns4_ip6, .dns_dns6_ip4, .dns_dns6_ip6").html(progress_bar).find(".progress-bar").css("width", "100%"); test_started(); $.ajax({ url: "//v6-zone4.ipv6-test.com/json/proto.php", dataType: "jsonp", timeout: 15000, success: function(resp) { if (resp.protocol === "6") { $p.find(".dns_dns4_ip6").html("Reachable"); results.dns_n4i6 = 1; } else { $p.find(".dns_dns4_ip6").html("Test failed"); results.dns_n4i6 = 0; } }, error: function(xopt, err) { $p.find(".dns_dns4_ip6").html("Unreachable"); results.dns_n4i6 = 0; }, complete: test_finished, }); test_started(); $.ajax({ url: "//v4-zone6.ipv6-test.com/json/proto.php", dataType: "jsonp", timeout: 15000, success: function(resp) { if (resp.protocol === "4") { $p.find(".dns_dns6_ip4").html("Reachable"); results.dns_n6i4 = 1; } else { $p.find(".dns_dns6_ip4").html("Test failed"); results.dns_n6i4 = 0; } }, error: function(xopt, err) { $p.find(".dns_dns6_ip4").html("Unreachable"); results.dns_n6i4 = 0; }, complete: test_finished, }); test_started(); $.ajax({ url: "//v6-zone6.ipv6-test.com/json/proto.php", dataType: "jsonp", timeout: 15000, success: function(resp) { if (resp.protocol === "6") { $p.find(".dns_dns6_ip6").html("Reachable"); results.dns_n6i6 = 1; } else { $p.find(".dns_dns6_ip6").html("Test failed"); results.dns_n6i6 = 0; } }, error: function(xopt, err) { $p.find(".dns_dns6_ip6").html("Unreachable"); results.dns_n6i6 = 0; }, complete: test_finished, }); } var first_adv = true; function update_score() { $.ajax({ url: "//ipv6-test.com/json/advise.php", data: results, dataType: "jsonp", timeout: 15000, success: function(resp) { $("#score h2").text(resp.score + " / 20"); if (resp.score > 18) { pclass = "success"; } else if (resp.score > 12) { pclass = "warning"; } else { pclass = "danger"; } $("#score .progress-bar").removeClass("active progress-striped progress-bar-success progress-bar-warning progress-bar-danger").addClass("progress-bar-" + pclass).animate({ width: (resp.score * 5) + "%"}, 2000); var $al = $("#advise_list"); $al.empty(); if (!resp.advise.length) { return; } $(resp.advise).each(function(k, adv) { var pclass = "default"; switch (adv[2]) { case 0: pclass = "danger"; break; case 1: pclass = "warning"; break; case 2: pclass = "success"; break; } $al.append('

' + (k + 1) + '. ' + adv[0] + '

' + adv[1] + '
'); }); $al.find("a[data-toggle='collapse']").click(function(ev) { $(this).blur(); }); if (first_adv) { setTimeout(function() { $("#toggle_advise").popover({ title: "Improve your score", content: "Click here to learn how to improve your score and enjoy a better connection to the IPv6 Internet.", placement: "auto top", trigger: "manual", container: "body", }).popover("show"); setTimeout(function() { $("#toggle_advise").popover("hide"); }, 5000); }, 2000); first_adv = false; } }, error: function(xopt, err) { $("#advise").hide(); }, }); } function i6tOnLoad() { $("#hide_noscript").css("display", ""); $("table span.glyphicon-question-sign").each(function(k, el) { $(el).attr("data-title", $(el).closest("tr").find("th").text()).popover({ placement: "auto right", container: "body", }); }); $("#refresh_v4").click(function(ev) { test_v4_conn(); ev.preventDefault(); return false; }); $("#refresh_v6").click(function(ev) { test_v6_conn(); ev.preventDefault(); return false; }); $("#refresh_browser").click(function(ev) { test_browser(); ev.preventDefault(); return false; }); $("#refresh_dns").click(function(ev) { test_dns(); ev.preventDefault(); return false; }); $("#toggle_advise").click(function(ev) { $("#toggle_advise").popover("hide"); $("#advise").slideToggle(); ev.preventDefault(); return false; }); test_browser(); test_v4_conn(); test_v6_conn(); test_dns(); };