「ココログ用検索」の検索ボックスを任意のココログに

    
      
  • /*
     * @title 「ココログ用検索」の検索ボックスを任意のココログに
     * @description http://java.cocolog-nifty.com/blog/2005/10/javascript_c163.html の移植版(jQuery使用)
     * @include *
     * @license MIT License
     */
    
    (function(){
    'use strict';
    
    window.cocolog_ajax_search_options = {
        color : '#ffcc33'
    ,   truncation_length : 80
    ,   entry_per_page : 20
    ,   search_box_id : 'search_box'
    ,   search_credit_id : 'search_credit'
    ,   debug : true
    };
    
    function check() {
        var $ = window.jQuery;
        if (!$) {
            setTimeout(check, 100);
            return;
        }
        function addSearchForm() {
            var form = $([
                    '<form onsubmit="cocologAjaxSearch( null, jQuery(\'#' + cocolog_ajax_search_options.search_box_id + '\').val() ); return false">'
                ,   '    <input type="search" id="' + cocolog_ajax_search_options.search_box_id + '" name="search_box" value=""  results="5" autosave="tangerine" placeholder="検索語を入力" />'
                ,   '    <input type="submit" value="検索" />'
                ,   '    <span style="font-size: xx-small; margin-left: 4px;" id="' + cocolog_ajax_search_options.search_credit_id + '"></span>'
                ,   '</form>'
                ].join('\n')),
                old_form = $( '#' + cocolog_ajax_search_options.search_box_id ).parents('form').first();
            
            if ( 0 < old_form.size() ) {
                old_form.replaceWith(form);
            }
            else {
                $('#right,#left,div.module').first().prepend(form);
            }
        }
        addSearchForm();
        
        $.getScript('http://furyu.tea-nifty.com/script/jq-highlight.js', function() {
            $.getScript('http://furyu.tea-nifty.com/script/jq-cocolog_ajax_search.js', function() {
            });
        });
    }
    var script = document.createElement('script');
    script.src = '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js';
    document.documentElement.appendChild(script);
    check();
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2020/10/29 12:42:51 - 2020-10-29
  2. 2020/10/29 12:39:57 - 2020-10-29
  3. 2020/10/29 12:37:22 - 2020-10-29
  4. 2020/10/29 07:59:16 - 2020-10-29
  5. 2015/09/01 14:50:33 - 2015-09-01
  6. 2015/08/31 21:25:14 - 2015-08-31
  7. 2015/08/31 17:48:29 - 2015-08-31
  8. 2015/08/31 13:37:07 - 2015-08-31
  9. 2015/08/31 13:20:10 - 2015-08-31
  10. 2015/08/31 09:42:07 - 2015-08-31
  11. 2015/08/31 09:41:41 - 2015-08-31
  12. 2015/08/29 06:33:30 - 2015-08-29
  13. 2015/08/29 04:32:53 - 2015-08-29