//============================================================ // string sprintf ( string i_format [, mixed i_arg1, mixed i_arg2, ...] ) //============================================================ function sprintf( i_format ) { var args = new Array(); for ( var i = 1; i < sprintf.arguments.length; ++i ) { args[ args.length ] = sprintf.arguments[i]; } return vsprintf( i_format, args ); } //============================================================ // string vsprintf ( string i_format, array i_args ) //============================================================ function vsprintf( i_format, i_args ) { var src = i_format; var dst = ""; var left_part, match_part, right_part; var flags, width, precision, type; for( var i = 0; 0 <= src.search(/%([#0 \-\+]*)([1-9]*[0-9]*)([\.][0-9]*|)([%bcdeEfgGoxXs]{1})/); ) { left_part = RegExp.leftContext; right_part = RegExp.rightContext; flags = RegExp.$1 + ''; width = RegExp.$2 + ''; precision = RegExp.$3 + ''; type = RegExp.$4 + ''; if ( type == '%' ) { match_part = '%'; } else if( i < i_args.length ) { match_part = _sprintf(flags, width, precision, type, i_args[i]); ++i; } else { match_part = ''; } dst += (left_part + match_part); src = right_part; } dst += src; return dst; } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf( i_flags, i_width, i_precision, i_type, i_value ) { switch( i_type ) { case 'b': func = _sprintf_b; break; case 'c': func = _sprintf_c; break; case 'd': func = _sprintf_d; break; case 'e': case 'E': case 'f': case 'g': case 'G': func = _sprintf_f; break; case 'o': func = _sprintf_o; break; case 's': func = _sprintf_s; break; case 'x': case 'X': func = _sprintf_x; break; default: return ''; } return func( i_flags, i_width, i_precision, i_type, i_value ); } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf_b( i_flags, i_width, i_precision, i_type, i_value ) { var align; var left_pad_char; // case align=right var right_pad_char; // case align=left var pad_len; var s; s = bin( Math.floor(i_value) ); align = (0 <= i_flags.search(/\-/)) ? 'left' : 'right'; left_pad_char = (0 <= i_flags.search(/0/) && i_precision == '') ? '0' : ' '; right_pad_char = ' '; if ( i_precision != '' ) { s = (s == '0') ? '' : s; pad_len = Number(i_precision.substr(1)) - s.length; if ( 0 < pad_len ) { s = str_repeat('0', pad_len) + s; } } if( i_width != '' ) { pad_len = Number(i_width) - s.length; if( 0 < pad_len ) { if ( align == 'left' ) { s = s + str_repeat(right_pad_char, pad_len); } else { s = str_repeat(left_pad_char, pad_len) + s; } } } return s; } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf_c( i_flags, i_width, i_precision, i_type, i_value ) { var align; var pad_len; var right_pad_char; var left_pad_char; var s; s = ''; s = String.fromCharCode( Number(i_value) ); align = (0 <= i_flags.search(/\-/)) ? 'left' : 'right'; left_pad_char = (0 <= i_flags.search(/0/) ) ? '0' : ' '; right_pad_char = ' '; if( i_width != '' ) { pad_len = Number(i_width) - strlen_b(s); if( 0 < pad_len ) { if ( align == 'left' ) { s = s + str_repeat(right_pad_char, pad_len); } else { s = str_repeat(left_pad_char, pad_len) + s; } } } return s; } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf_d( i_flags, i_width, i_precision, i_type, i_value ) { var align; var left_pad_char; // case align=right var right_pad_char; // case align=left var pad_len; var sign; var s; s = String(Math.floor(Math.abs( i_value ))); align = (0 <= i_flags.search(/\-/)) ? 'left' : 'right'; left_pad_char = (0 <= i_flags.search(/0/) && i_precision == '') ? '0' : ' '; right_pad_char = ' '; if ( i_precision != '' ) { s = (s == '0') ? '' : s; pad_len = Number(i_precision.substr(1)) - s.length; if ( 0 < pad_len ) { s = str_repeat('0', pad_len) + s; } } if( i_flags.search(/\+/) >= 0 ) { sign = ( i_value >= 0 ) ? '+' : '-'; } else if( i_flags.search(/ /) >= 0 ) { sign = ( i_value >= 0 ) ? ' ' : '-'; } else { sign = ( i_value >= 0 ) ? '' : '-'; } if( i_width != '' ) { pad_len = Number(i_width) - sign.length - s.length; if( 0 < pad_len ) { if ( align == 'left' ) { s = sign + s + str_repeat(right_pad_char, pad_len); } else if ( left_pad_char == '0' ) { // "+0000123" s = sign + str_repeat(left_pad_char, pad_len) + s; } else { // " +123" s = str_repeat(left_pad_char, pad_len) + sign + s; } } else { s = sign + s; } } else { s = sign + s; } return s; } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf_f( i_flags, i_width, i_precision, i_type, i_value ) { var precision; var s = ''; var num_l, num_r, num_e; var sign var point; precision = (i_precision == '') ? 6 : Number(i_precision.substr(1)); var arr = __float( i_value, i_type ); num_l = arr[0]; num_r = arr[1]; num_e = arr[2]; if ( num_r.length <= precision ) { num_r += str_repeat('0', precision); num_r = num_r.substr(0, precision); } else { var n = num_r.length - precision; num_r = parseFloat( num_r ); for ( ; 0 < n; --n ) { num_r /= 10.0; } num_r = Math.round( num_r ); num_r = String( num_r ); num_r = str_repeat('0', precision) + num_r; num_r = num_r.substr( num_r.length - precision ); } if( i_flags.search(/\+/) >= 0 ){ sign = ( i_value >= 0 ) ? '+' : '-'; } else if( i_flags.search(/ / ) >= 0 ){ sign = ( i_value >= 0 ) ? ' ' : '-'; } else { sign = ( i_value >= 0 ) ? '' : '-'; } if( i_flags.search(/#/) >= 0 ) { point = '.'; } else if( precision == 0 || num_r.length == 0 ) { point = ''; } else { point = '.'; } if ( num_e != '' ) { switch ( i_type ) { case 'e': case 'g': num_e = 'e' + num_e; break; case 'E': case 'G': num_e = 'E' + num_e; break; } } var s = num_l + point + num_r + num_e; if ( i_width != '' ) { var pad_len = Number(i_width) - (sign.length + s.length); if( 0 < pad_len ) { if( i_flags.search(/\-/) >= 0 ) { s = sign + s + str_repeat(' ', pad_len); } else { if( i_flags.search(/0/) >= 0 ) { s = sign + str_repeat('0', pad_len) + s; } else { s = str_repeat(' ', pad_len) + sign + s; } } } else { s = sign + s; } } else { s = sign + s; } return s; } function __float( i_value, i_type ) { var num_l, num_r, num_e; (i_value.toString()).search( /([+\-]*)([0-9]*)([\.]*)([0-9]*)([Ee]*)([+\-]*[0-9]*)/ ); num_l = RegExp.$2; num_r = RegExp.$4; num_e = RegExp.$6; switch ( i_type ) { case 'g': case 'G': if ( num_e != '' ) { num_e = sprintf("%+04d", num_e); } break; case 'e': case 'E': if ( num_e == '' ) { num_e = 0; if ( 1 < num_l.length ) { // 12345.67 --> 1.234567 e+04 num_e = num_l.length - 1; num_r = num_l.substr(1) + num_r; num_l = num_l.substr(0,1); } else if ( num_l.length == 1 && num_l != '0' ) { // 1.???? // do nothing } else { // .00001234 ---> 1.234 e-05 // 0.00123455 ---> 1.23455 e-03 var n = num_r.search( /([1-9][0-9]*)$/ ); if ( 0 <= n ) { num_l = num_r.substr( n, 1 ); num_r = num_r.substr( n + 1 ); num_e = -(n + 1); } } } else { num_e = Number(num_e); } num_e = sprintf("%+04d", num_e); break; case 'f': if ( num_e != '' ) { num_e = Number(num_e); if ( 0 < num_e ) { if ( num_e <= num_r.length ) { num_l += num_r.substr(0, num_e); num_r = num_r.substr(num_e); } else { num_l += num_r; num_e -= num_r.length; num_r = ""; num_l += str_repeat('0', num_e); } } else if ( num_e < 0 ) { num_e = Math.abs(num_e); if ( num_e <= num_l.length ) { num_r = num_l.substr(num_l.length - num_e) + num_r; num_l = num_l.substr(0, num_l.length - num_e); } else { num_r = num_l + num_r; num_e -= num_l.length; num_l = ""; num_r = str_repeat('0', num_e) + num_r; } if ( num_l == '' ) { num_l = '0'; } } num_e = ''; } break; default: break; } return new Array( num_l, num_r, num_e ); } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf_o( i_flags, i_width, i_precision, i_type, i_value ) { var align; var left_pad_char; // case align=right var right_pad_char; // case align=left var pad_len; var s; s = oct( Math.floor(i_value) ); align = (0 <= i_flags.search(/\-/)) ? 'left' : 'right'; left_pad_char = (0 <= i_flags.search(/0/) && i_precision == '') ? '0' : ' '; right_pad_char = ' '; if ( i_precision != '' ) { s = (s == '0') ? '' : s; pad_len = Number(i_precision.substr(1)) - s.length; if ( 0 < pad_len ) { s = str_repeat('0', pad_len) + s; } } if ( i_width != '' ) { pad_len = Number(i_width) - s.length; if( 0 < pad_len ) { if ( align == 'left' ) { s = s + str_repeat(right_pad_char, pad_len); } else { s = str_repeat(left_pad_char, pad_len) + s; } } } return s; } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf_s( i_flags, i_width, i_precision, i_type, i_value ) { var align; var left_pad_char; // case align=right var right_pad_char; // case align=left var pad_len; var s; s = String(i_value); align = (0 <= i_flags.search(/\-/)) ? 'left' : 'right'; left_pad_char = (0 <= i_flags.search(/0/) ) ? '0' : ' '; right_pad_char = ' '; if( i_precision != '' ) { s = substr_b( s, 0, Number(i_precision.substr(1)) ); } if( i_width != '' ) { pad_len = Number(i_width) - strlen_b(s); if( 0 < pad_len ) { if ( align == 'left' ) { s = s + str_repeat(right_pad_char, pad_len); } else { s = str_repeat(left_pad_char, pad_len) + s; } } } return s; } //------------------------------------------------------------ // local function //------------------------------------------------------------ function _sprintf_x( i_flags, i_width, i_precision, i_type, i_value ) { var align; var left_pad_char; // case align=right var right_pad_char; // case align=left var pad_len; var s; s = ''; s = hex( Math.floor(i_value) ); s = (i_type == 'X') ? s.toUpperCase() : s.toLowerCase(); align = (0 <= i_flags.search(/\-/)) ? 'left' : 'right'; left_pad_char = (0 <= i_flags.search(/0/) && i_precision == '') ? '0' : ' '; right_pad_char = ' '; if ( i_precision != '' ) { s = (s == '0') ? '' : s; pad_len = Number(i_precision.substr(1)) - s.length; if ( 0 < pad_len ) { s = str_repeat('0', pad_len) + s; } } if( i_width != '' ) { pad_len = Number(i_width) - s.length; if( 0 < pad_len ) { if ( align == 'left' ) { s = s + str_repeat(right_pad_char, pad_len); } else { s = str_repeat(left_pad_char, pad_len) + s; } } } return s; } //============================================================ // string hex( number i_num ) //============================================================ function hex( i_num ) { var num = Number(i_num); var str = ''; var mask = 0xF; do { str = "0123456789ABCDEF".substr((num & 0xF), 1) + str; num >>= 4; mask <<= 4; } while( num != 0 && mask != 0 ) return str; } //============================================================ // string oct( number i_num ) //============================================================ function oct( i_num ) { var bin_str; var str; var s, e; bin_str = bin( i_num ); if ( bin_str.length < 3 ) { e = bin_str.length; } else { e = bin_str.length % 3; if ( e == 0 ) e = 3; } str = ''; for ( s = 0; s < bin_str.length; s = e, e += 3 ) { buf = bin_str.substring(s, e); buf = bin2oct( buf ); str += buf; } return str; function bin2oct( i_bin_str ) { var chr; var bin; var mask; var num; num = 0; mask = 1; for ( var i = i_bin_str.length - 1; 0 <= i; --i ) { chr = i_bin_str.substr(i,1); bin = Number(chr); num += (mask * bin); mask <<= 1; } return String(num); } } //============================================================ // string bin( number i_num ) //============================================================ function bin( i_num ) { var num = Number(i_num); var str = ''; var mask = 0x1; do { str = String(num & 0x1) + str; num >>= 1; mask <<= 1; } while( num != 0 && mask != 0 ) return str; } function str_repeat( i_str, i_repeat ) { var arr = new Array(); for ( var i = i_repeat; i > 0; --i ) { arr[ arr.length ] = i_str; } return arr.join(''); } function strlen_b( i_str ) { var len; len = 0; for ( var i = 0; i < i_str.length; ++i ) { if ( i_str.charCodeAt(i) < 0x100 ) { len++; } else { len += 2; } } return len; } function substr_b( i_str, i_pos, i_len ) { var type_arr = new Array(); var char_arr = new Array(); var s; for ( var i = 0; i < i_str.length; ++i ) { if ( i_str.charCodeAt(i) < 0x100 ) { // ascii type_arr[ type_arr.length ] = 0; char_arr[ char_arr.length ] = i_str.substr(i,1); } else { // multibyte 1st type_arr[ type_arr.length ] = 1; char_arr[ char_arr.length ] = i_str.substr(i,1); // multibyte 2nd type_arr[ type_arr.length ] = 2; char_arr[ char_arr.length ] = i_str.substr(i,1); } } type_arr = type_arr.slice( i_pos, i_len ); char_arr = char_arr.slice( i_pos, i_len ); if ( 0 < type_arr.length ) { if ( type_arr[0] == 2 ) { type_arr[0] = 0; char_arr[0] = ' '; } if ( type_arr[type_arr.length - 1] == 1 ) { type_arr[type_arr.length - 1] = 0; char_arr[char_arr.length - 1] = ' '; } } s = ''; for ( var i = 0; i < type_arr.length; ++i ) { if ( type_arr[i] == 0 || type_arr[i] == 1 ) { s += char_arr[i]; } } return s; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function date1391875126x(TN,DA,MY,TI){ TN1391875126x=TN; DA1391875126x=DA; MY1391875126x=MY; TI1391875126x=TI; myOP=window.opera; myN4=document.layers; myN6=document.getElementById; myIE=document.all; if (myOP) myBR="O6"; else if (myIE) myBR="I4"; else if (myN6) myBR="N6"; else if (myN4) myBR="N4"; else myBR="OT"; if(MY[0]==''){ myWeek=new Array('sun','mon','tue','wed','thu','fri','sat'); }else{ myWeek=MY; } //TI=new Array('年','月','日','','時','分','秒'); //TI=new Array('\u5E74','\u6708','\u65E5','','\u6642','\u5206','\u79D2'); //DA=new Array('1','1','1','1','1','1','1'); //TN=0; myD=new Date(); Y=(myD.getYear()<2000)?1900+myD.getYear() : myD.getYear(); M=myD.getMonth()+1; D=myD.getDate(); W=myWeek[myD.getDay()]; H=myD.getHours(); I=myD.getMinutes(); S=myD.getSeconds(); H=sprintf('%02d',H); I=sprintf('%02d',I); S=sprintf('%02d',S); VM=''; if(DA[0]==1){ if(TN==1){ VM+=Y+TI[0]; }else{ if(DA[1]==1||DA[2]==1){ VM+=Y+'/'; }else{ VM+=Y+''; } } } if(DA[1]==1){ if(TN==1){ VM+=M+TI[1]; }else{ if(DA[2]==1){ VM+=M+'/'; }else{ VM+=M+''; } } } if(DA[2]==1){ if(TN==1){ VM+=D+TI[2]; }else{ VM+=D+''; } } if(DA[3]==1){ VM+='('+W+')'; } if(DA[0]==1||DA[1]==1||DA[2]==1||DA[3]==1&&DA[4]==1||DA[5]==1||DA[6]==1){ VM+=' '; } if(DA[4]==1){ if(TN==1){ VM+=H+TI[4]; }else{ if(DA[5]==1||DA[6]==1){ VM+=H+':'; }else{ VM+=H+''; } } } if(DA[5]==1){ if(TN==1){ VM+=I+TI[5]; }else{ if(DA[6]==1){ VM+=I+':'; }else{ VM+=I+''; } } } if(DA[6]==1){ if(TN==1){ VM+=S+TI[6]; }else{ VM+=S+''; } } if(myBR=="I4"){ document.all("ID1391875126x").innerHTML = VM; }else if(myBR=="O6"){ document.getElementById("ID1391875126x").innerHTML=VM; }else if(myBR=="N4"){ document.layers["ID1391875126x"].document.open(); document.layers["ID1391875126x"].document.write(VM); document.layers["ID1391875126x"].document.close(); }else if(myBR=="OT"||myBR=="N6"){ document.getElementById("ID1391875126x").innerHTML=VM; } setTimeout("date1391875126x(TN1391875126x,DA1391875126x,MY1391875126x,TI1391875126x)",1000); } function tohome(){ top.location.href='http://www.harudake.net/'; } function HToki_view1391875126x(){ if(document.all){ obj=CON1391875126x; }else{ obj=document.getElementById('CON1391875126x'); } str=obj.style.display; if(str=='block'){ obj.style.display='none'; }else{ obj.style.display='block'; } } document.write(''); document.write(''); document.write('harudake'); document.write(''); document.write('');