@mate-academy/sourcebuster 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- var gulp = require('gulp'),
4
- jshint = require('gulp-jshint'),
5
- map = require('map-stream'),
6
- finder = require('../helpers/finder'),
7
- notifier = require('../helpers/notifier'),
8
- config = require('../config').scripts.lint;
9
-
10
- module.exports = function() {
11
-
12
- var failReporter = map(function(file, cb) {
13
- if (!file.jshint.success) notifier(file.relative, true, 'Ooooooops!');
14
- cb(null, file);
15
- });
16
-
17
- return gulp.src(finder(config.dir, 'js'))
18
- .pipe(jshint(config.options))
19
- .pipe(jshint.reporter())
20
- .pipe(failReporter);
21
-
22
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- var gutil = require('gulp-util'),
4
- notifier = require('node-notifier');
5
-
6
- module.exports = function(file, is_fail, msg) {
7
-
8
- var say = msg || 'Bundled!',
9
- color = is_fail ? 'red' : 'green',
10
- icon = is_fail ? '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns' : false;
11
-
12
- if (global.do_beep) {
13
- notifier.notify({
14
- title: file,
15
- message: say,
16
- icon: icon,
17
- sound: true
18
- });
19
- }
20
-
21
- gutil.log(say, gutil.colors[color](file));
22
-
23
- };
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- var gulp = require('gulp'),
4
- del = require('del'),
5
- finder = require('../helpers/finder'),
6
- config = require('../config').clean;
7
-
8
- gulp.task('bundle', ['scripts'], function() {
9
- if (global.not_4production) { global.do_beep = true; }
10
- });
11
-
12
- gulp.task('clean', function(cb) {
13
-
14
- del([].concat(
15
- finder(config.scripts, 'js'),
16
- finder(config.scripts, 'map'),
17
- finder(config.dist, 'js'),
18
- finder(config.dist, 'map')
19
- ),
20
- cb
21
- );
22
-
23
- });
24
-
25
- gulp.task('build', ['clean'], function() {
26
- gulp.start('bundle')
27
- });
@@ -1,3 +0,0 @@
1
- var gulp = require('gulp');
2
-
3
- gulp.task('default', ['watch']);
@@ -1,78 +0,0 @@
1
- "use strict";
2
-
3
- var gulp = require('gulp'),
4
- browserify = require('browserify'),
5
- watchify = require('watchify'),
6
- uglify = require('gulp-uglify'),
7
- sourcemaps = require('gulp-sourcemaps'),
8
- derequire = require('gulp-derequire'),
9
- source = require('vinyl-source-stream'),
10
- buffer = require('vinyl-buffer'),
11
- rename = require('gulp-rename'),
12
- header = require('gulp-header'),
13
- gulpif = require('gulp-if'),
14
- linter = require('../helpers/linter'),
15
- notifier = require('../helpers/notifier'),
16
- config = require('../config').scripts;
17
-
18
- gulp.task('scripts', function(cb) {
19
-
20
- var bundle_queue = config.bundle_configs.length,
21
- not_4production = process.env.NODE_ENV !== 'production';
22
-
23
- var browserifyThis = function(bundle_config) {
24
-
25
- var bundler = browserify({
26
- cache: {}, packageCache: {}, fullPaths: not_4production,
27
- entries: bundle_config.in_dir + bundle_config.in_file,
28
- standalone: bundle_config.global,
29
- extensions: config.extensions,
30
- debug: config.debug
31
- });
32
-
33
- var bundle = function() {
34
-
35
- linter();
36
-
37
- return bundler
38
- .bundle()
39
- .pipe(source(bundle_config.out_file))
40
- .pipe(derequire())
41
- .pipe(gulpif(global.not_4production, gulp.dest(bundle_config.out_public_dir)))
42
- .pipe(gulpif(bundle_config.save_to_dist, gulp.dest(bundle_config.out_dist_dir)))
43
- .pipe(gulpif(bundle_config.compress, buffer()))
44
- .pipe(gulpif(bundle_config.compress && global.not_4production, sourcemaps.init({loadMaps: true})))
45
- .pipe(gulpif(bundle_config.compress, uglify()))
46
- .pipe(gulpif(bundle_config.compress, rename({suffix: '.min'})))
47
- .pipe(gulpif(!global.not_4production, header(config.banner)))
48
- .pipe(gulpif(bundle_config.compress && global.not_4production, sourcemaps.write('./')))
49
- .pipe(gulpif(bundle_config.save_to_dist, gulp.dest(bundle_config.out_dist_dir)))
50
- .pipe(gulp.dest(bundle_config.out_public_dir))
51
- .on('end', handleQueue);
52
- };
53
-
54
- if (global.is_watching) {
55
- bundler = watchify(bundler);
56
- bundler.on('update', bundle);
57
- }
58
-
59
- var handleQueue = function() {
60
- notifier(bundle_config.out_file);
61
- if (bundle_queue) {
62
- bundle_queue--;
63
- if (bundle_queue === 0) {
64
- cb();
65
- }
66
- }
67
- };
68
-
69
- return bundle();
70
- };
71
-
72
- config.bundle_configs.forEach(browserifyThis);
73
-
74
- });
75
-
76
- gulp.task('lint', function() {
77
- linter();
78
- });
@@ -1,13 +0,0 @@
1
- var gulp = require('gulp'),
2
- finder = require('../helpers/finder'),
3
- config = require('../config');
4
-
5
- gulp.task('watch', ['watching', 'build'], function() {
6
- gulp.watch(finder(config.css.in_dir), ['css']);
7
- gulp.watch(finder(config.imgs.in_dir), ['imgs']);
8
- gulp.watch(finder(config.html.in_dir), ['html']);
9
- });
10
-
11
- gulp.task('watching', function() {
12
- global.is_watching = true;
13
- });
@@ -1,2 +0,0 @@
1
- /** @mate-academy/sourcebuster v1.2.0 **/
2
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[o]={exports:{}};t[o][0].call(p.exports,function(e){var r=t[o][1][e];return i(r?r:e)},p,p.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(e,t,r){"use strict";var n=e("./init"),i={init:function(e){this.get=n(e),e&&e.callback&&"function"==typeof e.callback&&e.callback(this.get)}};t.exports=i},{"./init":6}],2:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/utils"),a={containers:{current:"sbjs_current",current_extra:"sbjs_current_add",first:"sbjs_first",first_extra:"sbjs_first_add",session:"sbjs_session",udata:"sbjs_udata",promocode:"sbjs_promo"},service:{migrations:"sbjs_migrations"},delimiter:"|||",aliases:{main:{type:"typ",source:"src",medium:"mdm",campaign:"cmp",content:"cnt",term:"trm",account_id:"ac_id",campaign_id:"cmp_id",ad_group_id:"adg_id",ad_id:"ad_id",term_id:"trm_id"},extra:{fire_date:"fd",entrance_point:"ep",referer:"rf"},session:{pages_seen:"pgs",current_page:"cpg"},udata:{visits:"vst",ip:"uip",agent:"uag"},promo:"code"},pack:{main:function(e){return a.aliases.main.type+"="+e.type+a.delimiter+a.aliases.main.source+"="+e.source+a.delimiter+a.aliases.main.medium+"="+e.medium+a.delimiter+a.aliases.main.campaign+"="+e.campaign+a.delimiter+a.aliases.main.content+"="+e.content+a.delimiter+a.aliases.main.term+"="+e.term+a.delimiter+a.aliases.main.account_id+"="+e.account_id+a.delimiter+a.aliases.main.campaign_id+"="+e.campaign_id+a.delimiter+a.aliases.main.ad_group_id+"="+e.ad_group_id+a.delimiter+a.aliases.main.ad_id+"="+e.ad_id+a.delimiter+a.aliases.main.term_id+"="+e.term_id},extra:function(e){return a.aliases.extra.fire_date+"="+i.setDate(new Date,e)+a.delimiter+a.aliases.extra.entrance_point+"="+document.location.href+a.delimiter+a.aliases.extra.referer+"="+(document.referrer||n.none)},user:function(e,t){return a.aliases.udata.visits+"="+e+a.delimiter+a.aliases.udata.ip+"="+t+a.delimiter+a.aliases.udata.agent+"="+navigator.userAgent},session:function(e){return a.aliases.session.pages_seen+"="+e+a.delimiter+a.aliases.session.current_page+"="+document.location.href},promo:function(e){return a.aliases.promo+"="+i.setLeadingZeroToInt(i.randomInt(e.min,e.max),e.max.toString().length)}}};t.exports=a},{"./helpers/utils":5,"./terms":9}],3:[function(e,t,r){"use strict";var n=e("../data").delimiter;t.exports={encodeData:function(e){return encodeURIComponent(e).replace(/\!/g,"%21").replace(/\~/g,"%7E").replace(/\*/g,"%2A").replace(/\'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29")},decodeData:function(e){try{return decodeURIComponent(e).replace(/\%21/g,"!").replace(/\%7E/g,"~").replace(/\%2A/g,"*").replace(/\%27/g,"'").replace(/\%28/g,"(").replace(/\%29/g,")")}catch(t){try{return unescape(e)}catch(r){return""}}},set:function(e,t,r,n,i){var a,o;if(r){var s=new Date;s.setTime(s.getTime()+60*r*1e3),a="; expires="+s.toGMTString()}else a="";o=n&&!i?";domain=."+n:"",document.cookie=this.encodeData(e)+"="+this.encodeData(t)+a+o+"; path=/"},get:function(e){for(var t=this.encodeData(e)+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return this.decodeData(i.substring(t.length,i.length))}return null},destroy:function(e,t,r){this.set(e,"",-1,t,r)},parse:function(e){var t=[],r={};if("string"==typeof e)t.push(e);else for(var i in e)e.hasOwnProperty(i)&&t.push(e[i]);for(var a=0;a<t.length;a++){var o;r[this.unsbjs(t[a])]={},o=this.get(t[a])?this.get(t[a]).split(n):[];for(var s=0;s<o.length;s++){var c=o[s].split("="),u=c.splice(0,1);u.push(c.join("=")),r[this.unsbjs(t[a])][u[0]]=this.decodeData(u[1])}}return r},unsbjs:function(e){return e.replace("sbjs_","")}}},{"../data":2}],4:[function(e,t,r){"use strict";t.exports={parse:function(e){for(var t=this.parseOptions,r=t.parser[t.strictMode?"strict":"loose"].exec(e),n={},i=14;i--;)n[t.key[i]]=r[i]||"";return n[t.q.name]={},n[t.key[12]].replace(t.q.parser,function(e,r,i){r&&(n[t.q.name][r]=i)}),n},parseOptions:{strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},getParam:function(e){for(var t={},r=e?e:window.location.search.substring(1),n=r.split("&"),i=0;i<n.length;i++){var a=n[i].split("=");if("undefined"==typeof t[a[0]])t[a[0]]=a[1];else if("string"==typeof t[a[0]]){var o=[t[a[0]],a[1]];t[a[0]]=o}else t[a[0]].push(a[1])}return t},getHost:function(e){return this.parse(e).host.replace("www.","")}}},{}],5:[function(e,t,r){"use strict";t.exports={escapeRegexp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},setDate:function(e,t){var r=e.getTimezoneOffset()/60,n=e.getHours(),i=t||0===t?t:-r;e.setHours(n+r+i);var a=e.getFullYear(),o=this.setLeadingZeroToInt(e.getMonth()+1,2),s=this.setLeadingZeroToInt(e.getDate(),2),c=this.setLeadingZeroToInt(e.getHours(),2),u=this.setLeadingZeroToInt(e.getMinutes(),2),p=this.setLeadingZeroToInt(e.getSeconds(),2);return a+"-"+o+"-"+s+" "+c+":"+u+":"+p},setLeadingZeroToInt:function(e,t){for(var r=e+"";r.length<t;)r="0"+r;return r},randomInt:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}}},{}],6:[function(e,t,r){"use strict";var n=e("./data"),i=e("./terms"),a=e("./helpers/cookies"),o=e("./helpers/uri"),s=e("./helpers/utils"),c=e("./params"),u=e("./migrations");t.exports=function(e){function t(){var e,t="undefined"!=typeof _.utm_source||"undefined"!=typeof _.utm_medium||"undefined"!=typeof _.utm_campaign||"undefined"!=typeof _.utm_content||"undefined"!=typeof _.utm_term||"undefined"!=typeof _.utm_ac_id||"undefined"!=typeof _.utm_id||"undefined"!=typeof _.utm_ad_group_id||"undefined"!=typeof _.utm_ad_id||"undefined"!=typeof _.utm_term_id||"undefined"!=typeof _.gclid||"undefined"!=typeof _.yclid||"undefined"!=typeof _[h.campaign_param]||"undefined"!=typeof _[h.term_param]||"undefined"!=typeof _[h.content_param],o=a.parse(n.containers),s=o[a.unsbjs(n.containers.current)],c=o[a.unsbjs(n.containers.current_extra)],u=new Date(c[n.aliases.extra.fire_date]).getTime(),p=864e5,f=(new Date).getTime(),m=f-u,l=d(i.traffic.organic),y=s[n.aliases.main.type]===i.traffic.utm,v=l&&(!y||m>45*p);if(t)g(),e=r(i.traffic.utm);else if(v)g(),e=r(i.traffic.organic);else if(!a.get(n.containers.session)&&d(i.traffic.referral))g(),e=r(i.traffic.referral);else{if(a.get(n.containers.first)||a.get(n.containers.current))return a.get(n.containers.current);g(),e=r(i.traffic.typein)}return e}function r(e){switch(e){case i.traffic.utm:b=i.traffic.utm,k="undefined"!=typeof _.utm_source?_.utm_source:"undefined"!=typeof _.gclid?"google":"undefined"!=typeof _.yclid?"yandex":i.none,w="undefined"!=typeof _.utm_medium?_.utm_medium:"undefined"!=typeof _.gclid?"cpc":"undefined"!=typeof _.yclid?"cpc":i.none,q="undefined"!=typeof _.utm_campaign?_.utm_campaign:"undefined"!=typeof _[h.campaign_param]?_[h.campaign_param]:"undefined"!=typeof _.gclid?"google_cpc":"undefined"!=typeof _.yclid?"yandex_cpc":i.none,I="undefined"!=typeof _.utm_content?_.utm_content:"undefined"!=typeof _[h.content_param]?_[h.content_param]:i.none,j="undefined"!=typeof _.utm_term?_.utm_term:"undefined"!=typeof _[h.term_param]?_[h.term_param]:p()||i.none,R="undefined"!=typeof _.utm_ac_id?_.utm_ac_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,D="undefined"!=typeof _.utm_id?_.utm_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,H="undefined"!=typeof _.utm_ad_group_id?_.utm_ad_group_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,T="undefined"!=typeof _.utm_ad_id?_.utm_ad_id:"undefined"!=typeof _.gclid?"google_cpc":i.none,E="undefined"!=typeof _.utm_term_id?_.utm_term_id:"undefined"!=typeof _.gclid?"google_cpc":i.none;break;case i.traffic.organic:b=i.traffic.organic,k=k||o.getHost(document.referrer),w=i.referer.organic,q=i.none,I=i.none,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;case i.traffic.referral:b=i.traffic.referral,k=k||o.getHost(document.referrer),w=w||i.referer.referral,q=i.none,I=o.parse(document.referrer).path,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;case i.traffic.typein:b=i.traffic.typein,k=h.typein_attributes.source,w=h.typein_attributes.medium,q=i.none,I=i.none,j=i.none,R=i.none,D=i.none,H=i.none,T=i.none,E=i.none;break;default:b=i.oops,k=i.oops,w=i.oops,q=i.oops,I=i.oops,j=i.oops,R=i.oops,D=i.oops,H=i.oops,T=i.oops,E=i.oops}var t={type:b,source:k,medium:w,campaign:q,content:I,term:j,account_id:R,campaign_id:D,ad_group_id:H,ad_id:T,term_id:E};return n.pack.main(t)}function p(){var e=document.referrer;if(_.utm_term)return _.utm_term;if(!(e&&o.parse(e).host&&o.parse(e).host.match(/^(?:.*\.)?yandex\..{2,9}$/i)))return!1;try{return o.getParam(o.parse(document.referrer).query).text}catch(t){return!1}}function d(e){var t=document.referrer;switch(e){case i.traffic.organic:return!!t&&f(t)&&m(t);case i.traffic.referral:return!!t&&f(t)&&l(t);default:return!1}}function f(e){if(h.domain){if(v)return o.getHost(e)!==o.getHost(y);var t=new RegExp("^(?:.*\\.)?"+s.escapeRegexp(y)+"$","i");return!o.getHost(e).match(t)}return o.getHost(e)!==o.getHost(document.location.href)}function m(e){var t="yandex",r="text",n="google",i=new RegExp("^(?:.*\\.)?"+s.escapeRegexp(t)+"\\..{2,9}$"),a=new RegExp(".*"+s.escapeRegexp(r)+"=.*"),c=new RegExp("^(?:www\\.)?"+s.escapeRegexp(n)+"\\..{2,9}$");if(o.parse(e).query&&o.parse(e).host.match(i)&&o.parse(e).query.match(a))return k=t,!0;if(o.parse(e).host.match(c))return k=n,!0;if(!o.parse(e).query)return!1;for(var u=0;u<h.organics.length;u++){if(o.parse(e).host.match(new RegExp("^(?:.*\\.)?"+s.escapeRegexp(h.organics[u].host)+"$","i"))&&o.parse(e).query.match(new RegExp(".*"+s.escapeRegexp(h.organics[u].param)+"=.*","i")))return k=h.organics[u].display||h.organics[u].host,!0;if(u+1===h.organics.length)return!1}}function l(e){if(!(h.referrals.length>0))return k=o.getHost(e),!0;for(var t=0;t<h.referrals.length;t++){if(o.parse(e).host.match(new RegExp("^(?:.*\\.)?"+s.escapeRegexp(h.referrals[t].host)+"$","i")))return k=h.referrals[t].display||h.referrals[t].host,w=h.referrals[t].medium||i.referer.referral,!0;if(t+1===h.referrals.length)return k=o.getHost(e),!0}}function g(){a.set(n.containers.current_extra,n.pack.extra(h.timezone_offset),x,y,v),a.get(n.containers.first_extra)||a.set(n.containers.first_extra,n.pack.extra(h.timezone_offset),x,y,v)}var h=c.fetch(e),_=o.getParam(),y=h.domain.host,v=h.domain.isolate,x=h.lifetime;u.go(x,y,v);var b,k,w,q,I,j,R,D,H,T,E;return function(){a.set(n.containers.current,t(),x,y,v),a.get(n.containers.first)||a.set(n.containers.first,a.get(n.containers.current),x,y,v);var e,r;a.get(n.containers.udata)?(e=parseInt(a.parse(n.containers.udata)[a.unsbjs(n.containers.udata)][n.aliases.udata.visits])||1,e=a.get(n.containers.session)?e:e+1,r=n.pack.user(e,h.user_ip)):(e=1,r=n.pack.user(e,h.user_ip)),a.set(n.containers.udata,r,x,y,v);var i;a.get(n.containers.session)?(i=parseInt(a.parse(n.containers.session)[a.unsbjs(n.containers.session)][n.aliases.session.pages_seen])||1,i+=1):i=1,a.set(n.containers.session,n.pack.session(i),h.session_length,y,v),h.promocode&&!a.get(n.containers.promocode)&&a.set(n.containers.promocode,n.pack.promo(h.promocode),x,y,v)}(),a.parse(n.containers)}},{"./data":2,"./helpers/cookies":3,"./helpers/uri":4,"./helpers/utils":5,"./migrations":7,"./params":8,"./terms":9}],7:[function(e,t,r){"use strict";var n=e("./data"),i=e("./helpers/cookies");t.exports={go:function(e,t,r){var a,o=this.migrations,s={l:e,d:t,i:r};if(i.get(n.containers.first)||i.get(n.service.migrations)){if(!i.get(n.service.migrations))for(a=0;a<o.length;a++)o[a].go(o[a].id,s)}else{var c=[];for(a=0;a<o.length;a++)c.push(o[a].id);var u="";for(a=0;a<c.length;a++)u+=c[a]+"=1",a<c.length-1&&(u+=n.delimiter);i.set(n.service.migrations,u,s.l,s.d,s.i)}},migrations:[{id:"1418474375998",version:"1.0.0-beta",go:function(e,t){var r=e+"=1",a=e+"=0",o=function(e,t,r){return t||r?e:n.delimiter};try{var s=[];for(var c in n.containers)n.containers.hasOwnProperty(c)&&s.push(n.containers[c]);for(var u=0;u<s.length;u++)if(i.get(s[u])){var p=i.get(s[u]).replace(/(\|)?\|(\|)?/g,o);i.destroy(s[u],t.d,t.i),i.destroy(s[u],t.d,!t.i),i.set(s[u],p,t.l,t.d,t.i)}i.get(n.containers.session)&&i.set(n.containers.session,n.pack.session(0),t.l,t.d,t.i),i.set(n.service.migrations,r,t.l,t.d,t.i)}catch(d){i.set(n.service.migrations,a,t.l,t.d,t.i)}}}]}},{"./data":2,"./helpers/cookies":3}],8:[function(e,t,r){"use strict";var n=e("./terms"),i=e("./helpers/uri");t.exports={fetch:function(e){var t=e||{},r={};if(r.lifetime=this.validate.checkFloat(t.lifetime)||6,r.lifetime=parseInt(30*r.lifetime*24*60),r.session_length=this.validate.checkInt(t.session_length)||30,r.timezone_offset=this.validate.checkInt(t.timezone_offset),r.campaign_param=t.campaign_param||!1,r.term_param=t.term_param||!1,r.content_param=t.content_param||!1,r.user_ip=t.user_ip||n.none,t.promocode?(r.promocode={},r.promocode.min=parseInt(t.promocode.min)||1e5,r.promocode.max=parseInt(t.promocode.max)||999999):r.promocode=!1,t.typein_attributes&&t.typein_attributes.source&&t.typein_attributes.medium?(r.typein_attributes={},r.typein_attributes.source=t.typein_attributes.source,r.typein_attributes.medium=t.typein_attributes.medium):r.typein_attributes={source:"(direct)",medium:"(none)"},t.domain&&this.validate.isString(t.domain)?r.domain={host:t.domain,isolate:!1}:t.domain&&t.domain.host?r.domain=t.domain:r.domain={host:i.getHost(document.location.hostname),isolate:!1},r.referrals=[],t.referrals&&t.referrals.length>0)for(var a=0;a<t.referrals.length;a++)t.referrals[a].host&&r.referrals.push(t.referrals[a]);if(r.organics=[],t.organics&&t.organics.length>0)for(var o=0;o<t.organics.length;o++)t.organics[o].host&&t.organics[o].param&&r.organics.push(t.organics[o]);return r.organics.push({host:"bing.com",param:"q",display:"bing"}),r.organics.push({host:"yahoo.com",param:"p",display:"yahoo"}),r.organics.push({host:"about.com",param:"q",display:"about"}),r.organics.push({host:"aol.com",param:"q",display:"aol"}),r.organics.push({host:"ask.com",param:"q",display:"ask"}),r.organics.push({host:"globososo.com",param:"q",display:"globo"}),r.organics.push({host:"go.mail.ru",param:"q",display:"go.mail.ru"}),r.organics.push({host:"rambler.ru",param:"query",display:"rambler"}),r.organics.push({host:"tut.by",param:"query",display:"tut.by"}),r.referrals.push({host:"t.co",display:"twitter.com"}),r.referrals.push({host:"plus.url.google.com",display:"plus.google.com"}),r},validate:{checkFloat:function(e){return!(!e||!this.isNumeric(parseFloat(e)))&&parseFloat(e)},checkInt:function(e){return!(!e||!this.isNumeric(parseInt(e)))&&parseInt(e)},isNumeric:function(e){return!isNaN(e)},isString:function(e){return"[object String]"===Object.prototype.toString.call(e)}}}},{"./helpers/uri":4,"./terms":9}],9:[function(e,t,r){"use strict";t.exports={traffic:{utm:"utm",organic:"organic",referral:"referral",typein:"typein"},referer:{referral:"referral",organic:"organic",social:"social"},none:"(none)",oops:"(Houston, we have a problem)"}},{}]},{},[1])(1)});
package/src/js/data.js DELETED
@@ -1,111 +0,0 @@
1
- "use strict";
2
-
3
- var terms = require('./terms'),
4
- utils = require('./helpers/utils');
5
-
6
- var data = {
7
-
8
- containers: {
9
- current: 'sbjs_current',
10
- current_extra: 'sbjs_current_add',
11
- first: 'sbjs_first',
12
- first_extra: 'sbjs_first_add',
13
- session: 'sbjs_session',
14
- udata: 'sbjs_udata',
15
- promocode: 'sbjs_promo'
16
- },
17
-
18
- service: {
19
- migrations: 'sbjs_migrations'
20
- },
21
-
22
- delimiter: '|||',
23
-
24
- aliases: {
25
-
26
- main: {
27
- type: 'typ',
28
- source: 'src',
29
- medium: 'mdm',
30
- campaign: 'cmp',
31
- content: 'cnt',
32
- term: 'trm',
33
- account_id: 'ac_id',
34
- campaign_id: 'cmp_id',
35
- ad_group_id: 'adg_id',
36
- ad_id: 'ad_id',
37
- term_id: 'trm_id'
38
- },
39
-
40
- extra: {
41
- fire_date: 'fd',
42
- entrance_point: 'ep',
43
- referer: 'rf'
44
- },
45
-
46
- session: {
47
- pages_seen: 'pgs',
48
- current_page: 'cpg'
49
- },
50
-
51
- udata: {
52
- visits: 'vst',
53
- ip: 'uip',
54
- agent: 'uag'
55
- },
56
-
57
- promo: 'code'
58
-
59
- },
60
-
61
- pack: {
62
-
63
- main: function(sbjs) {
64
- return (
65
- data.aliases.main.type + '=' + sbjs.type + data.delimiter +
66
- data.aliases.main.source + '=' + sbjs.source + data.delimiter +
67
- data.aliases.main.medium + '=' + sbjs.medium + data.delimiter +
68
- data.aliases.main.campaign + '=' + sbjs.campaign + data.delimiter +
69
- data.aliases.main.content + '=' + sbjs.content + data.delimiter +
70
- data.aliases.main.term + '=' + sbjs.term + data.delimiter +
71
- data.aliases.main.account_id + '=' + sbjs.account_id + data.delimiter +
72
- data.aliases.main.campaign_id + '=' + sbjs.campaign_id + data.delimiter +
73
- data.aliases.main.ad_group_id + '=' + sbjs.ad_group_id + data.delimiter +
74
- data.aliases.main.ad_id + '=' + sbjs.ad_id + data.delimiter +
75
- data.aliases.main.term_id + '=' + sbjs.term_id
76
- );
77
- },
78
-
79
- extra: function(timezone_offset) {
80
- return (
81
- data.aliases.extra.fire_date + '=' + utils.setDate(new Date, timezone_offset) + data.delimiter +
82
- data.aliases.extra.entrance_point + '=' + document.location.href + data.delimiter +
83
- data.aliases.extra.referer + '=' + (document.referrer || terms.none)
84
- );
85
- },
86
-
87
- user: function(visits, user_ip) {
88
- return (
89
- data.aliases.udata.visits + '=' + visits + data.delimiter +
90
- data.aliases.udata.ip + '=' + user_ip + data.delimiter +
91
- data.aliases.udata.agent + '=' + navigator.userAgent
92
- );
93
- },
94
-
95
- session: function(pages) {
96
- return (
97
- data.aliases.session.pages_seen + '=' + pages + data.delimiter +
98
- data.aliases.session.current_page + '=' + document.location.href
99
- );
100
- },
101
-
102
- promo: function(promo) {
103
- return (
104
- data.aliases.promo + '=' + utils.setLeadingZeroToInt(utils.randomInt(promo.min, promo.max), promo.max.toString().length)
105
- );
106
- }
107
-
108
- }
109
- };
110
-
111
- module.exports = data;
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- var delimiter = require('../data').delimiter;
4
-
5
- module.exports = {
6
-
7
- encodeData: function(s) {
8
- return encodeURIComponent(s).replace(/\!/g, '%21')
9
- .replace(/\~/g, '%7E')
10
- .replace(/\*/g, '%2A')
11
- .replace(/\'/g, '%27')
12
- .replace(/\(/g, '%28')
13
- .replace(/\)/g, '%29');
14
- },
15
-
16
- decodeData: function(s) {
17
- try {
18
- return decodeURIComponent(s).replace(/\%21/g, '!')
19
- .replace(/\%7E/g, '~')
20
- .replace(/\%2A/g, '*')
21
- .replace(/\%27/g, "'")
22
- .replace(/\%28/g, '(')
23
- .replace(/\%29/g, ')');
24
- } catch(err1) {
25
- // try unescape for backward compatibility
26
- try { return unescape(s); } catch(err2) { return ''; }
27
- }
28
- },
29
-
30
- set: function(name, value, minutes, domain, excl_subdomains) {
31
- var expires, basehost;
32
-
33
- if (minutes) {
34
- var date = new Date();
35
- date.setTime(date.getTime() + (minutes * 60 * 1000));
36
- expires = '; expires=' + date.toGMTString();
37
- } else {
38
- expires = '';
39
- }
40
- if (domain && !excl_subdomains) {
41
- basehost = ';domain=.' + domain;
42
- } else {
43
- basehost = '';
44
- }
45
- document.cookie = this.encodeData(name) + '=' + this.encodeData(value) + expires + basehost + '; path=/';
46
- },
47
-
48
- get: function(name) {
49
- var nameEQ = this.encodeData(name) + '=',
50
- ca = document.cookie.split(';');
51
-
52
- for (var i = 0; i < ca.length; i++) {
53
- var c = ca[i];
54
- while (c.charAt(0) === ' ') { c = c.substring(1, c.length); }
55
- if (c.indexOf(nameEQ) === 0) {
56
- return this.decodeData(c.substring(nameEQ.length, c.length));
57
- }
58
- }
59
- return null;
60
- },
61
-
62
- destroy: function(name, domain, excl_subdomains) {
63
- this.set(name, '', -1, domain, excl_subdomains);
64
- },
65
-
66
- parse: function(yummy) {
67
-
68
- var cookies = [],
69
- data = {};
70
-
71
- if (typeof yummy === 'string') {
72
- cookies.push(yummy);
73
- } else {
74
- for (var prop in yummy) {
75
- if (yummy.hasOwnProperty(prop)) {
76
- cookies.push(yummy[prop]);
77
- }
78
- }
79
- }
80
-
81
- for (var i1 = 0; i1 < cookies.length; i1++) {
82
- var cookie_array;
83
- data[this.unsbjs(cookies[i1])] = {};
84
- if (this.get(cookies[i1])) {
85
- cookie_array = this.get(cookies[i1]).split(delimiter);
86
- } else {
87
- cookie_array = [];
88
- }
89
- for (var i2 = 0; i2 < cookie_array.length; i2++) {
90
- var tmp_array = cookie_array[i2].split('='),
91
- result_array = tmp_array.splice(0, 1);
92
- result_array.push(tmp_array.join('='));
93
- data[this.unsbjs(cookies[i1])][result_array[0]] = this.decodeData(result_array[1]);
94
- }
95
- }
96
-
97
- return data;
98
-
99
- },
100
-
101
- unsbjs: function (string) {
102
- return string.replace('sbjs_', '');
103
- }
104
-
105
- };
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
-
5
- parse: function(str) {
6
- var o = this.parseOptions,
7
- m = o.parser[o.strictMode ? 'strict' : 'loose'].exec(str),
8
- uri = {},
9
- i = 14;
10
-
11
- while (i--) { uri[o.key[i]] = m[i] || ''; }
12
-
13
- uri[o.q.name] = {};
14
- uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
15
- if ($1) { uri[o.q.name][$1] = $2; }
16
- });
17
-
18
- return uri;
19
- },
20
-
21
- parseOptions: {
22
- strictMode: false,
23
- key: ['source','protocol','authority','userInfo','user','password','host','port','relative','path','directory','file','query','anchor'],
24
- q: {
25
- name: 'queryKey',
26
- parser: /(?:^|&)([^&=]*)=?([^&]*)/g
27
- },
28
- parser: {
29
- strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
30
- loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
31
- }
32
- },
33
-
34
- getParam: function(custom_params) {
35
- var query_string = {},
36
- query = custom_params ? custom_params : window.location.search.substring(1),
37
- vars = query.split('&');
38
-
39
- for (var i = 0; i < vars.length; i++) {
40
- var pair = vars[i].split('=');
41
- if (typeof query_string[pair[0]] === 'undefined') {
42
- query_string[pair[0]] = pair[1];
43
- } else if (typeof query_string[pair[0]] === 'string') {
44
- var arr = [ query_string[pair[0]], pair[1] ];
45
- query_string[pair[0]] = arr;
46
- } else {
47
- query_string[pair[0]].push(pair[1]);
48
- }
49
- }
50
- return query_string;
51
- },
52
-
53
- getHost: function(request) {
54
- return this.parse(request).host.replace('www.', '');
55
- }
56
-
57
- };
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
-
5
- escapeRegexp: function(string) {
6
- return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
7
- },
8
-
9
- setDate: function(date, offset) {
10
- var utc_offset = date.getTimezoneOffset() / 60,
11
- now_hours = date.getHours(),
12
- custom_offset = offset || offset === 0 ? offset : -utc_offset;
13
-
14
- date.setHours(now_hours + utc_offset + custom_offset);
15
-
16
- var year = date.getFullYear(),
17
- month = this.setLeadingZeroToInt(date.getMonth() + 1, 2),
18
- day = this.setLeadingZeroToInt(date.getDate(), 2),
19
- hour = this.setLeadingZeroToInt(date.getHours(), 2),
20
- minute = this.setLeadingZeroToInt(date.getMinutes(), 2),
21
- second = this.setLeadingZeroToInt(date.getSeconds(), 2);
22
-
23
- return (year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second);
24
- },
25
-
26
- setLeadingZeroToInt: function(num, size) {
27
- var s = num + '';
28
- while (s.length < size) { s = '0' + s; }
29
- return s;
30
- },
31
-
32
- randomInt: function(min, max) {
33
- return Math.floor(Math.random() * (max - min + 1)) + min;
34
- }
35
-
36
- };