Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinsworldcom/aef32c1b6b13ae36208845d86cd5921f to your computer and use it in GitHub Desktop.
Save vinsworldcom/aef32c1b6b13ae36208845d86cd5921f to your computer and use it in GitHub Desktop.
Tumblr New JavaScript
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
}
function autoResize(id){
var scaling = 100;
var scalingFactor = 5;
var width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var height = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
if (width > scaling*scalingFactor) {
width -= scaling;
}
if (height > scaling*scalingFactor) {
height -= scaling;
}
var orig =document.getElementById(id);
orig.height = height;
orig.width = width;
var world = getQueryVariable("world");
if (world != null) {
var unescapedurl = unescape(world);
var fullurl = 'https://drive.google.com/uc?export=view&id=' + unescapedurl;
var clone=orig.cloneNode(true);
clone.setAttribute('src',fullurl);
orig.parentNode.replaceChild(clone,orig);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment