JSFiddle - React, Tailwind, and code Playground
by ryanttb
HTML
<h1 class="he-debug"></h1>
<iframe width="640" height="360" data-he-internal="http://video.isites.harvard.edu/liveVideo/liveEmbed.do?name=HLS1x_copyright&width=auto&height=auto"
data-he-external="http://video.isites.harvard.edu/liveVideo/liveEmbed.do?name=HLS1x_copyright_global&width=auto&height=auto"></iframe>
JavaScript
$(function () {
$.getJSON("http://api.hostip.info/get_json.php").done(function (result) {
var harvardRanges = [ "140.247", "128.103", "131.142", "132.183", "134.174" ];
var heDebug = result.ip;
var network = "external"; //< client network (external | internal)
var $iframe, src;
$.each( harvardRanges, function() {
if ( result.ip.indexOf( this ) === 0 ) {
heDebug += " (Harvard)";
network = "internal";
return false;
}
} );
$("iframe").each( function() {
// check every iframe for harvard-embed data
$iframe = $(this);
src = $iframe.data( "he-" + network );
if ( src ) {
// actually change the iframe's src
$iframe.attr( "src", src );
heDebug += "<br>" + src;
}
} );
// push IP & flag to debug element if present
$(".he-debug").html(heDebug);
});
});