function listing(liststyle){ // author から以下の正規表現にマッチするものだけを自分の業績として表示します。 var myname_picker=/辰己|tatsumi/i; // listingの際にハイライトさせる著者名 var mynamepattern=/(辰己\ 丈夫|辰己丈夫|Takeo\ Tatsumi|Tatsumi\ Takeo|TATSUMI\ Takeo|T\.\ Tatsumi|Takeo\ TATSUMI|Tatsumi T)/g; // json形式で出力する際の配列全体の名前 var json_array_name="tatsumiworks"; // BiBTeX形式で出力する際に、エントリIDがついてないものへの仮エントリIDの冠 var bibidprefix="ttm"; // JSONで書かれた文献ファイルの置場(JSONPをしてないので、同一サーバにする必要がある) var jsonsource="https://qed.ouj.ac.jp/myworks.json"; // カラム名(BiBTeXにならった) var cols = new Array( "bibtype", "bibid", "year", "month", "day", "prizename", "author", "title", "journal", "booktitle", "series", "editor", "organization", "institution", "publisher", "volume", "number", "edition", "chapter", "pages", "type", "howpublished", "where", "address", "DOI", "ISBN", "ISSN", "URL", "note"); // カテゴリ名(BiBTeXにならった)とその和訳 var categ = new Array("prize", "article","bulletin","book","inbook","inproceedings","talk","magazine","manual","techreport","incollection","unpublished","booklet","misc"); var categj = new Array("授賞(下のカテゴリ別と重複記載されています。グループ授賞と、他者が主著のものも含みます。)", "論文・国際会議・ショートレターなど(査読ありのもの)","紀要","著書(単著)","著書(共著)","研究報告など(査読なし、あるいは通過率が高い査読あり)","講演","雑誌","マニュアル","技術報告","資料集の一部","発表されてないもの","ブックレット", "その他"); var colsep="\t"; var i; var request = new XMLHttpRequest(); var outtext = ""; request.open("GET", jsonsource, false); request.send(null); console.log("STATUS:" + request.status); if (request.status != 200) cosole.log("データをとれませんでした。"); else { eval("var bib = " + request.responseText); // リストを出さないときはカテゴリ分割のまえに出力が必要 if ( liststyle == 'bibtex'){ // bibtexのときの前処理 outtext += "
"; } else if ( liststyle == 'json'){ // JSONのときの前処理 outtext += "{"; } // 中身を完成させた後の処理 document.getElementById('titles').innerHTML = outtext; } }
\""+json_array_name+"\": \[
"; } else if ( liststyle == 'tsv' ){ // TSVのときの前処理 outtext += ""; outtext += "bibid" +colsep; for ( var colname in cols ){ if ( cols[colname] != "bibid" ){ outtext += cols[colname] +colsep; } } outtext += ""; } else if ( liststyle == 'json' ){ // JSONのときの後処理 outtext += " ]
"; } // カテゴリ毎に以下を繰り返す for ( catname in categ ){ if ( liststyle == 'list'){ outtext += "" + categj[catname] + "
" + ""; } // 各行の処理 for (i=0; i < bib.myworks.length; i++) { // 自分限定・カテゴリ指定 if ( bib.myworks[i].bibtype == categ[catname] && typeof bib.myworks[i].author != "undefined" && myname_picker.test(bib.myworks[i].author) ){ if ( liststyle == 'list' ){ outtext += "
"; } } // すべてのカテゴリを出力した後の処理 if ( liststyle == 'tsv' || liststyle == 'bibtex' ){ // bibtex のときの後処理 outtext += "- "; if ( typeof bib.myworks[i].year != "undefined" ){ outtext += bib.myworks[i].year; if ( typeof bib.myworks[i].month != "undefined" ){ outtext += "." + bib.myworks[i].month; if ( typeof bib.myworks[i].day != "undefined" ){ outtext += "." + bib.myworks[i].day; } } outtext += ", "; } if ( typeof bib.myworks[i]["prizename"] != "undefined" ){ newtitle = bib.myworks[i]["prizename"].replace(/[{}]/g,""); outtext += "" + newtitle + ", "; } if ( typeof bib.myworks[i].author != "undefined" ){ outauthor = bib.myworks[i].author.replace(mynamepattern, "$1").replace(/\ and\ /g,", ").replace(/[{}]/g,""); outtext += " : "; } if ( typeof bib.myworks[i]["title"] != "undefined" ){ newtitle = bib.myworks[i]["title"].replace(/[{}]/g,""); outtext += "" + newtitle + ", "; } for ( var colname in cols ){ if ( typeof bib.myworks[i][cols[colname]] != "undefined" && !(/^author$|^title$|^bibtype$|^bibid$|^year$|^month$|^day$|^prizename$/.test(cols[colname])) ){ if ( cols[colname] == "volume" ){ outtext += "Vol."; } else if ( cols[colname] == "number" ){ outtext += "No."; } else if ( cols[colname] == "pages" ){ // ページ範囲が複数に跨るときは pp. をつける。単一頁は p. をつける。 if ( /\-/.test(bib.myworks[i][cols[colname]]) ) outtext += "pp."; else outtext += "p."; } else if ( cols[colname] == "URL" ){ outtext += ""; } // BiBTeXの記法を除く addtext = bib.myworks[i][cols[colname]].replace(/[\-]+/g,"-").replace(/[\ ]+/g," ").replace(/\{/g,"-").replace(/\}/g,"-"); outtext += addtext; if ( cols[colname] == "URL" ){ outtext += ""; } if ( colname < cols.length-1 ) outtext += ", "; else outtext += "."; } } outtext = outtext + "
"; } else if ( liststyle == 'json' ){ outtext += " {
"; for ( var colname in cols ){ if ( typeof bib.myworks[i][cols[colname]] != "undefined" && cols[colname] != "bibid" ){ outtext += " \"" + cols[colname] + "\": \"" + bib.myworks[i][cols[colname]] + "\",
"; } } outtext = outtext + " },
"; } else if ( liststyle == 'bibtex' ){ outtext += "@"+bib.myworks[i]['bibtype']+"{"; if ( typeof bib.myworks[i]['bibid'] == "undefined" ){ outtext += bibidprefix+bib.myworks[i]['year']+bib.myworks[i]["title"].length+bib.myworks[i]["author"].length+", "; } else { outtext += bib.myworks[i]['bibid']+", "; } for ( var colname in cols ){ if ( typeof bib.myworks[i][cols[colname]] != "undefined" && cols[colname] != "bibid" && cols[colname] != "bibtype" ){ outtext += cols[colname] + "="; if ( cols[colname] != 'year' ) outtext += "\""; outtext += bib.myworks[i][cols[colname]]; if ( cols[colname] != 'year' ) outtext += "\""; outtext +=","; } } outtext = outtext + "}
"; } else if ( liststyle == 'tsv' ){ if ( typeof bib.myworks[i]['bibid'] == "undefined" ){ outtext += bibidprefix+bib.myworks[i]['year']+bib.myworks[i]["title"].length+bib.myworks[i]["author"].length+colsep; } else { outtext += bib.myworks[i]['bibid']+colsep; } for ( var colname in cols ){ if ( cols[colname] == "bibid" ){ ; } else if ( cols[colname] == "bibtype" ){ outtext += categj[catname] + colsep; } else { if (typeof bib.myworks[i][cols[colname]] == "undefined" ){ outtext +=colsep; } else { outtext += bib.myworks[i][cols[colname]] +colsep; } } } outtext += colsep + "
"; } } } if ( liststyle == 'list'){ // listのときの後処理 outtext += "
}