【ココログ】メンテナンス・障害情報を表示するスクリプト
<div id="cocoTrouble-maintenance-info">
<div class="cocoTroubleTitle"><a href="http://support.nifty.com/support/cs/maintenance/supinfo/cocolog/1.htm">メンテナンス情報</a></div>
<div class="cocoTrouble-update" id="cocoTrouble-update-maintenance" style="display:none;"></div>
<ul id="cocoTrouble-maintenance"></ul>
</div><!-- id="cocoTrouble-maintenance-info" -->
<div id="cocoTrouble-trouble-info">
<div class="cocoTroubleTitle"><a href="http://support.nifty.com/support/cs/trouble/supinfo/cocolog/1.htm">トラブル情報</a></div>
<div class="cocoTrouble-update" id="cocoTrouble-update-trouble" style="display:none;"></div>
<ul id="cocoTrouble-trouble"></ul>
</div><!-- id="cocoTrouble-trouble-info" -->
</div><!-- id="cocoTrouble" -->
<script type="text/javascript" >
<!--
var cocoTrouble = {
// ===
newperiod : { /* 表示期間(終了日時からの時間(hours)) */
trouble : 48
, maintenance : 24
}
, notrouble : { /* 情報無しの場合表示する文字列 */
trouble : 'ありません。'
, maintenance : 'ありません。'
}
// ===
, info : new Array()
// ===
, loadComplete : function ( kind ) {
var list = document.getElementById('cocoTrouble-'+kind) ;
if ( !list ) return false ;
var printInfo = '' ;
for ( var ci=0; ci < this.info[kind].data.length-1; ci++ ) {
var info = this.info[kind].data[ci] ;
var now = (new Date()).getTime() ;
var todate = Date.parse(info.to) ;
if ( isNaN(todate) == true || ( this.newperiod[kind] && (now-todate) < (this.newperiod[kind]*60*60*1000) ) ) {
var content = info.content ;
content = content.replace(/<font.*<\/font>/g,'') ;
content = content.replace(/<br[^>]*>/g,'') ;
content = content.replace(/左記/g,'上記') ;
printInfo += [
'<div class="' + ( ((isNaN(todate)==true)||(0<=(todate-now))) ?'cocoTroubleDate':'cocoTroubleDatePassed' ) + '">'
, info.from
, '~'
, info.to
, '</div>'
, '<div class="cocoTroubleContent">' + content + '</div>'
].join('\n') ;
}
}
var listObj = document.createElement('li') ;
if ( printInfo != '' ) {
listObj.innerHTML = printInfo ;
}
else if ( this.notrouble[kind] ) {
listObj.innerHTML = this.notrouble[kind] ;
}
list.appendChild(listObj) ;
var div = document.getElementById('cocoTrouble-update-'+kind) ;
if ( div && this.info[kind].update ) {
var txtObj = document.createTextNode('Update: ' + this.info[kind].update) ;
div.appendChild(txtObj) ;
}
return true ;
} // end of loadComplete()
// ===
, loadScript : function ( src, charset ) {
var scriptStr = [
'<scr' + 'ipt type="text/javascript" '
, 'charset="' + ((charset)?charset:'utf-8') + '" '
, 'src="' + src + '"></scr' + 'ipt>'
].join('') ;
document.write( scriptStr ) ;
} // end of loadScript()
// ===
, init : function () {
this.loadScript( "http://homepage3.nifty.com/furyu/cocoMaintenance.js?reload=" + (new Date).getTime() ) ;
this.loadScript( "http://homepage3.nifty.com/furyu/cocoTrouble.js?reload=" + (new Date).getTime() ) ;
} // end of init()
} // end of cocoTrouble object definition
cocoTrouble.init() ;
//-->
</script>
元情報は、@niftyの『ココログのメンテナンス情報』及び『ココログのトラブル情報』から、自宅サーバにて定期的に取得し、JavaScript形式に加工したあと、@niftyのホームページサーバ上にアップロードしています。
- [2007/01/24]
- 終了時刻が現在よりも前の場合、classを変えるように修正(cocoTroubleDate→cocoTroubleDatePassed)。
newperiodを設定して過去の情報もしばらく表示するようにしている場合に属性(色等)を変えられるようにした。
- Firefoxで動作が不安定になるのを修正。
スクリプト中で別の外部スクリプトを貼り付けたい場合、documentが閉じられる(onload状態)まではdocument.write()を、閉じられてからはappendChild()を、それぞれ使用した方が良い模様。
- loadComplete()内の処理で、既に存在する要素のinnerHTMLを直接変更していたのを、新規に作成した要素をappendChild()する形に修正。
こうしておかないと、IE6で誤動作する可能性有り。
- 終了時刻が現在よりも前の場合、classを変えるように修正(cocoTroubleDate→cocoTroubleDatePassed)。
2006/10/22(日) 01:26 | 固定リンク
| 記事の編集(管理者用)
「おもいつき」カテゴリの記事
- ちょっと小細工:textareaの高さを自動調節(2008.05.21)
- Yin and Yang:動作改善(?)他(2008.05.14)
- ノイズキャンセル(マスク|マイク)ってないのかな?(2008.05.07)
- 『はてブBOX』と、ココログ用『はてブコメント表示欄』スクリプトの更新(2008.05.05)
- Yin and Yang:リンク先の内容をその場で表示するスクリプトの更新(2008.05.02)
「ウェブログ・ココログ関連」カテゴリの記事
- 【ココログ】『続きを読む』をクリックしても、記事の途中に飛ばない場合の対策(2008.05.23)
- 『はてブBOX』と、ココログ用『はてブコメント表示欄』スクリプトの更新(2008.05.05)
- 【ココログ】はてブコメント表示欄をサイドバーにも(2008.04.12)
- 【ココログ】はてなブックマークコメントを個別ページにさり気なく表示するスクリプト(2008.04.11)
- 【ココログ】特定の記事に対する最近のコメントをRSSで取得(Yahoo!Pipes版)(2008.03.09)

