Skip to content

Commit

Permalink
#255 Added code improvement in js
Browse files Browse the repository at this point in the history
  • Loading branch information
santosh8793 committed Oct 11, 2019
1 parent 5320e2c commit 263ef1b
Showing 1 changed file with 75 additions and 73 deletions.
148 changes: 75 additions & 73 deletions public/assets/js/ads-front.js
Expand Up @@ -3,79 +3,6 @@ var e = document.createElement('div');
e.id = 'adsforwp-hidden-block';
e.style.display = 'none';
document.body.appendChild(e);
var curr_url = window.location.href;
var red_ulr = localStorage.getItem('curr');

var modal = document.getElementById("afw-myModal");

var adsforwpAllowedCookie = adsforwpgetCookie('adsforwpAllowedCookie');
if(adsforwpAllowedCookie!=adsforwpOptions.allow_cookies){
adsforwpsetCookie('adsforwpCookie', '', -1, '/');
adsforwpsetCookie('adsforwpAllowedCookie', adsforwpOptions.allow_cookies, 1, '/');
}

if(adsforwpOptions.allow_cookies == 2){
if( adsforwpOptions.adsforwpChoice == 'bar' || adsforwpOptions.adsforwpChoice == 'popup'){
modal.style.display = "block";
adsforwpsetCookie('adsforwpCookie', '', -1, '/');
}

if(adsforwpOptions.adsforwpChoice == 'page_redirect' && adsforwpOptions.page_redirect !="undefined"){
if(red_ulr==null || curr_url!=adsforwpOptions.page_redirect){
window.location = adsforwpOptions.page_redirect;
localStorage.setItem('curr',adsforwpOptions.page_redirect);
}
}
}else{
var adsCookie = adsforwpgetCookie('adsforwpCookie');
if(adsCookie==false) {
if( adsforwpOptions.adsforwpChoice == 'bar' || adsforwpOptions.adsforwpChoice == 'popup'){
modal.style.display = "block";
}
if(adsforwpOptions.adsforwpChoice == 'page_redirect' && adsforwpOptions.page_redirect !="undefined"){
window.location = adsforwpOptions.page_redirect;
adsforwpsetCookie('adsforwpCookie', true, 1, '/');
}
}else{
modal.style.display = "none";
}
}
function adsforwpgetCookie(cname){
var name = cname + '=';
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return false;
}
function adsforwpsetCookie(cname, cvalue, exdays, path){
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

var span = document.getElementsByClassName("afw-cls-notice")[0];
if(span){
span.onclick = function() {
modal.style.display = "none";
document.cookie = "adsforwp_prompt_close="+new Date();
adsforwpsetCookie('adsforwpCookie', 'true', 1, '/');
}
}

window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
document.cookie = "adsforwp_prompt_close="+new Date();
adsforwpsetCookie('adsforwpCookie', 'true', 1, '/');
}
}

//Ad Blocker Notice

jQuery( document ).ready(function($) {
/**
Expand Down Expand Up @@ -336,5 +263,80 @@ jQuery( document ).ready(function($) {
}

//Sticky Ads script ends here

//Adblocker Notice Script Starts Here
var curr_url = window.location.href;
var red_ulr = localStorage.getItem('curr');
var modal = document.getElementById("afw-myModal");

var adsforwpAllowedCookie = adsforwpgetCookie('adsforwpAllowedCookie');
if(adsforwpOptions){
if(adsforwpAllowedCookie!=adsforwpOptions.allow_cookies){
adsforwpsetCookie('adsforwpCookie', '', -1, '/');
adsforwpsetCookie('adsforwpAllowedCookie', adsforwpOptions.allow_cookies, 1, '/');
}

if(adsforwpOptions.allow_cookies == 2){
if( adsforwpOptions.adsforwpChoice == 'bar' || adsforwpOptions.adsforwpChoice == 'popup'){
modal.style.display = "block";
adsforwpsetCookie('adsforwpCookie', '', -1, '/');
}

if(adsforwpOptions.adsforwpChoice == 'page_redirect' && adsforwpOptions.page_redirect !="undefined"){
if(red_ulr==null || curr_url!=adsforwpOptions.page_redirect){
window.location = adsforwpOptions.page_redirect;
localStorage.setItem('curr',adsforwpOptions.page_redirect);
}
}
}else{
var adsCookie = adsforwpgetCookie('adsforwpCookie');
if(adsCookie==false) {
if( adsforwpOptions.adsforwpChoice == 'bar' || adsforwpOptions.adsforwpChoice == 'popup'){
modal.style.display = "block";
}
if(adsforwpOptions.adsforwpChoice == 'page_redirect' && adsforwpOptions.page_redirect !="undefined"){
window.location = adsforwpOptions.page_redirect;
adsforwpsetCookie('adsforwpCookie', true, 1, '/');
}
}else{
modal.style.display = "none";
}
}
}
function adsforwpgetCookie(cname){
var name = cname + '=';
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return false;
}
function adsforwpsetCookie(cname, cvalue, exdays, path){
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

var span = document.getElementsByClassName("afw-cls-notice")[0];
if(span){
span.onclick = function() {
modal.style.display = "none";
document.cookie = "adsforwp_prompt_close="+new Date();
adsforwpsetCookie('adsforwpCookie', 'true', 1, '/');
}
}

window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
document.cookie = "adsforwp_prompt_close="+new Date();
adsforwpsetCookie('adsforwpCookie', 'true', 1, '/');
}
}
//Adblocker Notice Script Ends Here

});

0 comments on commit 263ef1b

Please sign in to comment.