Created
March 18, 2013 21:59
-
-
Save MichelleGlauser/5191202 to your computer and use it in GitHub Desktop.
Update Banner for Get Satisfaction Community
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
// Head Tag: | |
<style> | |
.banner | |
{ | |
display: none; | |
margin-left: auto; | |
margin-right: auto; | |
background-clip: border-box; | |
background-origin: padding-box; | |
background-size: 40px 40px; | |
background-color: #E5F4F9; | |
border-style: solid; | |
border-width: 1px; | |
color: grey; | |
font-size: 15px; | |
height: 21px; | |
line-height: 15px; | |
outline-color: white; | |
outline-style: none; | |
outline-width: 0px; | |
overflow-y: visible; | |
padding: 15px; | |
vertical-align: baseline; | |
width: 948px; | |
} | |
.banner a { | |
color: grey; | |
} | |
.banner h3 | |
{ | |
margin: 3px 0 10px 40px; | |
} | |
.banner p | |
{ | |
margin: 0; | |
} | |
#littleX { | |
block: inline; | |
float: right; | |
width: 21px; | |
height: 21px; | |
overflow: hidden; | |
position: relative; | |
z-index: 1; | |
border: 0px; | |
margin: 0px; | |
vertical-align: middle | |
} | |
#alertmessage | |
{ | |
float: left; | |
height:32px; | |
background-image: url(https://d37wxxhohlp07s.cloudfront.net/s3_images/722489/megaphone-25.png); | |
background-repeat: no-repeat; | |
z-index: 1; | |
} | |
</style> | |
// Header HTML: | |
<div class="info banner" id="SpecialAlert"> | |
<div id=alertmessage><h3><a href="https://www.google.com"/>Please click here to take our survey!</a></h3></div> | |
<div id="littleX" onClick="maxCookie();"></div> | |
</div> | |
// Footer HTML: | |
<script language="javascript"> | |
var maxVisits= 2; | |
var cookieName = '_hasSeenSurvey'; | |
document.observe("dom:loaded", function() { | |
var cookieValue = 0; | |
// If the user has cookies enabled, let's show the dialog. Otherwise, don't | |
if (document.cookie.split(";").length > 0) | |
{ | |
// Check for existing cookie | |
var i,x,y,ARRcookies=document.cookie.split(";"); | |
for (i=0;i<ARRcookies.length;i++) | |
{ | |
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); | |
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); | |
x=x.replace(/^\s+|\s+$/g,""); | |
if (x==cookieName) | |
{ | |
cookieValue = unescape(y); | |
} | |
} | |
jQuery('#alertmessage a').click(function(){ | |
maxCookie(); | |
}) | |
// If none exists, set a cookie. | |
if (cookieValue == null || cookieValue == 0) | |
{ | |
cookieValue = 1; | |
} | |
document.cookie = cookieName + "=" + cookieValue + "; expires=Sat, 1 Jan 2050 20:47:11 UTC; path=/"; | |
if (document.URL == "http://getsatisfaction.com/devcommunity/topics/new_feature_topic_close-g1wf9") | |
{ | |
maxCookie(); | |
} | |
if (cookieValue < maxVisits) | |
{ | |
jQuery("#SpecialAlert").hide(); | |
jQuery("#SpecialAlert").insertAfter("#participation"); | |
jQuery("#SpecialAlert").fadeIn("slow"); | |
jQuery('#alertmessage a').live('click', function(e){ | |
window.open(this.href); | |
e.preventDefault(); | |
}); | |
} | |
else | |
{ | |
jQuery("#SpecialAlert").hide(); | |
} | |
} | |
else | |
{ | |
jQuery("#SpecialAlert").hide(); | |
} | |
}); | |
function maxCookie() | |
{ | |
document.cookie = cookieName + "=" + maxVisits + "; expires=Sat, 1 Jan 2050 20:47:11 UTC; path=/"; | |
jQuery("#SpecialAlert").hide(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment