Skip to content

Instantly share code, notes, and snippets.

@Tmeister
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tmeister/decb8ae0e92c0864f185 to your computer and use it in GitHub Desktop.
Save Tmeister/decb8ae0e92c0864f185 to your computer and use it in GitHub Desktop.
NoHat Popup - Sec
$(function(){
function secSetCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
}
function secGetCookie (cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
}
return "";
}
function secShowPopup(){
clearInterval(secTimer);
var $body = jQuery('body');
var $window = jQuery(window);
$body.prepend('<div id="sec-show-popup"></div>');
var $popup = jQuery('#sec-show-popup');
$popup.append('<div id="sec-opt-in-form"></div>');
var $form = jQuery('#sec-opt-in-form');
$form.html('<div class="opt-in-wrapper"><h3>Top 10 Security Interview Tips</h3><p>Learn exactly what security <br>guard employers want to<br> hear from you!</p><p>Download this FREE eBook<br> now by entering your email<br> address below:</p><form method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl"><div style="display: none;"><input type="hidden" name="meta_web_form_id" value="115525206"><input type="hidden" name="meta_split_id" value=""><input type="hidden" name="listname" value="securityguardtr"><input type="hidden" name="redirect" value="http://www.aweber.com/thankyou-coi.htm?m=text" id="redirect_b8910b59391b824df7ed4ad253444076"><input type="hidden" name="meta_adtracking" value="Opt_in_page"><input type="hidden" name="meta_message" value="1"><input type="hidden" name="meta_required" value="email"><input type="hidden" name="meta_tooltip" value="email||Your Best Email Address"></div><input class="text" id="awf_field-22512891" type="text" name="email" value="Your Best Email Address" tabindex="500" onfocus=" if (this.value == \'Your Best Email Address\') { this.value = \'\'; }" onblur="if (this.value == \'\') { this.value=\'Your Best Email Address\';} "><input name="submit" class="submit" type="submit" value="FREE INSTANT ACCESS" tabindex="501"></form><div id="popup-ebook-wrapper"><img src="http://www.securityguardtraininghq.com/wp-content/themes/security/images/ebook.png" width="174" height="124"></div><div id="popup-close"><span>X</span></div></div>');
$popup.css({
'position': 'fixed',
'width': '100%',
'height': '100%',
'top': '0',
'left': '0',
'background': 'rgba(0,0,0,.75)',
'z-index': '99998'
});
$form.css({
'display': 'table',
'width': '100%',
'height': '100%'
});
$form.find('.opt-in-wrapper').css({
'display' : 'table-cell',
'vertical-align': 'middle',
'position': 'absolute',
'left' : Math.ceil(( $window.width() - 290) / 2),
'top' : Math.ceil(( $window.height() - 240) / 2)
});
$form.find('#popup-ebook-wrapper').css({
'position': 'absolute',
'left': '170px',
'top': '45px'
});
$form.find('#popup-close').css({
'position': 'absolute',
'right': '-10px',
'top': '-10px',
'width': '30px',
'height': '30px',
'border-radius': '50px',
'background': 'white'
});
$form.find('#popup-close span').css({
'color': 'black',
'position': 'absolute',
'top': '6px',
'left': '10px',
'font-weight': '500',
'font-size': '15px',
'cursor': 'pointer'
}).on('click', function(event) {
event.preventDefault();
$popup.remove();
secSetCookie('dontShowPopup', 'true', 7);
});
$popup.on('click', function(event) {
if( $(event.target).attr('id') == 'sec-opt-in-form' ){
event.preventDefault();
$popup.remove();
secSetCookie('dontShowPopup', 'true', 7);
}
});
$window.resize(function(event) {
$form.find('.opt-in-wrapper').css({
'left' : Math.ceil(( $window.width() - 290) / 2),
'top' : Math.ceil(( $window.height() - 240) / 2)
});
});
}
//if( secGetCookie('dontShowPopup') !== 'true'){
var secTimer = setInterval(secShowPopup, 10000);
//}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment