はてなキーワード: com.aとは
7と8。
技術的なところが気になる人はこれだけ読んでくれたらいい
最後に技術的な観点からエアレペルソナが純国産ではないということを指摘する。
RocketChatという海外で開発されたOSSチャットアプリをフォーク、改変したもののよう。
ttps://github.com/RocketChat/Rocket.Chat.ReactNative
ttps://rocket.chat
フォーク元はバリバリ多国籍、外資である。(RocketChat自体は問題のないアプリであり、このエアレペルソナとはフォーク関係を超える関係はないと思われる)
冒頭のこの部分に関してである。
ttps://play.google.com/store/apps/details?id=chat.airlex.reactnative
Google Playで公開されているエアレペルソナのAndroidアプリをリバースエンジニアリングして調べてみた。
ちなみに、エアレペルソナには利用規約のようなものは見当たらず、リバースエンジニアリング禁止条項も無いようだった。
ttps://apps.evozi.com/apk-downloader/
ttps://github.com/pxb1988/dex2jar
この辺を使ってapkをダウンロードし、apkを解凍し、chat.airlex.reactnative/classes.dexをjar fileに変換した。
classes.dexから変換されたjarファイルを展開するとchat/airlex/reactnativeというフォルダ、パッケージが見つかる。
このパッケージ内のファイル(.class、クラス)がエアレペルソナの処理を行うもののようである。
このクラスをJadを使い、デコンパイルしてみた。その結果が以下である。
ちなみにここからapkをアップロードするとdex2jarをしなくてもJavaのソースコードにまでデコンパイルしてくれた。便利。
package chat.airlex.reactnative; import android.content.Context; import com.ammarahmed.mmkv.SecureKeystore; import com.facebook.react.bridge.ReactApplicationContext; import com.tencent.mmkv.MMKV; public class Ejson { private String TOKEN_KEY = "reactnativemeteor_usertoken-"; String cardId; String host; String messageId; String messageType; /* access modifiers changed from: private */ public MMKV mmkv; String msg; String notificationType; String rid; Sender sender; String senderName; String type; public Ejson() { ReactApplicationContext reactApplicationContext = CustomPushNotification.reactApplicationContext; if (reactApplicationContext != null) { MMKV.initialize((Context) reactApplicationContext); new SecureKeystore(reactApplicationContext).getSecureKey(C0617Utils.toHex("com.MMKV.default"), new RNCallback() { public void invoke(Object... objArr) { if (objArr[0] == null) { MMKV unused = Ejson.this.mmkv = MMKV.mmkvWithID("default", 1, objArr[1]); } } }); } } public String getAvatarUri() { if (this.type == null) { return null; } return serverURL() + "/avatar/" + this.sender._id + "?rc_token=" + token() + "&rc_uid=" + userId(); } public String token() { String userId = userId(); MMKV mmkv2 = this.mmkv; return (mmkv2 == null || userId == null) ? "" : mmkv2.decodeString(this.TOKEN_KEY.concat(userId)); } public String userId() { String serverURL = serverURL(); MMKV mmkv2 = this.mmkv; return (mmkv2 == null || serverURL == null) ? "" : mmkv2.decodeString(this.TOKEN_KEY.concat(serverURL)); } public String privateKey() { String serverURL = serverURL(); MMKV mmkv2 = this.mmkv; if (mmkv2 == null || serverURL == null) { return null; } return mmkv2.decodeString(serverURL.concat("-RC_E2E_PRIVATE_KEY")); } public String serverURL() { String str = this.host; return (str == null || !str.endsWith("/")) ? str : str.substring(0, str.length() - 1); } public class Sender { String _id; String username; public Sender() { } } }
フィールド名を見てみると、cardId, host, messageId, messageType, mmkv, msg, notificationType, rid, sender, senderName, typeが存在する。
メソッドには、getAvaterUri、token、userId、privateKey、severURLが存在する。
ところで、RocketChatというOSSのチャットアプリが存在する。
ttps://rocket.chat
そのRoketChatのAndroid実装の中に同名のEjsonというクラスが存在する。
ttps://github.com/RocketChat/Rocket.Chat.ReactNative
ttps://github.com/RocketChat/Rocket.Chat.ReactNative/blob/develop/android/app/src/play/java/chat/rocket/reactnative/Ejson.java
見比べてみると、フィールドにcardIdが追加されている以外はフィールドやメソッド名、そしてその処理の内容まで一致している。
他にもReplyBroadcastなど、同様のクラスがエアレペルソナに見つかる。
以上のことからエアレペルソナはRocketChatをフォークして、パッケージ名を変えて作られたチャットアプリであり、開発の大部分はRocketChat社の努力と多数のOSSコントリビュータによってなされたものであると思われる。
そもそもこのOSS時代に純だの何だの言っている時点で怪しい。
さて、エアレペルソナがRocketChatをフォークして作られたものであるとすると、気になるのはライセンスである。
RocketChatのOSSライセンスはMITライセンスである。
ttps://github.com/RocketChat/Rocket.Chat.ReactNative/blob/develop/LICENSE
MITライセンスは非常に緩いライセンスであるため、エアレペルソナの様にフォークして別のアプリケーションとして公開することにはおそらく問題がないということは強調しておく。
現状エアレペルソナにログインできておらず(2要素認証のコードが送信されないといった問題が起きている模様)、使用している各OSSのライセンス表示が適切に行われているかまでは調べられていない。
なぜ 君が機会を得られたにもかかわらずPHEICの宣言を一度見送ったのか!
その答えは
IHR緊急委員会(15名 from 13ヶ国 [1])が国際的に懸念される公衆衛生上の緊急事態(PHEIC)宣言に足るだけのエビデンスを見出せなかったから。
1月21、22日時点では中国外の感染者数が4~6人だけであり[2]、ヒト‐ヒト感染の強さも不明で、暫定的にR0は1.4〜2.5(季節性インフルエンザ~新型インフルエンザくらい)と推定されていた。(後の研究で、R0は4.7~6.6(天然痘や風疹レベル)くらいだと推定されている[3]。)
また、ちょうどWHOの専門家が武漢入りして調査を開始したところであり、その結果を待つ意味もあった。
そういうわけで「今はデータが足りないから保留。10日以内にもっかい検討するからその時にまた呼んで」との結論に至ったわけだ。
この見送りを中国への忖度と呼ぶ向きもあるが、過去のPHEIC宣言と比較してもそこに特別な違いは見られない。
また、「PHEIC宣言は時期尚早」というのは当時の緊急委員会が至った結論であり、それに同意したからといってテドロス局長を責めるのもお門違いであろう。
また個人的な感想だが、PHEIC見送りに関する非難には、人々のPHEICに対する認識もかかわっているのではないか。
「PHEIC宣言がなされなければ各国は対策の取りようがない」等々、PHEICを疫病対策の“起点”としてとらえるような認識だ。
一方のWHO、PHEICは“最後の切り札”と考えている模様[4]。
「データは提供する、ガイドラインも制定する、ガイダンスだって発布するから、あとは各国で適切な対応をしてくれ。もし怠るようならPHEIC宣言でケツ蹴っ飛ばしたる」と、そんな感じ。
「エビデンスは無いけど念のため」程度で宣言できるほどPHEICは軽くないのだ。
ただし、そういう時に使える“軽い警告”を制定するべきだとの議論は以前からあったため、それはそれでWHOの怠慢と言えなくもない。
長年のWHOの方針である。2009年に初めてPHEICを宣言した際も渡航制限を推奨していない[5]。
その理由は、渡航制限がパンデミックの防止に寄与するというエビデンスが乏しく、むしろ条件によっては有害ですらあるからだ(※)。
複数の研究[6][7][8][9][10]――2014年にはWHO自身が23の研究を用いたレビュー論文を出している[11]――によれば、厳しい渡航制限(全渡航の90~99%をシャットダウン)は感染拡大を数週間ほど遅らせる可能性があるが、最終的な感染者数と規模は据え置きである。
※ PHEICが宣言されるような状況に限れば。感染発生の最初期であれば話は別。例えば昨年11月末に全世界で渡航制限が行われていれば新型コロナの流行はなかっただろう。
各研究をまとめると、
・患者の総数が変わらないとしても、時間当たりの患者数は減るため、対応能力の低い国においてキャパシティオーバーを緩和できる。
・予防接種や治療薬が存在している場合、それらの準備を整えるまでの時間稼ぎになる。(今回のコロナ禍には当てはまらない)
・流行期間が延びるため、社会的対応(ロックダウン等)の継続時間も延びる。
WHO的に、渡航制限は高い経済的コスト、低い効果、そしていくつかのデメリットの存在から推奨されない。
全く無意味というわけではないが、より有効な政策――手洗い等の徹底、適切なスクリーニング及び隔離、ソーシャルディスタンシング(社会的距離をもたせるような政策。ロックダウンも含む)――にその分のリソースを振り分けるのが好ましい。
これらはあくまで過去のエビデンスに基づいており、将来の研究にて今回の新型コロナについては渡航制限が有効であったとのエビデンスが出るかもしれない。
しかし、“エビデンスに基づき結果的に間違った”対処を貶め、“エビデンスに基づかないが結果的に正しかった”対処を褒めることには同意できない。
諸君は↑の2項目について「中国への媚」と思っていたのだろうが(あとは台湾への対応か)、実際のところエビデンスベースな判断であり、発生国が中国以外でもWHOの対応は同じだった可能性が高い。
しかし、中国への批判を控えたり、台湾の冷遇、ちょくちょくあるリップサービス等、WHOが医学とは別の領域において中国へ甘い対応をしているのは事実。
なぜか?
テドロス局長の場合は簡単だ。政治的な支持基盤が主にアフリカ系とアジア系であり中国の存在が非常にでかい。なので中国批判はあまりしないし、リップサービスもする。 中国を称賛した回数はトランプのがテドロスより多いのだが[12]。
WHO全体でみるとどうか。金に媚びてることはない。チャイナマネーとは比べ物にならないほどのアメリカマネーとゲイツマジェスティがWHOに注ぎ込まれている。
WHOの宿痾として、情報提供を加盟国の善意に頼るしかないという問題がある。専門家/調査員を送り込むにも当該国の許可がいるため、独自の情報収集もできない。
中国を批判してデータが出てくる――「中国さん。あなた隠ぺいしてますね」「はい。申し訳ありません。これが隠ぺい前のデータです」――なんてことはない。
ゆえに政治や義理人情や感情に惑わされず医学的なベストを尽くすなら、中国を刺激せずに気持ちよくデータを渡してもらうことが最適解になる。(本当のベストは中国が正直に全データを差し出してくれることだが、実現不可能な案に拘泥するのはワーストである)
「(WHOは)何のための組織なんだ」「政治より医学を優先しろ」という感じのブコメも見かけたが、医学を最優先とし、組織の使命を突き詰めて、そうして達する結論が“中国のご機嫌とり”にならざるを得ないこの地獄よ。
オーストラリアなんかはこの問題を正確に認識していて、「(拠出金削減よりも)WHOの権限をより強化し、強制的な査察権の付与等をすべきだ」という提言をしている[13]。
ちなみに「中国抜きで新組織作れよ」的な冗談も目にしたが、それまた現実的ではない。
中国は世界最大の人口、広大な国土に加え多数の国と国境を接している。国際的な人の出入りは膨大な数に上り、貿易も盛んだ。民間レベルの医療水準は高くなく、貧富の差が激しく、人々は頻繁に生きた動物と接触する。そのうえ、国家は隠ぺい体質だ。
疫病、特に人獣共通感染症の発生源として絶対に無視し得ない国、それが中国。
今回のコロナ禍で中国からの情報が一切なければどうなっていたかを考えれば答えは明らかだろう。まさに大地獄。
故に切れない。切ってはいけない。
[1] ttps://www.who.int/ihr/procedures/novel-coronavirus-2019/ec-22012020-members/en/
[2] ttps://www.who.int/emergencies/diseases/novel-coronavirus-2019/situation-reports
[3] ttps://doi.org/10.1101/2020.02.07.20021154
[4] ttps://doi.org/10.4000%2Fpoldev.2178
[5] ttps://www.who.int/csr/disease/swineflu/guidance/public_health/travel_advice/en/
[6] ttps://doi.org/10.1038/nm0506-497
[7] ttps://dx.doi.org/10.1371%2Fjournal.pmed.0030212
[8] ttps://dx.doi.org/10.1371%2Fjournal.pone.0000401
[9] ttps://doi.org/10.1371/journal.pone.0016591
[10] ttps://doi.org/10.2807/1560-7917.ES2014.19.42.20936
[11] ttps://www.who.int/bulletin/volumes/92/12/14-135590/en/
[12] ttps://www.politico.com/news/2020/04/15/trump-china-coronavirus-188736
[13] ttps://www.smh.com.au/politics/federal/australia-wants-who-to-have-same-powers-of-weapons-inspectors-20200422-p54m7i.html
[[Markonah]] => (Zootopia) full.MOVIE.P.utlocker.1080p - Cancer ...
www.cancerconnections.com.au › ... › Forums › Discussion
11 mins ago - Watch Zootopia Online Free (2016) Stream HD Putlocker , Now!! Watch ... WATCH HERE http://bit.ly/1TPv0w9. WATCH HERE ... Group content.
imgfave.com/new
http://www.cancerconnections.com.au/content/markonah-zootopia-fullmovieputlocker1080p · Watch X-Men: Apocalypse Online Free M... about 6 mins ago.
imgfave.com/view/7122945
http://www.cancerconnections.com.au/content/markonah-zootopia-fullmovieputlocker1080p. fave; add to collection; reblog on tumblr; post to facebook; post to ...
Last 6 reports on domain: www.cancerconnections.com.au - urlquery.net
urlquery.net/report.php?id=1465139193165
9 mins ago - URL, www.cancerconnections.com.au/content/markonah-zootopia-fullmovieputlocker1080p. IP, 106.187.97.233. ASN, AS2516 KDDI ...
[[Markonah]] => (Zootopia) full.MOVIE.P.utlocker.1080p ... - Verify
www.verify-www.com/...cancerconnections.com.au/content/markonah-zootopia-full...
site address: www.cancerconnections.com.au/content/markonah-zootopia-fullmovieputlocker1080p. site title: [[Markonah]] = (Zootopia) full.MOVIE.P.utlocker.1080p | Cancer Connections supports people affected by cancer. Our opinion: ... Proceed to the page?Powered by: Very Tiny URL Shortener at http://vturl.net ...
Facebook Open Graph URL Check - FB Meta Info Tool
www.facebookog.com/sites/www.reddit.../287c61bddc7085a929d98ba296348d68
http://www.cancerconnections.com.au/content/markonah-zootopia-fullmovieputlocker1080p · http://www.cancerconnections.com.au/content/markonah-zootopia- ...
Facebook Open Graph URL Check - FB Meta Info Tool
www.facebookog.com/sites/aeterna.qip.ru/.../7d6947f2763ceb6a6ed01aa5dcac7919
http://aeterna.qip.ru/test/view/6016743/https://disqus.com/home/channel/theweather/ ... http://www.cancerconnections.com.au/content/markonah-zootopia- ...
[[Markonah]] => (Captain America: Civil War) full.MOVIE.P.utlocker ...
www.cancerconnections.com.au › ... › Forums › Discussion
10 mins ago - Watch Captain America: Civil War Online Free (2016) Stream HD Putlocker , Now!! Watch ... WATCH HERE http://bit.ly/1TPv0w9. WATCH ...
GooglePing - Ping Search Engines
googleping.com/
... at 2016-06-05 15:08:56 71 pings sent for http://www.cancerconnections.com.au/content/markonah-captain-america-civil-war-fullmovieputlocker1080p ...
open /var/mobile/Library/Preferences/com.apple.restrictionspassword.plist
you can find this kinds:
<key>RestrictionsPasswordKey</key>
<data>
xxxxxxxxxxxxxxxxxxxxxxxxxxx=
</data>
<key>RestrictionsPasswordSalt</key>
<data>
XXXXXX==
</data>
$ key=```echo "key" | base64 -d | xxd -p```
$ salt=```echo "salt" | base64 -d | xxd -p```
finally try matching hashed 0000~9999(PBKDF2-HMAC-SHA1, salt=salt, iterations=1000) and the given key
more info: http://hashcat.net/forum/archive/index.php?thread-2892.html
ニッチ過ぎて需要がないかもしれんが、幸せになる人がいるかもしれないのでここに残しておく。シムフリーiPhone5にSoftBankの4 / 4SのSIMカードを普通に挿すと、LTE契約を前提とした接続設定がされてしまいデータ通信が利用できない。今ネット上で手に入る対策は、どの方法を使っても設定できるのはAPNのみでMMSの設定を編集できないので3G通信はできてもMMS、キャリアメールは使えないという片手落ち状態になっている(iOS7では、非公式キャリアのSIMを挿抜すればMMS、APNの設定画面が残ってしまうバグが修正されている)。この度、iOS7をいれたシムフリーiPhone5で両方を有効にすることができたので報告する。シムロックがかかったiPhone5や、iPhone5S、5Cでも使えるかどうかは環境が無いためわからない。が、シムフリー5S / 5C では使える可能性が高いと思われる。また、もちろん大前提としてmicroSIMサイズの黒SIMをnanoSIMサイズに各自カットしてiPhone5に挿入済みのこと。
シムフリーiPhone5に黒SIMを入れると、iOSに最初からインストールされているSoftBankのキャリアバンドルにもとづいて設定されてしまうため、LTEサービス用のAPNが有効になってしまい、しかもiPhone上で設定することができない。そこで、Apple公式サイトから設定プロファイルを作ることができるiPhone構成ユーティリティーをダウンロードし、3G通信用のAPNを設定してやる。
アップル公式サイトからSoftBankのキャリアバンドルファイルをダウンロードし、編集。Carrier Testing Modeで起動したiTunesを使ってiPhone5内部のキャリアバンドルを上書きする。
はじめにiTunesが起動していないことを確認。
コマンドプロンプトを開き、
"%ProgramFiles%\iTunes\iTunes.exe" /setPrefInt carrier-testing 1
ターミナルを開き、
defaults write com.apple.iTunes carrier-testing -bool YES
見にくいだろうが・・・
最期まで読まないと文意が分からない日本語のマズさと一緒だよ。Amazon.comだろうとAmazon.co.jpだろうと、最初の方を読んだだけで、Amazonという重要なことがわかる。
com.amazonやjp.co.amazonでは、最初の方を見ただけではアメリカとか日本とか、どうでもいいことしかわからない。
トップレベルドメインがhttpのあとに来た方が大分類>中分類>小分類になって自然。http://com.hatena.diary/hogeなど
大事なことを先に書く今の方式のほうが優秀。
詳細は以下の通り。
English Russia ?? An Ancient Fortress on the Island
http://englishrussia.com/?p=1206
誰が置いたのか分からないです。詳細は以下の通り。
Jumbo Lego man all washed up : thewest.com.au
http://www.thewest.com.au/default.aspx?MenuID=29&ContentID=36837
大きな黒い壁のようなもの、これ実は世界最大の写真なんだそうです。
詳細は以下の通り。
The Legacy Project
/* Ten */
if (typeof(Ten) == 'undefined') {
Ten = {};
}
Ten.NAME = 'Ten';
Ten.VERSION = 0.06;
/* Ten.Class */
Ten.Class = function(klass, prototype) {
if (klass && klass.initialize) {
var c = klass.initialize;
} else if(klass && klass.base) {
var c = function() { return klass.base[0].apply(this, arguments) };
} else {
var c = function() {};
}
c.prototype = prototype || {};
c.prototype.constructor = c;
Ten.Class.inherit(c, klass);
if (klass && klass.base) {
for (var i = 0; i < klass.base.length; i++) {
var parent = klass.base[i];
if (i == 0) {
c.SUPER = parent;
c.prototype.SUPER = parent.prototype;
}
Ten.Class.inherit(c, parent);
Ten.Class.inherit(c.prototype, parent.prototype);
}
}
return c;
}
Ten.Class.inherit = function(child,parent) {
for (var prop in parent) {
if (typeof(child[prop]) != 'undefined' || prop == 'initialize') continue;
child[prop] = parent[prop];
}
}
/*
// Basic Ten Classes
**/
/* Ten.JSONP */
Ten.JSONP = new Ten.Class({
initialize: function(uri,obj,method) {
if (Ten.JSONP.Callbacks.length) {
setTimeout(function() {new Ten.JSONP(uri,obj,method)}, 500);
return;
}
var del = uri.match(/\?/) ? '&' : '?';
uri += del + 'callback=Ten.JSONP.callback';
if (!uri.match(/timestamp=/)) {
uri += '&' + encodeURI(new Date());
}
if (obj && method) Ten.JSONP.addCallback(obj,method);
this.script = document.createElement('script');
this.script.src = uri;
this.script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(this.script);
},
addCallback: function(obj,method) {
Ten.JSONP.Callbacks.push({object: obj, method: method});
},
callback: function(args) {
// alert('callback called');
var cbs = Ten.JSONP.Callbacks;
for (var i = 0; i < cbs.length; i++) {
var cb = cbs[i];
cb.object[cb.method].call(cb.object, args);
}
Ten.JSONP.Callbacks = [];
},
MaxBytes: 8000,
Callbacks: []
});
/* Ten.XHR */
Ten.XHR = new Ten.Class({
initialize: function(uri,opts,obj,method) {
if (!uri) return;
this.request = Ten.XHR.getXMLHttpRequest();
this.callback = {object: obj, method: method};
var xhr = this;
var prc = this.processReqChange;
this.request.onreadystatechange = function() {
prc.apply(xhr, arguments);
}
var method = opts.method || 'GET';
this.request.open(method, uri, true);
if (method == 'POST') {
this.request.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
}
var data = opts.data ? Ten.XHR.makePostData(opts.data) : null;
this.request.send(data);
},
getXMLHttpRequest: function() {
var xhr;
var tryThese = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
];
for (var i = 0; i < tryThese.length; i++) {
var func = tryThese[i];
try {
xhr = func;
return func();
} catch (e) {
//alert(e);
}
}
return xhr;
},
makePostData: function(data) {
var pairs = [];
var regexp = /%20/g;
for (var k in data) {
var v = data[k].toString();
var pair = encodeURIComponent(k).replace(regexp,'+') + '=' +
encodeURIComponent(v).replace(regexp,'+');
pairs.push(pair);
}
return pairs.join('&');
}
},{
processReqChange: function() {
var req = this.request;
if (req.readyState == 4) {
if (req.status == 200) {
var cb = this.callback;
cb.object[cb.method].call(cb.object, req);
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
}
}
}
});
/* Ten.Observer */
Ten.Observer = new Ten.Class({
initialize: function(element,event,obj,method) {
var func = obj;
if (typeof(method) == 'string') {
func = obj[method];
}
this.element = element;
this.event = event;
this.listener = function(event) {
return func.call(obj, new Ten.Event(event || window.event));
}
if (this.element.addEventListener) {
if (this.event.match(/^on(.+)$/)) {
this.event = RegExp.$1;
}
this.element.addEventListener(this.event, this.listener, false);
} else if (this.element.attachEvent) {
this.element.attachEvent(this.event, this.listener);
}
}
},{
stop: function() {
if (this.element.removeEventListener) {
this.element.removeEventListener(this.event,this.listener,false);
} else if (this.element.detachEvent) {
this.element.detachEvent(this.event,this.listener);
}
}
});
/* Ten.Event */
Ten.Event = new Ten.Class({
initialize: function(event) {
this.event = event;
},
keyMap: {
8:"backspace", 9:"tab", 13:"enter", 19:"pause", 27:"escape", 32:"space",
33:"pageup", 34:"pagedown", 35:"end", 36:"home", 37:"left", 38:"up",
39:"right", 40:"down", 44:"printscreen", 45:"insert", 46:"delete",
112:"f1", 113:"f2", 114:"f3", 115:"f4", 116:"f5", 117:"f6", 118:"f7",
119:"f8", 120:"f9", 121:"f10", 122:"f11", 123:"f12",
144:"numlock", 145:"scrolllock"
}
},{
mousePosition: function() {
if (!this.event.clientX) return;
return Ten.Geometry.getMousePosition(this.event);
},
isKey: function(name) {
var ecode = this.event.keyCode;
if (!ecode) return;
var ename = Ten.Event.keyMap[ecode];
if (!ename) return;
return (ename == name);
},
targetIsFormElements: function() {
var target = this.event.target;
if (!target) return;
var T = (target.tagName || '').toUpperCase();
return (T == 'INPUT' || T == 'SELECT' || T == 'OPTION' ||
T == 'BUTTON' || T == 'TEXTAREA');
},
stop: function() {
var e = this.event;
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
} else {
e.cancelBubble = true;
e.returnValue = false;
}
}
});
/* Ten.DOM */
Ten.DOM = new Ten.Class({
getElementsByTagAndClassName: function(tagName, className, parent) {
if (typeof(parent) == 'undefined') {
parent = document;
}
var children = parent.getElementsByTagName(tagName);
if (className) {
var elements = [];
for (var i = 0; i < children.length; i++) {
var child = children[i];
var cls = child.className;
if (!cls) {
continue;
}
var classNames = cls.split(' ');
for (var j = 0; j < classNames.length; j++) {
if (classNames[j] == className) {
elements.push(child);
break;
}
}
}
return elements;
} else {
return children;
}
},
removeEmptyTextNodes: function(element) {
var nodes = element.childNodes;
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
node.parentNode.removeChild(node);
}
}
},
nextElement: function(elem) {
do {
elem = elem.nextSibling;
} while (elem && elem.nodeType != 1);
return elem;
},
prevElement: function(elem) {
do {
elem = elem.previousSibling;
} while (elem && elem.nodeType != 1);
return elem;
},
scrapeText: function(node) {
var rval = [];
(function (node) {
var cn = node.childNodes;
if (cn) {
for (var i = 0; i < cn.length; i++) {
arguments.callee.call(this, cn[i]);
}
}
var nodeValue = node.nodeValue;
if (typeof(nodeValue) == 'string') {
rval.push(nodeValue);
}
})(node);
return rval.join('');
},
onLoadFunctions: [],
loaded: false,
timer: null,
addEventListener: function(event,func) {
if (event != 'load') return;
Ten.DOM.onLoadFunctions.push(func);
Ten.DOM.checkLoaded();
},
checkLoaded: function() {
var c = Ten.DOM;
if (c.loaded) return true;
if (document && document.getElementsByTagName &&
document.getElementById && document.body) {
if (c.timer) {
clearInterval(c.timer);
c.timer = null;
}
for (var i = 0; i < c.onLoadFunctions.length; i++) {
c.onLoadFunctions[i]();
}
c.onLoadFunctions = [];
c.loaded = true;
} else {
c.timer = setInterval(c.checkLoaded, 13);
}
}
});
/* Ten.Style */
Ten.Style = new Ten.Class({
applyStyle: function(elem, style) {
for (prop in style) {
elem.style[prop] = style[prop];
}
}
});
/* Ten.Geometry */
Ten.Geometry = new Ten.Class({
initialize: function() {
if (Ten.Geometry._initialized) return;
var func = Ten.Geometry._functions;
var de = document.documentElement;
if (window.innerWidth) {
func.getWindowWidth = function() { return window.innerWidth; }
func.getWindowHeight = function() { return window.innerHeight; }
func.getXScroll = function() { return window.pageXOffset; }
func.getYScroll = function() { return window.pageYOffset; }
} else if (de && de.clientWidth) {
func.getWindowWidth = function() { return de.clientWidth; }
func.getWindowHeight = function() { return de.clientHeight; }
func.getXScroll = function() { return de.scrollLeft; }
func.getYScroll = function() { return de.scrollTop; }
} else if (document.body.clientWidth) {
func.getWindowWidth = function() { return document.body.clientWidth; }
func.getWindowHeight = function() { return document.body.clientHeight; }
func.getXScroll = function() { return document.body.scrollLeft; }
func.getYScroll = function() { return document.body.scrollTop; }
}
Ten.Geometry._initialized = true;
},
_initialized: false,
_functions: {},
getScroll: function() {
if (!Ten.Geometry._initialized) new Ten.Geometry;
return {
x: Ten.Geometry._functions.getXScroll(),
y: Ten.Geometry._functions.getYScroll()
};
},
getMousePosition: function(pos) {
// pos should have clientX, clientY same as mouse event
if ((navigator.userAgent.indexOf('Safari') > -1) &&
(navigator.userAgent.indexOf('Version/') < 0)) {
return {
x: pos.clientX,
y: pos.clientY
};
} else {
var scroll = Ten.Geometry.getScroll();
return {
x: pos.clientX + scroll.x,
y: pos.clientY + scroll.y
};
}
},
getElementPosition: function(e) {
return {
x: e.offsetLeft,
y: e.offsetTop
};
},
getWindowSize: function() {
if (!Ten.Geometry._initialized) new Ten.Geometry;
return {
w: Ten.Geometry._functions.getWindowWidth(),
h: Ten.Geometry._functions.getWindowHeight()
};
}
});
/* Ten.Position */
Ten.Position = new Ten.Class({
initialize: function(x,y) {
this.x = x;
this.y = y;
},
subtract: function(a,b) {
return new Ten.Position(a.x - b.x, a.y - b.y);
}
});
/*
// require Ten.js
**/
/* Ten.SubWindow */
Ten.SubWindow = new Ten.Class({
initialize: function() {
var c = this.constructor;
if (c.singleton && c._cache) {
return c._cache;
}
var div = document.createElement('div');
Ten.Style.applyStyle(div, Ten.SubWindow._baseStyle);
Ten.Style.applyStyle(div, c.style);
this.window = div;
this.addContainerAndCloseButton();
document.body.appendChild(div);
if (c.draggable) {
this._draggable = new Ten.Draggable(div, this.handle);
}
if (c.singleton) c._cache = this;
return this;
},
_baseStyle: {
color: '#000',
position: 'absolute',
display: 'none',
zIndex: 2,
left: 0,
top: 0,
backgroundColor: '#fff',
border: '1px solid #bbb'
},
style: {
padding: '2px',
textAlign: 'center',
borderRadius: '6px',
MozBorderRadius: '6px',
width: '100px',
height: '100px'
},
handleStyle: {
position: 'absolute',
top: '0px',
left: '0px',
backgroundColor: '#f3f3f3',
borderBottom: '1px solid #bbb',
width: '100%',
height: '30px'
},
containerStyle: {
margin: '32px 0 0 0',
padding: '0 10px'
},
// closeButton: 'close.gif',
closeButton: 'http://s.hatena.com/images/close.gif',
closeButtonStyle: {
position: 'absolute',
top: '8px',
right: '10px',
cursor: 'pointer'
},
_baseScreenStyle: {
position: 'absolute',
top: '0px',
left: '0px',
display: 'none',
zIndex: 1,
overflow: 'hidden',
width: '100%',
height: '100%'
},
screenStyle: {},
showScreen: true,
singleton: true,
draggable: true,
_cache: null
},{
screen: null,
windowObserver: null,
visible: false,
addContainerAndCloseButton: function() {
var win = this.window;
var c = this.constructor;
var div = document.createElement('div');
win.appendChild(div);
Ten.Style.applyStyle(div, c.containerStyle);
this.container = div;
if (c.handleStyle) {
var handle = document.createElement('div');
Ten.Style.applyStyle(handle, c.handleStyle);
win.appendChild(handle);
this.handle = handle;
}
if (c.closeButton) {
var btn = document.createElement('img');
btn.src = c.closeButton;
btn.alt = 'close';
Ten.Style.applyStyle(btn, c.closeButtonStyle);
win.appendChild(btn);
new Ten.Observer(btn, 'onclick', this, 'hide');
this.closeButton = btn;
}
if (c.showScreen) {
var screen = document.createElement('div');
Ten.Style.applyStyle(screen, Ten.SubWindow._baseScreenStyle);
Ten.Style.applyStyle(screen, c.screenStyle);
document.body.appendChild(screen);
this.screen = screen;
new Ten.Observer(screen, 'onclick', this, 'hide');
}
},
show: function(pos) {
pos = (pos.x && pos.y) ? pos : {x:0, y:0};
with (this.window.style) {
display = 'block';
left = pos.x + 'px';
top = pos.y + 'px';
}
if (this.screen) {
with (this.screen.style) {
display = 'block';
left = Ten.Geometry.getScroll().x + 'px';
top = Ten.Geometry.getScroll().y + 'px';
}
}
this.windowObserver = new Ten.Observer(document.body, 'onkeypress', this, 'handleEscape');
this.visible = true;
},
handleEscape: function(e) {
if (!e.isKey('escape')) return;
this.hide();
},
hide: function() {
if (this._draggable) this._draggable.endDrag();
this.window.style.display = 'none';
if (this.screen) this.screen.style.display = 'none';
if (this.windowObserver) this.windowObserver.stop();
this.visible = false;
}
});
/* Ten.Draggable */
Ten.Draggable = new Ten.Class({
initialize: function(element,handle) {
this.element = element;
this.handle = handle || element;
this.startObserver = new Ten.Observer(this.handle, 'onmousedown', this, 'startDrag');
this.handlers = [];
}
},{
startDrag: function(e) {
if (e.targetIsFormElements()) return;
this.delta = Ten.Position.subtract(
e.mousePosition(),
Ten.Geometry.getElementPosition(this.element)
);
this.handlers = [
new Ten.Observer(document, 'onmousemove', this, 'drag'),
new Ten.Observer(document, 'onmouseup', this, 'endDrag'),
new Ten.Observer(this.element, 'onlosecapture', this, 'endDrag')
];
e.stop();
},
drag: function(e) {
var pos = Ten.Position.subtract(e.mousePosition(), this.delta);
Ten.Style.applyStyle(this.element, {
left: pos.x + 'px',
top: pos.y + 'px'
});
e.stop();
},
endDrag: function(e) {
for (var i = 0; i < this.handlers.length; i++) {
this.handlers[i].stop();
}
if(e) e.stop();
}
});
/* Hatena */
if (typeof(Hatena) == 'undefined') {
Hatena = {};
}
/* Hatena.User */
Hatena.User = new Ten.Class({
initialize: function(name) {
this.name = name;
},
getProfileIcon: function(name) {
if (!name) name = 'user';
var pre = name.match(/^[\w-]{2}/)[0];
var img = document.createElement('img');
img.src = 'http://www.hatena.ne.jp/users/' + pre + '/' + name + '/profile_s.gif';
img.alt = name;
img.setAttribute('class', 'profile-icon');
img.setAttribute('width','16px');
img.setAttribute('height','16px');
with (img.style) {
margin = '0 3px';
border = 'none';
verticalAlign = 'middle';
}
return img;
}
}, {
profileIcon: function() {
return Hatena.User.getProfileIcon(this.name);
}
});
/* Hatena.Star */
if (typeof(Hatena.Star) == 'undefined') {
Hatena.Star = {};
}
/*
// Hatena.Star.* classes //
**/
if (window.location && window.location.host.match(/hatena\.com/)) {
Hatena.Star.BaseURL = 'http://s.hatena.com/';
} else {
Hatena.Star.BaseURL = 'http://s.hatena.ne.jp/';
}
Hatena.Star.Token = null;
/* Hatena.Star.User */
Hatena.Star.User = new Ten.Class({
base: [Hatena.User],
initialize: function(name) {
if (Hatena.Star.User._cache[name]) {
return Hatena.Star.User._cache[name];
} else {
this.name = name;
Hatena.Star.User._cache[name] = this;
return this;
}
},
_cache: {}
},{
userPage: function() {
return Hatena.Star.BaseURL + this.name + '/';
}
});
/* Hatena.Star.Entry */
Hatena.Star.Entry = new Ten.Class({
initialize: function(e) {
this.entry = e;
this.uri = e.uri;
this.title = e.title;
this.star_container = e.star_container;
this.comment_container = e.comment_container;
this.stars = [];
this.comments = [];
},
maxStarCount: 11
},{
flushStars: function() {
this.stars = [];
this.star_container.innerHTML = '';
},
bindStarEntry: function(se) {
this.starEntry = se;
for (var i = 0; i < se.stars.length; i++) {
if (typeof(se.stars[i]) == 'number') {
this.stars.push(new Hatena.Star.InnerCount(se.stars[i],this));
} else {
this.stars.push(new Hatena.Star.Star(se.stars[i]));
}
}
if (se.comments && !this.comments.length) {
for (var i = 0; i < se.comments.length; i++) {
this.comments.push(new Hatena.Star.Comment(se.comments[i]));
}
}
this.can_comment = se.can_comment;
},
setCanComment: function(v) {
this.can_comment = v;
},
showButtons: function() {
this.addAddButton();
this.addCommentButton();
},
addAddButton: function() {
if (this.star_container) {
this.addButton = new Hatena.Star.AddButton(this);
this.star_container.appendChild(this.addButton);
}
},
addCommentButton: function() {
if (this.comment_container) {
this.commentButton = new Hatena.Star.CommentButton(this);
this.comment_container.appendChild(this.commentButton.img);
}
},
showStars: function() {
var klass = this.constructor;
// if (this.stars.length > klass.maxStarCount) {
// var ic = new Hatena.Star.InnerCount(this.stars.slice(1,this.stars.length));
// this.star_container.appendChild(this.stars[0]);
// this.star_container.appendChild(ic);
// this.star_container.appendChild(this.stars[this.stars.length - 1]);
// } else {
for (var i = 0; i < this.stars.length; i++) {
this.star_container.appendChild(this.stars[i]);
}
},
showCommentButton: function() {
if (this.can_comment) {
this.commentButton.show();
if (this.comments.length) this.commentButton.activate();
} else {
// this.commentButton.hide();
}
},
addStar: function(star) {
this.stars.push(star);
this.star_container.appendChild(star);
},
addComment: function(com) {
if (!this.comments) this.comments = [];
if (this.comments.length == 0) {
this.commentButton.activate();
}
this.comments.push(com);
},
showCommentCount: function() {
this.comment_container.innerHTML += this.comments.length;
}
});
/* Hatena.Star.Button */
Hatena.Star.Button = new Ten.Class({
createButton: function(args) {
var img = document.createElement('img');
img.src = args.src;
img.alt = img.title = args.alt;
with (img.style) {
cursor = 'pointer';
margin = '0 3px';
padding = '0';
border = 'none';
verticalAlign = 'middle';
}
return img;
}
});
/* Hatena.Star.AddButton */
Hatena.Star.AddButton = new Ten.Class({
base: ['Hatena.Star.Button'],
initialize: function(entry) {
this.entry = entry;
this.lastPosition = null;
var img = Hatena.Star.Button.createButton({
src: Hatena.Star.AddButton.ImgSrc,
alt: 'Add Star'
});
this.observer = new Ten.Observer(img,'onclick',this,'addStar');
this.img = img;
return img;
},
ImgSrc: Hatena.Star.BaseURL + 'images/add.gif'
},{
addStar: function(e) {
this.lastPosition = e.mousePosition();
var uri = Hatena.Star.BaseURL + 'star.add.json?uri=' + encodeURIComponent(this.entry.uri) +
'&title=' + encodeURIComponent(this.entry.title);
if (Hatena.Star.Token) {
uri += '&token=' + Hatena.Star.Token;
}
new Ten.JSONP(uri, this, 'receiveResult');
},
receiveResult: function(args) {
var name = args ? args.name : null;
if (name) {
this.entry.addStar(new Hatena.Star.Star({name: name}));
//alert('Succeeded in Adding Star ' + args);
} else if (args.errors) {
var pos = this.lastPosition;
pos.x -= 10;
pos.y += 25;
var scroll = Ten.Geometry.getScroll();
var scr = new Hatena.Star.AlertScreen();
var alert = args.errors[0];
scr.showAlert(alert, pos);
}
}
});
/* Hatena.Star.CommentButton */
Hatena.Star.CommentButton = new Ten.Class({
base: ['Hatena.Star.Button'],
initialize: function(entry) {
this.entry = entry;
this.lastPosition = null;
var img = Hatena.Star.Button.createButton({
src: Hatena.Star.CommentButton.ImgSrc,
alt: 'Comments'
});
img.style.display = 'none';
this.observer = new Ten.Observer(img,'onclick',this,'showComments');
this.img = img;
},
ImgSrc: Hatena.Star.BaseURL + 'images/comment.gif',
ImgSrcActive: Hatena.Star.BaseURL + 'images/comment_active.gif'
},{
showComments: function(e) {
if (!this.screen) this.screen = new Hatena.Star.CommentScreen();
this.screen.bindEntry(this.entry);
var pos = e.mousePosition();
pos.y += 25;
this.screen.showComments(this.entry, pos);
},
hide: function() {
this.img.style.display = 'none';
},
show: function() {
this.img.style.display = 'inline';
},
activate: function() {
this.show();
this.img.src = Hatena.Star.CommentButton.ImgSrcActive;
}
});
/* Hatena.Star.Star */
Hatena.Star.Star = new Ten.Class({
initialize: function(args) {
if (args.img) {
this.img = args.img;
this.name = this.img.getAttribute('alt');
} else {
this.name = args.name;
var img = document.createElement('img');
img.src = Hatena.Star.Star.ImgSrc;
img.alt = this.name;
with (img.style) {
padding = '0';
border = 'none';
}
this.img = img;
}
new Ten.Observer(this.img,'onmouseover',this,'showName');
new Ten.Observer(this.img,'onmouseout',this,'hideName');
if (this.name) {
this.user = new Hatena.Star.User(this.name);
this.img.style.cursor = 'pointer';
new Ten.Observer(this.img,'onclick',this,'goToUserPage');
}
if (args.count && args.count > 1) {
var c = document.createElement('span');
c.setAttribute('class', 'hatena-star-inner-count');
Ten.Style.applyStyle(c, Hatena.Star.InnerCount.style);
c.innerHTML = args.count;
var s = document.createElement('span');
s.appendChild(img);
s.appendChild(c);
return s;
} else {
return this.img;
}
},
ImgSrc: Hatena.Star.BaseURL + 'images/star.gif'
},{
showName: function(e) {
if (!this.screen) this.screen = new Hatena.Star.NameScreen();
var pos = e.mousePosition();
pos.x += 10;
pos.y += 25;
this.screen.showName(this.name, pos);
},
hideName: function() {
if (!this.screen) return;
this.screen.hide();
},
goToUserPage: function() {
window.location = this.user.userPage();
}
});
/* Hatena.Star.InnerCount */
Hatena.Star.InnerCount = new Ten.Class({
initialize: function(count, e) {
this.count = count;
this.entry = e;
var c = document.createElement('span');
c.setAttribute('class', 'hatena-star-inner-count');
Ten.Style.applyStyle(c, Hatena.Star.InnerCount.style);
c.style.cursor = 'pointer';
c.innerHTML = count;
new Ten.Observer(c,'onclick',this,'showInnerStars');
this.container = c;
return c;
},
style: {
color: '#f4b128',
fontWeight: 'bold',
fontSize: '80%',
fontFamily: '"arial", sans-serif',
margin: '0 2px'
}
},{
showInnerStars: function() {
var url = Hatena.Star.BaseURL + 'entry.json?uri=' +
encodeURIComponent(this.entry.uri);
new Ten.JSONP(url, this, 'receiveStarEntry');
},
receiveStarEntry: function(res) {
var se = res.entries[0];
var e = this.entry;
if (encodeURIComponent(se.uri) != encodeURIComponent(e.uri)) return;
e.flushStars();
e.bindStarEntry(se);
e.addAddButton();
e.showStars();
}
});
/* Hatena.Star.Comment */
Hatena.Star.Comment = new Ten.Class({
initialize: function(args) {
this.name = args.name;
this.body = args.body;
}
},{
asElement: function() {
var div = document.createElement('div');
with (div.style) {
margin = '0px 0';
padding = '5px 0';
borderBottom = '1px solid #ddd';
}
var ico = Hatena.User.getProfileIcon(this.name);
div.appendChild(ico);
var span = document.createElement('span');
with(span.style) {
fontSize = '90%';
}
span.innerHTML = this.body;
div.appendChild(span);
return div;
}
});
/* Hatena.Star.NameScreen */
Hatena.Star.NameScreen = new Ten.Class({
base: [Ten.SubWindow],
style: {
padding: '2px',
textAlign: 'center'
},
containerStyle: {
margin: 0,
padding: 0
},
handleStyle: null,
showScreen: false,
closeButton: null,
draggable: false
},{
showName: function(name, pos) {
this.container.innerHTML = '';
this.container.appendChild(Hatena.User.getProfileIcon(name));
this.container.appendChild(document.createTextNode(name));
this.show(pos);
}
});
/* Hatena.Star.AlertScreen */
Hatena.Star.AlertScreen = new Ten.Class({
base: [Ten.SubWindow],
style: {
padding: '2px',
textAlign: 'center',
borderRadius: '6px',
MozBorderRadius: '6px',
width: '240px',
height: '120px'
},
handleStyle: {
position: 'absolute',
top: '0px',
left: '0px',
backgroundColor: '#f3f3f3',
borderBottom: '1px solid #bbb',
width: '100%',
height: '30px',
borderRadius: '6px 6px 0 0',
MozBorderRadius: '6px 6px 0 0'
}
},{
showAlert: function(msg, pos) {
this.container.innerHTML = msg;
var win = Ten.Geometry.getWindowSize();
var scr = Ten.Geometry.getScroll();
var w = parseInt(this.constructor.style.width) + 20;
if (pos.x + w > scr.x + win.w) pos.x = win.w + scr.x - w;
this.show(pos);
}
});
/* Hatena.Star.CommentScreen */
Hatena.Star.CommentScreen = new Ten.Class({
base: [Ten.SubWindow],
initialize: function() {
var self = this.constructor.SUPER.call(this);
if (!self.commentsContainer) self.addCommentsContainer();
return self;
},
style: {
width: '280px',
height: '280px',
overflowY: 'auto',
padding: '2px',
textAlign: 'center',
borderRadius: '6px',
MozBorderRadius: '6px'
},
handleStyle: {
position: 'absolute',
top: '0px',
left: '0px',
backgroundColor: '#f3f3f3',
borderBottom: '1px solid #bbb',
width: '100%',
height: '30px',
borderRadius: '6px 6px 0 0',
MozBorderRadius: '6px 6px 0 0'
},
containerStyle: {
margin: '32px 0 0 0',
textAlign: 'left',
padding: '0 10px'
},
getLoadImage: function() {
var img = document.createElement('img');
img.src = Hatena.Star.BaseURL + 'images/load.gif';
img.setAttribute('alt', 'Loading');
with (img.style) {
verticalAlign = 'middle';
margin = '0 2px';
}
return img;
}
},{
addCommentsContainer: function() {
var div = document.createElement('div');
with (div.style) {
marginTop = '-3px';
}
this.container.appendChild(div);
this.commentsContainer = div;
},
showComments: function(e, pos) {
var comments = e.comments;
if (!comments) comments = [];
this.commentsContainer.innerHTML = '';
for (var i=0; i<comments.length; i++) {
this.commentsContainer.appendChild(comments[i].asElement());
}
if (e.starEntry && !e.can_comment) {
this.hideCommentForm();
} else {
this.addCommentForm();
}
var win = Ten.Geometry.getWindowSize();
var scr = Ten.Geometry.getScroll();
var w = parseInt(this.constructor.style.width) + 20;
if (pos.x + w > scr.x + win.w) pos.x = win.w + scr.x - w;
this.show(pos);
},
bindEntry: function(e) {
this.entry = e;
},
sendComment: function(e) {
if (!e.isKey('enter')) return;
var body = this.commentInput.value;
if (!body) return;
this.commentInput.disabled = 'true';
this.showLoadImage();
var url = Hatena.Star.BaseURL + 'comment.add.json?body=' + encodeURIComponent(body) +
'&uri=' + encodeURIComponent(this.entry.uri) +
'&title=' + encodeURIComponent(this.entry.title);
new Ten.JSONP(url, this, 'receiveResult');
},
receiveResult: function(args) {
if (!args.name || !args.body) return;
this.commentInput.value = '';
this.commentInput.disabled = '';
this.hideLoadImage();
var com = new Hatena.Star.Comment(args);
this.entry.addComment(com);
this.commentsContainer.appendChild(com.asElement());
},
showLoadImage: function() {
if (!this.loadImage) return;
this.loadImage.style.display = 'inline';
},
hideLoadImage: function() {
if (!this.loadImage) return;
this.loadImage.style.display = 'none';
},
hideCommentForm: function() {
if (!this.commentForm) return;
this.commentForm.style.display = 'none';
},
addCommentForm: function() {
if (this.commentForm) {
this.commentForm.style.display = 'block';
return;
}
var form = document.createElement('div');
this.container.appendChild(form);
this.commentForm = form;
with (form.style) {
margin = '0px 0';
padding = '5px 0';
// borderTop = '1px solid #ddd';
}
//if (Hatena.Visitor) {
// form.appendChild(Hatena.Visitor.profileIcon());
//} else {
// form.appendChild(Hatena.User.getProfileIcon());
//}
var input = document.createElement('input');
input.type = 'text';
with (input.style) {
width = '215px';
border = '1px solid #bbb';
padding = '3px';
}
form.appendChild(input);
this.commentInput = input;
var img = this.constructor.getLoadImage();
this.loadImage = img;
this.hideLoadImage();
form.appendChild(img);
new Ten.Observer(input,'onkeypress',this,'sendComment');
}
});
/* Hatena.Star.EntryLoader */
Hatena.Star.EntryLoader = new Ten.Class({
initialize: function() {
var entries = Hatena.Star.EntryLoader.loadEntries();
this.entries = [];
for (var i = 0; i < entries.length; i++) {
var e = new Hatena.Star.Entry(entries[i]);
e.showButtons();
this.entries.push(e);
}
this.getStarEntries();
},
createStarContainer: function() {
var sc = document.createElement('span');
sc.setAttribute('class', 'hatena-star-star-container');
sc.style.marginLeft = '1px';
return sc;
},
createCommentContainer: function() {
var cc = document.createElement('span');
cc.setAttribute('class', 'hatena-star-comment-container');
cc.style.marginLeft = '1px';
return cc;
},
scrapeTitle: function(node) {
var rval = [];
(function (node) {
if (node.tagName == 'SPAN' &&
(node.className == 'sanchor' ||
node.className == 'timestamp')) {
return;
} else if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
return;
}
var cn = node.childNodes;
if (cn) {
for (var i = 0; i < cn.length; i++) {
arguments.callee.call(this, cn[i]);
}
}
var nodeValue = node.nodeValue;
if (typeof(nodeValue) == 'string') {
rval.push(nodeValue);
}
})(node);
return rval.join('');
},
headerTagAndClassName: ['h3',null],
getHeaders: function() {
var t = Hatena.Star.EntryLoader.headerTagAndClassName;
return Ten.DOM.getElementsByTagAndClassName(t[0],t[1],document);
},
loadEntries: function() {
var entries = [];
//var headers = document.getElementsByTagName('h3');
var c = Hatena.Star.EntryLoader;
var headers = c.getHeaders();
for (var i = 0; i < headers.length; i++) {
var header = headers[i];
var a = header.getElementsByTagName('a')[0];
if (!a) continue;
var uri = a.href;
var title = '';
// Ten.DOM.removeEmptyTextNodes(header);
var cns = header.childNodes;
title = c.scrapeTitle(header);
var cc = c.createCommentContainer();
header.appendChild(cc);
var sc = c.createStarContainer();
header.appendChild(sc);
entries.push({
uri: uri,
title: title,
star_container: sc,
comment_container: cc
});
}
return entries;
}
},{
getStarEntries: function() {
var url = Hatena.Star.BaseURL + 'entries.json?';
for (var i = 0; i < this.entries.length; i++) {
if (url.length > Ten.JSONP.MaxBytes) {
new Ten.JSONP(url, this, 'receiveStarEntries');
url = Hatena.Star.BaseURL + 'entries.json?';
}
url += 'uri=' + encodeURIComponent(this.entries[i].uri) + '&';
}
new Ten.JSONP(url, this, 'receiveStarEntries');
},
receiveStarEntries: function(res) {
var entries = res.entries;
if (!entries) entries = [];
for (var i = 0; i < this.entries.length; i++) {
var e = this.entries[i];
for (var j = 0; j < entries.length; j++) {
var se = entries[j];
if (!se.uri) continue;
if (encodeURIComponent(se.uri) == encodeURIComponent(e.uri)) {
e.bindStarEntry(se);
entries.splice(j,1);
break;
}
}
if (typeof(e.can_comment) == 'undefined') {
e.setCanComment(res.can_comment);
}
e.showStars();
e.showCommentButton();
}
}
});
/* Hatena.Star.WindowObserver */
Hatena.Star.WindowObserver = new Ten.Class({
initialize: funct