1var Mylist = (function() { 2 3 var domain = $("#mylist_publicdomain").val(); // domain 4 var mylist = []; 5 var mylist_count = 'mylist_count_' + domain; // ãã¡ã¤ã³ãã¨ã«ç®¡ç 6 var mylist_prefix = 'mylist_' + domain + '_'; // ãã¡ã¤ã³ãã¨ã«ç®¡ç 7 var separator = '\t'; 8 var values = []; 9 var itemName = function(index) { 10 return mylist_prefix + index; 11 } 12 13 14 var getItem = function(ix) { 15 var cookie = getCookie(itemName(ix)); 16 var item = cookie.split(separator); 17 return { 18 title: item[0], 19 url: item[1] 20 }; 21 22 }; 23 24 var update = function() { 25 var count = mylist.length; 26 if (count) { 27 var html = ''; 28 for (var i = 0; i < count; i++) { 29 var item = values['mylist_item']; 30 for (var key in mylist[i]) { 31 item = item.split('{{' + key + '}}').join(mylist[i][key]); 32 } 33 html += item; 34 } 35 $('#mylist').html(html); 36 37 } else { 38 $('#mylist').html(values['mylist_none']); 39 40 } 41 var title = $('input[name="hotnews_title"]').val(); 42 var url = location.href; 43 if (itemExists(title, url)) { 44 $('.mylist_btn').html('ãã¤ãªã¹ãããåé¤ãã'); 45 $('.mylist_btn').addClass('delete'); 46 } 47 }; 48ã 49 var addItem = function(title, url) { 50 var count = mylist.length; 51 setCookieTitleUrl(itemName(count), title, url); 52 setCookie(mylist_count, ++count); 53 54 mylist.push({ 55 title: title, 56 url: url 57 58 }); 59 $('.mylist_btn').html('ãã¤ãªã¹ãããåé¤ãã'); 60 $('.mylist_btn').addClass('delete'); 61 62 }; 63 64 var removeUrl = function(url) { 65 var count = mylist.length; 66 for (var i = 0; i < count; i++) { 67 if (mylist[i].url == url) { 68 mylist.splice(i, 1); 69 count--; 70 resetCookie(itemName(count)); 71 setCookie(mylist_count, count); 72 for (var j = 0; j < count; j++) { 73 setCookieTitleUrl(itemName(j), mylist[j].title, mylist[j].url); 74 } 75 $('.mylist_btn').html('ãã¤ãªã¹ãã«è¿½å ãã'); 76 $('.mylist_btn').removeClass('delete'); 77 return true; 78 79 } 80 } 81 return false; 82 }; 83 84 var itemExists = function(title, url) { 85 var count = mylist.length; 86 for (var i = 0; i < count; i++) { 87 if (mylist[i].url == url) { 88 89 return true; 90 } 91 } 92 return false; 93 }; 94 95 var setCookieTitleUrl = function(name, title, url) { 96 setCookie(name, title + separator + url); 97 }; 98 99 var setCookie = function(name, value) { 100 var COOKIE_DATE = 43200; // save attr 30days 101 xDay = new Date; 102 xDay.setMinutes(xDay.getMinutes() + COOKIE_DATE); 103 document.cookie = name + '=' + encodeURIComponent(value) + ';expires=' + xDay.toGMTString() + ';path=/'; 104 105 }; 106 107 108 var getCookie = function(name) { 109 var all = document.cookie; 110 if (all != '') { 111 var cookies = all.split(';'); 112 for (var i = 0; i < cookies.length; i++) { 113 var cookie = cookies[i].split('='); 114 if (cookie[0].replace(/^\s+/, "") == name) { 115 return decodeURIComponent(cookie[1]); 116 } 117 } 118 } 119 return ''; 120 121 122 }; 123 124 var resetCookie = function(name) { 125 var date = new Date(0); 126 document.cookie = name + '=;expires=' + date.toGMTString(); 127 128 129 } 130 131 var globals = { 132 133 setup: function() { 134 var count = getCookie(mylist_count); 135 mylist = []; 136 for (var i = 0; i < count; i++) { 137 mylist.push(getItem(i)); 138 } 139 update(); 140 }, 141 addPage: function() { 142 var title = $('input[name="hotnews_title"]').val(); 143 var url = location.href; 144 if (itemExists(title, url)) { 145 this.removePage(url); 146 update(); 147 } else { 148 addItem(title, url); 149 update(); 150 } 151 }, 152 removePage: function(url) { 153 if (removeUrl(url)) { 154 ã $('.mylist_btn').html('ãã¤ãªã¹ãã«è¿½å ãã'); 155 ãã$('.mylist_btn').removeClass('delete');ã 156 ã update(); 157 } 158 }, 159 set: function(name, value) { 160 values[name] = value; 161 console.log(value); 162 163 } 164 165 }; 166 167 return globals; 168})();
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.