-
Notifications
You must be signed in to change notification settings - Fork 0
/
kwik-u-rltag.min.js
6 lines (6 loc) · 6.39 KB
/
kwik-u-rltag.min.js
1
2
3
4
5
6
/**
* LeadFerry Kwik-U-RLTag script v0.9.1
* Contact us at [email protected] if you are looking for assistance.
* Interested in working for us? Reach out to us at N4IgpgtghglgNiAXCAVgewEYGcACcxQAmAZmAE5kCeAdAMZoQgA0IALjAA5IgDKYAdoQAEAVyxCoQuDH4BrIazQKAFjHEcoAczAqorCYULio/NK2XkFUDAqXmdAWTCEYIiAHoeaEWVo6sYLTsaPxCAO4w5gqR+EIA5AASOADCANIAzAAicRKCVprxylC0ss5xIAC+QA=
*/
var urltagApp=angular.module("urltagApp",[]);urltagApp.config(["$locationProvider",function(a){a.html5Mode(false).hashPrefix("!")}]);urltagApp.controller("URLTagCtrl",["$scope","$location","$filter",function(b,g,e){var c=$("#urlParser")[0],d={mode:"basic",campaign:"",medium:"",source:"",media:[{medium:"Social",tag:"social",enabled:true,sources:[{source:"Facebook",tag:"facebook",enabled:true},{source:"Twitter",tag:"twitter",enabled:true},{source:"LinkedIn",tag:"linkedin",enabled:true},{source:"Pinterest",tag:"pinterest",enabled:true},{source:"Google Plus",tag:"google-plus",enabled:true}]},{medium:"Email",tag:"email",enabled:true,sources:[{source:"Internal Newsletter",tag:"internal-newsletter",enabled:true},{source:"Vendor Newsletter",tag:"vendor-name",enabled:true}]},{medium:"Content Distribution",tag:"content-distribution",enabled:true,sources:[{source:"Outbrain",tag:"outbrain",enabled:true},{source:"Taboola",tag:"taboola",enabled:true},{source:"Gravity",tag:"gravity",enabled:true},{source:"Revcontent",tag:"revcontent",enabled:true}]},{medium:"Banner",tag:"banner",enabled:true,sources:[{source:"AdWords",tag:"adwords",enabled:true},{source:"Bing Ads",tag:"bing",enabled:true},{source:"Adroll",tag:"adroll",enabled:true},{source:"Perfect Audience",tag:"perfect-audience",enabled:true}]}],content:"",term:""},f={rawURLs:[""],customTags:[{}]},a=g.path();if(a.length>1){a=JSON.parse(LZString.decompressFromEncodedURIComponent(a.substring(1)));b.tags=angular.merge({},d,a.tags);b.urls=angular.merge({},f,a.urls)}else{b.tags=angular.copy(d);b.urls=angular.copy(f)}b.taggedURLs={urls:[],selectAll:true,selectSome:false,headers:{basic:["URL"],advanced:["URL","Source","Medium","Term","Content","Campaign"]},sort:{by:"campaign",descending:false}};b.resetAll=function(h,k){var j=(angular.isDefined(h)||angular.isDefined(k))?true:confirm("Are you sure you want to reset everything?");if(j){b.resetTags();b.resetURLs()}};b.saveAll=function(h,j,k){h=angular.isDefined(h)?h:b.tags;j=angular.isDefined(j)?j:b.urls;g.path(LZString.compressToEncodedURIComponent(JSON.stringify({tags:h,urls:j})));b.modalSaveTitle=k||"Save All";$("#modalSave").modal("show")};b.bookmarkURL=function(){return g.absUrl()};b.addBookmark=function(){if(window.sidebar&&window.sidebar.addPanel){window.sidebar.addPanel(document.title,window.location.href,"")}else{if(window.sidebar&&!(window.sidebar instanceof Node)){return true}else{if(window.external&&("AddFavorite" in window.external)){window.external.AddFavorite(location.href,document.title)}else{if(window.opera&&window.print){return true}else{alert("Press "+(navigator.userAgent.toLowerCase().indexOf("mac")!=-1?"Command/Cmd":"CTRL")+" + D to bookmark this page.")}}}}return false};b.copyBookmark=function(){$("#modalSaveURL").select();document.execCommand("copy")};b.toggleAllMediumSource=function(h){angular.forEach(b.tags.media,function(j){j.enabled=h;angular.forEach(j.sources,function(k){k.enabled=h})})};b.resetTags=function(){angular.merge(b.tags,d,{mode:b.tags.mode})};b.saveTags=function(){b.saveAll(b.tags,{},"Save Tags")};b.addURL=function(){b.urls.rawURLs.push("");b.urls.customTags.push({})};b.removeURL=function(h){b.urls.rawURLs.splice(h,1);b.urls.customTags.splice(h,1)};b.addContentTerm=function(h){for(i=b.urls.customTags.length;i<=h;i++){b.urls.customTags.push({})}var j=b.urls.customTags[h];if(!j.content&&!j.term){j.content="custom";j.term="custom"}};b.removeContentTerm=function(h){var j=b.urls.customTags[h];if(angular.isDefined(j)){j.content=null;j.term=null}};b.saveURLs=function(){b.saveAll({},b.urls,"Save URLs")};b.resetURLs=function(){b.urls=angular.copy(f)};b.tagURLs=function(h,l,k){var j=[];if(h.mode=="basic"){angular.forEach(l,function(m){if(m){j.push(b.tagURL({url:m},{medium:"",tag:h.medium},{tag:h.source}))}})}else{angular.forEach(l,function(n,m){if(n){if(h.medium||h.source){j.push(b.tagURL(angular.merge({url:n},k[m]),{medium:"",tag:h.medium},{tag:h.source}))}angular.forEach(h.media,function(o){if(o.enabled&&o.tag){angular.forEach(o.sources,function(p){if(p.enabled&&p.tag){j.push(b.tagURL(angular.merge({url:n},k[m]),o,p))}})}})}})}return j};b.tagURL=function(l,h,n){var k=["source","medium","term","content","campaign"],p=[],o,m,j={};angular.forEach(k,function(q,r){o="utm_"+q+"=";m=null;if(q=="medium"){m=l[h.medium]||h.tag}else{if(q=="source"){m=l[h.medium]?(l[h.medium][n.source]||n.tag):n.tag}else{m=l[q]||b.tags[q]}}if(m){p.push(o+m);j[q]=m}});c.href=l.url;if(c.search){c.search+="&"+p.join("&")}else{c.search=p.join("&")}j.url=c.href;j.copy=b.taggedURLs.selectAll;return j};b.$watch("tags",function(j,h){b.taggedURLs.urls=b.tagURLs(b.tags,b.urls.rawURLs,b.urls.customTags)},true);b.$watch("urls",function(j,h){b.taggedURLs.urls=b.tagURLs(b.tags,b.urls.rawURLs,b.urls.customTags)},true);b.sortOrder=function(j){var h=e("lowercase")(b.taggedURLs.headers[b.tags.mode][j]);if(b.taggedURLs.sort.by==h){b.taggedURLs.sort.descending=!b.taggedURLs.sort.descending}else{b.taggedURLs.sort.by=h}};b.selectAllToggle=function(){angular.forEach(b.taggedURLs.urls,function(h){h.copy=b.taggedURLs.selectAll})};b.$watch("taggedURLs.urls",function(j,h){var l=0,k=0;angular.forEach(j,function(m){if(m.copy==true){l++}else{k++}});if(l>0&&k>0){b.taggedURLs.selectSome=true}else{if(l==j.length){b.taggedURLs.selectAll=true}else{if(k==j.length){b.taggedURLs.selectAll=false}}b.taggedURLs.selectSome=false}},true);b.copy=function(l){var o="",k=0;if(!angular.isDefined(l)){var n=e("orderBy")(b.taggedURLs.urls,b.taggedURLs.sort.by,b.taggedURLs.sort.descending);angular.forEach(n,function(p){if(p.copy){o+=p.url+"\n";k++}})}else{o=b.taggedURLs.urls[l]["url"]}var j=$("<textarea>");$("body").append(j);j.val(o).select();var m=document.execCommand("copy");j.remove();var h=$("#buttonCopy + .popover");h.toggleClass("alert-success",m);h.toggleClass("alert-danger",!m);h.find(".popover-content").text(m?k+" URL(s) copied to clipboard":"Failed to copy URL(s) to clipboard");h.fadeIn(function(){$(this).delay(m?1000:2000).fadeOut()});return m}}]);urltagApp.directive("ngIndeterminate",function(a){return{restrict:"A",link:function(d,c,b){d.$watch(b.ngIndeterminate,function(e){c.prop("indeterminate",!!e)})}}});