darekagakaku days--

    @@ -1,36 +1,55 @@ /* - * @title darekagakaku digging - * @description darekagakaku nikki de kako ni moguru + * @title darekagakaku timemachine + * @description dive into darekagakaku. more deep, deep, deeper * @include http://darekagakaku.herokuapp.com/* + * @include https://darekagakaku.herokuapp.com/* * @license MIT License + * @see http://let.hatelabo.jp/taizooo/let/gYC-ycuH_KPtfg (Fork of) */ +// [Changes] +// - code beautify +// - peitit refactoring -function trim(num, l) { - if (num < 0) { - num = -(num); - } - if (typeof (num) != 'string') { - num = '' + num; - } - var s = l - num.length; - while (s > 0) { - num = '0' + num; - --s; - } - return num; -}; -function nday(a) { - y=a.getFullYear(),m=a.getMonth()+1,d=a.getDate(); - x=trim(y,4)+'-'+trim(m,2)+'-'+trim(d,2); - return x; -} -x=location.pathname.substr(3).split('-'); -y=x[0],m=x[1]-1,d=x[2]; -z=new Date(y, m, d); -z.setDate(z.getDate()-1); // -1day -u='http://darekagakaku.herokuapp.com/'; -if(location.href.indexOf(u)==-1) { - location.href=u; -} else { - location.pathname='/v/'+nday(z); -} +// TODO create dkkDate{} and encapsulation methods and property +(function () { + var trim = function (num, l) { + if (num < 0) { + num = -(num); // absolutize: Math.abs(num) + } + if (typeof (num) !== 'string') { + num = '' + num; // stringfy: String(num) + } + var s = l - num.length; // zero-fill / zero-padding: slice(-l) + while(s > 0) { + num = '0' + num; + --s; + } + return num; + }; + + var toDBDateString = function (date) { + var y = date.getFullYear(), + m = date.getMonth() + 1, + d = date.getDate(); + return trim(y, 4) + '-' + trim(m, 2) + '-' + trim(d, 2); + }; + + (function () { + var date = location.pathname.slice(3).split('-'); + if (!date || date.length < 3) return; + + var year = date[0], + month = date[1] - 1, + day = date[2]; + + var eve = new Date(year, month, day); + eve.setDate(eve.getDate() - 1); // -1day + + var origin = 'https://darekagakaku.herokuapp.com/'; + if (location.href.indexOf(origin) === -1) { + location.href = origin; + } else { + location.pathname = '/v/' + toDBDateString(eve); + } + })(); +})();
  • /*
     * @title darekagakaku timemachine
     * @description dive into darekagakaku. more deep, deep, deeper
     * @include http://darekagakaku.herokuapp.com/*
     * @include https://darekagakaku.herokuapp.com/*
     * @license MIT License
     * @see http://let.hatelabo.jp/taizooo/let/gYC-ycuH_KPtfg (Fork of)
     */
    // [Changes]
    // - code beautify
    // - peitit refactoring
    
    // TODO create dkkDate{} and encapsulation methods and property
    (function () {
        var trim = function (num, l) {
            if (num < 0) {
                num = -(num); // absolutize: Math.abs(num)
            }
            if (typeof (num) !== 'string') {
                num = '' + num; // stringfy: String(num)
            }
            var s = l - num.length; // zero-fill / zero-padding: slice(-l)
            while(s > 0) {
                num = '0' + num;
                --s;
            }
            return num;
        };
    
        var toDBDateString = function (date) {
            var y = date.getFullYear(),
                m = date.getMonth() + 1,
                d = date.getDate();
            return trim(y, 4) + '-' + trim(m, 2) + '-' + trim(d, 2);
        };
    
        (function () {
            var date = location.pathname.slice(3).split('-');
            if (!date || date.length < 3) return;
            
            var year = date[0],
                month = date[1] - 1,
                day = date[2];
            
            var eve = new Date(year, month, day);
            eve.setDate(eve.getDate() - 1); // -1day
            
            var origin = 'https://darekagakaku.herokuapp.com/';
            if (location.href.indexOf(origin) === -1) {
                location.href = origin;
            } else {
                location.pathname = '/v/' + toDBDateString(eve);
            }
        })();
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2012/05/04 00:08:07 - 2012-05-04
  2. 2012/05/03 06:11:16 - 2012-05-03
  3. 2012/05/03 06:10:10 - 2012-05-03
  4. 2012/05/03 06:05:50 - 2012-05-03
  5. 2012/05/03 05:46:55 - 2012-05-03
  6. 2012/05/03 02:54:37 - 2012-05-03
  7. 2012/05/03 02:54:27 - 2012-05-03