1(function() { 2 window.ShareThisEvent = {}; 3 4 ShareThisEvent.listen = function (event_name, callback) { 5 if(document.addEventListener) { 6 document.addEventListener(event_name, callback, false); 7 } else { 8 document.documentElement.attachEvent('onpropertychange', function (e) { 9 if(e.propertyName == event_name) { 10 callback(); 11 } 12 }); 13 } 14 }; 15 16 ShareThisEvent.trigger = function (event_name) { 17 if(document.createEvent) { 18 var event = document.createEvent('Event'); 19 event.initEvent(event_name, true, true); 20 document.dispatchEvent(event); 21 } else { 22 document.documentElement[event_name]++; 23 } 24 }; 25 26})(); 27(function(tag){ 28 var e=document.createElement(tag); 29 var id = 'async-buttons'; 30 if (document.getElementById(id)) {return;}; 31 e.type="text/javascript";e.id=id; 32 e.src="https://ws.sharethis.com/button/async-buttons.js"; 33 var s = document.getElementsByTagName("script")[0]; 34 s.parentNode.insertBefore(e, s);})('script'); 35 36 37var stlib = stlib || { 38 functions: [], 39 functionCount: 0, 40 util: { 41 prop: function(p, obj) { 42 if (obj) { 43 return obj[p]; 44 } 45 return function(o) { return o[p]; }; 46 } 47 }, 48 dynamicOn: true, 49 setPublisher : function(pubKey){ 50 stlib.publisher = pubKey; 51 }, 52 setProduct : function(prod){ 53 stlib.product = prod; 54 }, 55 parseQuery: function( query ) { 56 var Params = new Object (); 57 if ( ! query ) return Params; // return empty object 58 var Pairs = query.split(/[;&]/); 59 for ( var i = 0; i < Pairs.length; i++ ) { 60 var KeyVal = Pairs[i].split('='); 61 if ( ! KeyVal || KeyVal.length != 2 ) continue; 62 var key = unescape( KeyVal[0] ); 63 var val = unescape( KeyVal[1] ); 64 val = val.replace(/\+/g, ' '); 65 Params[key] = val; 66 } 67 return Params; 68 }, 69 getQueryParams : function(){ 70 var buttonScript = document.getElementById('st_insights_js'); 71 if(buttonScript && buttonScript.src){ 72 var queryString = buttonScript.src.replace(/^[^\?]+\??/,''); 73 var params = stlib.parseQuery( queryString ); 74 stlib.setPublisher ( params.publisher); 75 stlib.setProduct( params.product); 76 } 77 } 78}; 79 80stlib.global = { 81 hash: stlib.util.prop('hash', document.location).substr(1) 82}; 83 84// Extract out parameters 85stlib.getQueryParams(); 86stlib.debugOn = false; 87stlib.debug = { 88 count: 0, 89 messages: [], 90 debug: function(message, show) { 91 if (show && (typeof console) != "undefined") { 92 console.log(message); 93 } 94 stlib.debug.messages.push(message); 95 }, 96 show: function(errorOnly) { 97 for (message in stlib.debug.messages) { 98 if ((typeof console) != "undefined") { 99 if (errorOnly) { 100 /ERROR/.test(stlib.debug.messages[message]) ? console.log(stlib.debug.messages[message]) : null; 101 } else { 102 console.log(stlib.debug.messages[message]); 103 } 104 } 105 } 106 }, 107 showError: function() { 108 stlib.debug.show(true); 109 } 110}; 111 112var _$d = function(message) { stlib.debug.debug(message, stlib.debugOn); } 113var _$d0 = function() { _$d(" "); }; 114var _$d_ = function() { _$d("___________________________________________"); }; 115var _$d1 = function(m) { _$d(_$dt() + "| " + m); }; 116var _$d2 = function(m) { _$d(_$dt() + "| * " + m); }; 117var _$de = function(m) { _$d(_$dt() + "ERROR: " + m); }; 118 119var _$dt = function() { 120 var today=new Date(); 121 var h=today.getHours(); 122 var m=today.getMinutes(); 123 var s=today.getSeconds(); 124 return h+":"+m+":"+s+" > "; 125}; 126 127stlib.allServices = { 128 adfty: {title: 'Adfty'}, 129 allvoices: {title:'Allvoices'}, 130 amazon_wishlist: {title:'Amazon Wishlist'}, 131 arto: {title:'Arto'}, 132 att: {title:'AT&T'}, 133 baidu: {title: 'Baidu'}, 134 blinklist : {title : 'Blinklist'}, 135 blip: {title: 'Blip'}, 136 blogmarks : {title : 'Blogmarks'}, 137 blogger : {title : 'Blogger',type : 'post'}, 138 buddymarks: {title: 'BuddyMarks'}, 139 buffer: {title: 'Buffer'}, 140 care2 : {title : 'Care2'}, 141 chiq : {title:'chiq'}, 142 citeulike : {title : 'CiteULike'}, 143 chiq : {title : 'chiq'}, 144 corkboard: {title: 'Corkboard'}, 145 dealsplus : {title : 'Dealspl.us'}, 146 delicious : {title : 'Delicious'}, 147 digg : {title : 'Digg'}, 148 diigo : {title : 'Diigo'}, 149 dzone: {title: 'DZone'}, 150 edmodo : {title : 'Edmodo'}, 151 email : {title : 'Email'}, 152 embed_ly : {title : 'Embed.ly'}, 153 evernote: {title:'Evernote'}, 154 facebook : {title : 'Facebook'}, 155 fark : {title : 'Fark'}, 156 fashiolista: {title:'Fashiolista'}, 157 flipboard: {title:'Flipboard'}, 158 folkd:{title:'folkd.com'},
159 foodlve: {title:'FoodLve'}, 160 fresqui : {title : 'Fresqui'}, 161 friendfeed : {title : 'FriendFeed'}, 162 funp : {title : 'Funp'}, 163 fwisp: {title:'fwisp'}, 164 google: {title: 'Google'}, 165 googleplus: {title: 'Google +'}, 166 google_bmarks : {title : 'Bookmarks'}, 167 google_reader: {title: 'Google Reader'}, 168 google_translate: {title: 'Google Translate'}, 169 hatena: {title:'Hatena'}, 170 instapaper : {title : 'Instapaper'}, 171 jumptags: {title:'Jumptags'}, 172 kaboodle:{title:'Kaboodle'}, 173 kik: {title:'Kik'}, 174 linkagogo:{title:'linkaGoGo'}, 175 linkedin : {title : 'LinkedIn'}, 176 livejournal : {title : 'LiveJournal',type : 'post'}, 177 mail_ru : {title : 'mail.ru'}, 178 meneame : {title : 'Meneame'}, 179 messenger : {title : 'Messenger'}, 180 mister_wong : {title : 'Mr Wong'}, 181 moshare : {title : 'moShare'}, 182 myspace : {title : 'MySpace'}, 183 n4g : {title : 'N4G'}, 184 netlog: {title: 'Netlog'}, 185 netvouz:{title:'Netvouz'}, 186 newsvine : {title : 'Newsvine'}, 187 nujij:{title:'NUjij'}, 188 odnoklassniki : {title : 'Odnoklassniki'}, 189 oknotizie : {title : 'Oknotizie'}, 190 pinterest:{title:'Pinterest'}, 191 pocket:{title:'Pocket'}, 192 print:{title:'Print'}, 193 raise_your_voice : {title : 'Raise Your Voice'}, 194 reddit : {title : 'Reddit'}, 195 segnalo : {title : 'Segnalo'}, 196 sharethis : {title : 'ShareThis'}, 197 sina: {title:'Sina'}, 198 sonico : {title : 'Sonico'}, 199 startaid:{title:'Startaid'}, 200 startlap:{title:'Startlap'}, 201 stumbleupon : {title : 'StumbleUpon'}, 202 stumpedia:{title:'Stumpedia'}, 203 typepad : {title : 'TypePad',type : 'post'}, 204 tumblr : {title : 'Tumblr'}, 205 twitter : {title : 'Twitter'}, 206 viadeo:{title:'Viadeo'}, 207 virb:{title:'Virb'}, 208 vkontakte : {title : 'Vkontakte'}, 209 voxopolis:{title: 'VOXopolis'}, 210 whatsapp : {title: 'WhatsApp'}, 211 weheartit : {title: 'We Heart It'}, 212 wordpress : {title : 'WordPress',type : 'post'}, 213 xerpi:{title:"Xerpi"}, 214 xing: {title:'Xing'}, 215 yammer : {title : 'Yammer'} 216}; 217stlib.allOauthServices = { 218 twitter: {title:'Twitter'}, 219 linkedIn : {title : 'LinkedIn'}, 220 facebook : {title : 'Facebook'} 221}; 222stlib.allNativeServices = { 223 fblike:{title:"Facebook Like"}, 224 fbrec:{title:"Facebook Recommend"}, 225 fbsend:{title:"Facebook Send"}, 226 fbsub:{title:"Facebook Subscribe"}, 227 foursquaresave:{title:"Foursquare Save"}, 228 foursquarefollow:{title:"Foursquare Follow"}, 229 instagram:{title:"Instagram Badge"}, 230 plusone: {title:'Google +1'}, 231 pinterestfollow : {title : 'Pinterest Follow'}, 232 twitterfollow : {title : 'Twitter Follow'}, 233 youtube : {title : 'Youtube Subscribe'} 234}; 235stlib.allDeprecatedServices = { 236 google_bmarks:{title:'Google Bookmarks'}, 237 yahoo_bmarks:{title:'Yahoo Bookmarks'} 238}; 239stlib.allOtherServices = { 240 copy:{title:'Copy Paste'}, 241 sharenow:{title:'ShareNow'}, 242 sharenow_auto:{title:'Frictionless Sharing'}, 243 fbunlike:{title:'Facebook Unlike'} 244}; 245var _all_services = stlib.allServices;/********************START BUTTON INFO CODE***********************/ 246/* 247 * This holds critical data about all st buttons on a page. Requires debug() 248 */ 249stlib.buttonInfo = { 250 buttonList: [], 251 addButton: function(obj) { 252 stlib.buttonInfo.buttonList.push(obj); 253 }, 254 getButton: function(key) { 255 if (!isNaN(key)) { 256 if (key >= stlib.buttonInfo.buttonList.length) 257 return false; 258 else 259 return stlib.buttonInfo.buttonList[key]; 260 } else { 261 for (c=0; c<stlib.buttonInfo.buttonList.length; c++) { 262 if (stlib.buttonInfo.buttonList[c].service==key) 263 debug(stlib.buttonInfo.buttonList[c]); 264 } 265 } 266 }, 267 clickButton: function(key) { 268 if (!isNaN(key)) { 269 if (key >= stlib.buttonInfo.buttonList.length) 270 return false; 271 else { 272 if (stlib.buttonInfo.getButton(key).service=="sharethis" || stlib.buttonInfo.getButton(key).service=="email" || stlib.buttonInfo.getButton(key).service=="wordpress") 273 stlib.buttonInfo.getButton(key).popup(); 274 else 275 stlib.buttonInfo.getButton(key).element.childNodes[0].onclick(); 276 } 277 } else { 278 for (c=0; c<stlib.buttonInfo.buttonList.length; c++) { 279 if (stlib.buttonInfo.buttonList[c].service==key) { 280 if (stlib.buttonInfo.getButton(c).service=="sharethis" || stlib.buttonInfo.getButton(c).service=="email" || stlib.buttonInfo.getButton(c).service=="wordpress") { 281 stlib.buttonInfo.getButton(c).popup(); 282 return true; 283 } 284 else 285 stlib.buttonInfo.getButton(c).element.childNodes[0].onclick(); 286 } 287 } 288 } 289 }, 290 resetButton: function() { 291 stlib.buttonInfo.buttonList = []; 292 }, 293 listButton: function () { 294 for (c=0; c<stlib.buttonInfo.buttonList.length; c++) 295 debug(stlib.buttonInfo.buttonList[c]); 296 } 297}; 298 299stlib.buttonInfo.resetButton(); 300/********************END BUTTON INFO CODE***********************/ 301 302/********************START MESSAGE QUEUE***********************/ 303 304stlib.messageQueue = function () { 305 var that = this; 306 this.pumpInstance = null; 307 this.queue = []; 308 this.dependencies = ["data"];
308 // This holds a sorted array of dependency tags, [0] should be loaded before [1]. 309 this.sending = true; 310 this.setPumpInstance = function(pumpInstance){ 311 this.pumpInstance = pumpInstance; 312 }; 313 this.send = function(message, tag){ 314 // Send debug message 315 if ((typeof(message) == "string") && (typeof(tag) == "string")) { 316 _$d_(); 317 _$d1("Queueing message: " + tag + ": " + message); 318 } 319 // Queue the message 320 (typeof(message) == "string") && (typeof(tag) == "string") ? this.queue.push([tag, message]) : null; 321 322 if (this.sending == false || stlib.browser.ieFallback) { // Don't process the queue if it's currently processing 323 if (this.pumpInstance != null) { // If the pumpInstance is valid 324 if (this.dependencies.length > 0) { // If there are current dependencies 325 for (messageSet in this.queue) { // Look for the dependency and send it. If not found, don't send anything. 326 if (this.queue.hasOwnProperty(messageSet) && this.queue[messageSet][0] == this.dependencies[0]) { 327 if(this.queue.length > 0) { 328 _$d1("Current Queue Length: " + this.queue.length); 329 var m = this.queue.shift(); 330 this.pumpInstance.broadcastSendMessage(m[1]); 331 this.dependencies.shift(); 332 this.sending = true; 333 } 334 } 335 } 336 } else { // If there are no dependencies, just send the first message 337 if (this.queue.length > 0) { 338 _$d1("Current Queue Length: " + this.queue.length); 339 var m = this.queue.shift(); 340 this.pumpInstance.broadcastSendMessage(m[1]); 341 this.sending = true; 342 } 343 } 344 } else { 345 _$d_(); 346 _$d1("Pump is null"); 347 } 348 } 349 if ((stlib.browser.ieFallback) && (this.queue.length > 0)) { 350 var processName = "process" + stlib.functionCount; 351 stlib.functionCount++; 352 stlib.functions[processName] = that.process; 353 setTimeout("stlib.functions['" + processName + "']()", 500); 354 } 355 }; 356 this.process = function() { 357 _$d1("Processing MessageQueue"); 358 that.sending = false; 359 _$d(this.queue); 360 that.send(); 361 }; 362}; 363/********************END MESSAGE QUEUE***********************/ 364/* 365 * This handles direct post sharing 366 */ 367stlib.sharer = { 368 sharerUrl: "https://ws.sharethis.com/api/sharer.php", 369 regAuto : new RegExp(/(.*?)_auto$/), //regexp to detect auto events 370 constructParamString: function() { 371 // Validate the data 372 stlib.data.validate(); 373// if (!stlib.hash.doNotHash) { 374 // stlib.hash.checkURL(); 375// } 376 // Pull all the parameters from the page the widget was on 377 var p = stlib.data.pageInfo; 378 var paramString = "?"; 379 var param; 380 for (param in p) { 381 // the following line creates "param=value&" 382 paramString += param + "=" + encodeURIComponent(p[param]) + "&"; 383 _$d1("constructParamStringPageInfo: " + param + ": " + p[param]); 384 } 385 // Pull all the parameters related to the share 386 p = stlib.data.shareInfo; 387 for (param in p) { 388 389 paramString += param + "=" + encodeURIComponent(p[param]) + "&"; 390 _$d1("constructParamStringShareInfo: " + param + ": " + p[param]); 391 } 392 paramString += "ts=" + new Date().getTime() + "&"; 393 394 return paramString.substring(0, paramString.length-1); 395 }, 396 stPrint : function() { 397 window.print(); 398 }, 399 incrementShare : function() { 400 var currentRefer = document.referrer; 401 var referArray = currentRefer.replace("http://", "").replace("https://", "").split("/"); 402 var refD = referArray.shift(); 403 if ( refD == "www.mangatown.com" || refD == "imobiliariacasa.com.br") { 404 return; 405 } 406 var url = stlib.data.get("url", "shareInfo"); 407 var dest = stlib.data.get("destination", "shareInfo"); 408 var proto = "https://"; 409 var cs_ep = "count-server.sharethis.com/increment_shares?countType=share&output=false"; 410 // remove #sthash 411 url = url.split("#sthash")[0] 412 var params = "&service=" + encodeURIComponent(dest) + "&url=" + encodeURIComponent(url) 413 var put_count_url = proto + cs_ep + params 414 if (dest != "copy") { 415 stlib.scriptLoader.loadJavascript(put_count_url, function(){}); 416 } 417 }, 418 sharePinterest : function() { 419 // stlib.sharer.incrementShare(); 420 if (stlib.data.get("image", "shareInfo") == false || stlib.data.get("image", "shareInfo") == null || stlib.data.get("pinterest_native", "shareInfo") == "true"){ 421 if (typeof(stWidget)!="undefined" && typeof(stWidget.closeWidget) === "function") 422 stWidget.closeWidget(); 423 if (typeof(stcloseWidget) === "function") 424 stcloseWidget(); 425 if (typeof(stToolbar) !="undefined" && typeof(stToolbar.closeWidget) === "function") 426 stToolbar.closeWidget(); 427 var e = document.createElement('script'); 428 e.setAttribute('type', 'text/javascript'); 429 e.setAttribute('charset', 'UTF-8'); 430 e.setAttribute('src', '//assets.pinterest.com/js/pinmarklet.js?r='+Math.random() * 99999999); 431 document.body.appendChild(e); 432 } 433 }, 434 share: function(callback, popup) { 435 var paramString = stlib.sharer.constructParamString(); 436 _$d_(); 437 _$d1("Initiating a Share with the following url:"); 438 _$d2(stlib.sharer.sharerUrl + paramString); 439 // stlib.sharer.incrementShare(); 440 441 // Pass sharer.php differently if destination has "_auto" 442 // ("fblike_auto""fbunlike_auto""fbsend_auto""twitter_click_auto""twitter_tweet_auto""twitter_retweet_auto""twitter_favorite_auto""twitter_follow_auto") 443 if ((stlib.data.get("destination", "shareInfo") == "print") || (stlib.data.get("destination", "shareInfo") == "email") || (stlib.data.get("destination", "shareInfo") == "pinterest" && stlib.data.get("source", "shareInfo").match(/share4xmobile/) == null && stlib.data.get("source", "shareInfo").match(/share4xpage/) == null && stlib.data.get("source", "shareInfo").match(/5xpage/) == null && (stlib.data.get("image", "shareInfo") == false || stlib.data.get("image", "shareInfo") == null))|| stlib.data.get("destination", "shareInfo") == "snapsets" || stlib.data.get("destination", "shareInfo") == "copy" || stlib.data.get("destination", "shareInfo") == "plusone" || stlib.data.get("destination", "shareInfo").match(stlib.sharer.regAuto) || (typeof(stlib.nativeButtons) != "undefined" && stlib.nativeButtons.checkNativeButtonSupport(stlib.data.get("destination", "shareInfo")))||(stlib.data.get("pinterest_native", "shareInfo") != false && stlib.data.get("pinterest_native", "shareInfo") != null)){ 444 var mImage = new Image(1,1); 445 mImage.src = stlib.sharer.sharerUrl + paramString; 446 mImage.onload = function(){return;}; 447 } else { 448 if (typeof(popup)!="undefined"&&popup==true) // <-- force popup here 449 window.open(stlib.sharer.sharerUrl + paramString, (new Date()).valueOf(), "scrollbars=1, status=1, height=480, width=640, resizable=1"); 450 else 451 window.open(stlib.sharer.sharerUrl + paramString); 452 } 453 454 callback ? callback() : null; 455 } 456}; 457/********************START SCRIPTLOADER***********************/ 458/* 459 * This handles on demand loading of javascript and CSS files 460 */ 461stlib.scriptLoader = { 462 loadJavascript : function(href,callBack){ 463 var loader = stlib.scriptLoader; 464 loader.head=document.getElementsByTagName('head')[0]; 465 loader.scriptSrc=href; 466 loader.script=document.createElement('script'); 467 loader.script.setAttribute('type', 'text/javascript'); 468 loader.script.setAttribute('src', loader.scriptSrc); 469 loader.script.async = true; 470 471 if(window.attachEvent && document.all) { //IE: 472 loader.script.onreadystatechange=function(){ 473 if(this.readyState=='complete' || this.readyState=='loaded'){ 474 callBack(); 475 } 476 }; 477 } else { //other browsers: 478 loader.script.onload=callBack; 479 } 480 loader.s = document.getElementsByTagName('script')[0]; 481 loader.s.parentNode.insertBefore(loader.script, loader.s); 482 }, 483 loadCSS : function(href,callBack) { 484 _$d_(); 485 _$d1("Loading CSS: " + href); 486 var loader = stlib.scriptLoader; 487 var cssInterval; 488 loader.head=document.getElementsByTagName('head')[0]; 489 loader.cssSrc=href; 490 loader.css=document.createElement('link'); 491 loader.css.setAttribute('rel', 'stylesheet'); 492 loader.css.setAttribute('type', 'text/css'); 493 loader.css.setAttribute('href', href); 494 loader.css.setAttribute('id', href); 495 setTimeout(function(){ 496 callBack(); 497 if(!document.getElementById(href)){ 498 cssInterval=setInterval(function(){ 499 if(document.getElementById(href)){ 500 clearInterval(cssInterval); 501 callBack(); 502 } 503 }, 100); 504 } 505 },100); 506 loader.head.appendChild(loader.css); 507 } 508}; 509/********************END SCRIPTLOADER***********************/ 510/********************START BROWSER CODE***********************/ 511stlib.browser = { 512 iemode: null, 513 firefox: null, 514 firefoxVersion: null, 515 safari: null, 516 chrome: null, 517 opera: null, 518 windows: null, 519 mac: null, 520 ieFallback: (/MSIE [6789]/).test(navigator.userAgent), 521 //ieFallback: true, 522 523 init: function() { 524 var ua = navigator.userAgent.toString().toLowerCase(); 525 526 if (/msie|trident/i.test(ua)) { 527 if (document.documentMode) // IE8 or later 528 stlib.browser.iemode = document.documentMode; 529 else{ // IE 5-7 530 stlib.browser.iemode = 5; // Assume quirks mode unless proven otherwise 531 if (document.compatMode){ 532 if (document.compatMode == "CSS1Compat") 533 stlib.browser.iemode = 7; // standards mode 534 } 535 } 536 //stlib.browser.iemode = getFirstMatch(/(?:msie |rv:)(\d+(\.\d+)?)/i); //IE11+ 537 } 538 /*stlib.browser.firefox =(navigator.userAgent.indexOf("Firefox") !=-1) ? true : false;
539 stlib.browser.firefoxVersion =(navigator.userAgent.indexOf("Firefox/5.0") !=-1 || navigator.userAgent.indexOf("Firefox/9.0") !=-1) ? false : true; 540 stlib.browser.safari =(navigator.userAgent.indexOf("Safari") !=-1 && navigator.userAgent.indexOf("Chrome") ==-1) ? true : false; 541 stlib.browser.chrome =(navigator.userAgent.indexOf("Safari") !=-1 && navigator.userAgent.indexOf("Chrome") !=-1) ? true : false; 542 stlib.browser.windows =(navigator.userAgent.indexOf("Windows") !=-1) ? true : false; 543 stlib.browser.mac =(navigator.userAgent.indexOf("Macintosh") !=-1) ? true : false;*/ 544 545 stlib.browser.firefox = ((ua.indexOf("firefox") !=-1) && (typeof InstallTrigger !== 'undefined'))?true:false; 546 stlib.browser.firefoxVersion =(ua.indexOf("firefox/5.0") !=-1 || ua.indexOf("firefox/9.0") !=-1) ? false : true; 547 stlib.browser.safari = (ua.indexOf("safari") !=-1 && ua.indexOf("chrome") ==-1)?true:false; 548 stlib.browser.chrome = (ua.indexOf("safari") !=-1 && ua.indexOf("chrome") !=-1)?true:false; 549 stlib.browser.opera = (window.opera || ua.indexOf(' opr/') >= 0)?true:false; 550 stlib.browser.windows =(ua.indexOf("windows") !=-1) ? true : false; 551 stlib.browser.mac =(ua.indexOf("macintosh") !=-1) ? true : false; 552 }, 553 554 getIEVersion : function() { 555 return stlib.browser.iemode; 556 }, 557 isFirefox : function() { 558 return stlib.browser.firefox; 559 }, 560 firefox8Version : function() { 561 return stlib.browser.firefoxVersion; 562 }, 563 isSafari : function() { 564 return stlib.browser.safari; 565 }, 566 isWindows : function() { 567 return stlib.browser.windows; 568 }, 569 isChrome : function() { 570 return stlib.browser.chrome; 571 }, 572 isOpera : function() { 573 return stlib.browser.opera; 574 }, 575 isMac : function() { 576 return stlib.browser.mac; 577 }, 578 isSafariBrowser: function(vendor, ua) { 579 // check if browser is safari 580 var isSafari = vendor && 581 vendor.indexOf('Apple Computer, Inc.') > -1 && 582 ua && !ua.match('CriOS'); 583 // check if browser is not chrome 584 var notChrome = /^((?!chrome|android).)*safari/i.test(ua); 585 // check if browser is not firefox 586 var notFireFox = /^((?!firefox|linux))/i.test(ua); 587 // check if OS is from Apple 588 var isApple = (ua.indexOf('Mac OS X') > -1) || 589 (/iPad|iPhone|iPod/.test(ua) && !window.MSStream); 590 // check if OS is windows 591 var isWindows = (ua.indexOf('Windows NT') > -1) && notChrome; 592 // browser is safari but not chrome 593 return (isSafari && notChrome && notFireFox && (isApple || isWindows)); 594 } 595}; 596 597stlib.browser.init(); 598/********************END BROWSER CODE***********************/ 599/********************START MOBILE BROWSER CODE***********************/ 600 601stlib.browser.mobile = { 602 mobile:false, 603 uagent: null, 604 android: null, 605 iOs: null, 606 silk: null, 607 windows: null, 608 kindle: null, 609 url: null, 610 sharCreated: false, 611 sharUrl: null, 612 isExcerptImplementation: false, //Flag to check if multiple sharethis buttons (Excerpt) have been implemented 613 iOsVer: 0, // It will hold iOS version if device is iOS else 0 614 615 init: function () { 616 this.uagent = navigator.userAgent.toLowerCase(); 617 if (this.isAndroid()) { 618 this.mobile = true; 619 }else if (this.isIOs()) { 620 this.mobile = true; 621 } else if (this.isSilk()) { 622 this.mobile = true; 623 } else if (this.isWindowsPhone()) { 624 this.mobile = true; 625 }else if (this.isKindle()) { 626 this.mobile = true; 627 } 628 629 630 }, 631 632 isMobile: function isMobile() { 633 return this.mobile; 634 }, 635 636 isAndroid: function() { 637 if (this.android === null) { 638 this.android = this.uagent.indexOf("android") > -1; 639 } 640 return this.android; 641 }, 642 643 isKindle: function() { 644 if (this.kindle === null) { 645 this.kindle = this.uagent.indexOf("kindle") > -1; 646 } 647 return this.kindle; 648 }, 649 650 isIOs: function isIOs() { 651 if (this.iOs === null) { 652 this.iOs = (this.uagent.indexOf("ipad") > -1) || 653 (this.uagent.indexOf("ipod") > -1) || 654 (this.uagent.indexOf("iphone") > -1); 655 } 656 return this.iOs; 657 658 }, 659 660 isSilk: function() { 661 if (this.silk === null) { 662 this.silk = this.uagent.indexOf("silk") > -1; 663 } 664 return this.silk; 665 }, 666 667 /** 668 * This is to get iOS version if iOS device, else return 0 669 */ 670 getIOSVersion: function() { 671 if (this.isIOs()) { 672 this.iOsVer = this.uagent.substr( (this.uagent.indexOf( 'os ' )) + 3, 5 ).replace( /\_/g, '.' ); 673 } 674 return this.iOsVer; 675 }, 676 677 isWindowsPhone: function() { 678 if (this.windows === null) { 679 this.windows = this.uagent.indexOf("windows phone") > -1; 680 } 681 return this.windows; 682 } 683 684}; 685 686stlib.browser.mobile.init(); 687 688/********************END MOBILE BROWSER CODE***********************/ 689 690/********************START MOBILE BROWSER FRIENDLY CODE***********************/ 691stlib = stlib || {}; 692stlib.browser = stlib.browser || {}; 693stlib.browser.mobile = stlib.browser.mobile || {}; 694 695stlib.browser.mobile.handleForMobileFriendly = function(o, options, widgetOpts) { 696 if (!this.isMobile()) { 697 return false;
698 } 699 if (typeof(stLight) === 'undefined') { 700 stLight = {} 701 stLight.publisher = options.publisher; 702 stLight.sessionID = options.sessionID; 703 stLight.fpc = ""; 704 } 705 var title = (typeof(o.title) !== 'undefined') ? o.title: encodeURIComponent(document.title); 706 var url = (typeof(o.url) !== 'undefined') ? o.url: document.URL; 707 //SA-77: introduce new st_short_url parameter 708 var shortUrl = (options.short_url != "" && options.short_url != null) ? options.short_url : ''; 709 710 if (options.service=="sharethis") { 711 var title = (typeof(o.title) !== 'undefined') ? o.title: encodeURIComponent(document.title); 712 var url = (typeof(o.url) !== 'undefined') ? o.url: document.URL; 713 714 715 716 var summary = ''; 717 if(typeof(o.summary)!='undefined' && o.summary!=null){ 718 summary=o.summary; 719 } 720 var form = document.createElement("form"); 721 form.setAttribute("method", "GET"); 722 form.setAttribute("action", "http://edge.sharethis.com/share4x/mobile.html"); 723 form.setAttribute("target", "_blank"); 724 //destination={destination}&url={url}&title={title}&publisher={publisher}&fpc={fpc}&sessionID={sessionID}&source=buttons 725 726 var params={url:url,title:title,summary:summary,destination:options.service,publisher:stLight.publisher,fpc:stLight.fpc,sessionID:stLight.sessionID,short_url:shortUrl}; 727 if(typeof(o.image)!='undefined' && o.image!=null){ 728 params.image=o.image; 729 }if(typeof(o.summary)!='undefined' && o.summary!=null){ 730 params.desc=o.summary; 731 }if(typeof(widgetOpts)!='undefined' && typeof(widgetOpts.exclusive_services)!='undefined' && widgetOpts.exclusive_services!=null){ 732 params.exclusive_services=widgetOpts.exclusive_services; 733 }if(typeof(options.exclusive_services)!='undefined' && options.exclusive_services!=null){ 734 params.exclusive_services=options.exclusive_services; 735 }if(typeof(widgetOpts)!='undefined' && typeof(widgetOpts.services)!='undefined' && widgetOpts.services!=null){ 736 params.services=widgetOpts.services; 737 }if(typeof(options.services)!='undefined' && options.services!=null){ 738 params.services=options.services; 739 } 740 741 // Get any additional options 742 var containsOpts = options; 743 if (typeof(widgetOpts)!='undefined') { 744 containsOpts = widgetOpts; 745 } 746 if(typeof(containsOpts.doNotHash)!='undefined' && containsOpts.doNotHash!=null){ 747 params.doNotHash=containsOpts.doNotHash; 748 } 749 if(typeof(o.via)!='undefined' && o.via!=null){ 750 params.via=o.via; 751 } 752 753 params.service = options.service; 754 params.type = options.type; 755 if (stlib.data) { 756 var toStoreA = stlib.json.encode(stlib.data.pageInfo); 757 var toStoreB = stlib.json.encode(stlib.data.shareInfo); 758 759 if (stlib.browser.isFirefox() && !stlib.browser.firefox8Version()) { 760 toStoreA = encodeURIComponent(encodeURIComponent(toStoreA)); 761 toStoreB = encodeURIComponent(encodeURIComponent(toStoreB)); 762 } 763 else { 764 toStoreA = encodeURIComponent(toStoreA); 765 toStoreB = encodeURIComponent(toStoreB); 766 } 767 768 params.pageInfo = toStoreA; 769 params.shareInfo = toStoreB; 770 } 771 772 for(var key in params) { 773 var hiddenField = document.createElement("input"); 774 hiddenField.setAttribute("type", "hidden"); 775 hiddenField.setAttribute("name", key); 776 hiddenField.setAttribute("value", params[key]); 777 form.appendChild(hiddenField); 778 } 779 document.body.appendChild(form); 780 form.submit(); 781 return true; 782 } 783 if(options.service=='email') { 784 var sharInterval, i=0; 785 stlib.browser.mobile.url = url; 786 if(stlib.browser.mobile.sharUrl == null) { 787 stlib.browser.mobile.createSharOnPage(); 788 } 789 var body = (shortUrl != "") ? shortUrl + "%0A%0a" : "{sharURLValue}" + "%0A%0a"; 790 if( (typeof(o.summary) != 'undefined') && o.summary!=null){ 791 body += o.summary + "%0A%0a"; 792 } 793 body += "Sent using ShareThis"; 794 var mailto = "mailto:?"; 795 mailto += "subject=" + title; 796 mailto += "&body=" +body; 797 798 //WID-709: Shar implementation done 799 sharInterval = setInterval( function(){ 800 if(stlib.browser.mobile.sharUrl != null){ 801 clearInterval(sharInterval); 802 window.location.href=mailto.replace("{sharURLValue}", stlib.browser.mobile.sharUrl); 803 } 804 if(i > 500) { 805 clearInterval(sharInterval); 806 window.location.href=mailto.replace("{sharURLValue}", stlib.browser.mobile.sharUrl); 807 } 808 i++; 809 }, 100); 810 } 811 return true; 812}; 813 814stlib.browser.mobile.createSharOnPage = function(){ 815 if(stlib.browser.mobile.url!=="" && stlib.browser.mobile.url!==" " && stlib.browser.mobile.url!==null && !stlib.browser.mobile.sharCreated) 816 { 817 var data=["return=json","cb=stlib.browser.mobile.createSharOnPage_onSuccess","service=createSharURL","url="+encodeURIComponent(stlib.browser.mobile.url)]; 818 data=data.join('&'); 819 stlib.scriptLoader.loadJavascript("https://ws.sharethis.com/api/getApi.php?"+data, function(){}); 820 } 821}; 822 823stlib.browser.mobile.createSharOnPage_onSuccess = function(response){ 824 if(response.status=="SUCCESS") { 825 stlib.browser.mobile.sharCreated = true; 826 stlib.browser.mobile.sharUrl = response.data.sharURL; 827 } else { 828 stlib.browser.mobile.sharUrl = stlib.browser.mobile.url; 829 } 830}; 831 832/********************END MOBILE BROWSER FRIENDLY CODE***********************/ 833 834/********************START COOKIE LIBRARY***********************/ 835/* 836 * This handles cookies 837 */ 838var tpcCookiesEnableCheckingDone = false;
839var tpcCookiesEnabledStatus = true; 840 841stlib.cookie = { 842 setCookie : function(name, value, days) { 843 var safari =(navigator.userAgent.indexOf("Safari") !=-1 && navigator.userAgent.indexOf("Chrome") ==-1); 844 var ie =(navigator.userAgent.indexOf("MSIE") !=-1); 845 846 if (safari || ie) { 847 var expiration = (days) ? days*24*60*60 : 0; 848 849 var _div = document.createElement('div'); 850 _div.setAttribute("id", name); 851 _div.setAttribute("type", "hidden"); 852 document.body.appendChild(_div); 853 854 var 855 div = document.getElementById(name), 856 form = document.createElement('form'); 857 858 try { 859 var iframe = document.createElement('<iframe name="'+name+'" ></iframe>'); 860 //try is ie 861 } catch(err) { 862 //catch is ff and safari 863 iframe = document.createElement('iframe'); 864 } 865 866 iframe.name = name; 867 iframe.src = 'javascript:false'; 868 iframe.style.display="none"; 869 div.appendChild(iframe); 870 871 form.action = "https://sharethis.com/account/setCookie.php"; 872 form.method = 'POST'; 873 874 var hiddenField = document.createElement("input"); 875 hiddenField.setAttribute("type", "hidden"); 876 hiddenField.setAttribute("name", "name"); 877 hiddenField.setAttribute("value", name); 878 form.appendChild(hiddenField); 879 880 var hiddenField2 = document.createElement("input"); 881 hiddenField2.setAttribute("type", "hidden"); 882 hiddenField2.setAttribute("name", "value"); 883 hiddenField2.setAttribute("value", value); 884 form.appendChild(hiddenField2); 885 886 var hiddenField3 = document.createElement("input"); 887 hiddenField3.setAttribute("type", "hidden"); 888 hiddenField3.setAttribute("name", "time"); 889 hiddenField3.setAttribute("value", expiration); 890 form.appendChild(hiddenField3); 891 892 form.target = name; 893 div.appendChild(form); 894 895 form.submit(); 896 } 897 else { 898 if (days) { 899 var date = new Date(); 900 date.setTime(date.getTime()+(days*24*60*60*1000)); 901 var expires = "; expires="+date.toGMTString(); 902 } else { 903 var expires = ""; 904 } 905 var cookie_string = name + "=" + escape(value) + expires; 906 cookie_string += "; domain=" + escape (".sharethis.com")+";path=/"; 907 document.cookie = cookie_string; 908 } 909 }, 910 setTempCookie : function(name, value, days) { 911 if (days) { 912 var date = new Date(); 913 date.setTime(date.getTime()+(days*24*60*60*1000)); 914 var expires = "; expires="+date.toGMTString(); 915 } else { 916 var expires = ""; 917 } 918 var cookie_string = name + "=" + escape(value) + expires; 919 cookie_string += "; domain=" + escape (".sharethis.com")+";path=/"; 920 document.cookie = cookie_string; 921 }, 922 getCookie : function(cookie_name) { 923 var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); 924 if (results) { 925 return (unescape(results[2])); 926 } else { 927 return false; 928 } 929 }, 930 deleteCookie : function(name) { 931 932 // For all browsers 933 var path="/"; 934 var domain=".sharethis.com"; 935 document.cookie = name.replace(/^\s+|\s+$/g,"") + "=" +( ( path ) ? ";path=" + path : "") 936 + ( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT"; 937 938 939 // For Safari and IE 940 var safari =(navigator.userAgent.indexOf("Safari") !=-1 && navigator.userAgent.indexOf("Chrome") ==-1); 941 var ie =(navigator.userAgent.indexOf("MSIE") !=-1); 942 943 if (safari || ie) { 944 var _div = document.createElement('div'); 945 _div.setAttribute("id", name); 946 _div.setAttribute("type", "hidden"); 947 document.body.appendChild(_div); 948 949 var 950 div = document.getElementById(name), 951 form = document.createElement('form'); 952 953 try { 954 var iframe = document.createElement('<iframe name="'+name+'" ></iframe>'); 955 //try is ie 956 } catch(err) { 957 //catch is ff and safari 958 iframe = document.createElement('iframe'); 959 } 960 961 iframe.name = name; 962 iframe.src = 'javascript:false'; 963 iframe.style.display="none"; 964 div.appendChild(iframe); 965 966 form.action = "https://sharethis.com/account/deleteCookie.php"; 967 form.method = 'POST'; 968 969 var hiddenField = document.createElement("input"); 970 hiddenField.setAttribute("type", "hidden"); 971 hiddenField.setAttribute("name", "name"); 972 hiddenField.setAttribute("value", name); 973 form.appendChild(hiddenField); 974 975 form.target = name; 976 div.appendChild(form); 977 978 form.submit(); 979 } 980 }, 981 deleteAllSTCookie : function() { 982 var a=document.cookie; 983 a=a.split(';'); 984 for(var i=0;i<a.length;i++){ 985 var b=a[i]; 986 b=b.split('='); 987 988 // do not delete the st_optout cookie 989 if(!/st_optout/.test(b[0])){ 990 var name=b[0]; 991 var path="/"; 992 var domain=".edge.sharethis.com"; 993 document.cookie = name + "=;
993path=" + path + ";domain=" + domain +";expires=Thu, 01-Jan-1970 00:00:01 GMT"; 994 } 995 } 996 }, 997 setFpcCookie : function(name, value) { 998// var name="__unam"; 999 var current_date = new Date; 1000 var exp_y = current_date.getFullYear(); 1001 var exp_m = current_date.getMonth() + 9;// set cookie for 9 months into future 1002 var exp_d = current_date.getDate(); 1003 var cookie_string = name + "=" + escape(value); 1004 if (exp_y) { 1005 var expires = new Date (exp_y,exp_m,exp_d); 1006 cookie_string += "; expires=" + expires.toGMTString(); 1007 } 1008 var domain=stlib.cookie.getDomain(); 1009 cookie_string += "; domain=" + escape (domain)+";path=/"; 1010 document.cookie = cookie_string; 1011 }, 1012 getFpcCookie : function(cookie_name) { 1013 var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); 1014 if (results) 1015 return (unescape(results[2])); 1016 else 1017 return false; 1018 }, 1019 getDomain : function() { 1020 var str = document.domain.split(/\./); 1021 var domain=""; 1022 if(str.length>1){ 1023 domain="."+str[str.length-2]+"."+str[str.length-1]; 1024 } 1025 return domain; 1026 }, 1027 checkCookiesEnabled: function() { 1028 if(!tpcCookiesEnableCheckingDone) { 1029 stlib.cookie.setTempCookie("STPC", "yes", 1); 1030 if(stlib.cookie.getCookie("STPC") == "yes") { 1031 tpcCookiesEnabledStatus = true; 1032 }else { 1033 tpcCookiesEnabledStatus = false; 1034 } 1035 tpcCookiesEnableCheckingDone = true; 1036 return tpcCookiesEnabledStatus; 1037 }else{ 1038 return tpcCookiesEnabledStatus; 1039 } 1040 }, 1041 hasLocalStorage: function() { 1042 try { 1043 localStorage.setItem("stStorage", "yes"); 1044 localStorage.removeItem("stStorage"); 1045 return true; 1046 } catch(e) { 1047 return false; 1048 } 1049 } 1050}; 1051/********************END COOKIE LIBRARY***********************/ 1052/* 1053 * Requires cookie.js 1054 */ 1055stlib.fpc = { 1056 cookieName: "__unam", 1057 cookieValue: "", 1058 createFpc: function() { 1059 if(!document.domain || document.domain.search(/\.gov/) > 0){ 1060 return false; 1061 } 1062// var firstPersonCookie = stlib.cookie.getCookie(stlib.fpc.cookieName); 1063 var firstPersonCookie = stlib.cookie.getFpcCookie(stlib.fpc.cookieName); 1064 if(firstPersonCookie==false){ 1065 // Create a new cookie 1066 var bigRan = Math.round(Math.random() * 2147483647); 1067 bigRan = bigRan.toString(16); 1068 1069 var time = (new Date()).getTime(); 1070 time = time.toString(16); 1071 1072 var partialDomain = window.location.hostname.split(/\./)[1]; 1073 if(!partialDomain){ 1074 return false; 1075 } 1076 1077 var cookieValue = ""; 1078 cookieValue = stlib.fpc.determineHash(partialDomain) + "-" + time + "-" + bigRan + "-1"; 1079 1080 firstPersonCookie = cookieValue; 1081 }else{ 1082 // Increment the counter on the cookie by one 1083 var originalCookie = firstPersonCookie; 1084 var originalCookieArray = originalCookie.split(/\-/); 1085 if(originalCookieArray.length == 4){ 1086 var num = Number(originalCookieArray[3]); 1087 num++; 1088 firstPersonCookie = originalCookieArray[0] + "-" + originalCookieArray[1] + "-" + originalCookieArray[2] + "-" + num; 1089 } 1090 } 1091 1092// stlib.cookie.setCookie(stlib.fpc.cookieName, firstPersonCookie, 90); 1093 stlib.cookie.setFpcCookie(stlib.fpc.cookieName, firstPersonCookie); 1094 stlib.fpc.cookieValue = firstPersonCookie; 1095 return firstPersonCookie; 1096 }, 1097 1098 determineHash: function(partialDomain) { 1099 var hash = 0; 1100 var salt = 0; 1101 for (var i = partialDomain.length - 1; i >= 0; i--) { 1102 var charCode = parseInt(partialDomain.charCodeAt(i)); 1103 hash = ((hash << 8) & 268435455) + charCode + (charCode << 12); 1104 if ((salt = hash & 161119850) != 0){ 1105 hash = (hash ^ (salt >> 20)); 1106 } 1107 } 1108 return hash.toString(16); 1109 } 1110}; 1111stlib.validate = { 1112 regexes: { 1113 notEncoded: /(%[^0-7])|(%[0-7][^0-9a-f])|["{}\[\]\<\>\\\^`\|]/gi, 1114 tooEncoded: /%25([0-7][0-9a-f])/gi, 1115 publisher: /^(([a-z]{2}(-|\.))|)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, 1116 url: /^(http|https):\/\/([a-z0-9!'\(\)\*\.\-\+:]*(\.)[a-z0-9!'\(\)\*\.\-\+:]*)((\/[a-z0-9!'\(\)\*\.\-\+:]*)*)/i, 1117 fpc: /^[0-9a-f]{7}-[0-9a-f]{11}-[0-9a-f]{7,8}-[0-9]*$/i, 1118 sessionID: /^[0-9]*\.[0-9a-f]*$/i, 1119 title: /.*/, 1120 description: /.*/, 1121 buttonType: /^(chicklet|vcount|hcount|large|custom|button|)$/, // TODO: verify, also, is blank ok. 1122 comment: /.*/, 1123 destination: /.*/, // TODO: check against all service (construct a regexp?) 1124 source: /.*/, // TODO: Need to define this 1125 image: /(^(http|https):\/\/([a-z0-9!'\(\)\*\.\-\+:]*(\.)[a-z0-9!'\(\)\*\.\-\+:]*)((\/[a-z0-9!'\(\)\*\.\-\+:]*)*))|^$/i, 1126 sourceURL: /^(http|https):\/\/([a-z0-9!'\(\)\*\.\-\+:]*(\.)[a-z0-9!'\(\)\*\.\-\+:]*)((\/[a-z0-9!'\(\)\*\.\-\+:]*)*)/i, 1127 sharURL: /(^(http|https):\/\/([a-z0-9!'\(\)\*\.\-\+:]*(\.)[a-z0-9!'\(\)\*\.\-\+:]*)((\/[a-z0-9!'\(\)\*\.\-\+:]*)*))|^$/i 1128 } 1129}; 1130 1131stlib.html = { 1132 encode : function(value) { 1133 if(stlib.html.startsWith(value, 'http')) {//URL check 1134 return String(value) 1135 .replace(/"/g, '"') 1136 .replace(/'/g, ''') 1137 .replace(/</g, '<') 1138 .replace(/>/g, '>'); 1139 } else { 1140 return String(value) 1141 .replace(/&/g, '&') 1142 .replace(/"/g, '"') 1143 .replace(/'/g, ''') 1144 .replace(/</g, '<') 1145 .replace(/>/g, '>'); 1146 } 1147 }, 1148 1149 startsWith : function(value, str) { 1150 return (value.match("^"+str)==str); 1151 } 1152}; 1153/* 1154 * This holds critical data, requires the cookie object 1155 */ 1156if (typeof(stlib.data) == "undefined") { 1157 stlib.data = { 1158 bInit: false, 1159 publisherKeySet: false, 1160 pageInfo: { 1161 }, 1162 shareInfo: { 1163 }, 1164 resetPageData: function() { 1165 //stlib.data.pageInfo.publisher = "00-00-00"; // The publisher key as given by the publisher 1166 //stlib.data.pageInfo.fpc = "ERROR"; // The cookie set on the publisher's domain to track the user on that domain 1167 stlib.data.pageInfo.sessionID = "ERROR"; // The session on any given pageview with our widget on it 1168 //stlib.data.pageInfo.sourceURL = "ERROR"; // The source domain 1169 stlib.data.pageInfo.hostname = "ERROR"; // The source domain 1170 stlib.data.pageInfo.location = "ERROR"; // The source domain 1171 stlib.data.pageInfo.product = "widget"; 1172 stlib.data.pageInfo.stid = ""; 1173 }, 1174 resetShareData: function() { 1175 stlib.data.shareInfo = {}; 1176 stlib.data.shareInfo.url = "ERROR"; // The url the service is sharing before any modification 1177 stlib.data.shareInfo.sharURL = ""; // The shar url the service is sharing before any modification 1178 stlib.data.shareInfo.buttonType = "ERROR"; // The button type that were clicked (hcount or vcount) 1179 stlib.data.shareInfo.destination = "ERROR"; // The channel that is being shared to (facebook, twitter) 1180 stlib.data.shareInfo.source = "ERROR"; // The widget or code location that is generating the request 1181 //stlib.data.shareInfo.title = ""; // The title of the article as best as can be determined 1182 //stlib.data.shareInfo.image = ""; // The title of the article as best as can be determined 1183 //stlib.data.shareInfo.description = ""; // The description of the article as best as can be determined 1184 //stlib.data.shareInfo.comment = ""; // The description of the article as best as can be determined 1185 }, 1186 resetData: function() { 1187 stlib.data.resetPageData(); 1188 stlib.data.resetShareData(); 1189 }, 1190 validate: function () { 1191 var regexes = stlib.validate.regexes; 1192 1193 function validateHelp(key, value) { 1194 if (value != encodeURIComponent(value)) { 1195 regexes.notEncoded.test(value) ? _$de(key + " not encoded") : null; 1196 regexes.tooEncoded.test(value) ? _$de(key + " has too much encoding") :null; 1197 } 1198 var valueOk = regexes[key] ? regexes[key].test(decodeURIComponent(value)) : true; 1199 if (!valueOk) { 1200 _$de(key + " failed validation"); 1201 } 1202 } 1203 1204 var p = stlib.data.pageInfo; 1205 var param; 1206 for (param in p) { 1207 validateHelp(param, p[param]) 1208 } 1209 p = stlib.data.shareInfo; 1210 for (param in p) { 1211 validateHelp(param, p[param]) 1212 } 1213 1214 }, 1215 init: function() { 1216 if (!stlib.data.bInit) { 1217 stlib.data.bInit = true; 1218 stlib.data.resetData(); 1219 stlib.data.set("fcmp", typeof(window.__cmp) == 'function', "pageInfo"); 1220 stlib.data.set("fcmpv2", typeof(window.__tcfapi) == 'function', "pageInfo"); 1221 1222 if(stlib.publisher){ 1223 stlib.data.setPublisher(stlib.publisher); 1224 } 1225 stlib.data.set("product",stlib.product,"pageInfo"); 1226 var rawUrl = document.location.href, refDomain = '', refQuery = '', referArray = [], currentRefer = '', cleanUrl = '', hashString = "", 1227 baseURL = '', sessionID_time = '', sessionID_rand = ''; 1228 1229 //Fix for WID-343 1230 referArray = stlib.data.getRefDataFromUrl(rawUrl);//get referrer data coming from share.es 1231 if(referArray.length > 0) { 1232 refDomain = (typeof(referArray[0]) != "undefined") ? referArray[0] : ""; 1233 refQuery = (typeof(referArray[1]) != "undefined") ? referArray[1] : ""; 1234 cleanUrl = stlib.data.removeRefDataFromUrl(rawUrl);//Remove referrer data from the URL. 1235 1236 //Displays the modified(without referrer data parameter) or original URL in the address bar 1237 stlib.data.showModifiedUrl(cleanUrl); 1238 stlib.data.set("url", cleanUrl, "shareInfo"); 1239 } else { //For old non-secure shar urls 1240 currentRefer = document.referrer; 1241 referArray = currentRefer.replace("http://", "").replace("https://", "").split("/"); 1242 refDomain = referArray.shift(); 1243 refQuery = referArray.join("/"); 1244 1245 stlib.data.set("url", rawUrl,"shareInfo"); 1246 } 1247 // TODO add option to not use hash tag 1248 1249 stlib.data.set("title", document.title, "shareInfo"); 1250 1251 if (stlib.data.publisherKeySet != true) { 1252 stlib.data.set("publisher","ur.00000000-0000-0000-0000-000000000000","pageInfo"); 1253 } 1254 1255 // no longer using fpc 1256 // stlib.fpc.createFpc(); 1257 // stlib.data.set("fpc",stlib.fpc.cookieValue,"pageInfo"); // Requires that the cookie has been created 1258 1259 sessionID_time = (new Date()).getTime().toString(); 1260 sessionID_rand = Number(Math.random().toPrecision(5).toString().substr(2)).toString(); 1261 stlib.data.set("sessionID",sessionID_time + '.' + sessionID_rand,"pageInfo"); 1262 1263 //stlib.data.set("sourceURL", document.location.href,"pageInfo"); 1264 stlib.data.set("hostname", document.location.hostname,"pageInfo"); 1265 stlib.data.set("location", document.location.pathname,"pageInfo"); 1266 1267 stlib.data.set("refDomain", refDomain ,"pageInfo"); 1268 stlib.data.set("refQuery", refQuery,"pageInfo"); 1269 } 1270 }, 1271 //Fix for WID-343 1272 showModifiedUrl: function(modUrl) { 1273 if (window.history && history.replaceState) 1274 history.replaceState(null, document.title, modUrl); 1275 else if ((/MSIE/).test(navigator.userAgent)) { 1276 var ampInHashIndex = 0, hashString = window.location.hash, patt1 = new RegExp("(\&st_refDomain=?)[^\&|]+"), 1277 patt2 = new RegExp("(\#st_refDomain=?)[^\&|]+"), hRef = document.location.href; 1278 if(patt1.test(hRef)) { 1279 ampInHashIndex = hashString.indexOf('&st_refDomain'); 1280 window.location.hash = hashString.substr(0, ampInHashIndex); 1281 } else if(patt2.test(hRef)) 1282 window.location.replace("#"); 1283 } else { 1284 document.location.replace(modUrl); 1285 } 1286 }, 1287 //Fix for WID-343 1288 getRefDataFromUrl: function(url) { 1289 var patt = new RegExp("st_refDomain="), tempDomain = '', tempQuery = '', result = []; 1290 1291 if(patt.test(url)) { 1292 tempDomain = url.match(/(st_refDomain=?)[^\&|]+/g); 1293 result.push(tempDomain[0].split('=')[1]); 1294 1295 tempQuery = url.match(/(st_refQuery=?)[^\&|]+/g); 1296 result.push(tempQuery[0].replace('st_refQuery=', '')); 1297 } 1298 1299 return result; 1300 }, 1301 //Fix for WID-343 1302 removeRefDataFromUrl: function(url) { 1303 var urlWoRefdomain = '', 1304 obj = '', 1305 patt1 = new RegExp("(\&st_refDomain=?)[^\&|]+"), 1306 patt2 = new RegExp("(\#st_refDomain=?)[^\&|]+"); 1307 1308 if(patt1.test(url)) { 1309 urlWoRefdomain = url.replace(/\&st_refDomain=(.*)/g,''); 1310 } else if(patt2.test(url)) { 1311 urlWoRefdomain = url.replace(/\#st_refDomain=(.*)/g,''); 1312 } else { 1313 urlWoRefdomain = url; 1314 } 1315 1316 return urlWoRefdomain; 1317 }, 1318 setPublisher: function(publisherKey) { 1319 // TODO: Add Validation 1320 stlib.data.set("publisher",publisherKey,"pageInfo"); 1321 stlib.data.publisherKeySet = true; 1322 }, 1323 setSource: function(src, options) { 1324 // TODO: Add Validation 1325 var source = ""; 1326 // Inside widget logging 1327 if (options) { 1328 if (options.toolbar) { 1329 source = "toolbar"+src; 1330 } else if (options.page && options.page != "home" && options.page != "") { 1331 source = "chicklet"+src; 1332 } else { 1333 source = "button"+src; 1334 } 1335 } 1336 // Outside widget logging 1337 else { 1338 // can be share5x, share4x, chicklet, fastshare, mobile 1339 source = src; 1340 } 1341 stlib.data.set("source",source,"shareInfo"); 1342 }, 1343 set: function(key, value, table) { 1344 if (typeof(value) == "number" || typeof(value) == "boolean") { 1345 stlib.data[table][key] = value; 1346 } else if (typeof(value) == "undefined" || value == null) { 1347 } else { 1348// _$d1("Stripping HTML: " + key + ": " + value.replace(/<[^<>]*>/gi, " ")); 1349// _$d1("decodeURI: " + key + ": " + decodeURI(value.replace(/<[^<>]*>/gi, " "))); 1350// _$d1("Escape percent: " + key + ": " + decodeURI(value.replace(/<[^<>]*>/gi, " ")).replace(/%/gi, "%25")); 1351// _$d1("Decoding: " + key + ": " + decodeURIComponent(decodeURI(value.replace(/<[^<>]*>/gi, " ")).replace(/%/gi, "%25"))); 1352// _$d1("Encoding: " + key + ": " + encodeURIComponent(decodeURIComponent(decodeURI(value.replace(/<[^<>]*>/gi, " ")).replace(/%/gi, "%25")))); 1353 stlib.data[table][key] = encodeURIComponent(decodeURIComponent(unescape(value.replace(/<[^<>]*>/gi, " ")).replace(/%/gi, "%25"))); 1354 // These might have url encoded data 1355 if (key=="url" /*|| key=="sourceURL"*/ || key=="location" || key=="image") { 1356 try { 1357 stlib.data[table][key] = encodeURIComponent(decodeURIComponent(decodeURI(value.replace(/<[^<>]*>/gi, " ")).replace(/%/gi, "%25"))); 1358 } catch (e) { 1359 stlib.data[table][key] = encodeURIComponent(decodeURIComponent(unescape(value.replace(/<[^<>]*>/gi, " ")).replace(/%/gi, "%25"))); 1360 } 1361 } 1362 } 1363 }, 1364 get: function(key, table) {
1365 try { 1366 if (stlib.data[table] && stlib.data[table][key]) 1367 return decodeURIComponent(stlib.data[table][key]); 1368 else 1369 return false; 1370 }catch(e){ 1371 return false 1372 } 1373 }, 1374 unset: function(key, table) { 1375 if (stlib.data[table] && typeof(stlib.data[table][key])!="undefined") 1376 delete stlib.data[table][key]; 1377 }, 1378 bindEvent: function(element, eventName, eventHandler) { 1379 if (element.addEventListener) { 1380 element.addEventListener(eventName, eventHandler, false); 1381 } else if (element.attachEvent) { 1382 element.attachEvent('on' + eventName, eventHandler); 1383 } 1384 }, 1385 debug: function(endpoint, event) { 1386 stlib.data.init(); 1387 var a = stlib.data.pageInfo; 1388 var c = ""; 1389 var b; 1390 for (b in a) { 1391 c += b + "=" + a[b] + "&" 1392 } 1393 c = c.substring(0, c.length - 1); 1394 1395 var loggerUrl = "https://l.sharethis.com/"; 1396 loggerUrl += endpoint; 1397 loggerUrl += "?event=" + event; 1398 loggerUrl += "&" + c; 1399 1400 var e = new Image(1, 1); 1401 e.src = loggerUrl; 1402 e.onload = function() { 1403 return 1404 }; 1405 }, 1406 hostname: function(url) { 1407 var a; 1408 if (url == null) { 1409 url = st.href; 1410 } 1411 a = document.createElement('a'); 1412 a.setAttribute('href', url); 1413 return a.hostname; 1414 }, 1415 protocol: function(url) { 1416 var a; 1417 if (url == null) { 1418 url = st.href; 1419 } 1420 a = document.createElement('a'); 1421 a.setAttribute('href', url); 1422 return a.protocol; 1423 }, 1424 parseCookie: function (name, cookie) { 1425 var values = cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)'); 1426 return values ? values.pop() : null; 1427 }, 1428 writeCookie: function(name, value, max_age) { 1429 if (!max_age) { 1430 max_age = 33696000 1431 } 1432 var host = (window && window.location && window.location.hostname) || ''; 1433 var parts = host.split('.'); 1434 var domain = ""; 1435 if (parts.length > 1) { 1436 domain = "domain=." + parts.slice(-2).join('.'); 1437 } 1438 var samesite_secure = ""; 1439 try { 1440 document.cookie = "st_samesite=1;SameSite=None;Secure"; 1441 if (stlib.data.parseCookie("st_samesite", document.cookie)) { 1442 samesite_secure = "SameSite=None;Secure" 1443 document.cookie = "st_samesite=1;max-age=0;SameSite=None;Secure"; 1444 } 1445 } catch (e) {} 1446 document.cookie = name + "=" + value + ";" + domain + ";path=/;max-age=" + max_age + ";" + samesite_secure; 1447 }, 1448 setConsent: function(consent) { 1449 for(var consent_key in consent) { 1450 stlib.data.set(consent_key,consent[consent_key],"pageInfo"); 1451 } 1452 }, 1453 getEUConsent: function (c) { 1454 1455 function once(fn, context) { 1456 var result; 1457 return function() { 1458 if(fn) { 1459 result = fn.apply(context || this, arguments); 1460 fn = null; 1461 } 1462 return result; 1463 }; 1464 } 1465 1466 var done = once(c); 1467 1468 // set usprivacy first if we have it 1469 var usprivacy = stlib.data.parseCookie("usprivacy", document.cookie); 1470 if (usprivacy) { 1471 stlib.data.setConsent({ 1472 usprivacy: usprivacy 1473 }); 1474 } 1475 1476 // keep track of how long it takes to get consent 1477 var start = Date.now(); 1478 1479 var useCookie = once(function() { 1480 1481 // check for first party cookies 1482 var euconsent_v2 = stlib.data.parseCookie("euconsent-v2", document.cookie); 1483 if (euconsent_v2 !== null) { 1484 stlib.data.setConsent({ 1485 gdpr_consent: euconsent_v2, 1486 gdpr_domain: document.location.hostname, 1487 gdpr_method: "cookie" 1488 }); 1489 } 1490 done(); 1491 }); 1492 1493 if (typeof window.__tcfapi == "function") { 1494 1495 // fallback to cookie in case the tcf api is too slow or unavailable 1496 var timeout = setTimeout(useCookie, 5000); 1497 1498 // first we try to get the data from the cmp 1499 // wrap in a try catch since we don't control the tcfapi code on page 1500 try { 1501 1502 const tcfapi_callback = (data) => { 1503 if (data && data.tcString) { 1504 var gdpr_domain = (data.isServiceSpecific) 1505 ? document.location.hostname : ".consensu.org"; 1506 stlib.data.setConsent({ 1507 consent_duration: Date.now() - start, 1508 gdpr_consent: data.tcString, 1509 gdpr_domain: gdpr_domain, 1510 gdpr_method: "api" 1511 }); 1512 clearTimeout(timeout); 1513 done(); 1514 __tcfapi('removeEventListener', 2, () => {}, data.listenerId); 1515 } 1516 } 1517 __tcfapi('addEventListener', 2, tcfapi_callback); 1518 1519 } catch (e) { 1520 1521 // fallback to cookie if there is an error 1522 useCookie(); 1523 } 1524 } else { 1525 1526 // fallback to cookie if the tcfapi doesn't exist 1527 useCookie(); 1528 } 1529 } 1530 }; 1531 1532 stlib.data.resetData(); 1533} 1534stlib.comscore = { 1535 load: function() { 1536 var ref=document.referrer; 1537 var lurl = "https://sb.scorecardresearch.com/"; 1538 lurl+="b?c1=7&c2=8097938&rn=" +Math.round(Math.random() * 2147483647 )+ "&c7=" + encodeURIComponent(document.location.href)+ "&c3=8097938"+ "&c8="+encodeURIComponent(document.title)+ ( (ref)? "&c9="+encodeURIComponent(document.referrer) : "" )+ "&cv=2.2"+ "&cs=js"; 1539 var logger = new Image(1,1); 1540 logger.src = lurl; 1541 logger.onload = function(){return;}; 1542 } 1543} 1544stlib.hash = { 1545 doNotHash: false, 1546 hashAddressBar: false,
1547 doNotCopy: false, 1548 prefix:"sthash", 1549 shareHash: "", 1550 incomingHash: "", 1551 validChars: ["1","2","3","4","5","6","7","8","9","0", 1552 "A","B","C","D","E","F","G","H","I","J", 1553 "K","L","M","N","O","P","Q","R","S","T", 1554 "U","V","W","X","Y","Z","a","b","c","d", 1555 "e","f","g","h","i","j","k","l","m","n", 1556 "o","p","q","r","s","t","u","v","w","x", 1557 "y","z"], 1558 servicePreferences: { 1559 linkedin: "param", 1560 stumbleupon: "param", 1561 bebo: "param" 1562 }, 1563 hashDestination: function(destination) { 1564 if (destination == "copy") {return "dpuf";} 1565 var condensedString = destination.substring(0,2) + destination.substring(destination.length-2, destination.length); 1566 var increment = function(string, pos) { 1567 if(string.charCodeAt(pos) == 122) { 1568 return "a"; 1569 } 1570 return String.fromCharCode(string.charCodeAt(pos) + 1); 1571 } 1572 return increment(condensedString, 0) + increment(condensedString, 1) + increment(condensedString, 2) + increment(condensedString, 3); 1573 }, 1574 getHash: function() { 1575 var sthashFound = false; 1576 var sthashValue = ""; 1577 var urlWithoutHash = document.location.href; 1578 urlWithoutHash = urlWithoutHash.split("#").shift(); 1579 var paramArray = urlWithoutHash.split("?"); 1580 if (paramArray.length > 1) { 1581 paramArray = paramArray[1].split("&"); 1582 for (arg in paramArray) { 1583 try { 1584 if (paramArray[arg].substring(0, 6) == "sthash") { 1585 sthashFound = true; 1586 sthashValue = paramArray[arg]; 1587 } 1588 } catch (err) { 1589 1590 } 1591 } 1592 if (sthashFound) { 1593 return sthashValue; 1594 } else { 1595 return document.location.hash.substring(1); 1596 } 1597 } else { 1598 return document.location.hash.substring(1); 1599 } 1600 }, 1601 stripHash: function(url) { 1602 var urlWithoutHash = url; 1603 urlWithoutHash = urlWithoutHash.split("#"); 1604 if (urlWithoutHash.length > 1) 1605 return urlWithoutHash[1]; 1606 else 1607 return ""; 1608 }, 1609 clearHash: function() { 1610 if (stlib.hash.validateHash(document.location.hash)) { 1611 var baseHref = document.location.href.split("#").shift(); 1612 1613 if (window.history && history.replaceState) 1614// history.replaceState(null, "ShareThis", "#"); 1615 history.replaceState(null, document.title, baseHref); 1616 else if ((/MSIE/).test(navigator.userAgent)) 1617 window.location.replace("#"); 1618 else 1619 document.location.hash = ""; 1620 } 1621 }, 1622 init: function() { 1623 var finalHash = ""; 1624 var max = stlib.hash.validChars.length; 1625 for (var i=0;i<8;i++) { 1626 finalHash += stlib.hash.validChars[Math.random()*max|0]; 1627 } 1628 if (stlib.hash.getHash() == "") { 1629 stlib.hash.shareHash = stlib.hash.prefix + "." + finalHash; 1630 } else { 1631 var splitHash = stlib.hash.getHash().split("."); 1632 var key = splitHash.shift(); 1633 if (key == stlib.hash.prefix || key == stlib.hash.prefix) { 1634 stlib.hash.incomingHash = stlib.hash.getHash(); 1635 stlib.hash.shareHash = stlib.hash.prefix + "." + splitHash.shift() + "." + finalHash; 1636 } else { 1637 stlib.hash.shareHash = stlib.hash.prefix + "." + finalHash; 1638 } 1639 } 1640 if (!stlib.hash.doNotHash && stlib.hash.hashAddressBar) { 1641 if (document.location.hash == "" || stlib.hash.validateHash(document.location.hash)) { 1642 if (window.history && history.replaceState) 1643 history.replaceState(null, "ShareThis", "#"+stlib.hash.shareHash + ".dpbs"); 1644 else if ((/MSIE/).test(navigator.userAgent)) 1645 window.location.replace("#"+stlib.hash.shareHash + ".dpbs"); 1646 else 1647 document.location.hash = stlib.hash.shareHash + ".dpbs"; 1648 } 1649 } else { 1650 stlib.hash.clearHash(); 1651 } 1652 if (!stlib.hash.doNotHash && !stlib.hash.doNotCopy) { 1653 stlib.hash.copyPasteInit(); 1654 } 1655 stlib.hash.copyPasteLog(); 1656 }, 1657 checkURL: function() { 1658 var destination = stlib.data.get("destination", "shareInfo"); 1659 var baseURL = stlib.hash.updateParams(destination); 1660 var shortenedDestination = "." + stlib.hash.hashDestination(destination); 1661 stlib.hash.updateDestination(shortenedDestination); 1662 if (!stlib.hash.doNotHash && typeof(stlib.data.pageInfo.shareHash) != "undefined") { 1663 var url = stlib.data.get("url", "shareInfo"); 1664 var hash = stlib.hash.stripHash(url); 1665 if (stlib.hash.validateHash(hash) || hash == "") { 1666 if(typeof(stlib.hash.servicePreferences[destination]) != "undefined") { 1667 if(stlib.hash.servicePreferences[destination] == "param") { 1668 _$d1("Don't use hash, use params"); 1669 _$d2(baseURL); 1670 if (baseURL.split("?").length > 1) { 1671 var parameterArray = baseURL.split("?")[1].split("&") 1672 var sthashExists = false;
1673 //for (arg in parameterArray) { 1674 for (var arg = 0; arg < parameterArray.length; arg++) { 1675 if (parameterArray[arg].split(".")[0] == "sthash") { 1676 sthashExists = true; 1677 } 1678 } 1679 if (sthashExists) { 1680 // Param was fixed by updateParams, dont need to add anything 1681 stlib.data.set("url",baseURL, "shareInfo"); 1682 } else { 1683 // Param wasn't there, need to add it. 1684 stlib.data.set("url",baseURL + "&" + stlib.data.pageInfo.shareHash, "shareInfo"); 1685 } 1686 } else { 1687 // There are no params, need to add the hash param 1688 stlib.data.set("url",baseURL + "?" + stlib.data.pageInfo.shareHash, "shareInfo"); 1689 } 1690 if (destination == "linkedin") { // shar url contains # which is an error in LinkedIn 1691 if (stlib.data.get("sharURL", "shareInfo") != "") { 1692 stlib.data.set("sharURL", stlib.data.get("url", "shareInfo"), "shareInfo"); 1693 } 1694 } 1695 } else { 1696 _$d1("Using Hash"); 1697 stlib.data.set("url",baseURL + "#" + stlib.data.pageInfo.shareHash, "shareInfo"); 1698 } 1699 } else { 1700 _$d1("Not using custom destination hash type"); 1701 stlib.data.set("url",baseURL + "#" + stlib.data.pageInfo.shareHash, "shareInfo"); 1702 } 1703 } 1704 } 1705 }, 1706 updateParams: function(destination) { 1707 var baseURL = stlib.data.get("url", "shareInfo").split("#").shift(); 1708 var regex2a = /(\?)sthash\.[a-zA-z0-9]{8}\.[a-zA-z0-9]{8}/; 1709 var regex2b = /(&)sthash\.[a-zA-z0-9]{8}\.[a-zA-z0-9]{8}/; 1710 var regex1a = /(\?)sthash\.[a-zA-z0-9]{8}/; 1711 var regex1b = /(&)sthash\.[a-zA-z0-9]{8}/; 1712 if (regex2a.test(baseURL)) { 1713 baseURL = baseURL.replace(regex2a, "?" + stlib.data.pageInfo.shareHash); 1714 } else if (regex2b.test(baseURL)) { 1715 baseURL = baseURL.replace(regex2b, "&" + stlib.data.pageInfo.shareHash); 1716 } else if (regex1a.test(baseURL)) { 1717 baseURL = baseURL.replace(regex1a, "?" + stlib.data.pageInfo.shareHash); 1718 } else if (regex1b.test(baseURL)) { 1719 baseURL = baseURL.replace(regex1b, "&" + stlib.data.pageInfo.shareHash); 1720 } 1721 return baseURL; 1722 }, 1723 updateDestination: function(destinationHash) { 1724 var regex2 = /sthash\.[a-zA-z0-9]{8}\.[a-zA-z0-9]{8}\.[a-z]{4}/; 1725 var regex1 = /sthash\.[a-zA-z0-9]{8}\.[a-z]{4}/; 1726 _$d_(); 1727 _$d1("Updating Destination"); 1728 if (regex2.test(stlib.data.pageInfo.shareHash)) { 1729 _$d2(stlib.data.pageInfo.shareHash.substring(0,24)); 1730 stlib.data.pageInfo.shareHash = stlib.data.pageInfo.shareHash.substring(0,24) + destinationHash; 1731 } else if (regex1.test(stlib.data.pageInfo.shareHash)) { 1732 _$d2(stlib.data.pageInfo.shareHash.substring(0,15)); 1733 stlib.data.pageInfo.shareHash = stlib.data.pageInfo.shareHash.substring(0,15) + destinationHash; 1734 } else { 1735 stlib.data.pageInfo.shareHash += destinationHash; 1736 } 1737 }, 1738 validateHash: function(isValidHash) { 1739 var regex3 = /[\?#&]?sthash\.[a-zA-z0-9]{8}\.[a-zA-z0-9]{8}$/; 1740 var regex2 = /[\?#&]?sthash\.[a-zA-z0-9]{8}\.[a-zA-z0-9]{8}\.[a-z]{4}$/; 1741 var regex1 = /[\?#&]?sthash\.[a-zA-z0-9]{8}\.[a-z]{4}$/; 1742 var regex0 = /[\?#&]?sthash\.[a-zA-z0-9]{8}$/; 1743 return regex0.test(isValidHash) || regex1.test(isValidHash) || regex2.test(isValidHash) || regex3.test(isValidHash); 1744 }, 1745 appendHash : function (url) { 1746 var hash = stlib.hash.stripHash(url); 1747 if (stlib.data.pageInfo.shareHash && (stlib.hash.validateHash(hash) || hash == "")) { 1748 url = url.replace("#"+hash,"") + "#" + stlib.data.pageInfo.shareHash; 1749 } else { 1750 } 1751 return url; 1752 }, 1753 copyPasteInit: function() { 1754 var body = document.getElementsByTagName("body")[0]; 1755 var replacement = document.createElement("div"); 1756 replacement.id = "stcpDiv"; 1757 replacement.style.position = "absolute"; 1758 replacement.style.top = "-1999px"; 1759 replacement.style.left = "-1988px"; 1760 body.appendChild(replacement); 1761 replacement.innerHTML = "ShareThis Copy and Paste"; 1762 var baseHref = document.location.href.split("#").shift(); 1763 var hash = "#" + stlib.hash.shareHash; 1764 if (document.addEventListener) { 1765 body["addEventListener"]("copy",function(e){ 1766 //TYNT CONFLICT FIX: do not copy if Tynt object exists 1767 if (typeof(Tynt)!="undefined"){ 1768// console.log("Tynt exists. Don't copy"); 1769 return; 1770 } 1771// console.log("Tynt doesn't exist. Proceed"); 1772 1773 //grab current range and append url to it 1774 var selection = document.getSelection(); 1775 1776 if (selection.isCollapsed) { 1777 return; 1778 } 1779 1780 var markUp = selection.getRangeAt(0).cloneContents(); 1781 replacement.innerHTML = ""; 1782 replacement.appendChild(markUp); 1783 1784 if (replacement.textContent.trim().length==0) { 1785 return; 1786 } 1787 1788 if((selection+"").trim().length==0) { 1789 //No text, don't need to do anything 1790 } else if (replacement.innerHTML == (selection+"") || replacement.textContent == (selection+"")) { 1791 //Fix for CNS FB:12969. Encode html data to avoid js script execution on content copy 1792 replacement.innerHTML = stlib.html.encode(stlib.hash.selectionModify(selection)); 1793 } else { 1794 //Fix for CNS FB:12969. Encode html data to avoid js script execution on content copy 1795 replacement.innerHTML += stlib.html.encode(stlib.hash.selectionModify(selection, true)); 1796 } 1797 var range = document.createRange(); 1798 range.selectNodeContents(replacement); 1799 var oldRange = selection.getRangeAt(0); 1800 },false); 1801 } else if (document.attachEvent) { 1802 /* 1803 body.oncopy = function() { 1804 var oldRange = document.selection.createRange(); 1805 replacement.innerHTML = oldRange.htmlText; 1806 try { 1807 var length = (oldRange.text).trim().length; 1808 } catch (e) { 1809 var length = (oldRange.text).replace(/^\s+|\s+$/g, '').length; 1810 } 1811 if(length==0) { 1812 //No text, don't need to do anything 1813 } else if (oldRange.htmlText == oldRange.text) { 1814 //Just text, treat normally 1815 replacement.innerHTML = stlib.hash.selectionModify(oldRange.text); 1816 } else { 1817 //Text and markup, special case 1818 replacement.innerHTML += stlib.hash.selectionModify(oldRange.text, true); 1819 } 1820 var range = document.body.createTextRange(); 1821 range.moveToElementText(replacement); 1822 range.select(); 1823 setTimeout(function() {oldRange.select();}, 1); 1824 }; 1825 */ 1826 } 1827 }, 1828 copyPasteLog: function() { 1829 var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; 1830 var messageEvent1 = eventMethod == "attachEvent" ? "oncopy" : "copy"; 1831 var body = document.getElementsByTagName("body")[0]; 1832 if(body){ 1833 body[eventMethod](messageEvent1,function(e){ 1834 var pass = true; 1835 stlib.data.resetShareData(); 1836 stlib.data.set("url", document.location.href, "shareInfo"); 1837 stlib.data.setSource("copy"); 1838 stlib.data.set("destination", "copy", "shareInfo"); 1839 stlib.data.set("buttonType", "custom", "shareInfo"); 1840 1841 if (typeof(Tynt)!="undefined"){ 1842 // Log Tynt 1843 stlib.data.set("result", "tynt", "shareInfo"); 1844 pass = false;
1845 } 1846 if (typeof(addthis_config)!="undefined") { 1847 // Log AddThis 1848 stlib.data.set("result", "addThis", "shareInfo"); 1849 if (typeof(addthis_config.data_track_textcopy)=="undefined"||addthis_config.data_track_textcopy) { 1850 stlib.data.set("enabled", "true", "shareInfo"); 1851 pass = false; 1852 } else { 1853 stlib.data.set("enabled", "false", "shareInfo"); 1854 } 1855 } 1856 },false); 1857 } 1858 }, 1859 logCopy: function(url, selection) { 1860 stlib.data.resetShareData(); 1861 stlib.data.set("url", url, "shareInfo"); 1862 stlib.data.setSource("copy"); 1863 stlib.data.set("destination", "copy", "shareInfo"); 1864 stlib.data.set("buttonType", "custom", "shareInfo"); 1865 if (selection) 1866 stlib.data.set("copy_text", selection, "shareInfo"); 1867 stlib.sharer.share(); 1868 }, 1869 selectionModify: function(selection, anchorOnly) { 1870 selection = "" + selection; 1871 _$d_(); 1872 _$d1("Copy Paste"); 1873 var regex = /^((http|https):\/\/([a-z0-9!'\(\)\*\.\-\+:]*(\.)[a-z0-9!'\(\)\*\.\-\+:]*)((\/[a-z0-9!'\(\)\*\.\-\+:]*)*))/i; 1874 var regex2 = /^([a-z0-9!'\(\)\*\.\-\+:]*(\.)[a-z0-9!'\(\)\*\.\-\+:]*)((\/[a-z0-9!'\(\)\*\.\-\+:]*)*)/i; 1875 var regexPhoneNumberUS = /^\+?1?[\.\-\\)_\s]?[\\(]?[0-9]{3}[\.\-\\)_\s]?[0-9]{3}[\.\-_\s]?[0-9]{4}$|^[0-9]{3}[\.\-_\s]?[0-9]{4}$/; 1876 var regexPhoneNumberIndia = /^[0-9]{3}[\.\-_\s]?[0-9]{8}$/; 1877 var regexPhoneNumberBrazil = /^[0-9]{2}[\.\-_\s]?[0-9]{4}[\.\-_\s]?[0-9]{4}$/; 1878 var regexEmail = /[\-_\.a-z0-9]+@[\-_\.a-z0-9]+\.[\-_\.a-z0-9]+/i; 1879 var regex3 = /[\s@]/; 1880 var baseHref = document.location.href.split("#").shift(); 1881 var hash = "#" + stlib.hash.shareHash; 1882 var anchorStr = ""; 1883 var urlStr = ""; 1884 var returnStr = selection; 1885 if (typeof(anchorOnly) == "undefined" && ((regex.test(selection) || regex2.test(selection)) && !regex3.test(selection.trim()))) { // the selection is a url 1886 _$d2("is Url"); 1887 if (selection.match(/#/) == null || stlib.hash.validateHash(selection)) { 1888 urlStr = selection.split("#")[0] + hash + ".dpuf"; 1889 } else { 1890 urlStr = selection; 1891 } 1892 } else { 1893 _$d2("is Not Url"); 1894 if (document.location.hash == "" || (/^#$/).test(document.location.hash) || stlib.hash.validateHash(document.location.hash)) { 1895 urlStr = baseHref + hash + ".dpuf"; 1896 } else { 1897 urlStr = document.location.href; 1898 } 1899 returnStr = selection; 1900 if (selection.length > 50) { 1901 if (!regexPhoneNumberUS.test(selection) && !regexPhoneNumberIndia.test(selection) && !regexPhoneNumberBrazil.test(selection) && !regexEmail.test(selection)) { // don't add if an email or phone number 1902 returnStr += anchorStr; 1903 } 1904 } 1905 } 1906 if (selection.length > 500) { 1907 selection = selection.substring(0, 497) + "..."; 1908 } 1909 stlib.hash.logCopy(urlStr, selection); 1910 return returnStr; 1911 } 1912}; 1913/* Requires browser obj */ 1914stlib.pump = function (destination, source, callback) { 1915 var that = this; 1916 this.isIframeReady = false; 1917 this.isIframeSending = false; 1918 1919 this.getHash = function(url) { 1920 var mArray = url.split("#"); 1921 mArray.shift(); 1922 return mArray.join("#"); 1923 } 1924 1925 this.broadcastInit = function(destination) { 1926 this.destination = destination; 1927 _$d_('---------------------'); 1928 _$d1("Initiating broadcaster:"); 1929 _$d(this.destination); 1930 }; 1931 this.broadcastSendMessage = function(message) { 1932 _$d_('---------------------'); 1933 _$d1("Initiating Send:"); 1934 if (this.destination === window) { // Iframe sends an event to the parent window 1935 if (stlib.browser.ieFallback) { 1936 //window.location.hash = message; 1937 window.location.replace(window.location.href.split("#")[0] + "#" + message); 1938 _$d2("child can't communicate with parent"); 1939 return; 1940 } 1941 _$d2("Iframe to publisher: " + message); 1942 parent.postMessage("#" + message, document.referrer); 1943 } else { // The parent window sends an event to the iframe 1944 _$d2("Publisher to Iframe: " + message); 1945 if (stlib.browser.ieFallback) { 1946 if (this.destination.contentWindow) { 1947 this.destination.contentWindow.location.replace(this.destination.src + "#" + message); 1948 this.isIframeSending = true; 1949 } 1950 return; 1951 } 1952 this.destination.contentWindow.postMessage("#" + message, this.destination.src); 1953 } 1954 }; 1955 this.receiverInit = function(source, callback) { 1956 _$d_('---------------------'); 1957 _$d1("Initiating Receiver:"); 1958 _$d(source); 1959 if (stlib.browser.ieFallback) { 1960 this.callback = callback; 1961 this.source = source; 1962 if (source === window) { // The iframe polls the hash value for any changes 1963 //window.location.hash = ""; 1964 window.location.replace(window.location.href.split("#")[0] + "#"); 1965 this.currentIframe = window.location.hash; 1966 1967 var receiverName = "receiver" + stlib.functionCount; 1968 stlib.functions[receiverName] = function (callback) { 1969 if ("" != window.location.hash && "#" != window.location.hash) { 1970 var hash = window.location.hash; 1971 callback(hash); 1972 //window.location.hash = ""; 1973 window.location.replace(window.location.href.split("#")[0] + "#"); 1974 } 1975 }; 1976 stlib.functionCount++; 1977 var callbackName = "callback" + stlib.functionCount; 1978 stlib.functions[callbackName] = callback; 1979 stlib.functionCount++; 1980 setInterval("stlib.functions['" + receiverName + "'](stlib.functions['" + callbackName + "'])", 200); 1981 1982 } else { // The parent polls the iframe 1983 /* 1984 var receiverName = "receiver" + stlib.functionCount; 1985 that.oldHash = that.getHash(source.src); 1986 stlib.functions[receiverName] = function (callback) { 1987 _$d1("ShareThis Publisher is polling: " + that.oldHash + ": " + (source.src)); 1988 if (that.oldHash != that.getHash(source.src)) { 1989 that.oldHash = that.getHash(source.src); 1990 callback(hash); 1991 } 1992 }; 1993 stlib.functionCount++; 1994 var callbackName = "callback" + stlib.functionCount; 1995 stlib.functions[callbackName] = callback; 1996 stlib.functionCount++; 1997 setInterval("stlib.functions['" + receiverName + "'](stlib.functions['" + callbackName + "'])", 200); 1998 */ 1999 } 2000 var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; 2001 var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; 2002 // Listen to message from child window 2003 window[eventMethod](messageEvent,function(e) { 2004 if (source == window) { 2005 } else { 2006 if (e.origin.indexOf("sharethis.com") != -1) { 2007 if (e.data.match(/#Pinterest Click/)) 2008 stlib.sharer.sharePinterest(); 2009 if (e.data.match(/#Print Click/)) 2010 stlib.sharer.stPrint(); 2011 } 2012 } 2013 },false); 2014 return; 2015 } 2016 var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; 2017 var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; 2018 // Listen to message from child window 2019 window[eventMethod](messageEvent,function(e) { 2020 if (source == window) { 2021 _$d1("arrived in iframe from:"); 2022 _$d(e.origin); 2023 if (e.data.match(/#fragmentPump/) || e.data.match(/#Buttons Ready/) || e.data.match(/#Widget Ready/) || e.data.indexOf("#light")==0 || e.data.indexOf("#widget")==0 || e.data.indexOf("#popup")==0 || e.data.indexOf("#show")==0 || e.data.indexOf("#init")==0 || e.data.indexOf("#test")==0 || e.data.indexOf("#data")==0) // Make sure data is our own 2024 callback(e.data); 2025 } else { 2026 if (e.origin.indexOf("sharethis.com") != -1) { 2027 _$d1("arrived in parent from:"); 2028 _$d(e.origin); 2029 if (e.data.match(/#fragmentPump/) || e.data.match(/#Buttons Ready/) || e.data.match(/#Widget Ready/) || e.data.indexOf("#light")==0 || e.data.indexOf("#widget")==0 || e.data.indexOf("#popup")==0 || e.data.indexOf("#show")==0 || e.data.indexOf("#init")==0 || e.data.indexOf("#test")==0 || e.data.indexOf("#data")==0) // Make sure data is our own 2030 callback(e.data); 2031 else if (e.data.match(/#Pinterest Click/)) 2032 stlib.sharer.sharePinterest(); 2033 else if (e.data.match(/#Print Click/)) 2034 stlib.sharer.stPrint(); 2035 } else { 2036 _$d1("discarded event from:"); 2037 _$d(e.origin); 2038 } 2039 } 2040 },false); 2041 }; 2042 2043 this.broadcastInit(destination); 2044 this.receiverInit(source, callback); 2045}; 2046/***************START JSON ENCODE/DECODE***************/ 2047stlib.json = { 2048 c : {"\b":"b","\t":"t","\n":"n","\f":"f","\r":"r",'"':'"',"\\":"\\","/":"/"}, 2049 d : function(n){return n<10?"0".concat(n):n}, 2050 e : function(c,f,e){e=eval;delete eval;if(typeof eval==="undefined")eval=e;f=eval(""+c);eval=e;return f}, 2051 i : function(e,p,l){return 1*e.substr(p,l)}, 2052 p : ["","000","00","0",""], 2053 rc : null, 2054 rd : /^[0-9]{4}\-[0-9]{2}\-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/, 2055 rs : /(\x5c|\x2F|\x22|[\x0c-\x0d]|[\x08-\x0a])/g, 2056 rt : /^([0-9]+|[0-9]+[,\.][0-9]{1,3})$/, 2057 ru : /([\x00-\x07]|\x0b|[\x0e-\x1f])/g, 2058 s : function(i,d){return "\\".concat(stlib.json.c[d])}, 2059 u : function(i,d){
2060 var n=d.charCodeAt(0).toString(16); 2061 return "\\u".concat(stlib.json.p[n.length],n) 2062 }, 2063 v : function(k,v){return stlib.json.types[typeof result](result)!==Function&&(v.hasOwnProperty?v.hasOwnProperty(k):v.constructor.prototype[k]!==v[k])}, 2064 types : { 2065 "boolean":function(){return Boolean}, 2066 "function":function(){return Function}, 2067 "number":function(){return Number}, 2068 "object":function(o){return o instanceof o.constructor?o.constructor:null}, 2069 "string":function(){return String}, 2070 "undefined":function(){return null} 2071 }, 2072 $$ : function(m){ 2073 function $(c,t) { 2074 t=c[m]; 2075 delete c[m]; 2076 try { 2077 stlib.json.e(c) 2078 } catch(z){c[m]=t;return 1;} 2079 }; 2080 return $(Array)&&$(Object); 2081 }, 2082 encode : function(){ 2083 var self = arguments.length ? arguments[0] : this, 2084 result, tmp; 2085 if(self === null) 2086 result = "null"; 2087 else if(self !== undefined && (tmp = stlib.json.types[typeof self](self))) { 2088 switch(tmp){ 2089 case Array: 2090 result = []; 2091 for(var i = 0, j = 0, k = self.length; j < k; j++) { 2092 if(self[j] !== undefined && (tmp = stlib.json.encode(self[j]))) 2093 result[i++] = tmp; 2094 }; 2095 result = "[".concat(result.join(","), "]"); 2096 break; 2097 case Boolean: 2098 result = String(self); 2099 break; 2100 case Date: 2101 result = '"'.concat(self.getFullYear(), '-', stlib.json.d(self.getMonth() + 1), '-', stlib.json.d(self.getDate()), 'T', stlib.json.d(self.getHours()), ':', stlib.json.d(self.getMinutes()), ':', stlib.json.d(self.getSeconds()), '"'); 2102 break; 2103 case Function: 2104 break; 2105 case Number: 2106 result = isFinite(self) ? String(self) : "null"; 2107 break; 2108 case String: 2109 result = '"'.concat(self.replace(stlib.json.rs, stlib.json.s).replace(stlib.json.ru, stlib.json.u), '"'); 2110 break; 2111 default: 2112 var i = 0, key; 2113 result = []; 2114 for(key in self) { 2115 if(self[key] !== undefined && (tmp = stlib.json.encode(self[key]))) 2116 result[i++] = '"'.concat(key.replace(stlib.json.rs, stlib.json.s).replace(stlib.json.ru, stlib.json.u), '":', tmp); 2117 }; 2118 result = "{".concat(result.join(","), "}"); 2119 break; 2120 } 2121 }; 2122 return result; 2123 }, 2124 decode : function(input){ 2125 if(typeof(input)=='string') 2126 { 2127 var data=null; 2128 try{if ( /^[\],:{}\s]*$/.test(input.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@") 2129 .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]") 2130 .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) { 2131 data=window.JSON && window.JSON.parse ? window.JSON.parse(input) : (new Function("return " + input))(); 2132 return data; 2133 }else{ 2134 return null; 2135 }}catch(err){} 2136 } 2137 } 2138}; 2139try{stlib.json.rc=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$')} 2140catch(z){stlib.json.rc=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/} 2141/***************END JSON ENCODE/DECODE***************/ 2142/********************START LOGGING***********************/ 2143/* 2144 * This handles logging 2145 */ 2146stlib.logger = { 2147 loggerUrl: "https://l.sharethis.com/", 2148 l2LoggerUrl: "https://l2.sharethis.com/", 2149 productArray: new Array(), 2150 version: '', 2151 lang: 'en', 2152 isFpEvent: false, 2153 2154 constructParamString: function() { 2155 2156 // Pull all the parameters from the page the widget was on 2157 var p = stlib.data.pageInfo; 2158 var paramString = ""; 2159 var param; 2160 2161 for (param in p) { 2162 2163 // the following line creates "param=value&" 2164 if (p[param] == null || p[param] === "" || p[param] == "ERROR") continue; 2165 paramString += param + "=" + p[param] + "&"; 2166 } 2167 2168 // Pull all the parameters related to the share 2169 p = stlib.data.shareInfo; 2170 for (param in p) { 2171 if (p[param] == null || p[param] === "" || p[param] == "ERROR") continue; 2172 paramString += param + "=" + p[param] + "&"; 2173 } 2174 2175 // add sop parameter 2176 paramString += "sop=false" 2177 2178 // add fpestid if it exists 2179 var fpestid = stlib.data.parseCookie("fpestid", document.cookie); 2180 if (fpestid) { 2181 paramString += "&fpestid=" + fpestid; 2182 } 2183 2184 // add description if it exists 2185 try { 2186 var elements = document.getElementsByTagName("meta"); 2187 for (var i = 0; i < elements.length; i++) { 2188 var attribute = elements[i].getAttribute('property'); 2189 if (attribute == null) { 2190 attribute = elements[i].getAttribute('name'); 2191 } 2192 if (attribute == "twitter:description" || attribute == "og:description" || attribute == "description" || attribute == "Description") { 2193 var description = encodeURIComponent(elements[i].getAttribute('content')); 2194 paramString += "&description=" + description; 2195 break; 2196 } 2197 } 2198 } catch (e) {} 2199 2200 return paramString 2201 }, 2202 ibl: function() { 2203 var blacklist, domain, protocol, hostname, href, i, len; 2204 href = document.referrer; 2205 if (href) { 2206 hostname = stlib.data.hostname(href) || ''; 2207 if (stlib.data.protocol) { 2208 protocol = stlib.data.protocol(href) || ''; 2209 if (protocol == "android-app:") { 2210 return true; 2211 } 2212 } 2213 blacklist = ['aol', 'bing', 'bs.to', 'facebook', 'google', 'yahoo', '
2213yandex', document.location.hostname]; 2214 for (i = 0, len = blacklist.length; i < len; i++) { 2215 domain = blacklist[i]; 2216 if (hostname.indexOf(domain) > -1) { 2217 return true; 2218 } 2219 } 2220 var logUrl = stlib.logger.loggerUrl + "log?event=ibl&url=" + href; 2221 stlib.logger.logByImage("ibl", logUrl, null); 2222 } 2223 return true; 2224 }, 2225 obl: function(e) { 2226 var href, prefix, ref; 2227 if ((e != null ? (ref = e.target) != null ? ref.tagName : void 0 : void 0) === 'A') { 2228 href = e.target.getAttribute('href') || ''; 2229 prefix = href.slice(0, href.indexOf(':')); 2230 if (href.slice(0, 4) === 'http' && e.target.hostname !== document.location.hostname) { 2231 var logUrl = stlib.logger.loggerUrl + "log?event=obl&url=" + href; 2232 stlib.logger.logByImage("obl", logUrl, null); 2233 } 2234 } 2235 return true; 2236 }, 2237 getGDPRQueryString: function() { 2238 var gdpr_consent = stlib.data.get("gdpr_consent", "pageInfo"); 2239 var gdpr_domain = encodeURIComponent(stlib.data.get("gdpr_domain", "pageInfo")); 2240 var gdpr_method = stlib.data.get("gdpr_method", "pageInfo"); 2241 var gdpr_query_str = ""; 2242 if (gdpr_consent) { 2243 gdpr_query_str += "&gdpr_consent=" + gdpr_consent; 2244 } 2245 if (gdpr_domain) { 2246 gdpr_query_str += "&gdpr_domain=" + gdpr_domain; 2247 } 2248 if (gdpr_method) { 2249 gdpr_query_str += "&gdpr_method=" + gdpr_method; 2250 } 2251 return gdpr_query_str; 2252 }, 2253 2254 loadPixelsAsync: function(res) { 2255 if (typeof(stlib.product) !== "undefined") { 2256 if ((stlib.product == "ecommerce") || 2257 (stlib.product == "dos2") || 2258 (stlib.product == "feather") || 2259 (stlib.product == "simple") || 2260 (stlib.product == "simpleshare") || 2261 (stlib.product == "simple-share-pro")) { 2262 return; 2263 } 2264 } 2265 if (typeof(res) !== "undefined") { 2266 if (res.status === "true") { 2267 // set stid 2268 stlib.data.set("stid", res.stid, "pageInfo") 2269 2270 // fire the pixel 2271 var pxcel_url = "https://t.sharethis.com/1/k/t.dhj?rnd=" + 2272 (new Date()).getTime() + 2273 "&cid=c010&dmn="+ 2274 window.location.hostname + 2275 stlib.logger.getGDPRQueryString(); 2276 var $el = document.createElement('script'); 2277 $el.async = 1; 2278 $el.src = pxcel_url; 2279 $el.id = "pxscrpt"; 2280 var first = document.getElementsByTagName('script')[0]; 2281 first.parentNode.insertBefore($el, first); 2282 } 2283 2284 if(res.status === "true" && res.atlas === "true") { 2285 stlib.logger.js("https://platform-api.sharethis.com/atlas-exp.js"); 2286 } 2287 2288 // run dmd script if indicated in response 2289 if (res.dmd === "true") { 2290 var f = function (w, d, s, m, n, t) { 2291 w[m] = w[m] || { 2292 init: function () { (w[m].q = w[m].q || []).push(arguments); }, ready: function (c) { 2293 if ('function' != typeof c) { return; } (w[m].c = w[m].c || []).push(c); c = w[m].c; 2294 n.onload = n.onreadystatechange = function () { 2295 if (!n.readyState || /loaded|complete/.test(n.readyState)) { 2296 n.onload = n.onreadystatechange = null; 2297 if (t.parentNode && n.parentNode) { t.parentNode.removeChild(n); } while (c.length) { (c.shift())(); } 2298 } 2299 }; 2300 } 2301 }, w[m].d = 1 * new Date(); n = d.createElement(s); t = d.getElementsByTagName(s)[0]; 2302 n.async=1;n.src='https://www.medtargetsystem.com/javascript/beacon.js?'+(Date.now().toString()).substring(0,4);n.setAttribute("data-aim",m);t.parentNode.insertBefore(n,t); 2303 } 2304 f(window, document, 'script', 'AIM'); 2305 2306 AIM.init('194-3051-2EAEFDBB', { 'onload_pageview': false }); 2307 2308 AIM.ready(function () { 2309 var stid = stlib.data.get("stid", "pageInfo"); 2310 var url = window.location.href + '#estid=' + stid; 2311 AIM.pageview(url); 2312 }); 2313 } 2314 2315 try { 2316 2317 // run lotame's panorama id code if indicated by the content rule 2318 if(res.status === "true" && res.lotame === "true") { 2319 !function() { 2320 // Callback that will be triggered after each call to sync() 2321 // and let you have access to the profile and/or panorama ids 2322 var syncCallback = function (profile) { 2323 2324 // sync the panorama id 2325 var panorama_id = profile.getPanoramaId(); 2326 if (panorama_id && res.stid) { 2327 var url = "https://sync.sharethis.com/panorama" 2328 url += "?uid=" + encodeURIComponent(panorama_id) 2329 url += "&stid=" + encodeURIComponent(res.stid) 2330 stlib.logger.send(url) 2331 } 2332 2333 }; 2334 2335 var lotame_client_id = '16621'; 2336 var lotame_tag_input = { 2337 config: { 2338 onProfileReady: syncCallback 2339 } 2340 }; 2341 2342 // Lotame initialization 2343 var lotame_config = lotame_tag_input.config || {}; 2344 var namespace = window['lotame_sync_' + lotame_client_id] = {}; 2345 namespace.config = lotame_config; 2346 namespace.data = {}; 2347 namespace.cmd = namespace.cmd || []; 2348 } (); 2349 2350 window.lotame_sync_16621.cmd.push(function() { 2351 window.lotame_sync_16621.sync(); 2352 }); 2353 2354 stlib.logger.js("https://platform-api.sharethis.com/panorama.js"); 2355 } 2356 } catch (e) { 2357 // do nothing for now 2358 } 2359 2360 } 2361 }, 2362 2363 send: function(url) { 2364 var img = new Image(1, 1); 2365 img.src = url; 2366 img.style.display = "none" 2367 img.onload = function() {}; 2368 img.onerror = function() {}; 2369 }, 2370 2371 js: function(url) { 2372 var el = document.createElement('script'); 2373 el.async = 1; 2374 el.src = url; 2375 var first = document.getElementsByTagName('script')[0]; 2376 first.parentNode.insertBefore(el, first); 2377 }, 2378 2379 logByImage: function(event, logUrl, callback) { 2380 2381 // add consent params if they exist 2382 var gdpr_consent = stlib.data.get("gdpr_consent", "pageInfo"); 2383 var gdpr_domain = stlib.data.get("gdpr_domain", "pageInfo"); 2384 if (gdpr_consent) { 2385 logUrl += "&gdpr_consent=" + gdpr_consent; 2386 } 2387 if (gdpr_domain) { 2388 logUrl += "&gdpr_domain=" + gdpr_domain; 2389 } 2390 var gdpr_method = stlib.data.get("gdpr_method", "pageInfo"); 2391 if (gdpr_method) { 2392 logUrl += "&gdpr_method=" + gdpr_method; 2393 } 2394 var usprivacy = stlib.data.get("usprivacy", "pageInfo"); 2395 if (usprivacy) { 2396 logUrl += "&usprivacy=" + usprivacy; 2397 } 2398 2399 // add fpestid if it exists 2400 var fpestid = stlib.data.parseCookie("fpestid", document.cookie); 2401 if (fpestid) { 2402 logUrl += "&fpestid=" + fpestid; 2403 } 2404 2405 // add description if it exists 2406 try { 2407 var elements = document.getElementsByTagName("meta"); 2408 for (var i = 0; i < elements.length; i++) { 2409 var attribute = elements[i].getAttribute('property'); 2410 if (attribute == null) { 2411 attribute = elements[i].getAttribute('name'); 2412 } 2413 if (attribute == "twitter:description" || attribute == "og:description" || attribute == "description" || attribute == "Description") { 2414 var description = encodeURIComponent(elements[i].getAttribute('content')); 2415 logUrl += "&description=" + description; 2416 break; 2417 } 2418 } 2419 } catch (e) {} 2420 2421 var mImage = new Image(1, 1);
2422 mImage.src = logUrl + "&img_pview=true"; 2423 mImage.onload = function () { 2424 return; 2425 }; 2426 if (event == "pview") { 2427 stlib.logger.loadPixelsAsync(undefined); 2428 } else { 2429 callback? callback() : null; 2430 } 2431 }, 2432 2433 // TODO: (step 1) error checking on data 2434 // TODO: (step 2) convert params into a generic object, normalize or prepare before logging 2435 log : function(event, loggingUrl, callback, newEndpoint) { 2436 2437 if(typeof(stlib.data.get("counter", "shareInfo")) != "undefined") { 2438 var count = 0; 2439 if (stlib.data.get("counter", "shareInfo")) { 2440 count = stlib.data.get("counter", "shareInfo"); 2441 } 2442 stlib.data.set("ts" + new Date().getTime() + "." + count, "", "shareInfo"); 2443 stlib.data.unset("counter", "shareInfo"); 2444 } else { 2445 stlib.data.set("ts" + new Date().getTime(), "", "shareInfo"); 2446 } 2447 2448 if(event == 'widget') { 2449 var shortenedDestination = "." + stlib.hash.hashDestination(stlib.data.shareInfo.destination); 2450 stlib.hash.updateDestination(shortenedDestination); 2451 } 2452 2453 //Fix for SAB-709 2454 if ( !loggingUrl || (loggingUrl != stlib.logger.loggerUrl && loggingUrl != stlib.logger.l2LoggerUrl)) { 2455 loggingUrl = stlib.logger.loggerUrl; 2456 } 2457 2458 // Step 3: log data (iterate through objects) 2459 var logName = null; 2460 if (newEndpoint) { 2461 logName = event; 2462 } else { 2463 logName = (event == "pview") ? event : ((event == "debug") ? "cns" : "log"); 2464 } 2465 stlib.data.getEUConsent(function(consent){ 2466 if(event == "pview") { 2467 var logUrl = loggingUrl + logName + "?event="+event+ "&" + "version="+stlib.logger.version+ "&" + "lang="+stlib.logger.lang + "&" + stlib.logger.constructParamString(); 2468 }else { 2469 var logUrl = loggingUrl + logName + "?event="+event + "&" + stlib.logger.constructParamString(); 2470 } 2471 var pview_had_consent = (stlib.data.get("gdpr_consent", "pageInfo")) ? true : false; 2472 stlib.data.set("pview_had_consent", pview_had_consent, "pageInfo"); 2473 2474 var user_agent_data = {} 2475 var ua_fields = {} 2476 stlib.data.ua_fields = ua_fields 2477 2478 try { 2479 if (navigator.userAgentData) { 2480 user_agent_data = navigator.userAgentData; 2481 } 2482 2483 if (Array.isArray(user_agent_data.brands)) { 2484 var ua = "" 2485 user_agent_data.brands.forEach((brand) => { 2486 if (ua) { 2487 ua += ", " 2488 } 2489 ua += `"${brand.brand}";v="${brand.version}"` 2490 }); 2491 ua_fields.ua = ua 2492 2493 logUrl += "&ua=" + encodeURIComponent(ua); 2494 } 2495 2496 if (user_agent_data.mobile !== undefined) { 2497 var ua_mobile = (user_agent_data.mobile) ? "true" : "false"; 2498 ua_fields.ua_mobile = ua_mobile 2499 logUrl += "&ua_mobile=" + encodeURIComponent(ua_mobile); 2500 } 2501 2502 if (user_agent_data.platform) { 2503 var ua_platform = user_agent_data.platform 2504 ua_fields.ua_platform = ua_platform 2505 logUrl += "&ua_platform=" + encodeURIComponent(ua_platform); 2506 } 2507 2508 } catch (e) { 2509 // do nothing for now if it fails 2510 } 2511 2512 // if there is no getHighEntropyValues function create a shell function 2513 // in order to keep the workflow unified 2514 if (!user_agent_data.getHighEntropyValues) { 2515 user_agent_data.getHighEntropyValues = () => { 2516 return new Promise((resolve) => { 2517 resolve({}); 2518 }); 2519 } 2520 } 2521 2522 function once(fn, context) { 2523 var result; 2524 return function() { 2525 if(fn) { 2526 result = fn.apply(context || this, arguments); 2527 fn = null; 2528 } 2529 return result; 2530 }; 2531 } 2532 2533 var sendPageView = once(function() { 2534 2535 try { 2536 var client = new XMLHttpRequest(); 2537 var res; 2538 try { 2539 if (crypto && crypto.randomUUID) { 2540 logUrl += "&uuid=" + crypto.randomUUID() 2541 } 2542 stlib.data.pageInfo.pview_url = logUrl 2543 } catch (e) {} 2544 client.open("GET", logUrl, true); 2545 client.withCredentials = true; 2546 client.timeout = 10000; 2547 client.onreadystatechange = function () { 2548 if (this.readyState == this.DONE) { 2549 try { 2550 res = JSON.parse(client.responseText); 2551 if (res.fpestid) { 2552 stlib.data.writeCookie("fpestid", res.fpestid, res.fpestid_maxage); 2553 } 2554 if (event == "pview") { 2555 /* 2556 // stop firing comscore beacon 2557 if (typeof (stlib.comscore) != "undefined") { 2558 stlib.comscore.load(); 2559 } 2560 */ 2561 stlib.logger.loadPixelsAsync(res); 2562 } else { 2563 callback ? callback(): null; 2564 } 2565 } catch (e) { 2566 // responseText is empty for request timeout 2567 stlib.logger.logByImage(event, logUrl, callback); 2568 } 2569 } 2570 }; 2571 client.send(); 2572 } catch (err) { // some browsers don't support XMLHttpRequest 2573 stlib.logger.logByImage(event, logUrl, callback); 2574 } 2575 }) 2576 2577 var getOverride = function() { 2578 var is_safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); 2579 if (is_safari) { 2580 var req = new XMLHttpRequest(); 2581 req.open("GET", "https://data.stbuttons.click/data", true); 2582 req.onreadystatechange = function() { 2583 try { 2584 if (this.readyState == this.DONE) { 2585 var res = JSON.parse(req.responseText) 2586 if (res.data) { 2587 var override = res.data 2588 logUrl += "&override=" + encodeURIComponent(override); 2589 stlib.data.override = override 2590 } 2591 sendPageView() 2592 } 2593 } catch(e) { 2594 sendPageView() 2595 } 2596 } 2597 req.send() 2598 2599 // send page view if request doesn't complete in 2 seconds 2600 setTimeout(sendPageView, 2000) 2601 } else { 2602 sendPageView() 2603 } 2604 } 2605 2606 var high_entropy_fields = [ 2607 "model", 2608 "platformVersion", 2609 "fullVersionList" 2610 ] 2611 2612 user_agent_data.getHighEntropyValues(high_entropy_fields).then((high_entropy_values) => { 2613 2614 try { 2615 2616 if (Array.isArray(high_entropy_values.fullVersionList)) { 2617 var ua_full_version_list = "" 2618 high_entropy_values.fullVersionList.forEach((brand) => { 2619 if (ua_full_version_list) { 2620 ua_full_version_list += ", " 2621 } 2622 ua_full_version_list += `"${brand.brand}";v="${brand.version}"` 2623 }); 2624 ua_fields.ua_full_version_list = ua_full_version_list 2625 logUrl += "&ua_full_version_list=" + encodeURIComponent(ua_full_version_list); 2626 } 2627 2628 if (high_entropy_values.model) { 2629 var ua_model = high_entropy_values.model 2630 ua_fields.ua_model = ua_model 2631 logUrl += "&ua_model=" + encodeURIComponent(ua_model); 2632 } 2633 2634 if (high_entropy_values.platformVersion) { 2635 var ua_platform_version = high_entropy_values.platformVersion 2636 ua_fields.ua_platform_version = ua_platform_version 2637 logUrl += "&ua_platform_version=" + encodeURIComponent(ua_platform_version); 2638 } 2639 2640 } catch (e) { 2641 // do nothing for now 2642 } 2643 2644 getOverride() 2645 2646 }); 2647 2648 }); 2649 }, 2650 tcfapi_listener: function() { 2651 var start = Date.now(); 2652 var interval = setInterval(function() { 2653 if (window.__tcfapi) { 2654 try { 2655 window.__tcfapi("addEventListener", 2, function(data) { 2656 if (data && data.eventStatus == "useractioncomplete") { 2657 stlib.data.set("gdpr_consent", data.tcString, "pageInfo"); 2658 var gdpr_domain = (data.isServiceSpecific) 2659 ? document.location.hostname : ".consensu.org"; 2660 stlib.data.set("gdpr_domain", gdpr_domain, "pageInfo"); 2661 stlib.data.set("gdpr_method", "api", "pageInfo"); 2662 var url = stlib.logger.loggerUrl; 2663 url += "log?event=updated_consent"; 2664 url += "&pview_had_consent=" + stlib.data.get("pview_had_consent", "pageInfo"); 2665 stlib.logger.logByImage("updated_consent", url, null); 2666 } 2667 }); 2668 } catch (e) { 2669 clearInterval(interval); 2670 } 2671 } 2672 if (Date.now() - start > 10000) { 2673 clearInterval(interval); 2674 } 2675 }, 1000); 2676 }() 2677}; 2678 2679/********************END LOGGING***********************/ 2680/* 2681 * This handles ajax requests 2682 */ 2683if(typeof(stlib.ajax)=="undefined") { 2684 stlib.ajax = { 2685 post: function(url, params, callback, async) { 2686 var xmlHttp = new XMLHttpRequest(); 2687 if (callback) { 2688 async ? (xmlHttp.onreadystatechange = callback) : null; 2689 } 2690 xmlHttp.open("POST", url, async); 2691 xmlHttp.send(params); 2692 if (callback) { 2693 !async ? callback() : null; 2694 } 2695 }, 2696 get: function(url, callback) {
2697 try { 2698 var client = new XMLHttpRequest(); 2699 client.open("GET", url, true); 2700 client.withCredentials = true; 2701 client.onreadystatechange = function () { 2702 if (this.readyState == this.HEADERS_RECEIVED) { 2703 callback ? callback() : null; 2704 } 2705 }; 2706 client.send(); 2707 } catch (err) { // some browsers don't support XMLHttpRequest 2708 var mImage = new Image(1, 1); 2709 mImage.src = url; 2710 mImage.onload = function () { 2711 return; 2712 }; 2713 callback ? callback() : null; 2714 } 2715 } 2716 } 2717} 2718/* end of ajax */ 2719stlib.logger.version = 'buttons.js' 2720var customProduct = 'widget' 2721 2722if(typeof(stLight)=="undefined" && typeof(SHARETHIS)=="undefined"){ //make sure it isnt called over and over again 2723 var stWidgetVersion = false; 2724 2725 if(typeof(switchTo5x)=="undefined") { 2726 stWidgetVersion = "4x"; // For Migration Phase 2 - by deafult widget will be 5xa 2727 }else{ 2728 if(switchTo5x == false){ 2729 stWidgetVersion = "4x"; 2730 } 2731 if(switchTo5x == true){ 2732 stWidgetVersion = "5xa"; 2733 } 2734 } 2735 2736 stLight=new function(){ 2737 this.version=false; 2738 this.publisher=null; 2739 this.sessionID_time = (new Date()).getTime().toString(); 2740 this.sessionID_rand = Number(Math.random().toPrecision(5).toString().substr(2)).toString(); 2741 this.sessionID = this.sessionID_time + '.' + this.sessionID_rand; 2742 this.fpc=null; 2743 this.counter=0; 2744 this.readyRun=false; 2745 this.meta={ 2746 hostname: document.location.host, 2747 location: document.location.pathname 2748 }; 2749 this.loadedFromBar=false; 2750 this.clickCallBack=false; 2751 }; 2752 2753 stLight.loadDefault = function() { 2754 if (typeof(customProduct) == "undefined") { 2755 this.product = "DOS2"; 2756 } else{ 2757 this.product = customProduct; 2758 } 2759 this.source = "DOS2"; 2760 this.version = "st_insights.js"; 2761 }; 2762 2763 stLight.options=function(options){ 2764 this.loadDefault(); 2765 // set custom publisher 2766 if(options && options.publisher){ 2767 stLight.setPublisher(options.publisher); 2768 } 2769 2770 // set custom ref domain 2771 if(options && options.refDomain){ 2772 stLight.setRefDomain(options.refDomain); 2773 } 2774 2775 // set custom product 2776 // calls setProduct but doesn't update stLight.product 2777 // deprecated: productArray 2778 stlib.logger.productArray = [] 2779 if(options && options.product){ 2780 stLight.setProduct(options.product); 2781 } 2782 else { 2783 stLight.setProduct(stLight.product); 2784 } 2785 2786 // set copy and share options 2787 if(options && typeof(options.hashAddressBar) != "undefined") { 2788 stlib.hash.hashAddressBar = options.hashAddressBar; 2789 } 2790 stlib.hash.doNotHash = stlib.hash.doNotCopy = false; 2791 if(options) { 2792 options.doNotCopy = options.doNotHash = false; 2793 } 2794 2795 stlib.stLightOptionsObj = options; 2796 }; 2797 2798 stLight.onReady=function(){ 2799 if(stLight.readyRun==true){ 2800 return false; 2801 } 2802 2803 stLight.loadFromScript(); 2804 stLight.readyRun=true; 2805 stlib.data.init(); 2806 stLight.fpc=stlib.data.get("fpc", "pageInfo"); 2807 if(stLight.publisher==null){ 2808 if(typeof(window.console)!=="undefined"){ 2809 try{ 2810 // console.debug("Please specify a ShareThis Publisher Key \nFor help, contact [email protected]"); 2811 }catch(err){} 2812 } 2813 } 2814 stLight.setProduct(stLight.product); 2815 2816 //TODO: set this from the ref? 2817 stlib.logger.lang = 'en'; 2818 2819 }; 2820 2821 2822 2823 2824 //Used only to generate widget and pview events logs. 2825 stLight.log=function(event){ 2826 stlib.data.resetShareData(); 2827 stlib.data.setSource(stLight.getSource()); 2828 stlib.data.set("url", document.location.href, "shareInfo"); 2829 stlib.data.set("title", document.title, "shareInfo"); 2830 stlib.data.set("counter", stLight.counter++, "shareInfo"); 2831 stlib.logger.log(event); 2832 }; 2833 2834 2835 if(window.document.readyState=="completed"){ 2836 stLight.onReady(); 2837 }else{ 2838 if (typeof(window.addEventListener) != 'undefined') { 2839 window.addEventListener("load", stLight.onReady, false); 2840 } else if (typeof(document.addEventListener) != 'undefined') { 2841 document.addEventListener("load", stLight.onReady, false); 2842 } else if (typeof window.attachEvent != 'undefined') { 2843 window.attachEvent("onload", stLight.onReady); 2844 } 2845 } 2846 2847 2848 stLight.setPublisher = function(publisher) { 2849 stlib.data.setPublisher(publisher); 2850 stLight.publisher=publisher; 2851 }; 2852 2853 stLight.setRefDomain = function(refDomain) { 2854 stlib.data.setRefDomain(refDomain); 2855 }; 2856 2857 stLight.setProduct = function(product) { 2858 this.product = product; 2859 stlib.data.set("product", product, "pageInfo"); 2860 }; 2861 2862 stLight.getProduct = function() { 2863 return this.product; 2864 }; 2865 2866 stLight.getSource=function(){ 2867 var source = 'share4x'; 2868 if(stWidgetVersion == "5xa"){ 2869 source = 'share5x'; 2870 } 2871 //TODO: Get share bar version before buttons load 2872 return source; 2873 }; 2874 2875} 2876 2877stLight.getUrlSearchParam = function() { 2878 var list = window.location.search.substring(1); 2879 return list.split("&"); 2880} 2881 2882stLight.getUrlQueryParams = function(url) { 2883 var params = {}; 2884 var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, 2885 function(m,key,value) { 2886 params[key] = value; 2887 }); 2888 return params; 2889} 2890 2891stLight.getScriptSrcParams = function(scriptId){ 2892 var s = document.getElementById(scriptId); 2893 if (s) { 2894 return stLight.getUrlQueryParams(s.src) 2895 } 2896} 2897 2898stLight.setParams = function(params) { 2899 if (params) { 2900 if (params.refdomain) { 2901 stLight.setRefDomain(params.refdomain); 2902 } 2903 if (params.publisher) { 2904 stLight.setPublisher(params.publisher); 2905 } 2906 if (params.product) { 2907 stLight.setProduct(params.product); 2908 } 2909 } 2910} 2911 2912stLight.loadFromScript = function() { 2913 // Load the url params from script "st_insights_js" src 2914 var params = stLight.getScriptSrcParams('st_insights_js'); 2915 stLight.setParams(params) 2916} 2917 2918stLight.loadFromWindowLocation = function() { 2919 var params = stLight.getUrlSearchParam(); 2920 stLight.setParams(params) 2921} 2922 2923//END OF light.js 2924 2925stLight.onDomContentLoaded=function(){ 2926 stLight.onReady(); 2927 ; 2928}; 2929 2930 2931stLight.domReady=function(){ 2932 stLight.onReady(); 2933}; 2934 2935 2936st_showing=false; 2937 2938stLight.clickSubscribers=[]; 2939stLight.nonClickSubscribers=[]; 2940 2941 2942if(window.document.readyState=="completed"){ 2943 stLight.domReady();//domReady 2944}else{ 2945 if (typeof(window.addEventListener) != 'undefined') { 2946 window.addEventListener("load", stLight.domReady, false); 2947 } else if (typeof(document.addEventListener) != 'undefined') { 2948 document.addEventListener("load", stLight.domReady, false); 2949 } else if (typeof window.attachEvent != 'undefined') { 2950 window.attachEvent("onload", stLight.domReady); 2951 } 2952} 2953 2954 2955 2956//DOMContentLoaded 2957if(typeof(__st_loadLate)=="undefined"){ 2958 if (typeof(window.addEventListener) != 'undefined') { 2959 window.addEventListener("DOMContentLoaded", stLight.onDomContentLoaded, false); 2960 } else if (typeof(document.addEventListener) != 'undefined') { 2961 document.addEventListener("DOMContentLoaded", stLight.onDomContentLoaded, false); 2962 } 2963} else { 2964 if (typeof(window.addEventListener) != 'undefined') { 2965 window.addEventListener("DOMContentLoaded", stLight.onDomContentLoadedLazy, false); 2966 } else if (typeof(document.addEventListener) != 'undefined') { 2967 document.addEventListener("DOMContentLoaded", stLight.onDomContentLoadedLazy, false); 2968 } 2969} 2970 2971 2972if(document.readyState == "complete" && stLight.readyRun==false){ //Keep at the end of the file 2973 //This is called after body is loaded so the domeready call would never get called, so call it here 2974 stLight.domReady(); 2975} 2976 2977 2978 2979 2980//deprecated (only used in special cases: i.e. Forbes) This will always get from ShareThis count service 2981var stButtons = stButtons || {}; 2982 2983stButtons.getCount=function(url,service,element){ 2984 var flag=false; 2985 2986 if(element && element!==null){ 2987 while (element.childNodes.length >= 1 ) 2988 {
2989 try{element.removeChild(element.firstChild );}catch(err){} //empty out old ones... 2990 } 2991 } 2992 // delay execution of these, so that async-buttons.js will show up 2993 ShareThisEvent.listen('on_async_buttons_load',function(){ 2994 stButtons = async_buttons.stButtons; 2995 stButtons.cbQueue.push({"url":url,"service":service,"element":element}); 2996 stButtons.getCountsFromService(url,service,element); 2997 },false); 2998}; 2999 3000stButtons.locateElements=function(clearChildren){ 3001 ShareThisEvent.listen('on_async_buttons_load', function(){ 3002 async_buttons.stButtons.locateElements(clearChildren); 3003 }, false); 3004}; 3005 3006var stWidget = stWidget || {}; 3007if(typeof(stWidget.readyRun) == 'undefined'){ 3008 stWidget.addEntry=function(options){ 3009 ShareThisEvent.listen('on_async_buttons_load',function(){ 3010 stWidget = async_buttons.stWidget; 3011 stWidget.addEntry(options); 3012 },false); 3013 }; 3014}; 3015 3016stLight.subscribe=function(evnt,fun){ 3017 ShareThisEvent.listen('on_async_buttons_load',function(){ 3018 stButtonsLib.subscribe(evnt,fun); 3019 },false); 3020}; 3021 3022// set product and property for new buttons 3023if (window.__sharethis__) { 3024 stlib.setProduct(window.__sharethis__.product); 3025 stlib.setPublisher(window.__sharethis__.property); 3026} 3027var sop_pview_logged = typeof __stdos__ !== 'undefined' && __stdos__ !== null && __stdos__.onscriptload; 3028if (!sop_pview_logged && !stlib.onscriptload && document.URL.indexOf("edge.sharethis.com") == -1) { 3029 stlib.data.init(); 3030 stlib.onscriptload = true; 3031 stlib.logger.log("pview", null); 3032} 3033stlib.logger.ibl(); 3034stlib.data.bindEvent(document, "click", stlib.logger.obl); 3035 3036/********************START SCRIPTLOADER***********************/ 3037/* 3038 * This handles on demand loading of javascript and CSS files 3039 */ 3040stlib.scriptLoader = { 3041 loadJavascript : function(href,callBack){ 3042 var loader = stlib.scriptLoader; 3043 loader.head=document.getElementsByTagName('head')[0]; 3044 loader.scriptSrc=href; 3045 loader.script=document.createElement('script'); 3046 loader.script.setAttribute('type', 'text/javascript'); 3047 loader.script.setAttribute('src', loader.scriptSrc); 3048 loader.script.async = true; 3049 3050 if(window.attachEvent && document.all) { //IE: 3051 loader.script.onreadystatechange=function(){ 3052 if(this.readyState=='complete' || this.readyState=='loaded'){ 3053 callBack(); 3054 } 3055 }; 3056 } else { //other browsers: 3057 loader.script.onload=callBack; 3058 } 3059 loader.s = document.getElementsByTagName('script')[0]; 3060 loader.s.parentNode.insertBefore(loader.script, loader.s); 3061 }, 3062 loadCSS : function(href,callBack) { 3063 _$d_(); 3064 _$d1("Loading CSS: " + href); 3065 var loader = stlib.scriptLoader; 3066 var cssInterval; 3067 loader.head=document.getElementsByTagName('head')[0]; 3068 loader.cssSrc=href; 3069 loader.css=document.createElement('link'); 3070 loader.css.setAttribute('rel', 'stylesheet'); 3071 loader.css.setAttribute('type', 'text/css'); 3072 loader.css.setAttribute('href', href); 3073 loader.css.setAttribute('id', href); 3074 setTimeout(function(){ 3075 callBack(); 3076 if(!document.getElementById(href)){ 3077 cssInterval=setInterval(function(){ 3078 if(document.getElementById(href)){ 3079 clearInterval(cssInterval); 3080 callBack(); 3081 } 3082 }, 100); 3083 } 3084 },100); 3085 loader.head.appendChild(loader.css); 3086 } 3087}; 3088/********************END SCRIPTLOADER***********************/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.