Created
December 18, 2019 01:09
-
-
Save Merlin04/a26dea6ceaf5e50c21850c1bc8b69c77 to your computer and use it in GitHub Desktop.
Comcast/Xfinity JavaScript popup that they injected into my HTTP traffic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="JavaScript" type="text/javascript"> | |
// Copyright (C) 2019 Comcast Cable Communications, LLC | |
// Contact Us: http://customer.xfinity.com/contact-us/ | |
// Intended use of this message is to display critical and time sensitive notifications to customers. | |
/* | |
This program is free software; you can redistribute it and/or | |
modify it under the terms of the GNU General Public License | |
as published by the Free Software Foundation; either version 2 | |
of the License, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
http://www.gnu.org/licenses/old-licenses/lgpl-2.0.en.html | |
*/ | |
var _ComcastAlert = (function(){ | |
return { | |
SYS_URL: '/e8f6b078-0f35-11de-85c5-efc5ef23aa1f/aupm/notify.do' | |
, dragObj: {zIndex: 999999} | |
, browser: null | |
, comcastCheck: 1 | |
, comcastTimer: null | |
, xmlhttp: null | |
, go: function(){ | |
if(self.location !== top.location) return; | |
if(document.body){ | |
_ComcastAlert.browser = _ComcastAlert.checkBrowser(); | |
_ComcastAlert.ComcastBrowserNotice(); | |
_ComcastAlert.getXmlhttp(); | |
_ComcastAlert.checkBulletin(); | |
_ComcastAlert.initResizeCheck(); | |
_ComcastAlert.polyfillClassList(); | |
return _ComcastAlert; | |
}else{ | |
setTimeout(_ComcastAlert.go, 200); | |
} | |
} | |
, ComcastBrowserNotice: function(){ | |
var image_url = 'https://bnp-service-alerts.gslb2.comcast.com/images/'; | |
var comcastAlertAnalytics = 'comcastalert.png'; | |
var noticeBMUID = '160296643'; | |
var winObj = { | |
image_url: image_url | |
, comcastAlertAnalytics: comcastAlertAnalytics | |
, comcastlogo_url: '<img src="' + image_url + 'comcast-logo-115x50.png" height="50" width="115"/>' | |
, xfinitylogo_url: '<img src="' + image_url + 'Xfinity-Logo-White-221x124.png" height="55" width="99"/>' | |
, headertext1: '<b>We've increased speeds in your area.</b>' | |
, headertext2: '<b>Update your device to take advantage of faster speeds.</b>' | |
, textline1: 'We're always working to improve our network and provide you with better service. As a result of our work, we're increasing speeds in your area. However, your current device is not compatible with our latest updates. Swap out your equipment today to take advantage of faster speeds.' | |
, textline2: 'Here's how:' | |
, textline3: '• Visit <a class="cclink" href="https://mydeviceinfo.xfinity.com" target="_new"><b>mydeviceinfo.xfinity.com</b></a> to find compatible devices you can purchase.' | |
, textline4: '• Call <b>1-800-xfinity</b> to lease an Xfinity modem, so you can automatically stay up-to-date with network improvements.' | |
, textline5: 'Thank you for being a Xfinity Customer.' | |
, textline6: 'Equipment Update' | |
, privacypolicylink: '<a class="privacystatement" href="http://my.xfinity.com/privacy/" target="_new" style="color: #000000">PRIVACY POLICY</a>' | |
, termslink: '<a class="termsofservice" href="http://my.xfinity.com/terms/" target="_new" style="color: #000000">TERMS OF SERVICE</a>' | |
, closebulletin: '<a href=\"#\" onClick=\"javascript:_ComcastAlert.close_comcast_alert()\"><img src="' + image_url + 'close_button_78x78.png" height="28" width="28"/></a>' | |
, analytics: '<img src="' + image_url + comcastAlertAnalytics + '?' + noticeBMUID + '_' + _ComcastAlert.comcastContentnoCache() + '">' | |
}; | |
this.createWindow(winObj); | |
} | |
, createWindow: function(winObj){ | |
var html = '<style type="text/css">'; | |
html+= '@font-face {font-family: XfinityStandard;src: url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Thin.woff2) format("woff2"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Thin.woff) format("woff"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Thin.ttf) format("truetype");font-weight: 100;font-style: normal}' | |
html+= '@font-face {font-family: XfinityStandard;src: url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-ExtraLight.woff2) format("woff2"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-ExtraLight.woff) format("woff"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-ExtraLight.ttf) format("truetype");font-weight: 200;font-style: normal}' | |
html+= '@font-face {font-family: XfinityStandard;src: url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Light.woff2) format("woff2"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Light.woff) format("woff"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Light.ttf) format("truetype");font-weight: 300;font-style: normal}' | |
html+= '@font-face {font-family: XfinityStandard;src: url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Regular.woff2) format("woff2"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Regular.woff) format("woff"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Regular.ttf) format("truetype");font-weight: 400;font-style: normal}' | |
html+= '@font-face {font-family: XfinityStandard;src: url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Medium.woff2) format("woff2"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Medium.woff) format("woff"), url(https://edge.static-assets.top.comcast.net/staticsites/fonts/latest/Xfinity_Standard/XfinityStandard-Medium.ttf) format("truetype");font-weight: 500;font-style: normal}' | |
html+='#comcast_content{width:650px;height:auto!important;height:450px;min-height:450px;max-height:100%;font-family: XfinityStandard,helvetica,arial,sans-serif;background:#fff;border:1px solid #454545;position:absolute;top:50vh;right:50%;-webkit-transform:translate(50%,-45%);-ms-transform:translate(50%,-45%);transform:translate(50%,-45%);zoom:1;z-index:9999999999;opacity:0;-webkit-animation:popup .4s ease-out 500ms;animation:popup .4s ease-out 500ms;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;display:flex;flex-direction:column}@-webkit-keyframes popup{0%{-webkit-transform:translate(50%,-45%);opacity:0}100%{-webkit-transform:translate(50%,-50%);opacity:1}}@keyframes popup{0%{transform:translate(50%,-45%);opacity:0}100%{transform:translate(50%,-50%);opacity:1}}'; | |
html+='#comcast_content .header{height:60px;min-height:60px;width:100%;background-color:#000;repeat-x;z-index:99999999}'; | |
html+='#comcast_content .content-wrapper{padding:20px; margin:0; max-height:60vh;height:auto;overflow-y:auto;}'; | |
html+='#comcast_content p{margin: 1em 0;}' | |
html+='#comcast_content .titletext1{margin: 10 0 0 0; font:22px/24px bold XfinityStandard,Helvetica,Geneva,sans-serif;color:#303030;text-align:left;padding:0;font-weight:200;}'; | |
html+='#comcast_content .titletext2{color:#0000000;text-align:left;padding:0;font:16px/18px bold XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200}'; | |
html+='#comcast_content .textcontent1{color:#303030;text-align:left;margin: 15 0 0 0;padding:0;font:15px/16px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;line-height:1.2}'; | |
html+='#comcast_content .textcontent2{color:#303030;text-align:left;margin: 15 0 0 15; padding:0;font:15px/16px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;line-height:1.2}'; | |
html+='#comcast_content .textcontent3{color:#808080;text-align:left;margin: 15 0 0 0;padding:0;font:15px/16px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;line-height:1.2}'; | |
html+='#comcast_content .textcontent4{color:#303030;text-align:left;margin: 15 0 0 0;padding-left:12px;font:15px/16px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;line-height:1.2}'; | |
html+='#comcast_content .privacystatement{display:inline-block;font:12px/12px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;text-align:bottom;white-space:nowrap}'; | |
html+='#comcast_content .privacystatement:link{color:#000;text-decoration:none}'; | |
html+='#comcast_content .privacystatement:visited{color:#000;text-decoration:none}'; | |
html+='#comcast_content .privacystatement:hover{color:#000;text-decoration:underline}'; | |
html+='#comcast_content .termsofservice{display:inline-block;font:12px/12px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;text-align:bottom;white-space:nowrap}'; | |
html+='#comcast_content .termsofservice:link{color:#000;text-decoration:none}'; | |
html+='#comcast_content .termsofservice:visited{color:#000;text-decoration:none}'; | |
html+='#comcast_content .termsofservice:hover{color:#000;text-decoration:underline}'; | |
html+='#comcast_content .ccsa{display:inline-block;margin-left: 15px; font:12px/12px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;text-align:bottom;white-space:nowrap}'; | |
html+='#comcast_content .ccsa:link{color:#000;text-decoration:none}'; | |
html+='#comcast_content .ccsa:visited{color:#000;text-decoration:none}'; | |
html+='#comcast_content .ccsa:hover{color:#000;text-decoration:underline}'; | |
html+='#comcast_content .comcastlogo{z-index:9999999999;height:50px;width:115px; margin:0 auto 50px;}'; | |
html+='#comcast_content .comcastanalytics{float:right; height:1px; width:1px; z-index:-99999; margin:0; padding:0; auto 1px;}'; | |
html+='#comcast_content .acknowledgebutton{margin: 0 0 0 0;color:#303030;text-align:center;padding-top:5px;padding-bottom:5px;font:14px/16px XfinityStandard,Helvetica,Geneva,sans-serif;line-height:1.2;z-index:9999999999}'; | |
html+='#comcast_content .xfinitylogo{display:inline-block;position:absolute;z-index:9999999999;left:10px;top:5px;margin:0 0 0 0;height:62px;width:110px}'; | |
html+='#comcast_content .closebn{display:inline-block;position:absolute;z-index:9999999999;right:0;top:16px;height:32px;width:32px;margin:0 10px 0 0}'; | |
html+='#comcast_content #footer{height:50px;width:100%;padding:10px;margin-top:10px; padding:0; box-sizing:border-box;color:white;background-color: white;text-align: left;}'; | |
html+='#comcast_content #footer .logo{float:right; width:115px; height:50px;}'; | |
html+='#comcast_content #footer .links{float: left}'; | |
html+='#comcast_content #footer .equipmentupdate{margin:0px; margin-top:18px; color:#303030;text-align:left;margin: 15 0 0 0;padding:0;font:15px/16px XfinityStandard,Helvetica,Geneva,sans-serif;font-weight:200;line-height:1.2}'; | |
html+='#comcast_content #footer .termsofservice{margin-left:20px; margin-top:18px;}'; | |
html+='#comcast_content .scroll-button {height:30px; padding:0; margin:0;background-color:black; position:absolute;bottom: 0; left: 0; width:100%; color:white;text-align:center;}'; | |
html+='#comcast_content .phone{color:#008EC9; white-space:nowrap; text-decoration:none}'; | |
html+='#comcast_content .phone:link{color:#008EC9;text-decoration:none}'; | |
html+='#comcast_content .phone:visited{color:#008EC9;text-decoration:none}'; | |
html+='#comcast_content .phone:hover{color:#008EC9;text-decoration:underline}'; | |
html+='#comcast_content #down{transform: rotate(0deg);-ms-transform: rotate(0deg);-webkit-transform: rotate(0deg);width:25px; height:30px; margin:0 auto; background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAICAYAAADJEc7MAAAAAXNSR0IArs4c6QAAAG9JREFUGBlj/P///1YGBgZ+IA5kZGR8DaRxAqBaUaDkeiD+yADkHAFiELgCxCAJrAAkB1UDpP4fAWlEFsCqGacanBJAu/HJgZ2GTQE2MWL8AXI2CIMAVi+gGAJUhOxn4jTBTACqFgNiUGiDMNaQBgCsa9JF9Yt6ZQAAAABJRU5ErkJggg==) no-repeat center center;}'; | |
html+='#comcast_content #down.rotate{transform: rotate(180deg);-ms-transform: rotate(180deg);-webkit-transform: rotate(180deg);}'; | |
html+='#comcast_content .cclink{color:#000; text-decoration:none;}'; | |
html+='#comcast_content .cclink:hover{text-decoration:underline;}'; | |
html+='#comcast_content .underline{text-decoration:underline;}'; | |
html+='#comcast_content .buttonlink{color:#FFF; text-decoration: none !important;}'; | |
html+='#comcast_content .button-row{text-align: center;}'; | |
html+='#comcast_content .button.primary{text-decoration:none; -webkit-appearance: none; -moz-appearance: none;-ms-appearance: none;-o-appearance: none; appearance: none; color: #fff; font-family: XfinityStandard,Helvetica,Geneva,sans-serif;font-weight: 100; font-size: 16px; letter-spacing: .2px;display: inline-block;line-height: 28px; color: #fff; box-sizing: border-box;cursor: pointer;-webkit-tap-highlight-color: rgba(0,0,0,0); text-align: center;background: 0;border: 0;height: 35px;line-height: 35px;padding: 0 2em;margin-top: 10px; border-radius: 3ex; background: transparent; background-color: #0070b8;}'; | |
html+='#comcast_content .button.primary:hover{text-decoration:none; background-color: #1a6992; border-color: #1a6992;}'; | |
html +='#comcast_content.mobile-size { width: 80%; min-width: 300px; height:90%; top:40vh;}'; | |
html += '#comcast_content.mobile-size .content-wrapper {padding: 10px 15px;overflow-y:scroll;-webkit-overflow-scrolling: touch;}'; | |
html += '#comcast_content.mobile-size .titletext1 { font: 22px/24px bold XfinityStandard,Helvetica, Geneva, sans-serif;}'; | |
html += '#comcast_content.mobile-size #footer .logo{width: 100%; margin: 0 auto;}'; | |
html += '#comcast_content.mobile-size #footer .links {float: none;text-align: center;}'; | |
html += '#comcast_content.mobile-size #footer .termsofservice {margin-left: 10px;}'; | |
if (_ComcastAlert.browser.isIE && _ComcastAlert.browser.version<10){ | |
html+='#comcast_content{opacity:1;}' | |
} | |
if (_ComcastAlert.browser.isIE && _ComcastAlert.browser.version<9){ | |
html+='#comcast_content {max-height:none;}'; | |
html+='#comcast_content .scroll-button{display: none;}'; | |
} | |
html += '</style>'; | |
if (_ComcastAlert.browser.isIE && _ComcastAlert.browser.version<9){ | |
html += '<div class="main-wrapper" id="comcast_content">'; | |
}else{ | |
var mq = window.matchMedia("(max-width: 650px)"); | |
if(mq.matches){ | |
html += '<div class="main-wrapper mobile-size" id="comcast_content">'; | |
}else{ | |
html += '<div class="main-wrapper" id="comcast_content">'; | |
} | |
} | |
html += '<div class="header" onmousedown="javascript:_ComcastAlert.dragStart(event,\'comcast_content\')">'; | |
html += '<p class="xfinitylogo">'; | |
html += winObj.xfinitylogo_url; | |
html += '</p>'; | |
html += '<p class="closebn">'; | |
html += winObj.closebulletin; | |
html += '</p>'; | |
html += '</div>'; | |
html += '<div class="content-wrapper">'; | |
html += '<p class="titletext1">'; | |
html += winObj.headertext1; | |
html += '</p>'; | |
html += '<p class="titletext2">'; | |
html += winObj.headertext2; | |
html += '</p>'; | |
html += '<p class="textcontent1">'; | |
html += winObj.textline1; | |
html += '</p>'; | |
html += '<p class="textcontent1">'; | |
html += winObj.textline2; | |
html += '</p>'; | |
html += '<p class="textcontent4">'; | |
html += winObj.textline3; | |
html += '</p>'; | |
html += '<p class="textcontent4">'; | |
html += winObj.textline4; | |
html += '</p>'; | |
html += '<p class="textcontent1">'; | |
html += winObj.textline5; | |
html += '</p>'; | |
html += '<p class="textcontent3">'; | |
html += winObj.textline6; | |
html += '</p>'; | |
html += '<p class="comcastanalytics">'; | |
html += winObj.analytics; | |
html += '</p>'; | |
html += '<div id="footer">'; | |
html += '<div class="links">'; | |
html += '<p class="privacystatement">'; | |
html += winObj.privacypolicylink; | |
html += '</p>'; | |
html += '<p class="termsofservice">'; | |
html += winObj.termslink; | |
html += '</p>'; | |
html += '</div>'; | |
html += '<div class="logo">'; | |
html += '<p class="comcastlogo">'; | |
html += winObj.comcastlogo_url; | |
html += '</p>'; | |
html += '</div>'; | |
html += '</div>'; | |
html += '</div>'; | |
html += '<div class="scroll-button" onmousedown="javascript:_ComcastAlert.scrollPopUp()"><div id="down"></div></div>'; | |
html += '</div>'; | |
html += '</div>'; | |
document.body.innerHTML = document.body.innerHTML + html; | |
} | |
// Function to Determine browser and version. Copyright 2001 by Mike Hall. | |
, checkBrowser: function() { | |
var ua, s, i; | |
var browser = { | |
isIE: false | |
, isNS: false | |
, version: null | |
}; | |
ua = navigator.userAgent; | |
s = "MSIE"; | |
if ((i = ua.indexOf(s)) >= 1) { | |
browser.isIE = true; browser.version = parseFloat(ua.substr(i + s.length)); | |
} | |
s = "Netscape6/"; | |
if ((i = ua.indexOf(s)) >= 0) { | |
browser.isNS = true; browser.version = parseFloat(ua.substr(i + s.length)); | |
} | |
s = "Gecko"; | |
if ((i = ua.indexOf(s)) >= 0) { | |
browser.isNS = true; browser.version = 6.1; | |
} | |
return browser; | |
} | |
, dragStart: function(event, id) { | |
var browser1 = _ComcastAlert.browser; | |
var dragObj = _ComcastAlert.dragObj; | |
//console.log("dragObj="+ dragObj) | |
var el; | |
var x, y; | |
if (id) dragObj.elNode = document.getElementById(id); | |
else { | |
if (browser1.isIE) dragObj.elNode = window.event.srcElement; | |
if (browser1.isNS) dragObj.elNode = event.target; | |
if (dragObj.elNode.nodeType == 3) dragObj.elNode = dragObj.elNode.parentNode; | |
} | |
if (browser1.isIE) { | |
x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; | |
y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop; | |
} | |
if (browser1.isNS) { | |
x = event.clientX + window.scrollX; | |
y = event.clientY + window.scrollY; | |
} | |
dragObj.cursorStartX = x; | |
dragObj.cursorStartY = y; | |
dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10); | |
dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10); | |
if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = dragObj.elNode.offsetLeft;//100; | |
if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = dragObj.elNode.offsetTop;//400; | |
if (browser1.isIE) { | |
document.attachEvent("onmousemove", _ComcastAlert.dragGo); | |
document.attachEvent("onmouseup", _ComcastAlert.dragStop); | |
window.event.cancelBubble = true; | |
window.event.returnValue = false; } | |
if (browser1.isNS) { | |
document.addEventListener("mousemove", _ComcastAlert.dragGo, true); | |
document.addEventListener("mouseup", _ComcastAlert.dragStop, true); | |
event.preventDefault(); | |
} | |
} | |
// End Function | |
, initResizeCheck: function() { | |
var browser1 = _ComcastAlert.browser; | |
if (browser1.isIE && browser1.version<10){ | |
window.attachEvent("onresize", _ComcastAlert.onWindowResize); | |
_ComcastAlert.onWindowResize(); | |
}else{ | |
window.addEventListener('resize', _ComcastAlert.onWindowResize, false); | |
_ComcastAlert.monitorScroll(); | |
} | |
} | |
, onWindowResize: function() { | |
var browser1 = _ComcastAlert.browser; | |
if (browser1.isIE && browser1.version<9){ | |
var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; | |
var dragObj = document.getElementById("comcast_content"); | |
dragObj.style.position = "absolute"; | |
dragObj.style.left = (windowWidth-dragObj.offsetWidth)/2 +"px"; | |
dragObj.style.top = '70px'; | |
}else{ | |
var popup = document.getElementById('comcast_content'); | |
var obj = popup.classList.contains('mobile-size'); | |
// console.log(obj) | |
var mq = window.matchMedia("(max-width: 650px)"); | |
// console.log(mq) | |
if(mq.matches) { | |
//alert('match') | |
popup.classList.add('mobile-size'); | |
} else{ | |
popup.classList.remove('mobile-size'); | |
} | |
} | |
} | |
, comcastContentnoCache: function() { | |
return Math.round(Math.random() * 96151252); | |
} | |
, dragGo: function(event) { | |
var browser1 = _ComcastAlert.browser; | |
var dragObj = _ComcastAlert.dragObj; | |
var x, y; | |
if (browser1.isIE) { | |
x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft; | |
y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop; | |
} | |
if (browser1.isNS) { | |
x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; | |
} | |
dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px"; | |
dragObj.elNode.style.top = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px"; | |
if (browser1.isIE) { window.event.cancelBubble = true; window.event.returnValue = false; } | |
if (browser1.isNS) event.preventDefault(); | |
} | |
, dragStop: function(event) { | |
var browser1 = _ComcastAlert.browser; | |
if (browser1.isIE) { | |
document.detachEvent("onmousemove", _ComcastAlert.dragGo); | |
document.detachEvent("onmouseup", _ComcastAlert.dragStop); | |
} | |
if (browser1.isNS) { | |
document.removeEventListener("mousemove", _ComcastAlert.dragGo, true); | |
document.removeEventListener("mouseup", _ComcastAlert.dragStop, true); | |
} | |
} | |
, getXmlhttp: function(){ | |
var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ | |
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { | |
try { | |
xmlhttp = new XMLHttpRequest(); | |
} catch (e) { | |
xmlhttp=false; | |
} | |
} | |
if (!xmlhttp && window.createRequest) { | |
try { | |
xmlhttp = window.createRequest(); | |
} catch (e) { | |
xmlhttp=false; | |
} | |
} | |
this.xmlhttp = xmlhttp; | |
} | |
, checkBulletin: function(){ | |
if(_ComcastAlert.comcastCheck==0) { return; } | |
var xmlhttp = _ComcastAlert.xmlhttp; | |
xmlhttp.open("GET", _ComcastAlert.SYS_URL+'?dispatch=checkBulletin',true); | |
xmlhttp.onreadystatechange = function() { | |
if (xmlhttp.readyState == 4) { | |
if(xmlhttp.responseText.indexOf('43a1028c-7d11-11de-b687-1f15c5ad6a13') == -1){ | |
document.getElementById('comcast_content').style.display="none"; | |
_ComcastAlert.comcastCheck = 0; | |
} | |
_ComcastAlert.comcastTimer = setTimeout("_ComcastAlert.checkBulletin()",cal5000); | |
}; | |
}; | |
xmlhttp.send(null); | |
} | |
, close_comcast_alert: function() { | |
document.getElementById('comcast_content').style.display = "none"; | |
_ComcastAlert.sendAck(); | |
} | |
, acknowledge: function() { | |
_ComcastAlert.sendAck(); | |
document.getElementById('comcast_content').style.display = "none"; | |
} | |
, sendAck: function(){ | |
var xmlhttp = _ComcastAlert.xmlhttp; | |
xmlhttp.open("GET", _ComcastAlert.SYS_URL+'?dispatch=ackBulletin',true); | |
xmlhttp.send(null) | |
} | |
, monitorScroll: function(){ | |
var div = document.getElementsByClassName('content-wrapper')[0]; | |
var downBtn = document.getElementById('down'); | |
div.addEventListener("scroll", function(e) { | |
if (div.scrollTop + div.clientHeight >= div.scrollHeight){ | |
downBtn.classList.add('rotate'); | |
}else if (div.scrollTop==0){ | |
downBtn.classList.remove('rotate'); | |
} | |
}); | |
} | |
, scrollPopUp: function() { | |
_ComcastAlert.scrollIt( | |
document.querySelector('.content-wrapper'), | |
100, | |
'easeOutQuad', | |
function(){ | |
//console.log('end scroll') | |
} | |
// function(){console.log('end scroll')} | |
); | |
} | |
, scrollIt: function(destination, duration, easing, callback) { | |
//scrollIt: function(destination, duration=200, easing='linear', callback) { | |
var easings = { | |
linear: function(t) { | |
return t; | |
}, | |
easeInQuad: function(t) { | |
return t * t; | |
}, | |
easeOutQuad: function(t) { | |
return t * (2 - t); | |
}, | |
easeInOutQuad: function(t) { | |
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t; | |
}, | |
easeInCubic: function(t) { | |
return t * t * t; | |
}, | |
easeOutCubic: function(t) { | |
return (--t) * t * t + 1; | |
}, | |
easeInOutCubic: function(t) { | |
return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; | |
}, | |
easeInQuart: function(t) { | |
return t * t * t * t; | |
}, | |
easeOutQuart: function(t) { | |
return 1 - (--t) * t * t * t; | |
}, | |
easeInOutQuart: function(t) { | |
return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t; | |
}, | |
easeInQuint: function(t) { | |
return t * t * t * t * t; | |
}, | |
easeOutQuint: function(t) { | |
return 1 + (--t) * t * t * t * t; | |
}, | |
easeInOutQuint: function(t) { | |
return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t; | |
} | |
}; | |
var div = document.getElementsByClassName('content-wrapper')[0]; | |
var downBtn = document.getElementById('down'); | |
var aTop; | |
(div.scrollTop + div.clientHeight >= div.scrollHeight) ? atTop = false : atTop = true; | |
var start = div.pageYOffset; | |
var scrollPanels = Math.floor(div.scrollHeight/div.clientHeight); | |
var startTime = 'now' in window.performance ? performance.now() : new Date().getTime(); | |
var distToEnd = div.scrollHeight - div.scrollTop; | |
var ratio = Math.ceil(div.scrollHeight/distToEnd); | |
var destinationOffsetToScroll = ratio*div.clientHeight; | |
if ('requestAnimationFrame' in window === false) { | |
if (atTop==true){ | |
div.scrollTop +=destinationOffsetToScroll; | |
if (div.scrollTop >= destinationOffsetToScroll || div.scrollTop+div.clientHeight >= div.scrollHeight) { | |
if (callback) { | |
if (div.scrollTop+div.clientHeight >= div.scrollHeight){ | |
atTop = false; | |
downBtn.classList.add('rotate'); | |
} | |
callback(); | |
} | |
return; | |
} | |
}else{ | |
div.scrollTop =0; | |
if (div.scrollTop == 0 ) { | |
if (callback) { | |
atTop = true; | |
downBtn.classList.remove('rotate'); | |
callback(); | |
} | |
return; | |
} | |
} | |
} | |
function scroll() { | |
var now = 'now' in window.performance ? performance.now() : new Date().getTime(); | |
var time = Math.min(1, ((now - startTime) / duration)); | |
var timeFunction = easings[easing](time); | |
if (atTop==true){ | |
div.scrollTop +=30; | |
if (div.scrollTop >= destinationOffsetToScroll || div.scrollTop+div.clientHeight >= div.scrollHeight) { | |
if (callback) { | |
if (div.scrollTop+div.clientHeight >= div.scrollHeight){ | |
//alert(div.scrollTop >= destinationOffsetToScroll) | |
atTop = false; | |
downBtn.classList.add('rotate'); | |
} | |
callback(); | |
} | |
return; | |
} | |
}else{ | |
div.scrollTop -=60; | |
if (div.scrollTop == 0 ) { | |
if (callback) { | |
atTop = true; | |
downBtn.classList.remove('rotate'); | |
callback(); | |
} | |
return; | |
} | |
} | |
requestAnimationFrame(scroll); | |
} | |
scroll(); | |
} | |
// Function for Cross-browser full element.classList implementation. | |
/* | |
* By Eli Grey, http://eligrey.com | |
* License: Dedicated to the public domain. | |
* See https://github.com/eligrey/classList.js/blob/master/LICENSE.md | |
*/ | |
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */ | |
,polyfillClassList: function(){ | |
"document"in self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||!function(t){"use strict";if("Element"in t){var e="classList",n="prototype",i=t.Element[n],s=Object,r=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,"")},o=Array[n].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},a=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},c=function(t,e){if(""===e)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new a("INVALID_CHARACTER_ERR","String contains an invalid character");return o.call(t,e)},l=function(t){for(var e=r.call(t.getAttribute("class")||""),n=e?e.split(/\s+/):[],i=0,s=n.length;s>i;i++)this.push(n[i]);this._updateClassName=function(){t.setAttribute("class",""+this)}},u=l[n]=[],h=function(){return new l(this)};if(a[n]=Error[n],u.item=function(t){return this[t]||null},u.contains=function(t){return t+="",-1!==c(this,t)},u.add=function(){var t,e=arguments,n=0,i=e.length,s=!1;do t=e[n]+"",-1===c(this,t)&&(this.push(t),s=!0);while(++n<i);s&&this._updateClassName()},u.remove=function(){var t,e,n=arguments,i=0,s=n.length,r=!1;do for(t=n[i]+"",e=c(this,t);-1!==e;)this.splice(e,1),r=!0,e=c(this,t);while(++i<s);r&&this._updateClassName()},u.toggle=function(t,e){t+="";var n=this.contains(t),i=n?e!==!0&&"remove":e!==!1&&"add";return i&&this[i](t),e===!0||e===!1?e:!n},u.toString=function(){return this.join(" ")},s.defineProperty){var f={get:h,enumerable:!0,configurable:!0};try{s.defineProperty(i,e,f)}catch(g){(void 0===g.number||-2146823252===g.number)&&(f.enumerable=!1,s.defineProperty(i,e,f))}}else s[n].__defineGetter__&&i.__defineGetter__(e,h)}}(self),function(){"use strict";var t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var n,i=arguments.length;for(n=0;i>n;n++)t=arguments[n],e.call(this,t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:n.call(this,t)}}t=null}()); | |
} | |
} | |
}()); | |
_ComcastAlert.go(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment