PageSourceSearch

https://hid.dosanko.co.jp/js/mylist.js

js dosanko.co.jp collected 2026-10-02 17:55:35 UTC 4,205 bytes, 168 lines download raw bytes

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.