Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(){
- var Linkbucks = {
- LinkId: "2a2ef173",
- LinkType: 2,
- LinkTarget: 2,
- Exclusions: "",
- Frequency: 0,
- Domain: "linkbucks.com",
- Outside: this,
- Init: function() {
- // Backwards compatibility
- if (this.LinkId == 0) {
- if (typeof this.Outside.lb_params != "undefined" && this.Outside.lb_params[0] != null)
- this.LinkId = this.Outside.lb_params[0];
- else if (typeof this.Outside.uid != "undefined")
- this.LinkId = this.Outside.uid;
- if (this.LinkId != 0)
- this.AddScript("http://www." + this.Domain + "/WebServices/jsParseLinks.aspx?id=" + this.LinkId);
- return;
- }
- // Link does not exist
- if (this.LinkType == 0)
- return;
- // Attach to the click event on the document
- Linkbucks.AddEvent(document, "mousedown", function(e){
- var anchor = Linkbucks.GetAnchorElement(e);
- if (anchor != null && !Linkbucks.IsExcluded(anchor)) {
- if (Linkbucks.Frequency == 0 || Linkbucks.Increment() <= Linkbucks.Frequency)
- Linkbucks.HandleClick(anchor)
- }
- });
- },
- HandleClick: function(e) {
- if (this.LinkTarget == 1)
- e.target = "_top";
- else if (this.LinkTarget == 2)
- e.target = "_blank";
- var linkUrl = "http://" + this.LinkId + "." + this.Domain + "/url/";
- if (this.LinkType == 4)
- e.href = linkUrl + this.ConvertToHex(this.Encode(e.href), "");
- else
- e.href = linkUrl + e.href;
- },
- IsExcluded: function(e) {
- var exclusionList = this.FormatExclusionsArray(this.Exclusions);
- exclusionList.push(this.LinkId, this.ConvertToUnicode(this.LinkId), this.ConvertToHex(this.LinkId, "%"));
- if (!this.StartsWith(e.href, new Array("http://", "https://")))
- return true;
- if (exclusionList[0].length > 0 && this.MatchesWith(e.href, exclusionList))
- return true;
- return false;
- },
- AddEvent: function(target,eventName,handlerName) {
- if ( target.addEventListener ) {
- target.addEventListener(eventName, eval(handlerName), false);
- } else if ( target.attachEvent ) {
- target.attachEvent("on" + eventName, eval(handlerName));
- } else {
- var originalHandler = target["on" + eventName];
- if ( originalHandler ) {
- target["on" + eventName] = eval(handlerName);
- } else {
- target["on" + eventName] = eval(handlerName);
- }
- }
- },
- AddScript: function(scriptUrl) {
- var s1 = document.createElement("script");
- s1.type = "text/javascript";
- s1.async = true;
- s1.src = scriptUrl;
- var s2 = document.getElementsByTagName("script")[0];
- s2.parentNode.insertBefore(s1, s2);
- },
- FormatExclusionsArray: function(items) {
- var exclusionList = items.split(",");
- var wildCardIndex = 0;
- for (i = 0; i < exclusionList.length; i++)
- {
- wildCardIndex = exclusionList[i].indexOf("*");
- if (wildCardIndex > -1) {
- exclusionList[i] = exclusionList[i].substring(wildCardIndex+1);
- }
- exclusionList[i] = this.LTrim(this.RTrim(exclusionList[i]));
- }
- return exclusionList;
- },
- GetAnchorElement: function(e) {
- if (!e)
- e = window.event;
- var srcElement = e.srcElement ? e.srcElement : e.target;
- do
- {
- if (srcElement.tagName == "A")
- return srcElement;
- if (srcElement.parentNode)
- srcElement = srcElement.parentNode;
- }
- while (srcElement.parentNode)
- return null;
- },
- Increment: function() {
- var cookie = "lbfrequency";
- var total = this.ReadCookie(cookie);
- total = (total != null) ? parseInt(++total) : 1;
- this.CreateCookie(cookie, total, 1);
- return total;
- },
- CreateCookie: function(name, value, days) {
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else var expires = "";
- document.cookie = name+"="+value+expires+"; path=/";
- },
- ReadCookie: function(name) {
- var ca = document.cookie.split(';');
- var nameEQ = name + "=";
- for(var i=0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
- }
- return null;
- },
- ConvertToUnicode: function(value) {
- result = '';
- for (i = 0; i < value.length; i++) {
- result += '&#' + value.charCodeAt(i);
- }
- return result;
- },
- ConvertToHex: function(value, prepend) {
- var hex = '';
- for (i = 0; i < value.length; i++) {
- if (value.charCodeAt(i).toString(16).toUpperCase().length < 2) {
- hex += prepend + "0" + value.charCodeAt(i).toString(16);
- } else {
- hex += prepend + value.charCodeAt(i).toString(16);
- }
- }
- return hex;
- },
- StartsWith: function(str, e) {
- if (typeof e == "object")
- {
- for (_i = 0; _i < e.length; _i++)
- {
- if (str.toLowerCase().indexOf(e[_i].toLowerCase()) == 0)
- return true;
- }
- return false;
- }
- else
- return (str.toLowerCase().indexOf(e.toLowerCase()) == 0);
- },
- MatchesWith: function(str, e) {
- if (typeof e == "object")
- {
- for (_i = 0; _i < e.length; _i++)
- {
- if (str.toLowerCase().indexOf(e[_i].toLowerCase()) > -1)
- return true;
- }
- return false;
- }
- else
- return (str.toLowerCase().indexOf(e.toLowerCase()) > -1);
- },
- LTrim: function(str) {
- return str.replace(/^\s+/,'');
- },
- RTrim: function(str) {
- return str.replace(/\s+$/,'');
- },
- Encode: function(str) {
- var s = [], j = 0, x, res = '', k = arguments.callee.toString().replace(/\s+/g, "");
- for (var i = 0; i < 256; i++) {
- s[i] = i;
- }
- for (i = 0; i < 256; i++) {
- j = (j + s[i] + k.charCodeAt(i % k.length)) % 256;
- x = s[i];
- s[i] = s[j];
- s[j] = x;
- }
- i = 0;
- j = 0;
- for (var y = 0; y < str.length; y++) {
- i = (i + 1) % 256;
- j = (j + s[i]) % 256;
- x = s[i];
- s[i] = s[j];
- s[j] = x;
- res += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
- }
- return res;
- }
- }
- Linkbucks.Init();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement