PageSourceSearch

https://static.seesaawiki.jp/js/usr/second/wikier.js?0.8.610

js seesaawiki.jp collected 2026-09-27 20:54:39 UTC 12,862 bytes, 366 lines download raw bytes

1// common utils
2function stripTags(str) {
3    return str.replace(/<\/?[^>]+>/gi, '');
4}
5function escapeHTML (str) {
6    var div = document.createElement('div');
7    var text = document.createTextNode(str);
8    div.appendChild(text);
9    return div.innerHTML;
10}
11
12function ldw_unique_namespace(prefix, cb) {
13    if (!prefix) prefix = "ldwiki_tmp_";
14    var ns;
15    var limit = 3;
16    while (limit--) {
17        ns = prefix + Math.random().toString(36).slice(2);
18        if ( cb(ns) ) continue;
19        return ns;
20    }
21    return ns;
22}
23function ldw_unique_name(prefix) {
24    return ldw_unique_namespace(prefix, function(ns) {
25        return (window[name]) ? 1 : 0;
26    });
27}
28function ldw_unique_id(prefix) {
29    return ldw_unique_namespace(prefix, function(ns) {
30        return document.getElementById(ns) ? 1 : 0;
31    });
32}
33function ldw_user_wiki_url(path) {
34    if (!path) path = '';
35    var domain = location.host;
36    if ( /seesaawiki\.jp$/.test(domain) ) {
37        var url = location.href;
38
39        var result_w = url.match( /^(https?:\/\/)((?:stg\.)?seesaawiki\.jp\/w\/[^\/]+?\/)/ );
40        if (result_w && result_w.length == 3) {
41            return result_w[1] + (result_w[2] + path).replace(/\/{2,}/g, '/');
42        }
43
44        var result = url.match( /^(https?:\/\/)((?:stg\.)?seesaawiki\.jp\/[^\/]+?\/)/ );
45        if (result && result.length == 3) {
46            return result[1] + (result[2] + path).replace(/\/{2,}/g, '/');
47        }
48
49    }
50    else if ( /\.seesaa\.com$/.test(domain) ) {
51        var url = location.href;
52        var result = url.match(/seesaa\.com\/(?:w\/)?([^\/]+)/);
53        if (result) {
54            return '/' + result[1] + path;
55        }
56    }
57    return location.protocol + "//" + domain + path;
58}
59
60
61//cooperate with server side :-)  I have a id!
62function wikiJsonP(id,feed) {
63    var $ = jQuery;
64    var e = document.createElement("script"); 
65    e.type = "text/javascript";
66    e.src  = feed;
67    $('#img-' + id)[0].href = "javascript:Wikier.toggle('" + id + "' , 'tags')";
68    $('#label-' + id)[0].href = "javascript:Wikier.toggle('" + id + "' , 'tags')";
69    $('#'+id)[0].className = 'tags-box tags-open';
70    $('#ul-' + id)[0].className = 'list-pagelist-on';
71    $('#ul-' + id).html("<li>ÆÉ¤ß¹þ¤ßÃæ...</li>");
72    document.body.appendChild(e);
73}
74function wikiTags(id,json) {
75    var $ = jQuery;
76    if (json.status == 'ok' ) {
77        var names = json.names;
78        var html ='';
79        if( names.length == 0 ) {
80            html ='<li class="caution">´ØÏ¢¥Ú¡¼¥¸¤Ï¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£</li>';
81        }
82        else {
83            for( var i = 0 ; i < names.length; i++ ) {
84                html  += '<li><a href="' +  names[i].link + '">' +escapeHTML(names[i].label) + '</a></li>' + "\n";
85            }
86        }
87    }
88    else {
89        html = '<li class="caution">¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£</li>';
90    }
91    $('#img-' + id)[0].href = "javascript:Wikier.toggle('" + id + "' , 'tags')";
92    $('#label-' + id)[0].href = "javascript:Wikier.toggle('" + id + "' , 'tags')";
93    $('#'+id)[0].className = 'tags-box tags-open';
94    var $ul_id = $('#ul-' + id);
95    $ul_id[0].className = 'list-pagelist-on';
96    $ul_id.html(html);
97}
98
99Wikier = ( function(){
100    var $ = jQuery;
101    return {
102        toggle : ( function( id , type ) {
103            id_ele = $('#' + id)[0];
104            ul_id_ele = $('#ul-' + id )[0];
105            if( type == 'feed') {
106                if( id_ele.className  == 'feed-box feed-open' ) {
107                    id_ele.className = 'feed-box feed-close';
108                    ul_id_ele.className = 'list-pagelist';
109                }
110                else {
111                    id_ele.className = 'feed-box feed-open';
112                    ul_id_ele.className = 'list-pagelist-on';
113                }
114            }
115            else if( type == 'tags') {
116                if( id_ele.className  == 'tags-box tags-open' ) {
117                    id_ele.className = 'tags-box tags-close';
118                    ul_id_ele.className = 'list-pagelist';
119                }
120                else {
121                    id_ele.className = 'tags-box tags-open';
122                    ul_id_ele.className = 'list-pagelist-on';
123                }
124            }
125        })
126    }
127})();
128
129// no cooperation with this API server. I do not have id!
130// require auto generate callback function.
131if (!livedoorProfileFeed){
132    var livedoorProfileFeed = function (url, row, elm_id, opts) {
133        this.url            = url;
134        this.row            = Math.abs(row) ? Math.abs(row) > 10 ? 10 : Math.abs(row) : 5;
135        this.charset        = opts.charset ? opts.charset : 'euc-jp';
136        this.retry_cnt      = 10;
137        this.api_url        = this.base_url+'api/item/feed?url='+encodeURIComponent(this.url)+'&row='+this.row+'&oe='+this.charset;
138        this.elm_id         = elm_id;
139        this.inbox_id       = 'inbox-' + elm_id;
140        this.label_id       = 'label-' + elm_id;
141        this.list_id        = 'ul-'    + elm_id;
142        this.replace_title = opts.replace_title ;
143        var $list_id  = $('#' + this.list_id);
144        $list_id.html('<li class="caution">ÉÔÄ´¤Ë¤è¤êRSSµ­Ë¡¤Ï¸½ºßÄ´À°Ãæ¤Ç¤¹¡£</li>');
145    };
146}
147
148var NicoVideo = {
149    loadMylist: function(output_id, mylist_id, opts) {
150        var $ = jQuery;
151        var domain = "//" + location.hostname;
152        var api_url = domain + "/internal_api/nicovideo/getmylistinfo";
153        $.ajax({
154            type : 'POST',
155            url  : api_url,
156            data : { 'mylist_id':mylist_id},
157            dataType: 'json',
158            success : function (r) {
159                var json = r;
160                var html = '<p class="title"><a href="' + json.url + '">' + json.title + '</a></p>';
161                html += '<p class="description">' + json.description + '</p>';
162                html += '<ul class="movie-list">';
163                var video = json.videos;
164                for (var i=0,len=video.length; i<len; i++) {
165                    html += '<li><a href="' + video[i].url + '"><img src="' + video[i].thumbnail + '" alt="' + video[i].title + '" width="65" height="50" /></a></li>';
166                }
167                html += '</ul>';
168                $('#' + output_id).html(html);
169            },
170            error: function () {
171                var html = '¥Ë¥³¥Ë¥³Æ°²è <br />¤³¤Î¥Þ¥¤¥ê¥¹¥È¤Ïɽ¼¨¤Ç¤­¤Þ¤»¤ó¡£';
172                html += '¸½ºß¥¢¥¯¥»¥¹¤Ç¤­¤Ê¤¤¤«¡¢ºï½ü¤µ¤ì¤¿²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£';
173                $('#' + output_id).html(html);
174            }
175        });
176    }
177}
178
179if (!NicoNicoAPI){
180    var NicoNicoAPI = function (movie_id, elm_id, opts) {
181        this.base_url  = location.hostname + '/internal_api/nicovideo/';
182        this.api_url   = "//" + this.base_url + 'getthumbinfo';
183        this.elm_id    = elm_id;
184        this.movie_id  = movie_id;
185        this.opts = opts;
186        var obj = this;
187        setTimeout(function() { obj.getNicoVideo(); }, 100);
188    };
189    NicoNicoAPI.prototype = {
190        getNicoVideo : function() {
191            var $ = jQuery;
192            var obj = this;
193            $.ajax({
194                type : 'POST',
195                url  : obj.api_url, 
196                data : {'video_id' : this.movie_id },
197                dataType: 'json',
198                success : function (res) {
199                    obj.renderOutput(res);
200                },
201                error: function () {
202                    obj.errorMessage();
203                }
204            });
205        },
206        renderOutput : function(json) {
207            if (!json || !json.valid) {
208                this.errorMessage();
209                return;
210            }
211
212            if (this.opts.is_smartphone) {
213                var html = '<p class="title"><a href="' + json.watch_url + '">' + json.title + '</a></p>';
214                html += '<a href="' + json.watch_url + '"><img src="' + json.thumbnail_url + '" alt="' + json.title + '" /></a>';
215                html += '<p class="summary">' + json.description + '</p>';
216                document.getElementById(this.elm_id).innerHTML = html;
217            }
218            else {
219                var obj = this;
220                var html = '<iframe width="312" height="176" src="//www.nicovideo.jp/thumb/' + json.video_id + '" scrolling="no" style="border:solid 1px #ccc;" frameborder="0">';
221                html += '<a href="' + json.watch_url + '">' + stripTags(json.title) + '</a>';
222                html += '</iframe>';
223                document.getElementById(obj.elm_id).innerHTML = html;
224            }
225        },
226        errorMessage : function() {
227            var html = '¥Ë¥³¥Ë¥³Æ°²è <br />¤³¤Îư²è¤Ïɽ¼¨¤Ç¤­¤Þ¤»¤ó¡£';
228            html += '¸½ºß¥¢¥¯¥»¥¹¤Ç¤­¤Ê¤¤¤«¡¢»ëݤǤ­¤Ê¤¤¤«¡¢ºï½ü¤µ¤ì¤¿²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£';
229            document.getElementById(this.elm_id).innerHTML = html;
230        }
231    };
232}
233
234if (!RecentUpdateLog) {
235    var RecentUpdateLog = {
236        load: function(limit, id) {
237            if (!limit) limit = 10;
238            var url = ldw_user_wiki_url('/api/recent_update/');
239            jQuery.ajax({
240                type : 'POST',
241                url  : url,
242                data : { 'limit':limit},
243                dataType: 'json',
244                success : function (res) {
245                    RecentUpdateLog.render(res, id);
246                },
247                error: function (res) {
248                }
249            });
250        },
251
252        render: function(logs, id) {
253            var html = [];
254            for (var i=0,len=logs.length; i<len; i++) {
255                var permalink = ldw_user_wiki_url('/d/' + logs[i].encoded_name);
256                var updated_at = logs[i].lastupdate.replace(/^\d\d/, "").replace(/-/g, ".").replace(/:\d\d$/, "");
257                var pagename = logs[i].name;
258                html.push('<li>' + updated_at + ' <a href="' + permalink + '">' + pagename + '</a></li>');
259            }
260            jQuery('#'+id).html('<p class="title">ºÇ¶á¹¹¿·¤·¤¿¥Ú¡¼¥¸</p><ul>' + html.join('') + '</ul>');
261        }
262    };
263}
264
265
266
267jQuery(document).ready(function($){
268
269    doToggleRegion('menu','#sub');
270    doToggleRegion('wikipage','#main');
271    doToggleRegion('wikipage','#wikipage-article'); //smartphone
272
273    function doToggleRegion (type,wrapperId){
274        var cookieName = regionConfig()['cookieName'][type];
275        var regionToggleState = $.cookie(cookieName) || {};
276        
277        $(wrapperId + ' .toggle-link-close, ' + wrapperId + ' .toggle-link-open').each(function(){
278            var id = this.id;
279            
280            if (typeof regionToggleState[id] !== 'undefined') {
281                var statusName = (regionToggleState[id] == 1) ? 'toggle-link-open' : 'toggle-link-close';
282                if (this.className != statusName) {
283                    $(this).click();
284                }
285            }
286        });
287    }
288
289    $('.title-2-part-edit').hide();
290    $('.title-3-part-edit').hide();
291    $('.title-2, .title-3').hover(function(){
292        $(this).find('.part-edit').show();
293    },function(){
294        $(this).find('.part-edit').hide();
295    });
296    
297});
298
299
300function getWikiNameFromPath () {
301    var paths =  location.pathname.split('/');
302    paths.shift(); // trash empty string
303
304    var wikiname = (paths[0] == 'w') ? [paths[0],paths[1]].join('/') : paths[0];
305    return wikiname;
306}
307
308function regionConfig () {
309    return {
310        cookieName : {
311            menu:'StateOfRegionToggleInMenu',
312            wikipage:'StateOfRegionToggleInWikiPage'
313        }
314    };
315}
316
317function toggleRegion (toggleEle,hideContentId,smartphone) {
318    var $ = jQuery;
319    var $hideContent = $('#' + hideContentId);
320
321
322    if ( $hideContent.is(':hidden') ) {
323        $hideContent.show();
324        if(smartphone){
325            tableWrapper($($hideContent));// /js/wiki/lite/common.js
326        }
327        toggleEle.className = 'toggle-link-close';
328    } else {
329        $hideContent.hide();
330        toggleEle.className = 'toggle-link-open';
331    };
332
333    var cookiePath;
334    var cookieName;
335    if ( $hideContent.parents('#sub').length > 0 ) {
336        cookieName = regionConfig()['cookieName']['menu'];
337        cookiePath ='/'+ getWikiNameFromPath() + '/';
338    }else if ( $hideContent.parents('#main,#wikipage-article').length > 0 ) {
339        var cookieName = regionConfig()['cookieName']['wikipage'];
340        cookiePath = location.pathname;
341    }else{
342        return false;
343    }
344
345    var regionToggleState = $.cookie(cookieName) || {};
346    regionToggleState[toggleEle.id] = (toggleEle.className == 'toggle-link-open') ? 1 : 0; // save size of cookie 
347    $.cookie(cookieName,regionToggleState, { expires: 30, path: cookiePath });
348
349}
350
351function asUnknownUser() {
352    var $ = jQuery;
353    $('#captcha_form').show();
354    $('#unknown-user').show();
355    $('#livedoor-user').hide();
356    $('#no_livedoor_id').val(1);
357    $('#author').val('');
358}
359
360function asLivedoorUser() {
361    var $ = jQuery;
362    $('#captcha_form').hide();
363    $('#unknown-user').hide();
364    $('#livedoor-user').show();
365    $('#no_livedoor_id').val(0);
366}

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.