2007年10月19日
カウンターその3
[ 2004.7.2より集計開始 ]
連続アクセス無効
サーバー出力
http://jsgt.org/mt/01/counter_1/cntx41.php
クライアント側
http://jsgt.org/mt/01/counter_1/cntx41.htm
<script charset="EUC-JP"
src="http://jsgt.org/mt/01/counter_1/cntx41.php?uid=1091192023"></script>
<a href="http://jsgt.org/mt/archives/01/000103.html"
><img src="http://jsgt.org/mt/01/counter_1/cntgraph2.png" border="0"></a>
<br />
<script charset="EUC_JP" >
<!--
function get_jg_tato_GraphCounter01_HTML(){
var wk =["日","月","火","水","木","金","土"];
var cnt = new jg_tato_GraphCounter01();
var msgcnt2 ="今日は <b>"+ md(cnt,0)
+"("+ wkcolor(wk[cnt.d[0][3]]) +") "
+ cnt.d[0][1] +" 人</b><br /> "
msgcnt2 +="昨日は " + md(cnt,1)
+"("+ wkcolor(wk[cnt.d[1][3]]) +") "
+ cnt.d[1][1] +" 人<br /> "
for(var i =2;i<14;i++){
msgcnt2 +=i+"日前は "+ md(cnt,i)
+"("+ wkcolor(wk[cnt.d[i][3]]) +") "
+ cnt.d[i][1] +" 人<br /> "
if(i==6)msgcnt2 +="<hr>"
}
function md(cnt,i){
var m= cnt.d[i][2].substr(4,2);
var d= cnt.d[i][2].substr(6,2);
return m+"/"+d;
}
function wkcolor(wk){
return (wk=='日')?"<span style='color:red'>"+wk+"</span>":wk;
}
return msgcnt2;
}
document.write(get_jg_tato_GraphCounter01_HTML())
//-->
</script>
#続けられずに、すっかり、しょぼってしまったjsGadgetです(_ _b。jsGadgetやろうと宣言したのが2004/2/18なんですが、その1年後の2005/2/18は、Ajaxの誕生日だったりしますf^^;。
早すぎたjsGadget^^;<続けることが大切、という教訓。<でも、実は別件が、、、。<おまえに別件などないっ。<おとうさん。。。<数年後にはこのネタは意味がわからなくなる
masa ( 2007年10月19日 12:52 )
http://mb.softbank.jp/mb/campaign/2G/cm/
ここの、「ホワイト家族24「お兄さん遅刻する」篇(30秒)」とリンクを張っておけば、柔銀が、サイト構成変えない限り、ネタ元が分かるかと…。おせっかいしてみる。
高橋 ( 2007年10月19日 13:02 )
ありがとうございます〜
(←clickで入力欄open)
2007年08月30日
【更新】
20070906 v0.042 スコープの不具合を修正&いくつかのインスタンス変数をローカル変数に。
20070903 v0.041 インジケータDIVをIMGへ変更。_iniを_startで起動。
【最新版】
jsgt_indicator0042.js
【使用例】
version v0.042 Sample
http://jsgt.org/lib/indicator/0042/test42-1.htm
http://jsgt.org/lib/indicator/0042/test42-2.htm
http://jsgt.org/lib/indicator/004/test42yui2.htm
http://jsgt.org/lib/indicator/004/test42yui3.htm
Allabout
YUIコネクション+インジケータ
【Dounload】
http://jsgt.org/lib/indicator/0042.zip
【サンプル】
【サンプルソース】
<!--jsgt_indicator004x.jsを読み込む-->
<script type = "text/javascript"
src = "./jsgt_indicator0042.js" charset="utf-8"></script>
<script type = "text/javascript">
<!--
//インジケータインスタンスを生成
var indi1679 = new jsgt_Indicator(
'indidiv1679', //インジケータ用親DIV名
'./indicator32.gif' //インジケータ画像
) ;
//-->
</script>
<form>
<input type="button" value="インジケータ開始"
onclick="indi1679.start();">
<input type="button" value="インジケータ停止"
onclick="indi1679.stop();">
</form>
<!-- インジケータ用親DIV (省略時はページのfirstChiledとして自動生成)-->
<div id="indidiv1679"></div>
【jsgt_Indicator インジケータ オブジェクト ソース】
//--jsGadget--------------------------------------------------------------------------
// 最新情報 : http://jsgt.org/mt/01/
// Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
////
// jsgt_Indicator インジケータ オブジェクト
//
//更新情報
// 20070906 v0.042 スコープの不具合を修正&いくつかのインスタンス変数をローカル変数に。
// 20070903 v0.041 インジケータをダイレクトにIMG生成へ変更。_iniを_startで起動
// @author Toshiro Takahashi
// @support http://jsgt.org/mt/archives/01/001679.html
// @sample http://jsgt.org/lib/indicator/0042/test.htm
// @sample http://jsgt.org/lib/indicator/0042/test4yui.htm
// @download http://jsgt.org/lib/indicator/0042.zip
// @version 0.041 jsgt_indicator0041.j
// @memo oj.start()で現れ、oj.stop()で消えます。インジケータ用DIVオブジェクト
// をHTML内で指定しなければ、ページのfirstChildとして自動生成されます。
// @license Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
// @syntax oj = new jsgt_Indicator(element,imagSrc)
// @sample oj = new jsgt_Indicator('divName','img.gif')
// @sample oj = new jsgt_Indicator(divOj,'img.gif')
// @param element 第一引数はインジケータの親要素またはID名
// @param imagSrc 第二引数はインジケータの画像URL
// @method oj.start() インジケータスタート
// @method oj.stop() インジケータスタート
// @property oj.img インジケータ用IMGオブジェクト
// @property oj.img.id インジケータ用IMGオブジェクトのID(indi_***)
// @object oj.img.style インジケータ用IMGのスタイルオブジェクト(CSSを利用できます)
// @property oj.p インジケータ用IMGの親要素(存在しなければDIVが生成される)
// @property oj.p.id インジケータ用IMGの親要素ID名(第一引数で渡されたID)
// @return インジケータオブジェクトのインスタンス
// @Thanx Thanx for AJAX Activity indicators
// http://mentalized.net/activity-indicators/
//
function jsgt_Indicator(el,imagSrc){
var seq = (new Date()).getTime();
this.img = _setIndicator(imagSrc);
this.p = null;
this.start = _start;
this.stop = _stop;
function _setIndicator(imagSrc){
var img = document.createElement("IMG") ;
// インジケータ用IMGのデフォルト値(インスタンスで上書き変更できます)
img.id='indicator_'+ seq;//idを生成;
img.style.display='none';
img.src = imagSrc;
return img
}
//インジケータIMGを引数で指定された親要素elへ追加
function _ini(oj){
var pa =(typeof el=='object')?el:document.getElementById(el);
if(document.getElementById(el)){
pa.innerHTML='';
pa.appendChild(oj.img);
} else {
pa=mkParentDiv(oj.img);
}
return pa
}
//インジケータを出力する親要素elが無かったら作ってページ先頭へinsert
function mkParentDiv(child){
var pa=document.createElement("DIV");
pa.id=el;
document.body.insertBefore(pa,document.body.firstChild);
pa.appendChild(child);
return pa
}
//インジケータ スタート
function _start(){
this.p=_ini(this);
this.img.style.display='block';
}
//インジケータ ストップ
function _stop(){
this.img.style.display='none';
}
return this
}
【旧バージョン】
@see v0.03 →
http://jsgt.org/mt/archives/01/000906.html
@see v0.01 →
http://jsgt.org/mt/archives/01/000747.html
2006年09月18日
この10年くらいの間に書いたいろいろ雑多なスクリプトがあって、数年前に一度、それらもまとめつつ、jsGadetというライブラリを作ろうと宣言したことがあるのですけれど、ぽしゃってました。
最近、書籍原稿書きなども一段落し、本業の方でもお盆が終わりましたので、あと彼岸が過ぎたら、時間ができるので、試しに、リトライしてみようかな、と、思い立っています。クロスブラウザ関数群をブラウザ限定して小さくし、欲を言えば、日付入力用カレンダー やダイナミックロードとか、jslb_ajaxやドラッガブルフロートやインジケータオブジェクト、AjaSQLなども整理したいなぁと。
まぁ、安倍政権誕生にちなんで「再チャレンジ」みたいな? (でも、また、いつ突然忙しくなるかわかりませんので、続かない可能性も少なくはありませんけれど;;;;) たぶん、頭の整理にもなると思いますので、こんなときに、ちょっとでもやっておこうという感じです。
再利用可能なJavaScriptライブラリという、基本的な方針は、jsGadetと同じです。でも、この数年の間に、いろいろなライブラリが登場し、やりたかったことの多くは実現されていますので、今回の方向は多少違ってくるかな、と思います。
ターゲットブラウザについては、たとえば、レイヤーの表示/非表示を切り替える関数showLAYER
http://game.gr.jp/js/books/dhtml2/part3/cross/show.htm
は
次のような物でしたが、、、
function showLAYER(layName){
if(document.getElementById) //e5,e6,n6,n7,m1,f1,o6,o7,08,09,s1,s2,k3用
document.getElementById(layName).style.visibility='visible'
else if(document.all) //e4用
document.all(layName).style.visibility='visible'
else if(document.layers) //n4用
document.layers[layName].visibility='show'
}
e4とn4を捨てれば、、、
function showLAYER(layName){
//e5,e6,n6,n7,m1,f1,o6,o7,08,09,s1,s2,k3用
document.getElementById(layName).style.visibility='visible'
}
こんなに短く、たった1行になってしまうわけで、最近のライブラリは、皆このやり方になってきています。
で、今回は更に、opacityの使えないo6,o7,08とバグが多くAjaxで文字コード処理の特殊なs1、古すぎるe5、を捨てることを考えています。
そうするだけで、たとえば
クロスブラウザ関数群のうち主なものは下記のようなわずか20行程度のコードに収まってしまいます。
var oj=this[e]||(this[e]=(document.getElementById(e)||e));
var s=oj.style,p=parseInt,u='px',c='',ua=navigator.userAgent;
crossbwFunc={
oj: function(){return oj},
id: function(){return oj.id},
show: function(){s.visibility='visible'},
hide: function(){s.visibility='hidden'},
move: function(x,y){s.left=p(x)+u;s.left=p(y)+u},
moveBy: function(x,y){s.left=p(s.left)+p(x)+u;s.top =p(s.top)+p(y)+u},
resize: function(w,h){s.width=p(w)+u;s.height=p(h)+u},
resizeBy: function(ox,oy){s.width=p(s.width)+ox+u;s.height=p(s.height)+oy+u},
getLeft: function(){return (s.left!=c)?p(s.left):c},
getTop: function(){return (s.left!=c)?p(s.left):c},
getRight: function(){return (s.left!=c && s.width!=c)?p(s.left)+p(s.width):c},
getBottom: function(){return (s.top!=c && s.height!=c)?p(s.top)+p(s.height):c},
setWith: function(w){return s.width=p(w)+u},
setHeight: function(h){return s.height=p(h)+u},
getWith: function(w){return p(s.width)},
getHeight: function(h){return p(s.height)},
setZ: function(z){return s.zIndex=z},
getZ: function(){return s.zIndex}
}
もちろん、このままでは、駄目なので、少し加工してみようかな、ということで、
まず、ネームスペースから考えます。
つづく、、、
2006年03月13日
【jsGadget】Indicatorオブジェクトをv0.03にしました。
インジケータを出力するDIVをdocument内のDIVに指定したい時に、v0.02までは、 jsgt_Indicatorクラスの第二引数でDIV名を渡して、create divな処理と一緒に指定していましたが、これだと、インスタンス生成時に、そのDIVの構築待ちとか別にonload処理を用意するという無駄な時間や手間が発生してしまうので、append to divな処理をcreate divな処理の外に出して、切り離してしまいました。
ちなみに、インジケータ用画像は、インスタンス生成時(new jsgt_Indicator('./img/xxx.gif'))にプレロードしてしまいますので、できればheadで早めに生成してしまいましょう。
インジケータは、インスタンス生成後、「oj.indi_append("インジケータを追加するdiv名")」とすることで追加できます。あとは、今までどおり、oj.indi_start() で開始。 oj.indi_stop() で停止。oj.div.style でCSSな修飾となります。
【使用例】version v0.03 Sample
1.簡単なサンプル
http://jsgt.org/lib/jsoniframerequest/sample/003/test.htm
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!--jsgt_indicator003.jsを読み込む-->
<script type = "text/javascript"
src = "./jsgt_indicator003.js" charset="utf-8"></script>
<script type = "text/javascript">
<!--
//インジケータインスタンスを生成
var indi = new jsgt_Indicator('./img/pleasewait.gif') ;
//インジケータを追加するDIVを指定
window.onload = function(){indi.indi_append("indidiv");}
//-->
</script>
<body>
<form>
<input type="button" value="インジケータ開始"
onclick="indi.indi_start();">
<input type="button" value="インジケータ停止"
onclick="indi.indi_stop();">
</form>
<!-- インジケータ用DIV -->
<div id="indidiv"></div>
2.XMLHttpRequest風iframe処理
jsgt_JSONIframeReqest で試してみました。
jsgt_JSONIframeReqest のインスタンスへインジケータオブジェクトを追加して使っています。
http://jsgt.org/about/cu/CU20060315A/1/test1.htm
3. jslb_ajax050_c.jsを使ったサンプル。クリックでリクエスト後、インジケータが回り、2秒後のレスポンス時に停止します。
http://jsgt.org/lib/indicator/003/01/test1.htm
4. prototype.jsを使って、上記3とまったく同じことをしたサンプル。
http://jsgt.org/sau/tests/test1.htm
*ちなみに、3と4が同じ機能なので、最近Myブーム(古っ)な
ロード時間
ISDNでの 3. jslb_ajax050_c.js+jsgt_indicator003_c.jsの場合のロード時間
http://jsgt.org/lib/indicator/003/01/test1_loadtime.htm
1回目 load時間--3.295秒--
2回目 load時間--0.911秒--
3回目 load時間--0.311秒--
ISDNでの 4. prototype.js+jsgt_indicator003_c.jsの場合のロード時間
http://jsgt.org/sau/tests/test1_loadtime.htm
1回目 load時間--26.278秒--
2回目 load時間--6.67秒--
3回目 load時間--0.32秒--
#教訓::この程度のサンプルにFull prototype.jsはあまり向いていないかも。Dojoは言うまでもなく、、、。
【最新版ディレクトリ】
http://jsgt.org/lib/indicator/
【最新版】 /003/jsgt_indicator003.js(3.3k)
コメント無しの0.7kバージョンは、
/003/jsgt_indicator003_c.js(0.752k)
license Public Domain
//--jsGadget--------------------------------------------------------------------------
// 最新情報 : http://jsgt.org/mt/01/
// Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
////
// jsgt_Indicator インジケータ オブジェクト
//
// @author Toshiro Takahashi
// @support http://jsgt.org/mt/archives/01/000747.html
// @download http://jsgt.org/lib/indicator/
// @version 0.03 jsgt_indicator003.js DOM構築待ちを回避するindi_append
// @license Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
// @syntax oj = new jsgt_Indicator(imagSrc)
// @sample oj = new jsgt_Indicator('img.gif')
// @method oj.indi_apend(id) DOMへ追加 引数はインジケータをappendする要素のID名
// @method oj.indi_start() インジケータスタート
// @method oj.indi_stop() インジケータスタート
// @property oj.div 出力するdivオブジェクト
// @property oj.div.style スタイルオブジェクト(CSSを利用できます)
// @return インジケータオブジェクトのインスタンス
//
// @Thanx Thanx for AJAX Activity indicators http://mentalized.net/activity-indicators/
//
function jsgt_Indicator(src)
{
this.div = setIndicatorDIV(src);
this.indi_append = indi_append;
this.indi_start = indi_start;
this.indi_stop = indi_stop;
this.img = new Image();
this.img.src = src;
function setIndicatorDIV(src)
{
// インジケータを出力するdiv
id = "_indicator"+(new Date()).getTime();//idを生成;
this.div = document.createElement("DIV") ;
// インジケータ用DIVのデフォルト値(インスタンスで上書き変更できます)
this.div.style.position = "relative";
this.div.style.top = "0px";
this.div.style.left = "0px";
this.div.style.width = "0px";
this.div.style.height = "0px";
this.div.style.margin = '0px' ;
this.div.style.padding = '0px' ;
return this.div
}
function indi_append(id)
{
if(typeof document.getElementById(id) != 'object')return;
document.getElementById(id).appendChild(this.div);
}
//インジケータ スタート
function indi_start()
{
//サイズを与えることで表示する
this.div.style.height ="12px";
this.div.style.width ="auto";
this.div.innerHTML = '<img src="'+this.img.src+'">' ;
}
//インジケータ ストップ
function indi_stop()
{
this.div.style.width ="0px";
this.div.style.height ="0px";
this.div.innerHTML = '' ;
}
return this
}
2006年01月27日
Ajaxがメジャーになる前は、imgや隠しframe、iframe、jsのダイナミックロードとかいろいろ苦労した歴史があるわけですが、ここ数ヶ月、集中的にAjaxをいじってきて、思うのは、うーん、、やっぱ、XMLHttpRequestでなくても良いじゃん。ということだったりします。
もちろん、その候補は、HTTPクライアントとしてのXMLHttpRequestの右に出るのは難しい裏技ばかりで、それぞれ一長一短あるわけですが、現状に限るなら、いくつかのブラウザのバグのおかげで(?)、XMLHttpRequestが力量を発揮できないために、たとえば、Google Mapsのように、iframeでもほとんど同じことができて、しかも、動作ブラウザの数が増えて、日本語も大丈夫、という道もあったりするのです。
で、今回は、今まで自分があまり使わなかった「IFRAME」を使って、XMLHttpRequest風の動作+アルファをしてくれるクラスを作ってみました。OperaのせいでHTTPヘッダを封印されたXMLHttpRequestなら、超える可能性を秘めています、、、<ほんまかいなf^^? 。しかし、久々に、クロスブラウザ技開発は、正直しんどかったです、、、が、できてしまえばこっちのものです(笑;。
http://jsgt.org/lib/jsoniframerequest/sample/001/writetable/test.htm
動作ブラウザは、こんなところです。
【動作ブラウザ】
| win |
mac |
linux |
| n7 | m1 | e6 | o8 |
n7 | m1 | e5 | s1.24 | s2.0 | o8 |
n7 | m1 | k3.3 | o8 |
| ○ | ○ | ○ | ○ |
○ | ○ | ○ | ○ | ○ | ○ |
○ | ○ | ○ | ○ |
n=Netscape/m=Mozilla/e=IE/o=Opera/s=Safari/k=Konqueror
Mac Safari1.25だけは、まだ駄目です。←2006.1.28 直りました。
このスクリプトの最大のポイントは、JSONなIFRAMEでXMLHttpRequest風通信、ではなくて、実は、引数に オプションオブジェクトを渡すことで、オリジナルのクラスをカスタマイズできるようにしたことです。中身を丸ごと、書き換えることすらできます(笑)<なんじゃそりゃ。
このサンプルでは、試しに、iframeをoj.show()/oj.hide()するオプションを引数で渡して、Ajax風データ受信+IFRAME本来の動作を使ってみています。
詳細は後日。。。
追記 2006.1.30
AllaboutにXMLHttpRequestとの機能比較などを書いてみました
http://allabout.co.jp/career/javascript/closeup/CU20060115A/index2.htm
追記 2006.1.28
Win IEとFierfoxは、何もしなくてもAjaxの弱点である履歴を自動保存をしてくれますね、これは当然ですが収穫かも。。。(OperaとSafariは駄目かな?)
tosik ( 2006年01月30日 01:39 )
面白いですね。
しかし、履歴が残るのは逆に欠点でもあるのでは?
高橋 ( 2006年01月30日 09:41 )
そうですね〜。Webアクセサビリティ的には、履歴が残る方が良いと思うので、XMLHttpRequestでは、わざわざ、historyを記録する仕組みを作ったりするわけですけれど、こうして観ると、mouseoverの履歴全部が残るというのは、逆に破壊的かもしれないですねf^^;
(←clickで入力欄open)
2006年01月11日
というわけで、「script.aculo.usのテスト/auto floating zIndex 」のオブジェクトへ「 【jsGadget】引数で各オブジェクトを繋いでみる 」のインジケータガジェットを引数で渡してみました(^^)。
ドラッグスタート時にインジケータが回ります
http://jsgt.org/ajax/sau/test/tato/dragdrop_tato_indi_test1.html
高橋 ( 2006年01月13日 00:09 )
インスタンス用引数で使っている同じスクリプトの繰り返しが無駄なので、クラスそのものを専用に上書きしようと思ったら、script.aculo.usの内部のそのfunctionが長くて丸ごと書くのがもっと無駄、、、。うーん。やっぱり、こういうことになると我慢しきれずに自分で作ってしまいたくなります、、、。でも、もう少し我慢^^;;
(←clickで入力欄open)
2006年01月10日
このエントリどこへいっちゃったんだろう、、、。削除しちゃったのかなぁf^^;;ということで再。
関数jsgt_DoFadeOpacityを関数jsgt_Indicator の引数用オブジェクトとして渡し、まとめてnewする方法
http://jsgt.org/lib/fadeopacity/jsgt_DoFadeOpacity010/jsgt_DoFadeOpacity010.htm
2005年12月29日
次のバージョン→Indicatorオブジェクトv0.04
http://jsgt.org/mt/archives/01/001679.html
AJAX Activity indicators(
http://mentalized.net/journal/2005/11/29/ajax_activity_indicators/)の画像を利用して、Indicator Objectを作ってみました。
インターフェイスは
ProgressBarオブジェクトv0.02と揃えてあります。oj = new jsgt_jsgt_Indicator(src[,id]) でインスタンスojを作ったら、あとは、oj.indi_start() で開始。
oj.indi_stop() で停止。oj.div.style でCSSな修飾となります。
【使用例】
version v0.01 Sample
http://jsgt.org/lib/indicator/jsgt_indicator001/jsgt_indicator001.htm
【サンプル】
ここへtest747のインジケータが出力され、2秒以上待ってから、サーバーからのレスポンスが表示されます
【最新版ディレクトリ】
http://jsgt.org/lib/indicator/
【最新版】 jsgt_indicator001.js
//--jsGadget--------------------------------------------------------------------------
// 最新情報 : http://jsgt.org/mt/01/
// Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
////
// jsgt_Indicator インジケータ オブジェクト
//
// @author Toshiro Takahashi
// @support http://jsgt.org/mt/archives/01/000743.html
// @source http://jsgt.org/lib/indicator/
// @version 0.02 jsgt_indicator001.js
// @license Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
// @syntax oj = new jsgt_Indicator(src[,id])
// @sample oj = new jsgt_Indicator('img.gif') //DIVを自動生成する場合
// @sample oj = new jsgt_Indicator('img.gif','nloading') //既存のDIV名で指定する場合
// @param id インジケータ用DIVのID名(省略時は"_indicator"+(new Date()).getTime())
// @method oj.indi_start() インジケータスタート
// @method oj.indi_stop() インジケータスタート
// @property oj.div バーを出力するdivオブジェクト
// @property oj.div.style スタイルオブジェクト(CSSを利用できます)
// @return インジケータオブジェクトのインスタンス
//
// @Thanx Thanx for AJAX Activity indicators http://mentalized.net/activity-indicators/
//
function jsgt_Indicator(src,id)
{
this.div = setIndicatorDIV(src,id)
this.indi_start = indi_start
this.indi_stop = indi_stop
function setIndicatorDIV(src,id)
{
// インジケータを出力するdiv
if(!id){
id = "_indicator"+(new Date()).getTime();//idを生成;
if(document.getElementsByTagName('BODY').length==0)
document.write('<body>')//ダミーのbodyタグ
var creDIV = document.createElement("DIV") ;
this.div = document.body.appendChild(creDIV) ;
this.div.setAttribute("id",id) ;
this.div.style.position = "relative";
this.div.style.top = "0px";
this.div.style.left = "0px";
this.div.style.width = "0px";
this.div.style.height = "0px";
} else {
this.div = document.getElementById(id)
}
// インジケータ用DIVのデフォルト値(インスタンスで上書き変更できます)
this.div.style.margin = '0px' ; //バーのマージン
this.div.style.padding = '0px' ; //バーのパディング
//インジケータ画像のプレロード
this.div.img = new Image()
this.div.img.src = src
// インジケータのデフォルト値
this.div.indi_bar= '|'; //バーのキャラクタ
this.div.indi_interval= 50; //インジケータ インターバル 1/1000秒単位
this.div.indi_count =0; //インジケータカウンター初期値
this.div.indi_count_max =18; //インジケータ カウンターMax
this.div.indi_array= []; //バーのタイマーIDを格納する配列
return this.div
}
//インジケータ スタート
function indi_start()
{
//サイズを与えることで表示する
this.div.style.height ="12px";
this.div.style.width ="auto";
this.div.innerHTML = '<img src="'+this.div.img.src+'">' ;
}
//インジケータ ストップ
function indi_stop()
{
this.div.style.width ="0px";
this.div.style.height ="0px";
this.div.innerHTML = '' ;
}
return this
}
2005年12月28日
progressBarオブジェクトを書き換えました。複数動作時に、一部上書きがおきていたものを修正したついでにメンバーもprogressオブジェクトをやめてフラットでシンプルな構成にしました。oj = new jsgt_ProgressBar() でインスタンスojを作ったら、あとは、oj.prog_start() で開始。
oj.prog_stop() で停止。oj.div.style でCSSな修飾です。
【使用例】
version v0.02 サンプル
http://jsgt.org/lib/progressbar/jsgt_progressbar002.htm
【最新版ディレクトリ】
http://jsgt.org/lib/progressbar/
【最新版】 jsgt_progressbar002.js
【旧版】 http://jsgt.org/mt/archives/01/000543.html
//--jsGadget--------------------------------------------------------------------------
// 最新情報 : http://jsgt.org/mt/01/
// Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
////
// jsgt_ProgressBar プログレスバー オブジェクト
//
// @author Toshiro Takahashi
// @support http://jsgt.org/mt/archives/01/000743.html
// @version 0.02
// @license Public Domain 著作権表示義務無し。商用利用、改造、自由。連絡不要。
// @sample oj = new jsgt_ProgressBar() //DIVを自動生成する場合
// @sample oj = new jsgt_ProgressBar('nloading') //既存のDIV名で指定する場合
// @param id プログレス用DIVのID名(省略時は"_progress"+(new Date()).getTime())
// @method oj.prog_start() プログレススタート
// @method oj.prog_stop() プログレススタート
// @property oj.div バーを出力するdivオブジェクト
// @property oj.div.style スタイルオブジェクト(CSSを利用できます)
// @property oj.prog_bar バーのキャラクタ(デフォルトは'|')
// @property oj.prog_interval プログレスインターバル(デフォルトは50 1/1000秒単位)
// @property oj.prog_count プログレスバーカウンター
// @property oj.prog_count_max プログレスバーカウンターMax(デフォルトは18)
// @return プログレスバーオブジェクトのインスタンス
//
function jsgt_ProgressBar(id)
{
this.div = setProgressDIV(id)
this.prog_start = prog_start
this.prog_stop = prog_stop
var oj = this.div
function setProgressDIV(id)
{
// プログレスバーを出力するdiv
if(!id){
id = "_progress"+(new Date()).getTime();//idを生成;
if(document.getElementsByTagName('BODY').length==0)
document.write('')//ダミーのbodyタグ
var creprgDIV = document.createElement("DIV") ;
this.div = document.body.appendChild(creprgDIV) ;
this.div.setAttribute("id",id) ;
this.div.style.position = "relative";
this.div.style.top = "0px";
this.div.style.left = "0px";
this.div.style.width = "0px";
this.div.style.height = "0px";
} else {
this.div = document.getElementById(id)
}
// プログレスバー用DIVのデフォルト値(インスタンスで上書き変更できます)
this.div.style.color = 'red' ; //バーの色
this.div.style.margin = '0px' ; //バーのマージン
this.div.style.padding = '4px'; //バーのパディング
// プログレスバーのデフォルト値
this.div.prog_bar= '|'; //バーのキャラクタ
this.div.prog_interval= 50; //プログレス インターバル 1/1000秒単位
this.div.prog_count =0; //プログレスカウンター初期値
this.div.prog_count_max =18; //プログレスバー カウンターMax
this.div.prog_array= []; //バーのタイマーIDを格納する配列
return this.div
}
//プログレス スタート
function prog_start()
{
//サイズを与えることで表示する
this.div.style.height ="12px";
this.div.style.width ="auto";
this.div.prog_array.unshift(
setInterval(
function(){ doProguress() }
, this.div.prog_interval
)
)
}
//プログレス ストップ
function prog_stop()
{
clearInterval(this.div.prog_array[0])
//停止したタイマーを削除
this.div.prog_array.shift()
//消去
this.div.style.width ="0px";
this.div.style.height ="0px";
this.div.innerHTML = '' ;
}
//プログレスバー作動
function doProguress()
{
//window.status=oj.id //チェック
if(oj.prog_count >= oj.prog_count_max||
oj.prog_count <= 0 ){
oj.innerHTML = '' ; //初期化
oj.prog_count =0;
}
oj.innerHTML += oj.prog_bar ;
oj.prog_count++ ;
}
return this
}
2005年11月23日
ドラッガブルフロートなDIVをv08へアップデートしました。
http://jsgt.org/mt/archives/01/000419.html
フロートDIVを出現させると元のページのテキストが反転選択できなくなるのを修正。
document.onmousemoveのreturn falseをコメントアウトするとセレクトできるのですが、
jsgt_dragfloat08.js
で、コメントアウトをデフォルトにしました。
【サンプル】
2005年10月25日