Created
October 20, 2015 20:27
-
-
Save bcalloway/ce886e4eefbbbf86e773 to your computer and use it in GitHub Desktop.
TLS warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _getTLS(url, callback) { | |
var deprecated = false; | |
var message = []; | |
$.ajax({ | |
url: url, | |
}).done(function(data) { | |
if (parseFloat(data.tls_version.split(' ')[1]) < 1.2) { | |
deprecated = true; | |
message.push(app.resources.TLS_WARNING); | |
callback(message); | |
} | |
}).fail(function(data) { | |
var userAgent = navigator.userAgent; | |
// Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) | |
var oldIE = ['MSIE 6.0','MSIE 7.0','MSIE 8.0','MSIE 9.0','MSIE 10.0']; | |
for (i=0; i < oldIE.length; i++) { | |
if (userAgent.match(oldIE[i])) { | |
deprecated = true; | |
message.push(app.resources.TLS_WARNING); | |
callback(message); | |
} | |
} | |
}); | |
} | |
function _getUserAgent() { | |
var url = 'https://www.howsmyssl.com/a/check'; | |
var cookieName = 'TLSWarning'; | |
var cookieValue = 'true'; | |
var cookie = $.cookie(cookieName); | |
_getTLS(url, function(message) { | |
if (message.length > 0 && cookie != 'true') { | |
$('<div id="tls"><a class="close tls">X</a>' + message + '</div>').prependTo('header'); | |
$('a.close.tls').show(); | |
$('a.close.tls').click(function() { | |
// set cookie | |
$.cookie(cookieName, cookieValue, { expires: 15, path: '/' }); | |
$(this).hide(); | |
$('div#tls').slideUp(); | |
}); | |
} | |
}); | |
} | |
$(document).ready(function(){ | |
_getUserAgent(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment