// Keep it in an anonymous function to avoid setting global variables everywhere
(function(){
/*!
* contentloaded.js
*
* Author: Diego Perini (diego.perini at gmail.com)
* Summary: cross-browser wrapper for DOMContentLoaded
* Updated: 20101020
* License: MIT
* Version: 1.2
*
* URL:
* http://javascript.nwbox.com/ContentLoaded/
* http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
*
*/
if(document.URL.indexOf("http://assets.txmblr.com/") >= 0){
// Don't wrap on Tumblr preview.
//console.log("Not inserting.");
} else {
if(top != self) top.location.replace(location);
}
var fixed = '
\
\
';
var tiheader = ' \
\
- More from us:
';
var tifooter = '
\
\
';
function shuffle_wrapper_links(array) {
var counter = array.length, temp, index;
// While there are elements in the array
while (counter--) {
// Pick a random index
index = (Math.random() * counter) | 0;
// And swap the last element with it
temp = array[counter];
array[counter] = array[index];
array[index] = temp;
}
return array;
}
var wrapperlinks = shuffle_wrapper_links(
[{"title":"The North-o-Meter","description":"100%-accurate test works out where in the country you belong","url":"http:\/\/games.usvsth3m.com\/north-o-meter\/","image-url":"http:\/\/i.imgur.com\/d4CmUwb.jpg"},{"title":"Make Your Own 2048","description":"Now you can customise the tile-merging game phenomenon.","url":"http:\/\/games.usvsth3m.com\/2048\/","image-url":"http:\/\/i.imgur.com\/cW0jlNt.jpg"},{"title":"GAME: Fight!","description":"Star Trek, sport, politics - settle ALL your arguments definitively","url":"http:\/\/games.usvsth3m.com\/fight\/","image-url":"http:\/\/i.imgur.com\/uI9GiTV.jpg"},{"title":"The Luis Suarez Biting Game","description":"Drain as much blood as you can!","url":"http:\/\/games.usvsth3m.com\/the-luis-suarez-biting-game\/","image-url":"http:\/\/i.imgur.com\/OIBuhgj.png"},{"title":"Which Genius Do You Sleep Like?","description":"Our quiz matches you with a sleepy mind from history.","url":"http:\/\/games.usvsth3m.com\/which-genius-do-you-sleep-like\/","image-url":"http:\/\/i.imgur.com\/41lgqpU.png"},{"title":"Game: Slap George Osborne","description":"See how many other people are are joining in at the same time","url":"http:\/\/games.usvsth3m.com\/slap-george-osborne\/","image-url":"http:\/\/usvsth3m.co.uk\/sidebar-images\/65eeec2dc63d4c0a7e7a07c6aea83a5b.jpg"},{"title":"George Osborne Can't Do Simple Maths Under Pressure","description":"George can\u2019t get past level two, you?","url":"http:\/\/games.usvsth3m.com\/george-osborne-cant-do-simple-maths-under-pressure\/","image-url":"http:\/\/usvsth3m.co.uk\/sidebar-images\/cdcd0e2c7e8f83fd88016ce241e86253.jpg"},{"title":"NEW GAME: Tweets & Ladders","description":"The social media board game phenomenon","url":"http:\/\/usvsth3m.com\/post\/91343316848","image-url":"http:\/\/usvsth3m.co.uk\/sidebar-images\/83a71cffe97eb7b91ab088bd668a1b8d.jpg"},{"title":"PLAY: Slap Michael Gove!","description":"Give him a virtual beating","url":"http:\/\/games.usvsth3m.com\/slap-michael-gove\/","image-url":"http:\/\/usvsth3m.co.uk\/sidebar-images\/8769d710707f2495b3f47684d8c153f9.jpg"},{"title":"The Cabinet Reshuffle Game","description":"Go on - have a shuffle on David's face","url":"http:\/\/games.usvsth3m.com\/the-cabinet-reshuffle-game\/","image-url":"http:\/\/usvsth3m.co.uk\/sidebar-images\/96ed8a8b15663990e3ebed8baf9352bb.jpg"},{"title":"Who Were You In Your Past Life?","description":"Which celeb died on your birthday and was reincarnated as you?","url":"http:\/\/games.usvsth3m.com\/who-were-you-in-your-past-life\/","image-url":"http:\/\/imgur.com\/uB2zvZm.jpg"},{"title":"GAME: Spot the Tory!","description":"Can you guess the party an MP belongs to just by looking at their face?","url":"http:\/\/games.usvsth3m.com\/spot-the-tory\/","image-url":"http:\/\/imgur.com\/mSKZfwt.jpg"},{"title":"Is this quip Morrissey or UKIP?","description":"It's not always easy to tell...","url":"http:\/\/games.usvsth3m.com\/quiz\/morrissey-or-ukip","image-url":"http:\/\/imgur.com\/INg1iES.jpg"},{"title":"Pi: is the next digit higher or lower?","description":"How far can you get?","url":"http:\/\/games.usvsth3m.com\/pi-game\/","image-url":"http:\/\/i.imgur.com\/yRnuwMq.jpg"},{"title":"Robin Williams Soundboard","description":"\"Good morning Vietnam!!!\"","url":"http:\/\/games.usvsth3m.com\/soundboard\/robin-williams\/","image-url":"http:\/\/i.imgur.com\/HQLMtfE.jpg"},{"title":"Who\u2019s Your Celebrity A-Level Twin?","description":"Enter your grades to find your famous examalike","url":"http:\/\/games.usvsth3m.com\/celebrity-a-level-twin\/","image-url":"http:\/\/i.imgur.com\/y4MIWeV.jpg"},{"title":"Around the World in 80 Million Clicks","description":"Click to help power our skyboat around the world!","url":"http:\/\/games.usvsth3m.com\/around-the-world\/","image-url":"http:\/\/i.imgur.com\/JmyYiiW.png"},{"title":"How Clean Is Your Screen?","description":"Can you tell our real dirt from your fake dirt?","url":"http:\/\/games.usvsth3m.com\/how-clean-is-your-screen\/","image-url":"http:\/\/i.imgur.com\/A74OEgB.jpg?1"},{"title":"Whac-A-Gif","description":"Whack anything you like! From Daleks to George Osborne!","url":"http:\/\/games.usvsth3m.com\/whac-a-gif\/","image-url":"http:\/\/i.imgur.com\/kTt9Tw5.jpg?1"},{"title":"How Old Is Your Hearing?","description":"Find out the true age of your lugholes!","url":"http:\/\/games.usvsth3m.com\/how-old-is-your-hearing\/","image-url":"http:\/\/i.imgur.com\/RNT5Xne.jpg?1"},{"title":"Make your own games and quizzes!","description":"Customize our games to make your own special version!","url":"http:\/\/community.usvsth3m.com\/","image-url":"http:\/\/i.imgur.com\/UI32IPG.png"},{"title":"Apple Watch Simulator","description":"Open as many apps as you can before the battery runs out","url":"http:\/\/games.usvsth3m.com\/apple-watch\/","image-url":"http:\/\/i.imgur.com\/ChOCnRx.png"},{"title":"iQueue","description":"Quick, line up for the new Apple product!","url":"http:\/\/games.usvsth3m.com\/iqueue\/","image-url":"http:\/\/i.imgur.com\/FKOiG4m.png"},{"title":"Kick The Tories Out Of Scotland","description":"Can you give Cameron the boot, literally?","url":"http:\/\/games.usvsth3m.com\/kick-the-tories-out-of-scotland\/","image-url":"http:\/\/i.imgur.com\/mrsj1s8.jpg"},{"title":"Connect One","description":"A Game For Complete Winners! ","url":"http:\/\/games.usvsth3m.com\/easy-games\/connect-one\/","image-url":"http:\/\/i.imgur.com\/PG8fmZ1.png"},{"title":"How Porny Is Your Name?","description":"We'll find out how NSFW you are!","url":"http:\/\/games.usvsth3m.com\/how-porny-is-your-name\/","image-url":"http:\/\/i.imgur.com\/Ooz8Cjr.jpg"},{"title":"The Twitter Perspective Vortex","description":"Find out how important you really are on social media!","url":"http:\/\/games.usvsth3m.com\/twitter-perspective-vortex\/","image-url":"http:\/\/i.imgur.com\/LTqD1wa.jpg"},{"title":"Dance Dance Revolution: 1812 Overture Edition","description":"Bang! Crash! Explode! Fun times ahead! ","url":"http:\/\/games.usvsth3m.com\/dance-dance-revolution-1812-overture-edition\/","image-url":"http:\/\/usvsth3m.co.uk\/sidebar-images\/e24f9cbbda201dc61d8a33b3d4200ebc.jpg"},{"title":"90s Nokia Nostalgia Game ","description":"Microsoft have killed Nokia so play it now","url":"http:\/\/games.usvsth3m.com\/90s-nokia-nostalgia-game\/","image-url":"http:\/\/usvsth3m.co.uk\/sidebar-images\/3c3e4d3ad2fa2e762573b2afc3bf8651.jpg"}]
);
var toinsert = tiheader + "" + wrapperlinks[0]['title'] + "" + "" + wrapperlinks[1]['title'] + "" + "" + wrapperlinks[2]['title'] + "" + tifooter;
var contents = [toinsert, toinsert,
'Be the first to know when we make new stuff. Follow
@UsVsTh3m on Twitter:
\
\
',
'Be the first to know when we make new stuff. Like
Us Vs Th3m on Facebook:
\
\
',
'Be the first to know when we make new stuff. Join our mailing list:
\
\
'
];
function contentLoaded(win, fn) {
var done = false, top = true,
doc = win.document, root = doc.documentElement,
add = doc.addEventListener ? 'addEventListener' : 'attachEvent',
rem = doc.addEventListener ? 'removeEventListener' : 'detachEvent',
pre = doc.addEventListener ? '' : 'on',
init = function(e) {
if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
(e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
if (!done && (done = true)) fn.call(win, e.type || e);
},
poll = function() {
try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; }
init('poll');
};
if (doc.readyState == 'complete') fn.call(win, 'lazy');
else {
if (doc.createEventObject && root.doScroll) {
try { top = !win.frameElement; } catch(e) { }
if (top) poll();
}
doc[add](pre + 'DOMContentLoaded', init, false);
doc[add](pre + 'readystatechange', init, false);
win[add](pre + 'load', init, false);
}
}
function uvt_wrap() {
if(top != self) top.location.replace(location);
var body = document.body;
var uvt_over = document.createElement('div');
uvt_over.id = 'uvt_over';
var uvt_box = document.createElement('div');
uvt_box.id = 'uvt_box';
var node;
while (node = body.firstChild) {
uvt_box.appendChild(node);
}
uvt_over.appendChild(uvt_box);
body.appendChild(uvt_over);
var uvt_credits = document.createElement('div');
uvt_credits.id = 'uvt_credits';
// Sometimes, we might want to override which panel is shown, based on JS on the parent page
if (typeof whichpanel === 'function') {
//console.log("Panel preselected.");
var boselecta = whichpanel();
} else {
//console.log("Choosing random panel.");
var boselecta = Math.floor(Math.random() * contents.length);
}
uvt_credits.innerHTML = fixed + contents[boselecta];
// body.appendChild(uvt_credits); // this knocks out the uvt top black line
if(document.getElementById('uvt_apply_twitter') != null) {
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
}
}
if(document.URL.indexOf("http://assets.txmblr.com/") >= 0){
// Don't wrap on Tumblr preview.
} else {
contentLoaded(window,uvt_wrap);
}
})();