1var Article, isLocalStorageSupported; 2 3isLocalStorageSupported = function() { 4 try { 5 if (window['localStorage'] != null) return true; 6 } catch (error) { 7 return false; 8 } 9}; 10 11Article = (function() { 12 13 Article.prototype.id = null; 14 15 Article.prototype.lastView = null; 16 17 Article.prototype.nowTimestamp = null; 18 19 Article.prototype.allViewed = {}; 20 21 Article.prototype.UUID = ''; 22 23 function Article() { 24 this.id = $('#post-view').data('id'); 25 if ((this.id != null) && isLocalStorageSupported()) { 26 this.loadViewsHistory(); 27 this.getTImestamp(); 28 this.getCode(); 29 this.updateData(); 30 } 31 } 32 33 Article.prototype.loadViewsHistory = function() { 34 var data; 35 if (!(this.viewsHistoryLoaded != null) && isLocalStorageSupported()) { 36 data = localStorage.getItem('news.viewed'); 37 this.allViewed = data ? JSON.parse(data) : {}; 38 if (this.id != null) this.lastView = this.allViewed[this.id]; 39 return this.viewsHistoryLoaded = true; 40 } 41 }; 42 43 Article.prototype.getTImestamp = function() { 44 return this.nowTimestamp = Math.round((new Date()).getTime() / 1000); 45 }; 46 47 Article.prototype.getCode = function() { 48 if ((this.id != null) && isLocalStorageSupported()) { 49 this.UUID = localStorage.getItem('my.UUID'); 50 if (!(this.UUID != null)) { 51 this.UUID = $("#gCode").val(); 52 if (this.UUID != null) localStorage.setItem('my.UUID', this.UUID); 53 } 54 } 55 return this.UUID; 56 }; 57 58 Article.prototype.updateData = function() { 59 if ((this.id != null) && isLocalStorageSupported()) { 60 61 if (typeof this.allViewed[this.id] === 'undefined') { 62 var url = $('#post-view').data('tracking-url'); 63 $.ajax({ 64 url: url, 65 type: 'POST', 66 dataType: 'json', 67 data: { 68 id: this.id 69 }, 70 71 success: function (data) { 72 // 73 }, 74 75 error: function (data) { 76 // 77 } 78 }); 79 } 80 this.allViewed[this.id] = this.getTImestamp(); 81 return localStorage.setItem('news.viewed', JSON.stringify(this.allViewed)); 82 } 83 }; 84 85 return Article; 86 87})(); 88 89if ($("#post-view").length) {
90 new Article(); 91}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.