var __r = { template : '' , targetID : '' , CSS : '' , canFitImage : true , Data : {} , $ : function( id ) { return document.getElementById( id ); } , $$ : function ( cls ){ var ret = []; var obj = null; if( arguments.length == 2 ) obj = arguments[1]; else obj = document.body; if( !obj.childNodes || !obj.childNodes.length ) return ret; for( var i = 0, l =obj.childNodes.length; i < l ;i++ ){ if( !obj.childNodes[i] || !obj.childNodes[i].tagName ) continue; if( obj.childNodes[i].className == cls ) ret.push( obj.childNodes[i] ); var tmp = this.$$( cls, obj.childNodes[i] ); for( var j = 0; j < tmp.length; j++ ) ret.push( tmp[j] ); } return ret; } , callback : function( data ){ if( data['rdf:RDF'] ) data['rss'] = data['rdf:RDF']; this.Data = data; if( !this.template && this.targetID.match( /^ID:(.+?)$/ ) ){ this.targetID = RegExp.$1; this.template = this.$( this.targetID ).innerHTML.replace( /(?:^\s*<\!--|-->\s*$)/g, '') ; } if( this.targetID != '' && this.$( this.targetID ) ){ this.$(this.targetID).innerHTML = this.parseTemplate( this.template, data ); } else { document.write( this.parseTemplate( this.template, data ) ); } if( this.CSS ){ if( navigator.appName == 'Microsoft Internet Explorer' ){ document.createStyleSheet(this.CSS); } else { var node = document.createElement( 'link' ); node.href = this.CSS; node.rel = 'stylesheet'; node.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild( node ); } } if( this.canFitImage ) window.setTimeout( this.fitImage ,500 ); } , parseTemplate : function( template, data ){ var lines = template.split( /(\r\n|\r|\n)/ ); for(var i = 0, l = lines.length ; i < l; i++ ){ var ln = lines[i].toString().replace( /\s+$/, ''); if( ln == '' ) continue; if( ln.match(/ " + len + " ? " + nm + ".toString().substr( 0, " + len + " ) + '...' : " + nm + ") + '") : ("' + " + nm + " + '"); if( tag ) tmp = tmp.replace( new RegExp( nm, 'g' ), nm + ".replace(/<.*?>/g,'')" ); ln = ln.replace( //, tmp ); } } else if( ln.match(/<\/?TMPL_[^\>]+>/ ) ){ ln = ln.replace( /<\/TMPL_IF>/g , '}' ) .replace( /<\/TMPL_LOOP>/g, '}\ndata_bk.pop();data=data_bk[data_bk.length - 1];i.pop();' ) .replace( //g , "} else {" ) .replace( /|<=|>=)? *(\d+)? *'>/g, "if( i[i.length-1] $1 $2 ) {" ) .replace( //g, "if( i[i.length-1] == ( data_bk[data_bk.length-1].length - 1 ) ) {" ) .replace( /|<=|>=)? *(\S+)? *'>/g, "if( data.$1 $2 $3) {" ); if( ln.match( //, "data_bk.push( data.$1 );\n i.push(0); \n" + "for( i[i.length-1] = 0; i[i.length-1] < data_bk[data_bk.length-1].length; i[i.length-1]++ ){ \n" + "data = data_bk[data_bk.length-1][i[i.length-1]];" + ( RegExp.$2 ? 'if( i[i.length-1] >= ' + RegExp.$2 + ' ) break;' : '' ) ); ln = ln.replace(/(['"])/g,'\\$1'); } else { ln = "body += '" + ln.replace(/(['"])/g,'\\$1') + "\\r\\n';\r\n"; } if( ln.match(/<\/?TMPL_/) ) alert( i + '行目:パース出来てない:' + ln ); lines[i] = ln; } var body = '', data_bk = [], i = []; data_bk.push( data ); eval( lines.join( "\r\n" ) ); return body; function formatDate( value,tmpl ){ if( !value.match( /(\d+)[\/\-](\d+)[\/\-](\d+)/ ) ) return ''; var y = RegExp.$1, m = RegExp.$2, d = RegExp.$3; return tmpl.replace( /YYYY/ig, y ).replace( /MM/ig, m ).replace( /DD/ig, d ); } } , fitImage : function(){ var elms = document.getElementsByTagName('img'); if( !elms.length ) return; var width = 0; var height = 0; for( var i = 0, l = elms.length; i < l; i++ ){ if( elms[i].className != 'justify' ) continue; var obj = getTargetParentByClassName( elms[i], 'img-box' ); if( !obj ) return; height = obj.style.height; width = obj.style.width; if( !width || !height ){ var src = elms[i].src; elms[i].src = ''; width = ( obj.clientWidth - 6 ) ; height = ( obj.clientHeight - 6 ) ; elms[i].src = src; } else { height = height.replace( /\D/g, '' ); width = width.replace( /\D/g, '' ); } break; } for( var i = 0; i < elms.length; i++ ){ var elm = elms[i]; if( elm.className != 'justify' ) continue; var src = elm.src; elm.src = ''; elm.src = src; elm.onload = function( e ){ if( navigator.appName == 'Microsoft Internet Explorer' ){ e = event; e.target = e.srcElement; } if( e.target.width > e.target.height ){ if( height < ( width * ( e.target.height / e.target.width ) ) ){ e.target.style.height = height + 'px'; e.target.style.width = ''; } else { e.target.style.width = width + 'px'; e.target.style.height = ''; } } else { if( width < ( height * ( e.target.width / e.target.height ) ) ){ e.target.style.width = width + 'px'; e.target.style.height = ''; } else { e.target.style.height = height + 'px'; e.target.style.width = ''; } } } } function getTargetParentByClassName( elm, class_nm ){ if( elm == null ) return null; if( elm.parentNode == null ) return null; if( elm.className == class_nm ) return elm; return getTargetParentByClassName( elm.parentNode, class_nm ); } }, showPreviewer : function ( e, url ) { var obj = document.getElementById( '__PREVIEWER__' ); if( !obj ) { obj = this.createPreviewer(); document.body.appendChild( obj ); } else if( !obj.onmosedown ){ obj = this.installEvent( obj ); } var d = obj.getElementsByTagName('iframe')[0].contentWindow.document; var article = {}; for( var i = 0, l = this.Data.rss.length; i < l; i++ ){ if( this.Data.rss[i].link == url ){ article = this.Data.rss[i]; break; } } d.open(); if( d.body ) d.body.innerHTML = ''; d.write( '

' + article.title + '(' + article.creator + ')

' ); d.write( article.description ); d.close(); if( obj.style.display == 'none' ){ obj.style.display = ''; if( navigator.appName == 'Microsoft Internet Explorer' ){ e = event; obj.style.top = ( e.clientY + document.body.scrollTop) + 'px'; obj.style.left = e.clientX + 'px'; } else { obj.style.top = e.pageY + 'px'; obj.style.left = e.clientX + 'px'; } } }, hidePreviewer : function () { var obj = document.getElementById( '__PREVIEWER__' ); obj.getElementsByTagName( 'iframe' )[0].src = ''; obj.style.display = 'none'; }, createPreviewer : function() { var previewer = document.createElement( 'div' ); previewer.id = '__PREVIEWER__'; previewer.style.width = '500px'; previewer.style.height = '500px'; previewer.style.textAlign = 'right'; previewer.style.border = 'solid thin'; previewer.style.backgroundColor = 'white'; previewer.style.position = 'absolute'; var btn = document.createElement( 'input' ); btn.type = 'button'; btn.value = '×'; btn.onclick = this.hidePreviewer; previewer.appendChild( btn ); for( var i = 0; i < 5; i++ ) previewer.appendChild( document.createElement('br') ); var container = document.createElement( 'p' ); container.style.textAlign = 'center'; var ifr = document.createElement( 'iframe' ); ifr.style.width = '95%'; ifr.style.height = '400px'; container.appendChild( ifr ); previewer.appendChild( container ); previewer.style.display = 'none'; previewer = this.installEvent( previewer ); return previewer; } , installEvent : function( previewer ){ if( document.onmousemove ) return previewer; previewer.style.cursor = 'move'; previewer.style.position = 'absolute'; previewer.onmousedown = function( e ){ if( navigator.appName != 'Microsoft Internet Explorer' ){ e.preventDefault(); e.stopPropagation(); } document.onmousemove = function( e ){ var obj = document.getElementById( '__PREVIEWER__' ); if( navigator.appName == 'Microsoft Internet Explorer' ){ e = event; obj.style.top = ( e.clientY + document.body.scrollTop + 5 ) + 'px'; obj.style.left = ( e.clientX - 50 ) + 'px'; } else { e.preventDefault(); e.stopPropagation(); obj.style.top = ( e.pageY + 5 ) + 'px'; obj.style.left = ( e.clientX - 200 ) + 'px'; } return false; } document.onmouseup = function( e ){ document.onmouseup = null; document.onmousemove = null; } previewer.getElementsByTagName('iframe')[0].contentWindow.document.onmouseover = function( e ){ document.onmouseup = null; document.onmousemove = null; } return false; }; return previewer; } }; __r.template = ""; __r.template += '\n'; __r.template += '
  • \n'; __r.template += '
    \n'; __r.template += '\n';