Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(w) {
- var getParam = function (name) {
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
- var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
- results = regex.exec(w.location.search);
- return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
- },
- rc = function(n) {
- var c = document.cookie.match(new RegExp('(^|;)\\s*' + escape(n) + '=([^;\\s]*)'));
- return (c ? unescape(c[2]) : null);
- },
- paginate = function () {
- if (!w.aConf.pagination.singlePage) {
- document.write('<style>' + '.sa-a #a-cont .p {display:none;} .sa-a #a-cont .p.p' + page + ' {display:block;}' + '</style>');
- }
- },
- unblock_authors_pick = "false",
- noRBCheck = function(){
- return !!(log || fromPartner || fromInStream || !fromInsight || unblock_authors_pick === "true")
- },
- noRbStrategy = function () {
- noRBandPagination = (noRBCheck() || pages === 1 );
- w.aConf.pagination = {
- limit: pLimit,
- pages: pages,
- page: page,
- singlePage: noRBandPagination,
- singlePageBtn: false
- };
- w.aConf.roadblock = {
- timed: false,
- active: false,
- type: 'no_rb_strategy'
- };
- },
- softRbStrategy = function () {
- var hideRb = noRBCheck();
- w.aConf.pagination = {
- limit: 100,
- pages: pages,
- page: page,
- singlePage: hideRb,
- singlePageBtn: false
- };
- w.aConf.roadblock = {
- timed: !hideRb,
- active: !hideRb,
- type: 'soft_rb_strategy'
- };
- },
- hardRbStrategy = function () {
- firstArticle = parseInt(store.getItem('skipped_rb'), 10) === id;
- noRBandPagination = (noRBCheck() || pages === 1 );
- timedRBNotActive = noRBandPagination || (firstArticle && page === 1);
- rbNotActive = noRBandPagination || page < pLimit;
- w.aConf.pagination = {
- limit: pLimit,
- pages: pages,
- page: page,
- singlePage: noRBandPagination,
- singlePageBtn: false
- };
- w.aConf.roadblock = {
- timed: !timedRBNotActive,
- active: !rbNotActive,
- type: 'hard_rb_strategy'
- };
- };
- var pLimit = 2,
- pages = 6,
- log = rc('user_id'),
- p = parseInt(getParam('page'), 10) || 1,
- page = (p < 1) ? 1 : p,
- id = 4162910,
- source = rc('_sasource') || getParam('source') || '',
- store = w.sessionStorage,
- ls = w.localStorage,
- fromPartner = (/cnbc|marketwatch|aoldf|msn|nasdaq|bloomberg|partner_djnw|partner_thomsonreuters/).test(source),
- fromInStream = /instream/.test(source),
- fromInsight = true;
- try {
- if (!store.getItem('skipped_rb')) {
- store.setItem('skipped_rb', id);
- }
- } catch (e) {
- // do nothing
- }
- if (pages === 2) {
- pages = 3;
- }
- w.aConf = {};
- var firstArticle,
- noRBandPagination,
- timedRBNotActive,
- rbNotActive,
- rbType = (ls.getItem('roadblock_calc_type') || 'no_rb_strategy').trim();
- switch (rbType) {
- case 'no_rb_strategy':
- case 'control':
- noRbStrategy();
- break;
- case 'soft_rb_strategy':
- softRbStrategy();
- break;
- case 'hard_rb_strategy':
- hardRbStrategy();
- break;
- default:
- noRbStrategy();
- break;
- }
- paginate();
- }(window));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement