Skip to content

Instantly share code, notes, and snippets.

@felixlaumon
Forked from anonymous/untitled
Last active August 29, 2015 13:57
Show Gist options
  • Save felixlaumon/9620384 to your computer and use it in GitHub Desktop.
Save felixlaumon/9620384 to your computer and use it in GitHub Desktop.
(function () {
try {
var orcWidth = parseInt(window.location.search.match(/width=(\d+)/)[1], 10);
var orcHeight = parseInt(window.location.search.match(/height=(\d+)/)[1], 10);
var hasFailed = window.location.search.match(/oswidthheight=(\w+)/);
if (hasFailed && hasFailed.length) {
console.log('ignore width height verification because it has failed once before');
return;
}
if (orcWidth !== window.innerWidth || orcHeight !== window.innerHeight) {
// If browse and Orc dimension do not match up, reload but without the
// width, height and size query string and hash
var search = window.location.search
.replace(/width=\d+&?/, '')
.replace(/height=\d+&?/, '')
.replace(/size=\w+&?/, '');
search += '&oswidthheight=failed';
var newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + search;
window.location.href = newUrl;
}
} catch (e) {
console.error('Failed to verify dimension from Orc', e);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment