Created
November 20, 2009 14:41
-
-
Save azu/239541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var w = unsafeWindow; | |
Mylist = { | |
// マイリストの属性 | |
/* | |
Mylist.groupListのツリー | |
id (number): マイリストID | |
user_id (number): マイリストのユーザーID | |
name (string): マイリストのタイトル | |
description (string): マイリスト説明文 | |
public (boolean): true // 公開状況 | |
default_sort (number): 1 (1-17) | |
create_time (number): UNIX時間(util.unix2で戻せる) | |
update_time (number): UNIX時間 | |
icon_id (number): 0 | |
sort_order (number): 0 | |
*/ | |
// Mylist.groupList - my.CurrentGroupのコピー | |
groupList: function () { | |
return w.my.currentGroup; | |
}, | |
/* | |
my.currentItemsのツリー | |
item_type (number): 0 | |
item_id (string): 接頭辞がない動画番号(常時) | |
description (string): マイリスト登録者による説明文 | |
item_data | |
video_id (string): 接頭辞がある動画番号(sm数字) | |
title (string): 動画タイトル | |
thumbnail_url (string): サムネイルURL | |
first_retrieve (number): 投稿日時(UNIX時間) | |
update_time (number): 更新日時(UNIX時間) | |
view_counter (string): 再生数 | |
mylist_counter (string): マイリスト数 | |
num_res (string): コメント数 | |
group_type (string): default | |
length_seconds (string): 再生時間(秒) | |
deleted (string): 0 (削除状態0-3?) | |
last_res_body (string): 最近のコメント(文字列) | |
watch_id (string): 接頭辞なしの動画番号(コミュ、マイメモリー以外だと接頭辞がある) | |
watch (number): 0 | |
create_time (number): マイリスト登録日時(UNIX時間) | |
update_time (number): マイリスト更新日時(UNIX時間) | |
*/ | |
// Mylist.itemList - my.currentItemsのコピー | |
itemList : function(){ | |
return w.my.currentItems; | |
}, | |
} | |
// utility関数群 | |
utils = { | |
playlength : transPlaylength, | |
unix2 : unixTodate, | |
clone : clone, | |
} | |
// 再生時間を分秒に変換 | |
function transPlaylength(length){ | |
return (length / 60).toFixed(2).toString().split(".").join("分") + "秒"; | |
} | |
// 10桁の数字(UNIXTIME)から2009/10/1 00:00形式で返す | |
function unixTodate(x){ | |
var t=new Date(x*1000); | |
return t.getFullYear() + "/" + fillZero(t.getMonth() + 1) + "/" + fillZero(t.getDate()) + " " + fillZero(t.getHours()) + ":" + fillZero(t.getMinutes()) + ":" + fillZero(t.getSeconds()); | |
} | |
// http://d.hatena.ne.jp/javascripter/20080514/1210791575 | |
// 先頭を0で埋める デフォルト2桁 | |
function fillZero(num , digit){ | |
var n = (digit) ? digit : 2;// デフォルト値 | |
var zero=new Array(n).join('0');//0をn-1文字分つなげた文字列を作る。n==4だと'000' | |
var str=zero+num;//zeroとthisをくっつけた文字列を作る。 | |
var result=str.substr(-n);//strの後ろから、n文字分の文字列を取ってくる。 | |
return result; | |
} | |
// オブジェクトのコピーのコピーを作成 | |
function clone(obj){ | |
return (typeof uneval == "function") ? eval(uneval(obj)) : false; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment