Common.js

/* כל הסקריפטים שנכתבים כאן ייטענו עבור כל המשתמשים בכל טעינת עמוד. */

$(".thumbimage").attr({ webkitallowfullscreen:"", allowfullscreen:"" });
 
	! function () {
	    /** get all the <img> width class thumbimage  **/
	    var imgs = document.querySelectorAll(".thumbimage[src*='pdf']");
	    var s = imgs.length,
	        viewer = "/w/upload/ViewerJS/#../sheatufim", // replace in word thumb in url
	        http = ""; // http or ViewerJS
	    var pdf = /([\\\/\:\"\'\?\<\>\|\.])/g; //Regular expression that seeks to precede the special characters "\"
	    var refactor = /^.*\/thumb/, // Regular expression for everything before the word thumb in the url
	        aux = "",
	        src = "",
	        alt = "",
	        refa = "";
	    for (var i = 0; i < s; i++) {
	        alt = encodeURI( imgs[i].getAttribute("alt") ); //Get attribute alt
 
	        aux = new RegExp("pdf" + ".*");
	        src = imgs[i].src; //Get Src the img
	        src = src.replace(aux, "pdf"); // Deletes everything after the word in the alt attribute
 
 
	        src = src.replace(refactor, http + viewer); // Applies the regular expression refactor and concatenates http and viewer
 
	        imgs[i].src = src;
	        refa = imgs[i].outerHTML.replace(/(<|(?:<\/))img/g, "$1iframe"); //change img for iframe
	        imgs[i].outerHTML = refa; // 
	    //    iframe.setAttribute('allowFullScreen', 'webkitallowfullscreen');
	    }
	}();