JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf8" />
<title></title>
<style type="text/css">
#adexample1,#adexample2,#adexample3{
font-size:25px;
background:yellow;
border:solid 1px black;
}
#adexample1{
width:120px;
height:600px;
}
#adexample2{
width:120px;
height:600px;
}
#adexample3{
width:600px;
height:120px;
}
</style>
<script type="text/javascript">
var AdKlix =
{
/* code by [i-stats.net]cottton */
/* license: iDontCare */
maxclix:3, /*[int] max clicks allowed on 1 ad*/
maxtime:10, /*[int] if clicks on ad > maxclix then shut down this ad for x sec*/
localstorage_name:'gotya', /*[string] local storage name (key)*/
shutdownall:true, /*[bool] if user is blacklisted: true => shut down all ads*/
wraps:false, /*[array] array or objects (ad wrapper)*/
mem:false, /*[array] temp memory*/
is_blacklisted:function(obj)
{
var str = this.localStorage('get',this.localstorage_name);
if(str){
var data = this.decodeStr(str);
if(
data && data['id'] && data['count']
&& (data['id'] == obj.id || this.shutdownall)
&& data['count'] >= this.maxclix
){
/*check if stored max clicks are too long ago:*/
if(parseInt(data['last'])+parseInt(this.maxtime) < this._time()){
this.localStorage('del',this.localstorage_name);
return false;
}
return true;
}
}
return false;
},
init:function(ids)
{
if(typeof ids != 'object'){
throw 'expected parameter 1 to be object, `'+(typeof ids)+'` given! @AdKlix.init()';
}
this.wraps = [];
var temp;
for(var i in ids){
temp = this.getElById(ids[i]);
if(temp){
if(this.is_blacklisted(temp)){
this.shutdownAd(temp);
}else{
this.wraps[i] = temp;
}
}else{
console.log('id...