flyson
flyso****@users*****
2005年 12月 14日 (水) 00:47:09 JST
Index: bbs2chreader/content/bbs2chreader/bbsmenu-update.xul diff -u bbs2chreader/content/bbs2chreader/bbsmenu-update.xul:1.3 bbs2chreader/content/bbs2chreader/bbsmenu-update.xul:removed --- bbs2chreader/content/bbs2chreader/bbsmenu-update.xul:1.3 Sat Sep 17 04:27:14 2005 +++ bbs2chreader/content/bbs2chreader/bbsmenu-update.xul Wed Dec 14 00:47:09 2005 @@ -1,33 +0,0 @@ -<?xml version="1.0" encoding="EUC-JP"?> -<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> - -<window id="winMain" title="BBSMENU UPDATE [bbs2chreader]" - onload="startup()" onunload="shutdown()" width="450" height="300" - persist="width, height, screenX, screenY" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - -<script type="application/x-javascript" src="chrome://bbs2chreader/content/global.js"/> -<script type="application/x-javascript" src="chrome://bbs2chreader/content/lib/downloader.js"/> -<script type="application/x-javascript" src="chrome://bbs2chreader/content/bbsmenu-update.js"/> - - -<deck id="dckTop"> - <hbox align="center" class="box-padded"> - <label value="BBSMENU URL :"/> - <textbox id="txtBbsmenuURL" flex="1"/> - <button label="Update" oncommand="bbsmenuUpdate()"/> - </hbox> - <hbox align="center" class="box-padded"> - <progressmeter id="prgrsMeter" flex="1"/> - <button label="Cancel" oncommand="bbsmenuUpdate()"/> - </hbox> -</deck> - - -<vbox id="boxOutputBox" collapsed="false" class="box-padded" flex="1"> - <textbox id="txtOutput" multiline="true" flex="1"/> -</vbox> - - - -</window> \ No newline at end of file Index: bbs2chreader/content/bbs2chreader/bbsmenu-update.js diff -u bbs2chreader/content/bbs2chreader/bbsmenu-update.js:1.5 bbs2chreader/content/bbs2chreader/bbsmenu-update.js:removed --- bbs2chreader/content/bbs2chreader/bbsmenu-update.js:1.5 Sat Sep 17 04:27:14 2005 +++ bbs2chreader/content/bbs2chreader/bbsmenu-update.js Wed Dec 14 00:47:09 2005 @@ -1,127 +0,0 @@ - -var bbsMenuFile; -var bbsMenuDownloader; -var oldBoardList; -var newBoardList; - -var txtBbsmenuURL; - - -function startup(){ - txtBbsmenuURL = document.getElementById("txtBbsmenuURL"); - - bbsMenuFile = Bbs2chGlobal.getDataDir(); - bbsMenuFile.appendRelativePath("bbsmenu.html"); - - oldBoardList = getBoardList(); - - txtBbsmenuURL.value = Bbs2chGlobal.getPrefValue("fls.bbs2chreader.bbsmenu_load_url"); -} - - -function shutdown(){ - if(bbsMenuDownloader && bbsMenuDownloader.loading) - bbsMenuDownloader.abort(true); - - // 更新しないで終了 - if(!window.arguments[0].value) window.arguments[0].value = false; -} - - -function output(aString){ - document.getElementById("txtOutput").value += aString + "\n"; -} - - -/** - * bbsmenu.html をダウンロードして板一覧を更新する - */ -function bbsmenuUpdate(){ - document.getElementById("boxOutputBox").collapsed = false; - - var bbsmenuURL = txtBbsmenuURL.value; - var bbsmenuFilePath = bbsMenuFile.path; - bbsMenuDownloader = new Bbs2chDownloader(bbsmenuURL, bbsmenuFilePath); - - bbsMenuDownloader.onStart = function(aDownloader){ - document.getElementById("dckTop").selectedIndex = 1; - output("start: " + aDownloader.urlSpec); - }; - bbsMenuDownloader.onStop = function(aDownloader, aStatus){ - document.getElementById("dckTop").selectedIndex = 0; - output("Update Succeed."); - window.setTimeout("serverMovedCheck()", 0); - }; - bbsMenuDownloader.onProgressChange = function(aDownloader, aPercentage){ - document.getElementById("prgrsMeter").value = aPercentage; - }; - bbsMenuDownloader.onError = function(aDownloader, aErrorCode){ - alert("Download Error: " + aErrorCode + "\n" + aDownloader.urlSpec); - }; - - bbsMenuDownloader.download(); -} - - -function getBoardList(){ - var result = new Array(); - if(!bbsMenuFile.exists()) return result; - - var threadReg = /^<A HREF=([^> ]+)>([^<]+)<\/A>/i; - var threadReg2 = /^<A HREF=([^> ]+) TARGET=_blank>([^<]+)<\/A>/i; - - var contentLines = Bbs2chGlobal.readFile(bbsMenuFile.path); - contentLines = Bbs2chGlobal.fromSJIS(contentLines).split("\n"); - - // ぐるぐる - for(var i=0; i<contentLines.length; i++){ - var line = contentLines[i]; - if(threadReg.test(line) || threadReg2.test(line)){ - var title = RegExp.$2; - var url = RegExp.$1; - var type = Bbs2chGlobal.getBoardType(url); - - if(type != Bbs2chGlobal.TYPE_PAGE) result[title] = url; - } - } - - return result; -} - - -/** - * 更新前と後の板リストを比較してサーバ移転があったらログを移動するメソッド - */ -function serverMovedCheck(){ - var serverMoved = false; - output("\nMoved Check."); - - newBoardList = getBoardList(); - - for(var i in newBoardList){ - if(oldBoardList.hasOwnProperty(i) && (oldBoardList[i] == newBoardList[i])){ - delete oldBoardList[i]; - } - } - - for(i in oldBoardList){ - var title = i; - var oldURL = oldBoardList[i]; - var newURL = newBoardList[i]; - var oldDir = Bbs2chGlobal.createLogFile(oldURL); - var newDir = Bbs2chGlobal.createLogFile(newURL); - - if(oldDir.exists()){ - try{ - oldDir.moveTo(newDir.parent, ""); - }catch(ex){} - serverMoved = true; - output(title +"\n "+ oldURL +" > "+ newURL); - } - } - - // 更新して終了 - output("OK"); - window.arguments[0].value = true; - if(!serverMoved) window.setTimeout("window.close()", 500); -} \ No newline at end of file Index: bbs2chreader/content/bbs2chreader/bbsmenu-page.xul diff -u bbs2chreader/content/bbs2chreader/bbsmenu-page.xul:1.14 bbs2chreader/content/bbs2chreader/bbsmenu-page.xul:removed --- bbs2chreader/content/bbs2chreader/bbsmenu-page.xul:1.14 Sun Sep 25 22:50:14 2005 +++ bbs2chreader/content/bbs2chreader/bbsmenu-page.xul Wed Dec 14 00:47:09 2005 @@ -1,114 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> -<?xml-stylesheet href="chrome://bbs2chreader/skin/bbsmenu-page.css" type="text/css"?> - - -<!DOCTYPE page [ - <!ENTITY % bbsmenu-page-dtd SYSTEM "chrome://bbs2chreader/locale/bbsmenu-page.dtd"> - %bbsmenu-page-dtd; -]> -<page id="pageMain" onload="startup()" onunload="shutdown()" - onmousedown="event.preventBubble()" onkeypress="event.preventBubble()" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> - - <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-ds.js"/> - <script type="application/x-javascript" src="chrome://bbs2chreader/content/bbsmenu-page.js"/> - - -<popupset> - <popup id="popBbsMenuContext" - onpopupshowing="return showBbsMenuContext(event)"> - <menuitem label="&ctxtOpen.label;" oncommand="openBoard(false)"/> - <menuitem label="&ctxtOpenInNewTab.label;" oncommand="openBoard(true)"/> - <menuseparator/> - <menuitem label="&ctxtCopuURL.label;" oncommand="copyURL()"/> - <menuitem label="&ctxtCopuURLnTitle.label;" oncommand="copyTitleAndURL()"/> - </popup> -</popupset> - - -<hbox align="center"> - <textbox id="search-box" value="" flex="1" type="autocomplete" - autocompletesearch="form-history" - autocompletesearchparam="bbs2ch-bbsmenu-history" - onkeypress="searchTitle(event, this.value)"/> - <toolbarbutton id="btnHistory" label="&history.label;" type="menu"> - <menupopup id="popHistory" onpopupshowing="updateHistoryMenu()" - onclick="popHistoryClick(event)"/> - </toolbarbutton> - <toolbarbutton label="&tools.label;" type="menu"> - <menupopup> - <menuitem label="&bbsmenuUpdate.label;" oncommand="bbsmenuUpdate()"/> - <menuseparator/> - <menuitem label="&openLogsDirectory.label;" oncommand="openLogsDir()"/> - <menuitem label="&options.label;" oncommand="openSettings()"/> - <menuitem label="&about.label;" oncommand="openAbout()"/> - - <menuseparator/> - <menu label="Tests"> - <menupopup ref="urn:bbs2ch-test-menu:root" - datasources="chrome://bbs2chreader/content/test/test-menu.rdf" - oncommand="testMenuClick(event)"> - <template> - <rule> - <menuitem uri="rdf:*" value="rdf:*" - opentype="rdf:http://bbs2ch.sourceforge.jp/#opentype" - label="rdf:http://bbs2ch.sourceforge.jp/#title"/> - </rule> - </template> - </menupopup> - </menu> - - </menupopup> - </toolbarbutton> - <spacer class="small-margin"/> -</hbox> - - -<tree id="treeBbsMenu" class="plain" flex="1" context="popBbsMenuContext" - flags="dont-build-content" hidecolumnpicker="true" - onclick="treeBbsMenuClick(event)" - datasources="rdf:null" ref="urn:bbs2ch:bbsmenu:root"> - <treecols> - <treecol id="colTitle" hideheader="true" flex="1" primary="true"/> - </treecols> - <template> - <rule> - <treechildren> - <treeitem uri="rdf:*"> - <treerow> - <treecell label="rdf:http://bbs2ch.sourceforge.jp/#title" - properties="Name type-rdf:http://bbs2ch.sourceforge.jp/#type"/> - </treerow> - </treeitem> - </treechildren> - </rule> - </template> -</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 Index: bbs2chreader/content/bbs2chreader/bbsmenu-page.js diff -u bbs2chreader/content/bbs2chreader/bbsmenu-page.js:1.29 bbs2chreader/content/bbs2chreader/bbsmenu-page.js:removed --- bbs2chreader/content/bbs2chreader/bbsmenu-page.js:1.29 Sun Nov 20 14:33:14 2005 +++ bbs2chreader/content/bbs2chreader/bbsmenu-page.js Wed Dec 14 00:47:09 2005 @@ -1,431 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is bbs2chreader. - * - * The Initial Developer of the Original Code is - * flyson. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * flyson <flyso****@users*****> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -var gBbs2chService = Components.classes["@mozilla.org/bbs2ch-service;1"] - .getService(Components.interfaces.nsIBbs2chService); - -var gTreeBbsMenu; -var gBbsmenuDS; -var gHistoryRDF; - - -function startup(){ - gBbsmenuDS = new Bbs2chBbsMenuDS(); - - gHistoryRDF = new Bbs2chRDF(); - gHistoryRDF.initWithRDFURL("rdf:history"); - - var btnHistory = document.getElementById("btnHistory"); - btnHistory.hidden = !gBbs2chService.pref.getBoolPref("fls.bbs2chreader.bbsmenu_historymenu_show"); - - - gTreeBbsMenu = document.getElementById("treeBbsMenu"); - - if(gBbsmenuDS.bbsMenuFile.exists()){ - initTreeBbsMenu(); - }else{ // bbsmenu.html が無いときは自動で取得 - bbsmenuUpdate(); - } -} - -function shutdown(){ - -} - - -function initTreeBbsMenu(){ - // 古いデータソースが存在するときは削除 - var databases = gTreeBbsMenu.database.GetDataSources(); - while(databases.hasMoreElements()){ - try{ - var ds = databases.getNext() - .QueryInterface(Components.interfaces.nsIRDFDataSource); - if(ds.URI != "rdf:localstore") - gTreeBbsMenu.database.RemoveDataSource(ds); - }catch(ex){}; - } - - gTreeBbsMenu.hidden = true; - gBbsmenuDS.initDS(); - gTreeBbsMenu.database.AddDataSource(gBbsmenuDS.ds); - gTreeBbsMenu.builder.rebuild(); - gTreeBbsMenu.hidden = false; - - // フォーカス - if(gTreeBbsMenu.treeBoxObject.view.selection){ - gTreeBbsMenu.focus(); - gTreeBbsMenu.treeBoxObject.view.selection.select(0); - } -} - - -/** - * 選択中の板をブラウザで開く - * @param aAddTab boolean true なら新しいタブで開く - */ -function openBoard(aAddTab){ - if(gTreeBbsMenu.currentIndex == -1) return; - var resource = gTreeBbsMenu.view.getResourceAtIndex(gTreeBbsMenu.currentIndex); - - var boardURL = resource.Value; - if(boardURL.indexOf("http://")!=0) return; - - var boardType = gBbsmenuDS.rdf.getLiteralProperty(resource.Value, - gBbs2chService.nameSpace + "type"); - - switch(parseInt(boardType)){ - case gBbs2chService.BOARD_TYPE_2CH: - case gBbs2chService.BOARD_TYPE_BE2CH: - case gBbs2chService.BOARD_TYPE_JBBS: - boardURL = "bbs2ch:board:" + boardURL; - break; - } - - gBbs2chService.openURL(boardURL, null, aAddTab); -} - - -/** - * ツリーをクリックしたときに呼ばれる - * - * @param aEvent event - */ -function treeBbsMenuClick(aEvent){ - var row = {} - var obj = {}; - gTreeBbsMenu.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, {}, obj); - if(row.value == -1) return; // ツリーのアイテム以外をクリック - - var eButton = aEvent.button; - var eDetail = aEvent.detail; - var objName = obj.value; - var isContainer = gTreeBbsMenu.view.isContainer(row.value); - - if(eButton==0 && eDetail==1 && objName=="twisty"){ - // twisty ボタンを使ったコンテナのオープン - closeAllOpendContainers(row.value); - return; - }else if(eDetail==2 && objName!="twisty" && isContainer){ - // ダブルクリックによるコンテナのオープン - closeAllOpendContainers(row.value); - return; - } - - var openAction = gBbs2chService.pref.getIntPref("fls.bbs2chreader.bbsmenu_open_action"); - - if(eButton==0 && eDetail==1 && !isContainer){ - // クリック - }else if(eButton==0 && eDetail==2 && !isContainer){ - // ダブルクリック - openBoard(openAction == 1); - }else if(eButton==1 && eDetail==1 && !isContainer){ - // ミドルクリック - openBoard(openAction == 0); - } - - -} - - -/** - * ツリーのコンテキストメニューが表示されるときに呼ばれる - */ -function showBbsMenuContext(aEvent){ - var row = {} - var obj = {}; - gTreeBbsMenu.treeBoxObject.getCellAt(aEvent.clientX, aEvent.clientY, row, {}, obj); - - // ツリーのアイテム以外をクリック - if(row.value == -1) return false; - - // コンテナの場合はコンテキストメニューを出さない - return !gTreeBbsMenu.view.isContainer(row.value); -} - - -/** - * 選択中の板の URL をクリップボードにコピー - */ -function copyURL(){ - if(gTreeBbsMenu.currentIndex == -1) return; - var resource = gTreeBbsMenu.view.getResourceAtIndex(gTreeBbsMenu.currentIndex); - - var boardURL = resource.Value; - if(boardURL.indexOf("http://")!=0) return; - - Bbs2chClipboard.setString(boardURL); -} - - -/** - * 選択中の板の URL とタイトルをクリップボードにコピー - */ -function copyTitleAndURL(){ - if(gTreeBbsMenu.currentIndex == -1) return; - var resource = gTreeBbsMenu.view.getResourceAtIndex(gTreeBbsMenu.currentIndex); - - var title = gBbsmenuDS.rdf.getLiteralProperty(resource.Value, - gBbs2chService.nameSpace + "title"); - - var boardURL = resource.Value; - if(boardURL.indexOf("http://")!=0) return; - - Bbs2chClipboard.setString(title +"\n"+ boardURL); -} - - -/** - * ログフォルダを開く - */ -function openLogsDir(){ - var logDir = gBbs2chService.getDataDir(); - - try{ - logDir.reveal(); - }catch(ex){ - // for Unix - var ioService = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService); - var protocolService = Components.classes - ["@mozilla.org/uriloader/external-protocol-service;1"] - .getService(Components.interfaces.nsIExternalProtocolService); - var logDirURI = ioService.newFileURI(logDir); - protocolService.loadUrl(logDirURI); - } -} - - -/** - * 設定ダイアログを開く - */ -function openSettings(){ - var settingDialogURL = "chrome://bbs2chreader/content/settings/settings.xul"; - window.openDialog(settingDialogURL, "_blank", "chrome, modal, resizable"); -} - - -/** - * エクステンションマネージャを使った About の表示 - */ -function openAbout(){ - var ExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"] - .getService(Components.interfaces.nsIExtensionManager); - var emDS = ExtensionManager.datasource; - var ExtensionID = ""; - if(gBbs2chService.geckoVersionCompare("1.8") <= 0){ - ExtensionID = "urn:mozilla:item:{0B9D558E-6983-486b-9AAD-B6CBCD2FC807}"; - }else{ - ExtensionID = "urn:mozilla:extension:{0B9D558E-6983-486b-9AAD-B6CBCD2FC807}"; - } - - window.openDialog("chrome://mozapps/content/extensions/about.xul", "", - "chrome, modal", ExtensionID, emDS); -} -/** - * About ダイアログがホームページを開く時に利用するメソッド - */ -function openURL(aURLSpec){ - gBbs2chService.openURL(aURLSpec, null, true); -} - - -/** - * 開いているすべてのツリーコンテナを閉じる - * @param aExceptIndex number 閉じないコンテナのインデックス - */ -function closeAllOpendContainers(aExceptIndex){ - if(!gTreeBbsMenu.view.isContainerOpen(aExceptIndex)) return; - - if(!gBbs2chService.pref.getBoolPref("fls.bbs2chreader.bbsmenu_toggle_open_container")) return; - - // 閉じないコンテナのリソースを取得しておく - var exceptResource = gTreeBbsMenu.builder.getResourceAtIndex(aExceptIndex); - - var rootContainer = Components.classes["@mozilla.org/rdf/container;1"] - .createInstance(Components.interfaces.nsIRDFContainer); - rootContainer.Init(gTreeBbsMenu.database, - gBbsmenuDS.rdf.getResource("urn:bbs2ch:bbsmenu:root")); - var containers = rootContainer.GetElements(); - while(containers.hasMoreElements()){ - var container = containers.getNext() - .QueryInterface(Components.interfaces.nsIRDFResource); - var index = gTreeBbsMenu.builder.getIndexOfResource(container); - if(exceptResource == container) continue; - if(container.Value.indexOf("urn:bbs2ch:") == -1) continue; - if(!gTreeBbsMenu.view.isContainerOpen(index)) continue; - - if(index != -1) gTreeBbsMenu.view.toggleOpenState(index); - } - - // 閉じないコンテナが表示されるようにスクロール - aExceptIndex = gTreeBbsMenu.builder.getIndexOfResource(exceptResource); - gTreeBbsMenu.boxObject.ensureRowIsVisible(aExceptIndex); -} - - -/** - * 履歴を読んで 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("fls.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.getLiteralProperty(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){} - } - } - - treeHiddenHistory.ref = "find:datasource=history&match=URL&method=startswith&text=bbs2ch:thread:"; - var threadCount = treeHiddenHistory.treeBoxObject.view.rowCount; - var threadMax = gBbs2chService.pref.getIntPref("fls.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")); - - for(i=0; i<threadCount; i++){ - try{ - url = treeHiddenHistory.builder.getResourceAtIndex(i).Value; - title = gHistoryRDF.getLiteralProperty(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){} - } - } -} - - -/** - * History メニューアイテムをクリックしたときの処理 - * @param aEvent event イベントオブジェクト - */ -function popHistoryClick(aEvent){ - var target = aEvent.originalTarget; - if(target.localName != "menuitem" || !(target.value)) return; - if(aEvent.button == 0){ - gBbs2chService.openURL(target.value, null, false); - }else if(aEvent.button == 1){ - target.parentNode.hidePopup(); - gBbs2chService.openURL(target.value, null, true); - } -} - - -/** - * Tests メニューアイテムをクリックしたときの処理 - * @param aEvent event イベントオブジェクト - */ -function testMenuClick(aEvent){ - var target = aEvent.originalTarget; - var url = target.getAttribute("value"); - var openType = target.getAttribute("opentype"); - - if(openType == "dialog"){ - window.openDialog(url, "", "chrome,resizable"); - }else{ - gBbs2chService.openURL(url, null, true); - } -} - - -/** - * 板タイトルを検索して、結果をツリーに表示 - * aSearchString が空ならツリーを元に戻す - * @param aEvent event イベントオブジェクト - * @param aSearchString string 検索文字列 - */ -function searchTitle(aEvent, aSearchString){ - // keypress イベント時にエンター以外が押された - if((aEvent.type == "keypress") && - ((aEvent.keyCode != KeyEvent.DOM_VK_ENTER) && - (aEvent.keyCode != KeyEvent.DOM_VK_RETURN))) - return; - - if(aSearchString){ - // フォーム履歴に検索文字列を追加 - var formHistory = Components.classes["@mozilla.org/satchel/form-history;1"] - .getService(Components.interfaces.nsIFormHistory); - formHistory.addEntry("bbs2ch-bbsmenu-history", aSearchString); - - gBbsmenuDS.searchTitle(aSearchString); - gTreeBbsMenu.ref = "urn:bbs2ch:bbsmenu:search"; - }else{ - gTreeBbsMenu.ref = "urn:bbs2ch:bbsmenu:root"; - } -} - - -/** - * bbsmenu.html をダウンロードして板一覧を更新する - */ -function bbsmenuUpdate(){ - var updateDialogURL = "chrome://bbs2chreader/content/bbsmenu-update.xul"; - var updated = {}; - window.openDialog(updateDialogURL, "", "chrome, modal", updated); - - if(updated.value) initTreeBbsMenu(); -} Index: bbs2chreader/content/bbs2chreader/bbsmenu-ds.js diff -u bbs2chreader/content/bbs2chreader/bbsmenu-ds.js:1.13 bbs2chreader/content/bbs2chreader/bbsmenu-ds.js:removed --- bbs2chreader/content/bbs2chreader/bbsmenu-ds.js:1.13 Sat Nov 5 01:20:01 2005 +++ bbs2chreader/content/bbs2chreader/bbsmenu-ds.js Wed Dec 14 00:47:09 2005 @@ -1,224 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is bbs2chreader. - * - * The Initial Developer of the Original Code is - * flyson. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * flyson <flyso****@users*****> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -function Bbs2chBbsMenuDS(){ - this.init(); -} - -Bbs2chBbsMenuDS.prototype = { - - -// ********** ********* プロパティ ********** ********** - - - /** - * 板一覧用の RDF - * @return Bbs2chRDF - */ - get rdf(){ - return this._rdf; - }, - - - /** - * 板一覧の RDF データソース - * @return nsIRDFDataSource - */ - get ds(){ - return this.rdf.ds; - }, - - - /** - * データフォルダ内の bbsmenu.html - * @return nsILocalFile - */ - get bbsMenuFile(){ - return this._bbsMenuFile; - }, - - - /** - * データフォルダ内の bbsmenu.rdf - * @return nsILocalFile - */ - get bbsMenuRDFFile(){ - return this._bbsMenuRDFFile; - }, - - /** - * データフォルダ内の outside.txt - * @return nsILocalFile - */ - get outsideFile(){ - return this._outsideFile; - }, - -// ********** ********* メソッド ********** ********** - - - init: function(){ - this._rdf = new Bbs2chRDF(); - - this._bbs2chService = Components.classes["@mozilla.org/bbs2ch-service;1"] - .getService(Components.interfaces.nsIBbs2chService); - this._ioService = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService); - - this._bbsMenuFile = this._bbs2chService.getDataDir(); - this._bbsMenuFile.appendRelativePath("bbsmenu.html"); - this._bbsMenuRDFFile = this._bbs2chService.getDataDir(); - this._bbsMenuRDFFile.appendRelativePath("bbsmenu.rdf"); - this._outsideFile = this._bbs2chService.getDataDir(); - this._outsideFile.appendRelativePath("outside.txt"); - }, - - initDS: function(){ - const NS_BBS2CH = this._bbs2chService.nameSpace; - - var categoryReg = /<BR><B>([^<]+)<\/B><BR>/i; - var threadReg = /^<A HREF=([^> ]+)>([^<]+)<\/A>/i; - var threadReg2 = /^<A HREF=([^> ]+) TARGET=_blank>([^<]+)<\/A>/i; - - // bbsmenu.html が無いときは終了 - if(!this.bbsMenuFile.exists()) return; - - if(this.bbsMenuRDFFile.exists() && this.outsideFile.exists()){ - var rdfLMTime = this.bbsMenuRDFFile.lastModifiedTime; - var bbsmenuLMTime = this.bbsMenuFile.lastModifiedTime; - var outsideLMTime = this.outsideFile.lastModifiedTime; - - if((rdfLMTime > bbsmenuLMTime) && (rdfLMTime > outsideLMTime)){ - var rdfURL = this._ioService.newFileURI(this.bbsMenuRDFFile); - this.rdf.initWithRDFURL(rdfURL.spec); - return; - } - } - - // ルートコンテナの作成 - var rootContainer = this.rdf.makeSeqContainer("urn:bbs2ch:bbsmenu:root"); - - // 外部板コンテナの作成 - var outsideContainer = this.rdf.makeSeqContainer("urn:bbs2ch:bbsmenu:outside-board"); - this.rdf.setLiteralProperty(outsideContainer.Resource, NS_BBS2CH + "title", "OUTSIDE"); - - // 外部板リストが存在しないときはテンプレートから作る - if(!this.outsideFile.exists()){ - var templateContent = this._bbs2chService.readLocalURI( - "chrome://bbs2chreader/content/res/outside.txt"); - this._bbs2chService.writeFile(this.outsideFile.path, templateContent, false); - } - var outsideLines = this._bbs2chService.readFile(this.outsideFile.path); - outsideLines = this._bbs2chService.fromSJIS(outsideLines).split("\n"); - - var regOutsideLine = /^(http:\/\/.*)\t(.+)\t(type-.+)/; - var typeHash = new Array(); - typeHash["type-2ch"] = 0; - typeHash["type-old2ch"] = 1; - typeHash["type-be2ch"] = 2; - typeHash["type-jbbs"] = 3; - typeHash["type-machi"] = 4; - typeHash["type-page"] = 5; - for(var i=0; i<outsideLines.length; i++){ - var line = outsideLines[i]; - if(regOutsideLine.test(line)){ - if(RegExp.$3 in typeHash){ - var board = this.rdf.appendResource(RegExp.$1, outsideContainer); - var type = typeHash[RegExp.$3]; - this.rdf.setLiteralProperty(board, NS_BBS2CH + "title", RegExp.$2); - this.rdf.setLiteralProperty(board, NS_BBS2CH + "type", type); - } - } - } - rootContainer.AppendElement(outsideContainer.Resource); - - - // bbsmenu.html を読み込んで、行を配列に格納 - var content = this._bbs2chService.readFile(this.bbsMenuFile.path); - content = this._bbs2chService.fromSJIS(content); - // 改行位置がおかしい部分の修正 - content = content.replace(/<\/B><BR><A HREF/igm, "</B><BR>\n<A HREF") - var contentLines = content.split("\n"); - content = null; - - var currentCategory; - // ぐるぐる - for(i=0; i<contentLines.length; i++){ - line = contentLines[i]; - - if(categoryReg.test(line)){ - // カテゴリのコンテナを作成 - currentCategory = this.rdf.makeSeqContainer("urn:bbs2ch:bbsmenu:category:" + RegExp.$1); - this.rdf.setLiteralProperty(currentCategory.Resource, - NS_BBS2CH + "title", RegExp.$1); - rootContainer.AppendElement(currentCategory.Resource); - }else if((threadReg.test(line) || threadReg2.test(line)) && currentCategory){ - // 板一覧のリソース作成 - board = this.rdf.appendResource(RegExp.$1, currentCategory); - - this.rdf.setLiteralProperty(board, NS_BBS2CH + "title", RegExp.$2); - this.rdf.setLiteralProperty(board, NS_BBS2CH + "type", - this._bbs2chService.getBoardType(RegExp.$1)); - } - } - - // RDF をキャッシュとして保存 - var rdfSource = this.rdf.getXmlSource("bbs2ch", NS_BBS2CH); - this._bbs2chService.writeFile(this.bbsMenuRDFFile.path, rdfSource, false); - }, - - - /** - * aSearchString とマッチするタイトルをもつリソースを - * コンテナ urn:bbs2ch:bbsmenu:search 以下に追加する - * @param aSearchString string 検索する文字列 - */ - searchTitle: function(aSearchString){ - // サーチコンテナの作成 - this.rdf.clearContainer("urn:bbs2ch:bbsmenu:search"); - var searchContainer = this.rdf.getContainer("urn:bbs2ch:bbsmenu:search"); - - var resources = this.ds.GetAllResources(); - while(resources.hasMoreElements()){ - var resource = resources.getNext().QueryInterface(Components.interfaces.nsIRDFResource); - var title = this.rdf.getLiteralProperty(resource, this._bbs2chService.nameSpace + "title"); - if(title && (title.toUpperCase().indexOf(aSearchString.toUpperCase()) != -1)) - searchContainer.AppendElement(resource); - } - } -} \ No newline at end of file