frames[i].document.documentElement.scrollTop; hasParentFrame = true; break; } } } } } else { scrollX = 0; scrollY = 0; } return [parseInt(scrollX,10), parseInt(scrollY,10), hasParentFrame];};searchshield.viewPortSize = function (){ // returns an array [width, height, scrollYWidth], where scrollYWidth is always 0 for IE var scrollXWidth = 19; var scrollYWidth = 0; // 0 for Microsoft IE var scrollBarX = false; var windowX; var windowY; // firefox if (window.innerWidth && window.innerHeight) { //TODO: validate this block if implemented for firefox windowX = window.innerWidth - scrollXWidth; windowY = window.innerHeight; try { scrollYWidth = Math.floor(Math.abs(window.innerHeight - document.documentElement.clientHeight)) + 1; scrollBarX = (document.documentElement.clientWidth < document.documentElement.scrollWidth); } catch(err){} if (scrollBarX && !scrollYWidth) scrollYWidth = 18; //normally 17 (+1 top border) } else if (document.documentElement || document.body) { windowX = (document.documentElement.clientWidth || document.body.clientWidth) - scrollXWidth; windowY = document.documentElement.clientHeight || document.body.clientHeight; } else { windowX = 0; windowY = 0; } return [windowX, windowY, scrollYWidth];};searchshield.zoomLevel = function (){ var level = 1; if (document.body.getBoundingClientRect) { // rect is only in physical pixel size before IE8 var rect = document.body.getBoundingClientRect(); level = Math.round (((rect.right - rect.left) / (document.body.offsetWidth)) * 100) / 100; } return level;};// Href functionssearchshield.checkUrl = function (url){ // cleanup a url, make sure there is a protocol on the front for scanning try { // trim url = url.replace(/^\s+/, "").replace(/\s+$/, ""); // if no protocol, add http:// to it if (url.indexOf("://") == -1) url = "http://" + url; } catch(err){} return url;};searchshield.DoesURLContain = function (url, contain){ if ((url == null) || (url.length < 1)) return false; // breakup the url to check var parts = url.split('/'); if (parts.length < 3) return false; var domain= parts[2].toLowerCase(); if (domain.indexOf(contain) > -1) return true; return false;};searchshield.FilterUrl = function (url, filter){ if (!url || (url.length < 1)) return false; if (!filter || !(filter instanceof Array)) return false; var parts = url.split('/'); if ((parts == null) || (parts.length < 3)) return false; var domain = parts[2]; for (var i = 0; i < filter.length; i++) { if (domain.indexOf(filter[i]) != -1) return true; } return false;};searchshield.GetDomain = function (url){ if (url != null) { // get url domain var parts = url.split('/'); if ((parts != null) && (parts.length >= 3)) { return parts[2].toLowerCase(); } } return url;};searchshield.getUrlContents = function (url) { if (url == null) return null; // don't query if local url if (url.indexOf("linkscanner://") != -1) return null; try { req = new XMLHttpRequest(); req.open("GET", url, false); req.send(null); if (req.status == 200) return req.responseText; else return null; } catch (err) { // nothing to do return null; }};searchshield.parseLink = function (href, simpleMode){ var uri = {}; var parameter = { complex: { pattern: /^(?:([a-z]+):(?:([a-z]*):)?\/\/)?(?:([^:@]*)(?::([^:@]*))?@)?((?:[a-z0-9_-]+\.)+[a-z]{2,})(?::(\d+))?(?:([^:\?\#]+))?(?:\?([^\#]+))?(?:\#([^\s]+))?$/i, element: ['source','scheme','subscheme','user','pass','host','port','path','query','fragment'] }, simple: { pattern: /^(?:([a-z]+):\/\/)?((?:[a-z0-9_-]+\.)+[a-z]{2,})(?:\/)([^:\?]+)?(?:([\?|\#])([^\?]+))?$/i, element: ['source','scheme','host','path','delimiter','query'] } }; var mode = simpleMode !== false ? 'simple' : 'complex'; var pattern = parameter[mode].pattern; var element = parameter[mode].element; if (!href) return uri; var matches = href.match(pattern); if (matches) { // -------------------- // iterate over the matches array and populate uri properties // using the respective element parameter as the name. // NOTE: set raw property type as String to make inArray() // work properly with instanceof. // -------------------- for (var