svnno****@sourc*****
svnno****@sourc*****
2007年 7月 22日 (日) 03:25:51 JST
Revision: 169 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=169 Author: flyson Date: 2007-07-22 03:25:50 +0900 (Sun, 22 Jul 2007) Log Message: ----------- 履歴メニューを独自履歴に変更 Modified Paths: -------------- trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.js trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.xul Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.js 2007-07-21 17:54:38 UTC (rev 168) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.js 2007-07-21 18:25:50 UTC (rev 169) @@ -6,7 +6,6 @@ var gTreeBbsMenuView; var gBbsMenuFile; var gBbsMenuXMLFile; -var gHistoryRDF; function startup(){ gBbsmenuUpdater = document.getElementById("bbsmenuUpdater"); @@ -25,16 +24,6 @@ document.loadOverlay(overlayURL, null); } - if("@mozilla.org/rdf/datasource;1?name=history" in Components.classes){ - gHistoryRDF = new b2rRDF("rdf:history"); - var btnHistory = document.getElementById("btnHistory"); - btnHistory.hidden = !gBbs2chService.pref.getBoolPref( - "extensions.bbs2chreader.bbsmenu_historymenu_show"); - }else{ - var btnHistory = document.getElementById("btnHistory"); - btnHistory.hidden = true; - } - // ツリーの偶数行に色をつける if(gBbs2chService.pref.getBoolPref("extensions.bbs2chreader.enable_tree_stripe2")) gTreeBbsMenu.setAttribute("stripe", "true"); @@ -140,61 +129,70 @@ * 履歴を読んで History メニューを更新する */ function updateHistoryMenu(){ - const NS_NC_NAME = "http://home.netscape.com/NC-rdf#Name"; - var popHistory = document.getElementById("popHistory"); while(popHistory.hasChildNodes()){ popHistory.removeChild(popHistory.firstChild); } - var treeHiddenHistory = document.getElementById("treeHiddenHistory"); - if(treeHiddenHistory.hidden){ - treeHiddenHistory.hidden = false; - treeHiddenHistory.database.AddDataSource(gHistoryRDF.ds); - } - - treeHiddenHistory.ref = "find:datasource=history&match=URL&method=startswith&text=bbs2ch:board:"; - var boardCount = treeHiddenHistory.treeBoxObject.view.rowCount; var boardMax = gBbs2chService.pref.getIntPref("extensions.bbs2chreader.bbsmenu_historymenu_board_max"); if(boardMax > 15) boardMax = 15; - if(boardCount > boardMax) boardCount = boardMax; - if(boardCount > 0){ - for(var i=0; i<boardCount; i++){ - try{ - var url = treeHiddenHistory.builder.getResourceAtIndex(i).Value; - var title = gHistoryRDF.getObject(url, NS_NC_NAME); - title = title.replace(" [bbs2chreader]", ""); - var menuNode = document.createElement("menuitem"); - menuNode.setAttribute("label", title); - menuNode.setAttribute("value", url); - menuNode.setAttribute("tooltiptext", url); - popHistory.appendChild(menuNode); - }catch(ex){} + + var sql = "SELECT url, title FROM history WHERE type=0 ORDER BY last_visited DESC LIMIT ?1"; + var statement = gBbs2chService.historyDB.createStatement(sql); + statement.bindInt32Parameter(0, boardMax); + + gBbs2chService.historyDB.beginTransaction(); + try{ + while(statement.executeStep()){ + var url = "bbs2ch:board:" + statement.getString(0); + var title = statement.getString(1); + var menuNode = document.createElement("menuitem"); + menuNode.setAttribute("label", title); + menuNode.setAttribute("value", url); + menuNode.setAttribute("tooltiptext", url); + popHistory.appendChild(menuNode); } + statement.reset(); + }finally{ + gBbs2chService.historyDB.commitTransaction(); } - var serverURL = gBbs2chService.serverURL.resolve("./thread/"); + if(popHistory.hasChildNodes()){ + popHistory.appendChild(document.createElement("menuseparator")); + } - treeHiddenHistory.ref = "find:datasource=history&match=URL&method=startswith&text=" + serverURL; - var threadCount = treeHiddenHistory.treeBoxObject.view.rowCount; + var threadViewLimit = gBbs2chService.pref.getIntPref("extensions.bbs2chreader.board_thread_view_limit"); var threadMax = gBbs2chService.pref.getIntPref("extensions.bbs2chreader.bbsmenu_historymenu_thread_max"); if(threadMax > 15) threadMax = 15; - if(threadCount > threadMax) threadCount = threadMax; - if(threadCount > 0){ - if(boardCount > 0) popHistory.appendChild(document.createElement("menuseparator")); + sql = sql = "SELECT url, title FROM history WHERE type=1 ORDER BY last_visited DESC LIMIT ?1"; + statement = gBbs2chService.historyDB.createStatement(sql); + statement.bindInt32Parameter(0, threadMax); - for(i=0; i<threadCount; i++){ - try{ - url = treeHiddenHistory.builder.getResourceAtIndex(i).Value; - title = gHistoryRDF.getObject(url, NS_NC_NAME); - title = title.replace(" [bbs2chreader]", ""); - menuNode = document.createElement("menuitem"); - menuNode.setAttribute("label", title); - menuNode.setAttribute("value", url); - menuNode.setAttribute("tooltiptext", url); - popHistory.appendChild(menuNode); - }catch(ex){} + gBbs2chService.historyDB.beginTransaction(); + try{ + while(statement.executeStep()){ + var url = statement.getString(0); + var title = statement.getString(1); + var type = gBbs2chService.getBoardType(url); + var threadURL = gBbs2chService.serverURL.resolve("./thread/" + url); + + if(threadViewLimit > 0){ + if(type == gBbs2chService.BOARD_TYPE_MACHI){ + threadURL += "&LAST=" + threadViewLimit; + }else{ + threadURL += "l" + threadViewLimit; + } + } + + var menuNode = document.createElement("menuitem"); + menuNode.setAttribute("label", title); + menuNode.setAttribute("value", threadURL); + menuNode.setAttribute("tooltiptext", threadURL); + popHistory.appendChild(menuNode); } + statement.reset(); + }finally{ + gBbs2chService.historyDB.commitTransaction(); } } Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.xul =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.xul 2007-07-21 17:54:38 UTC (rev 168) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/bbsmenu/page.xul 2007-07-21 18:25:50 UTC (rev 169) @@ -14,7 +14,6 @@ <script type="application/x-javascript" src="chrome://bbs2chreader/content/lib/downloader.js"/> <script type="application/x-javascript" src="chrome://bbs2chreader/content/lib/clipboard.js"/> -<script type="application/x-javascript" src="chrome://bbs2chreader/content/lib/rdf.js"/> <script type="application/x-javascript" src="chrome://bbs2chreader/content/bbsmenu/treeview.js"/> <script type="application/x-javascript" src="chrome://bbs2chreader/content/bbsmenu/page.js"/> @@ -63,25 +62,4 @@ <treechildren/> </tree> -<!-- History Menu --> -<tree flex="1" id="treeHiddenHistory" hidden="true" collapsed="true" - datasources="rdf:null" flags="dont-build-content" hidecolumnpicker="true"> - <template> - <rule> - <treechildren> - <treeitem uri="rdf:*" rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"> - <treerow> - <treecell label="rdf:http://home.netscape.com/NC-rdf#Date"/> - </treerow> - </treeitem> - </treechildren> - </rule> - </template> - <treecols> - <treecol flex="1" id="ColHiddenHistoryTreeDate" hideheader="true" - primary="true" sort="rdf:http://home.netscape.com/NC-rdf#Date" - sortActive="true" sortDirection="descending"/> - </treecols> -</tree> - </page> \ No newline at end of file