소스 검색

Implement astl-load-from-file

pull/15/head
10sr 9 년 전
부모
커밋
3ea3690bf2
1개의 변경된 파일24개의 추가작업 그리고 1개의 파일을 삭제
  1. +24
    -1
      _keysnail.js

+ 24
- 1
_keysnail.js 파일 보기

@@ -271,6 +271,7 @@ var autoSaveTabList = (function(){
function selectDirectory(title){
// open dialog and return nsILocalFile object
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker
// this function blocks.
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].
@@ -285,6 +286,24 @@ var autoSaveTabList = (function(){
return fp.file;
}

function selectFile(title){
// open dialog and return nsILocalFile object
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsILocalFile
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker
// this function blocks.
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].
createInstance(nsIFilePicker);
fp.init(window, title, nsIFilePicker.modeOpen);

// block
var res = fp.show();
if (res !== nsIFilePicker.returnOK) {
return null;
}
return fp.file;
}

function setup(){
// set destination directory
var dstdir = selectDirectory("Select Directory to Save Tab List");
@@ -349,7 +368,9 @@ var autoSaveTabList = (function(){

function openFromFile(){
var file = selectFile();
openFromLFSplittedString(util.readTextFile(file));
if (file) {
openFromLFSplittedString(util.readTextFile(file.path));
}
}

function openFromClipboard(){
@@ -371,11 +392,13 @@ var autoSaveTabList = (function(){
getTabList: getTabList,
saveCurrentList: saveCurrentList,
openFromClipboard: openFromClipboard
openFromFile: openFromFile
};
})();

ext.add("astl-setup", autoSaveTabList.setup, "Auto save tab list - Setup");
ext.add("astl-open-from-clipboard", autoSaveTabList.openFromClipboard, "Auto save tab list - Open tabs from clipboard");
ext.add("astl-open-from-file", autoSaveTabList.openFromFile, "Auto save tab list - Open tabs from local file");
ext.add("astl-save-current", autoSaveTabList.saveCurrentList,
"Auto save tab list - Save current list");



불러오는 중...
취소
저장