Add Scaffold as a built-in developer tool
|
@ -73,3 +73,8 @@ contract @mozilla.org/autocomplete/search;1?name=zotero {06a2ed11-d0a4-4ff0-a56
|
||||||
|
|
||||||
component {9BC3D762-9038-486A-9D70-C997AF848A7C} components/zotero-protocol-handler.js
|
component {9BC3D762-9038-486A-9D70-C997AF848A7C} components/zotero-protocol-handler.js
|
||||||
contract @mozilla.org/network/protocol;1?name=zotero {9BC3D762-9038-486A-9D70-C997AF848A7C}
|
contract @mozilla.org/network/protocol;1?name=zotero {9BC3D762-9038-486A-9D70-C997AF848A7C}
|
||||||
|
|
||||||
|
# Scaffold
|
||||||
|
content scaffold chrome/content/scaffold/
|
||||||
|
locale scaffold en-US chrome/locale/en-US/scaffold/
|
||||||
|
skin scaffold default chrome/skin/default/scaffold/
|
19560
chrome/content/scaffold/ace/ace.js
Normal file
509
chrome/content/scaffold/ace/ext-searchbox.js
Normal file
|
@ -0,0 +1,509 @@
|
||||||
|
define("ace/ext/searchbox",["require","exports","module","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/keyboard/hash_handler","ace/lib/keys"], function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var dom = require("../lib/dom");
|
||||||
|
var lang = require("../lib/lang");
|
||||||
|
var event = require("../lib/event");
|
||||||
|
var searchboxCss = "\
|
||||||
|
.ace_search {\
|
||||||
|
background-color: #ddd;\
|
||||||
|
color: #666;\
|
||||||
|
border: 1px solid #cbcbcb;\
|
||||||
|
border-top: 0 none;\
|
||||||
|
overflow: hidden;\
|
||||||
|
margin: 0;\
|
||||||
|
padding: 4px 6px 0 4px;\
|
||||||
|
position: absolute;\
|
||||||
|
top: 0;\
|
||||||
|
z-index: 99;\
|
||||||
|
white-space: normal;\
|
||||||
|
}\
|
||||||
|
.ace_search.left {\
|
||||||
|
border-left: 0 none;\
|
||||||
|
border-radius: 0px 0px 5px 0px;\
|
||||||
|
left: 0;\
|
||||||
|
}\
|
||||||
|
.ace_search.right {\
|
||||||
|
border-radius: 0px 0px 0px 5px;\
|
||||||
|
border-right: 0 none;\
|
||||||
|
right: 0;\
|
||||||
|
}\
|
||||||
|
.ace_search_form, .ace_replace_form {\
|
||||||
|
margin: 0 20px 4px 0;\
|
||||||
|
overflow: hidden;\
|
||||||
|
line-height: 1.9;\
|
||||||
|
}\
|
||||||
|
.ace_replace_form {\
|
||||||
|
margin-right: 0;\
|
||||||
|
}\
|
||||||
|
.ace_search_form.ace_nomatch {\
|
||||||
|
outline: 1px solid red;\
|
||||||
|
}\
|
||||||
|
.ace_search_field {\
|
||||||
|
border-radius: 3px 0 0 3px;\
|
||||||
|
background-color: white;\
|
||||||
|
color: black;\
|
||||||
|
border: 1px solid #cbcbcb;\
|
||||||
|
border-right: 0 none;\
|
||||||
|
box-sizing: border-box!important;\
|
||||||
|
outline: 0;\
|
||||||
|
padding: 0;\
|
||||||
|
font-size: inherit;\
|
||||||
|
margin: 0;\
|
||||||
|
line-height: inherit;\
|
||||||
|
padding: 0 6px;\
|
||||||
|
min-width: 17em;\
|
||||||
|
vertical-align: top;\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn {\
|
||||||
|
border: 1px solid #cbcbcb;\
|
||||||
|
line-height: inherit;\
|
||||||
|
display: inline-block;\
|
||||||
|
padding: 0 6px;\
|
||||||
|
background: #fff;\
|
||||||
|
border-right: 0 none;\
|
||||||
|
border-left: 1px solid #dcdcdc;\
|
||||||
|
cursor: pointer;\
|
||||||
|
margin: 0;\
|
||||||
|
position: relative;\
|
||||||
|
box-sizing: content-box!important;\
|
||||||
|
color: #666;\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn:last-child {\
|
||||||
|
border-radius: 0 3px 3px 0;\
|
||||||
|
border-right: 1px solid #cbcbcb;\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn:disabled {\
|
||||||
|
background: none;\
|
||||||
|
cursor: default;\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn:hover {\
|
||||||
|
background-color: #eef1f6;\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn.prev, .ace_searchbtn.next {\
|
||||||
|
padding: 0px 0.7em\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn.prev:after, .ace_searchbtn.next:after {\
|
||||||
|
content: \"\";\
|
||||||
|
border: solid 2px #888;\
|
||||||
|
width: 0.5em;\
|
||||||
|
height: 0.5em;\
|
||||||
|
border-width: 2px 0 0 2px;\
|
||||||
|
display:inline-block;\
|
||||||
|
transform: rotate(-45deg);\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn.next:after {\
|
||||||
|
border-width: 0 2px 2px 0 ;\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn_close {\
|
||||||
|
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;\
|
||||||
|
border-radius: 50%;\
|
||||||
|
border: 0 none;\
|
||||||
|
color: #656565;\
|
||||||
|
cursor: pointer;\
|
||||||
|
font: 16px/16px Arial;\
|
||||||
|
padding: 0;\
|
||||||
|
height: 14px;\
|
||||||
|
width: 14px;\
|
||||||
|
top: 9px;\
|
||||||
|
right: 7px;\
|
||||||
|
position: absolute;\
|
||||||
|
}\
|
||||||
|
.ace_searchbtn_close:hover {\
|
||||||
|
background-color: #656565;\
|
||||||
|
background-position: 50% 100%;\
|
||||||
|
color: white;\
|
||||||
|
}\
|
||||||
|
.ace_button {\
|
||||||
|
margin-left: 2px;\
|
||||||
|
cursor: pointer;\
|
||||||
|
-webkit-user-select: none;\
|
||||||
|
-moz-user-select: none;\
|
||||||
|
-o-user-select: none;\
|
||||||
|
-ms-user-select: none;\
|
||||||
|
user-select: none;\
|
||||||
|
overflow: hidden;\
|
||||||
|
opacity: 0.7;\
|
||||||
|
border: 1px solid rgba(100,100,100,0.23);\
|
||||||
|
padding: 1px;\
|
||||||
|
box-sizing: border-box!important;\
|
||||||
|
color: black;\
|
||||||
|
}\
|
||||||
|
.ace_button:hover {\
|
||||||
|
background-color: #eee;\
|
||||||
|
opacity:1;\
|
||||||
|
}\
|
||||||
|
.ace_button:active {\
|
||||||
|
background-color: #ddd;\
|
||||||
|
}\
|
||||||
|
.ace_button.checked {\
|
||||||
|
border-color: #3399ff;\
|
||||||
|
opacity:1;\
|
||||||
|
}\
|
||||||
|
.ace_search_options{\
|
||||||
|
margin-bottom: 3px;\
|
||||||
|
text-align: right;\
|
||||||
|
-webkit-user-select: none;\
|
||||||
|
-moz-user-select: none;\
|
||||||
|
-o-user-select: none;\
|
||||||
|
-ms-user-select: none;\
|
||||||
|
user-select: none;\
|
||||||
|
clear: both;\
|
||||||
|
}\
|
||||||
|
.ace_search_counter {\
|
||||||
|
float: left;\
|
||||||
|
font-family: arial;\
|
||||||
|
padding: 0 8px;\
|
||||||
|
}";
|
||||||
|
var HashHandler = require("../keyboard/hash_handler").HashHandler;
|
||||||
|
var keyUtil = require("../lib/keys");
|
||||||
|
|
||||||
|
var MAX_COUNT = 999;
|
||||||
|
|
||||||
|
dom.importCssString(searchboxCss, "ace_searchbox");
|
||||||
|
|
||||||
|
var html = '<div class="ace_search right">\
|
||||||
|
<span action="hide" class="ace_searchbtn_close"></span>\
|
||||||
|
<div class="ace_search_form">\
|
||||||
|
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
|
||||||
|
<span action="findPrev" class="ace_searchbtn prev"></span>\
|
||||||
|
<span action="findNext" class="ace_searchbtn next"></span>\
|
||||||
|
<span action="findAll" class="ace_searchbtn" title="Alt-Enter">All</span>\
|
||||||
|
</div>\
|
||||||
|
<div class="ace_replace_form">\
|
||||||
|
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
|
||||||
|
<span action="replaceAndFindNext" class="ace_searchbtn">Replace</span>\
|
||||||
|
<span action="replaceAll" class="ace_searchbtn">All</span>\
|
||||||
|
</div>\
|
||||||
|
<div class="ace_search_options">\
|
||||||
|
<span action="toggleReplace" class="ace_button" title="Toggel Replace mode"\
|
||||||
|
style="float:left;margin-top:-2px;padding:0 5px;">+</span>\
|
||||||
|
<span class="ace_search_counter"></span>\
|
||||||
|
<span action="toggleRegexpMode" class="ace_button" title="RegExp Search">.*</span>\
|
||||||
|
<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>\
|
||||||
|
<span action="toggleWholeWords" class="ace_button" title="Whole Word Search">\\b</span>\
|
||||||
|
<span action="searchInSelection" class="ace_button" title="Search In Selection">S</span>\
|
||||||
|
</div>\
|
||||||
|
</div>'.replace(/> +/g, ">");
|
||||||
|
|
||||||
|
var SearchBox = function(editor, range, showReplaceForm) {
|
||||||
|
var div = dom.createElement("div");
|
||||||
|
div.innerHTML = html;
|
||||||
|
this.element = div.firstChild;
|
||||||
|
|
||||||
|
this.setSession = this.setSession.bind(this);
|
||||||
|
|
||||||
|
this.$init();
|
||||||
|
this.setEditor(editor);
|
||||||
|
};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
this.setEditor = function(editor) {
|
||||||
|
editor.searchBox = this;
|
||||||
|
editor.renderer.scroller.appendChild(this.element);
|
||||||
|
this.editor = editor;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setSession = function(e) {
|
||||||
|
debugger
|
||||||
|
this.searchRange = null;
|
||||||
|
this.$syncOptions(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$initElements = function(sb) {
|
||||||
|
this.searchBox = sb.querySelector(".ace_search_form");
|
||||||
|
this.replaceBox = sb.querySelector(".ace_replace_form");
|
||||||
|
this.searchOption = sb.querySelector("[action=searchInSelection]");
|
||||||
|
this.replaceOption = sb.querySelector("[action=toggleReplace]");
|
||||||
|
this.regExpOption = sb.querySelector("[action=toggleRegexpMode]");
|
||||||
|
this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]");
|
||||||
|
this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
|
||||||
|
this.searchInput = this.searchBox.querySelector(".ace_search_field");
|
||||||
|
this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
|
||||||
|
this.searchCounter = sb.querySelector(".ace_search_counter");
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$init = function() {
|
||||||
|
var sb = this.element;
|
||||||
|
|
||||||
|
this.$initElements(sb);
|
||||||
|
|
||||||
|
var _this = this;
|
||||||
|
event.addListener(sb, "mousedown", function(e) {
|
||||||
|
setTimeout(function(){
|
||||||
|
_this.activeInput.focus();
|
||||||
|
}, 0);
|
||||||
|
event.stopPropagation(e);
|
||||||
|
});
|
||||||
|
event.addListener(sb, "click", function(e) {
|
||||||
|
var t = e.target || e.srcElement;
|
||||||
|
var action = t.getAttribute("action");
|
||||||
|
if (action && _this[action])
|
||||||
|
_this[action]();
|
||||||
|
else if (_this.$searchBarKb.commands[action])
|
||||||
|
_this.$searchBarKb.commands[action].exec(_this);
|
||||||
|
event.stopPropagation(e);
|
||||||
|
});
|
||||||
|
|
||||||
|
event.addCommandKeyListener(sb, function(e, hashId, keyCode) {
|
||||||
|
var keyString = keyUtil.keyCodeToString(keyCode);
|
||||||
|
var command = _this.$searchBarKb.findKeyCommand(hashId, keyString);
|
||||||
|
if (command && command.exec) {
|
||||||
|
command.exec(_this);
|
||||||
|
event.stopEvent(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$onChange = lang.delayedCall(function() {
|
||||||
|
_this.find(false, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
event.addListener(this.searchInput, "input", function() {
|
||||||
|
_this.$onChange.schedule(20);
|
||||||
|
});
|
||||||
|
event.addListener(this.searchInput, "focus", function() {
|
||||||
|
_this.activeInput = _this.searchInput;
|
||||||
|
_this.searchInput.value && _this.highlight();
|
||||||
|
});
|
||||||
|
event.addListener(this.replaceInput, "focus", function() {
|
||||||
|
_this.activeInput = _this.replaceInput;
|
||||||
|
_this.searchInput.value && _this.highlight();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
this.$closeSearchBarKb = new HashHandler([{
|
||||||
|
bindKey: "Esc",
|
||||||
|
name: "closeSearchBar",
|
||||||
|
exec: function(editor) {
|
||||||
|
editor.searchBox.hide();
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
this.$searchBarKb = new HashHandler();
|
||||||
|
this.$searchBarKb.bindKeys({
|
||||||
|
"Ctrl-f|Command-f": function(sb) {
|
||||||
|
var isReplace = sb.isReplace = !sb.isReplace;
|
||||||
|
sb.replaceBox.style.display = isReplace ? "" : "none";
|
||||||
|
sb.replaceOption.checked = false;
|
||||||
|
sb.$syncOptions();
|
||||||
|
sb.searchInput.focus();
|
||||||
|
},
|
||||||
|
"Ctrl-H|Command-Option-F": function(sb) {
|
||||||
|
sb.replaceOption.checked = true;
|
||||||
|
sb.$syncOptions();
|
||||||
|
sb.replaceInput.focus();
|
||||||
|
},
|
||||||
|
"Ctrl-G|Command-G": function(sb) {
|
||||||
|
sb.findNext();
|
||||||
|
},
|
||||||
|
"Ctrl-Shift-G|Command-Shift-G": function(sb) {
|
||||||
|
sb.findPrev();
|
||||||
|
},
|
||||||
|
"esc": function(sb) {
|
||||||
|
setTimeout(function() { sb.hide();});
|
||||||
|
},
|
||||||
|
"Return": function(sb) {
|
||||||
|
if (sb.activeInput == sb.replaceInput)
|
||||||
|
sb.replace();
|
||||||
|
sb.findNext();
|
||||||
|
},
|
||||||
|
"Shift-Return": function(sb) {
|
||||||
|
if (sb.activeInput == sb.replaceInput)
|
||||||
|
sb.replace();
|
||||||
|
sb.findPrev();
|
||||||
|
},
|
||||||
|
"Alt-Return": function(sb) {
|
||||||
|
if (sb.activeInput == sb.replaceInput)
|
||||||
|
sb.replaceAll();
|
||||||
|
sb.findAll();
|
||||||
|
},
|
||||||
|
"Tab": function(sb) {
|
||||||
|
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$searchBarKb.addCommands([{
|
||||||
|
name: "toggleRegexpMode",
|
||||||
|
bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"},
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.regExpOption.checked = !sb.regExpOption.checked;
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "toggleCaseSensitive",
|
||||||
|
bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"},
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "toggleWholeWords",
|
||||||
|
bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"},
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "toggleReplace",
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.replaceOption.checked = !sb.replaceOption.checked;
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: "searchInSelection",
|
||||||
|
exec: function(sb) {
|
||||||
|
sb.searchOption.checked = !sb.searchRange;
|
||||||
|
sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange());
|
||||||
|
sb.$syncOptions();
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
this.setSearchRange = function(range) {
|
||||||
|
this.searchRange = range;
|
||||||
|
if (range) {
|
||||||
|
this.searchRangeMarker = this.editor.session.addMarker(range, "ace_active-line");
|
||||||
|
} else if (this.searchRangeMarker) {
|
||||||
|
this.editor.session.removeMarker(this.searchRangeMarker);
|
||||||
|
this.searchRangeMarker = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$syncOptions = function(preventScroll) {
|
||||||
|
dom.setCssClass(this.replaceOption, "checked", this.searchRange);
|
||||||
|
dom.setCssClass(this.searchOption, "checked", this.searchOption.checked);
|
||||||
|
this.replaceOption.textContent = this.replaceOption.checked ? "-" : "+";
|
||||||
|
dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
|
||||||
|
dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
|
||||||
|
dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
|
||||||
|
this.replaceBox.style.display = this.replaceOption.checked ? "" : "none";
|
||||||
|
this.find(false, false, preventScroll);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.highlight = function(re) {
|
||||||
|
this.editor.session.highlight(re || this.editor.$search.$options.re);
|
||||||
|
this.editor.renderer.updateBackMarkers()
|
||||||
|
};
|
||||||
|
this.find = function(skipCurrent, backwards, preventScroll) {
|
||||||
|
var range = this.editor.find(this.searchInput.value, {
|
||||||
|
skipCurrent: skipCurrent,
|
||||||
|
backwards: backwards,
|
||||||
|
wrap: true,
|
||||||
|
regExp: this.regExpOption.checked,
|
||||||
|
caseSensitive: this.caseSensitiveOption.checked,
|
||||||
|
wholeWord: this.wholeWordOption.checked,
|
||||||
|
preventScroll: preventScroll,
|
||||||
|
range: this.searchRange
|
||||||
|
});
|
||||||
|
var noMatch = !range && this.searchInput.value;
|
||||||
|
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
||||||
|
this.editor._emit("findSearchBox", { match: !noMatch });
|
||||||
|
this.highlight();
|
||||||
|
this.updateCounter();
|
||||||
|
};
|
||||||
|
this.updateCounter = function() {
|
||||||
|
var editor = this.editor;
|
||||||
|
var regex = editor.$search.$options.re;
|
||||||
|
var all = 0;
|
||||||
|
var before = 0
|
||||||
|
if (regex) {
|
||||||
|
var value = this.searchRange
|
||||||
|
? editor.session.getTextRange(this.searchRange)
|
||||||
|
: editor.getValue();
|
||||||
|
|
||||||
|
var offset = editor.session.doc.positionToIndex(editor.selection.anchor);
|
||||||
|
if (this.searchRange)
|
||||||
|
offset -= editor.session.doc.positionToIndex(this.searchRange.start);
|
||||||
|
|
||||||
|
var last = regex.lastIndex = 0;
|
||||||
|
var m;
|
||||||
|
while ((m = regex.exec(value))) {
|
||||||
|
all++;
|
||||||
|
last = m.index;
|
||||||
|
if (last <= offset)
|
||||||
|
before++;
|
||||||
|
if (all > MAX_COUNT)
|
||||||
|
break
|
||||||
|
if (!m[0]) {
|
||||||
|
regex.lastIndex = last += 1;
|
||||||
|
if (last >= value.length)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.searchCounter.textContent = before + " of " + (all > MAX_COUNT ? MAX_COUNT + "+" : all);
|
||||||
|
};
|
||||||
|
this.findNext = function() {
|
||||||
|
this.find(true, false);
|
||||||
|
};
|
||||||
|
this.findPrev = function() {
|
||||||
|
this.find(true, true);
|
||||||
|
};
|
||||||
|
this.findAll = function(){
|
||||||
|
var range = this.editor.findAll(this.searchInput.value, {
|
||||||
|
regExp: this.regExpOption.checked,
|
||||||
|
caseSensitive: this.caseSensitiveOption.checked,
|
||||||
|
wholeWord: this.wholeWordOption.checked
|
||||||
|
});
|
||||||
|
var noMatch = !range && this.searchInput.value;
|
||||||
|
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
|
||||||
|
this.editor._emit("findSearchBox", { match: !noMatch });
|
||||||
|
this.highlight();
|
||||||
|
this.hide();
|
||||||
|
};
|
||||||
|
this.replace = function() {
|
||||||
|
if (!this.editor.getReadOnly())
|
||||||
|
this.editor.replace(this.replaceInput.value);
|
||||||
|
};
|
||||||
|
this.replaceAndFindNext = function() {
|
||||||
|
if (!this.editor.getReadOnly()) {
|
||||||
|
this.editor.replace(this.replaceInput.value);
|
||||||
|
this.findNext()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.replaceAll = function() {
|
||||||
|
if (!this.editor.getReadOnly())
|
||||||
|
this.editor.replaceAll(this.replaceInput.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.hide = function() {
|
||||||
|
this.active = false;
|
||||||
|
this.setSearchRange(null)
|
||||||
|
this.editor.off("changeSession", this.setSession);
|
||||||
|
|
||||||
|
this.element.style.display = "none";
|
||||||
|
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
|
||||||
|
this.editor.focus();
|
||||||
|
};
|
||||||
|
this.show = function(value, isReplace) {
|
||||||
|
this.active = true;
|
||||||
|
this.editor.on("changeSession", this.setSession);
|
||||||
|
this.element.style.display = "";
|
||||||
|
this.replaceOption.checked = isReplace;
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
this.searchInput.value = value;
|
||||||
|
|
||||||
|
this.searchInput.focus();
|
||||||
|
this.searchInput.select();
|
||||||
|
|
||||||
|
this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
|
||||||
|
|
||||||
|
this.$syncOptions(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.isFocused = function() {
|
||||||
|
var el = document.activeElement;
|
||||||
|
return el == this.searchInput || el == this.replaceInput;
|
||||||
|
}
|
||||||
|
}).call(SearchBox.prototype);
|
||||||
|
|
||||||
|
exports.SearchBox = SearchBox;
|
||||||
|
|
||||||
|
exports.Search = function(editor, isReplace) {
|
||||||
|
var sb = editor.searchBox || new SearchBox(editor);
|
||||||
|
sb.show(editor.session.getTextRange(), isReplace);
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
(function() {
|
||||||
|
window.require(["ace/ext/searchbox"], function() {});
|
||||||
|
})();
|
||||||
|
|
1181
chrome/content/scaffold/ace/keybinding-emacs.js
Normal file
5598
chrome/content/scaffold/ace/keybinding-vim.js
Normal file
789
chrome/content/scaffold/ace/mode-javascript.js
Normal file
|
@ -0,0 +1,789 @@
|
||||||
|
define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
|
var DocCommentHighlightRules = function() {
|
||||||
|
this.$rules = {
|
||||||
|
"start" : [ {
|
||||||
|
token : "comment.doc.tag",
|
||||||
|
regex : "@[\\w\\d_]+" // TODO: fix email addresses
|
||||||
|
},
|
||||||
|
DocCommentHighlightRules.getTagRule(),
|
||||||
|
{
|
||||||
|
defaultToken : "comment.doc",
|
||||||
|
caseInsensitive: true
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
|
DocCommentHighlightRules.getTagRule = function(start) {
|
||||||
|
return {
|
||||||
|
token : "comment.doc.tag.storage.type",
|
||||||
|
regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
DocCommentHighlightRules.getStartRule = function(start) {
|
||||||
|
return {
|
||||||
|
token : "comment.doc", // doc comment
|
||||||
|
regex : "\\/\\*(?=\\*)",
|
||||||
|
next : start
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
DocCommentHighlightRules.getEndRule = function (start) {
|
||||||
|
return {
|
||||||
|
token : "comment.doc", // closing comment
|
||||||
|
regex : "\\*\\/",
|
||||||
|
next : start
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||||
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
|
||||||
|
|
||||||
|
var JavaScriptHighlightRules = function(options) {
|
||||||
|
var keywordMapper = this.createKeywordMapper({
|
||||||
|
"variable.language":
|
||||||
|
"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
|
||||||
|
"Namespace|QName|XML|XMLList|" + // E4X
|
||||||
|
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
|
||||||
|
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
|
||||||
|
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
|
||||||
|
"SyntaxError|TypeError|URIError|" +
|
||||||
|
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
|
||||||
|
"isNaN|parseFloat|parseInt|" +
|
||||||
|
"JSON|Math|" + // Other
|
||||||
|
"this|arguments|prototype|window|document" , // Pseudo
|
||||||
|
"keyword":
|
||||||
|
"const|yield|import|get|set|async|await|" +
|
||||||
|
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
|
||||||
|
"if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
|
||||||
|
"__parent__|__count__|escape|unescape|with|__proto__|" +
|
||||||
|
"class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
|
||||||
|
"storage.type":
|
||||||
|
"const|let|var|function",
|
||||||
|
"constant.language":
|
||||||
|
"null|Infinity|NaN|undefined",
|
||||||
|
"support.function":
|
||||||
|
"alert",
|
||||||
|
"constant.language.boolean": "true|false"
|
||||||
|
}, "identifier");
|
||||||
|
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
|
||||||
|
|
||||||
|
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
|
||||||
|
"u[0-9a-fA-F]{4}|" + // unicode
|
||||||
|
"u{[0-9a-fA-F]{1,6}}|" + // es6 unicode
|
||||||
|
"[0-2][0-7]{0,2}|" + // oct
|
||||||
|
"3[0-7][0-7]?|" + // oct
|
||||||
|
"[4-7][0-7]?|" + //oct
|
||||||
|
".)";
|
||||||
|
|
||||||
|
this.$rules = {
|
||||||
|
"no_regex" : [
|
||||||
|
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||||
|
comments("no_regex"),
|
||||||
|
{
|
||||||
|
token : "string",
|
||||||
|
regex : "'(?=.)",
|
||||||
|
next : "qstring"
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : '"(?=.)',
|
||||||
|
next : "qqstring"
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // hexadecimal, octal and binary
|
||||||
|
regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/
|
||||||
|
}, {
|
||||||
|
token : "constant.numeric", // decimal integers and floats
|
||||||
|
regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"storage.type", "punctuation.operator", "support.function",
|
||||||
|
"punctuation.operator", "entity.name.function", "text","keyword.operator"
|
||||||
|
],
|
||||||
|
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
||||||
|
"keyword.operator", "text", "storage.type", "text", "paren.lparen"
|
||||||
|
],
|
||||||
|
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"entity.name.function", "text", "keyword.operator", "text", "storage.type",
|
||||||
|
"text", "paren.lparen"
|
||||||
|
],
|
||||||
|
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
||||||
|
"keyword.operator", "text",
|
||||||
|
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
||||||
|
],
|
||||||
|
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
||||||
|
],
|
||||||
|
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"entity.name.function", "text", "punctuation.operator",
|
||||||
|
"text", "storage.type", "text", "paren.lparen"
|
||||||
|
],
|
||||||
|
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"text", "text", "storage.type", "text", "paren.lparen"
|
||||||
|
],
|
||||||
|
regex : "(:)(\\s*)(function)(\\s*)(\\()",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : "keyword",
|
||||||
|
regex : "from(?=\\s*('|\"))"
|
||||||
|
}, {
|
||||||
|
token : "keyword",
|
||||||
|
regex : "(?:" + kwBeforeRe + ")\\b",
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
token : ["support.constant"],
|
||||||
|
regex : /that\b/
|
||||||
|
}, {
|
||||||
|
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
|
||||||
|
regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
|
||||||
|
}, {
|
||||||
|
token : keywordMapper,
|
||||||
|
regex : identifierRe
|
||||||
|
}, {
|
||||||
|
token : "punctuation.operator",
|
||||||
|
regex : /[.](?![.])/,
|
||||||
|
next : "property"
|
||||||
|
}, {
|
||||||
|
token : "storage.type",
|
||||||
|
regex : /=>/
|
||||||
|
}, {
|
||||||
|
token : "keyword.operator",
|
||||||
|
regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
token : "punctuation.operator",
|
||||||
|
regex : /[?:,;.]/,
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
token : "paren.lparen",
|
||||||
|
regex : /[\[({]/,
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
token : "paren.rparen",
|
||||||
|
regex : /[\])}]/
|
||||||
|
}, {
|
||||||
|
token: "comment",
|
||||||
|
regex: /^#!.*$/
|
||||||
|
}
|
||||||
|
],
|
||||||
|
property: [{
|
||||||
|
token : "text",
|
||||||
|
regex : "\\s+"
|
||||||
|
}, {
|
||||||
|
token : [
|
||||||
|
"storage.type", "punctuation.operator", "entity.name.function", "text",
|
||||||
|
"keyword.operator", "text",
|
||||||
|
"storage.type", "text", "entity.name.function", "text", "paren.lparen"
|
||||||
|
],
|
||||||
|
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
|
||||||
|
next: "function_arguments"
|
||||||
|
}, {
|
||||||
|
token : "punctuation.operator",
|
||||||
|
regex : /[.](?![.])/
|
||||||
|
}, {
|
||||||
|
token : "support.function",
|
||||||
|
regex : /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
|
||||||
|
}, {
|
||||||
|
token : "support.function.dom",
|
||||||
|
regex : /(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
|
||||||
|
}, {
|
||||||
|
token : "support.constant",
|
||||||
|
regex : /(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
|
||||||
|
}, {
|
||||||
|
token : "identifier",
|
||||||
|
regex : identifierRe
|
||||||
|
}, {
|
||||||
|
regex: "",
|
||||||
|
token: "empty",
|
||||||
|
next: "no_regex"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start": [
|
||||||
|
DocCommentHighlightRules.getStartRule("doc-start"),
|
||||||
|
comments("start"),
|
||||||
|
{
|
||||||
|
token: "string.regexp",
|
||||||
|
regex: "\\/",
|
||||||
|
next: "regex"
|
||||||
|
}, {
|
||||||
|
token : "text",
|
||||||
|
regex : "\\s+|^$",
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
token: "empty",
|
||||||
|
regex: "",
|
||||||
|
next: "no_regex"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"regex": [
|
||||||
|
{
|
||||||
|
token: "regexp.keyword.operator",
|
||||||
|
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
|
||||||
|
}, {
|
||||||
|
token: "string.regexp",
|
||||||
|
regex: "/[sxngimy]*",
|
||||||
|
next: "no_regex"
|
||||||
|
}, {
|
||||||
|
token : "invalid",
|
||||||
|
regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
|
||||||
|
}, {
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
|
||||||
|
}, {
|
||||||
|
token : "constant.language.delimiter",
|
||||||
|
regex: /\|/
|
||||||
|
}, {
|
||||||
|
token: "constant.language.escape",
|
||||||
|
regex: /\[\^?/,
|
||||||
|
next: "regex_character_class"
|
||||||
|
}, {
|
||||||
|
token: "empty",
|
||||||
|
regex: "$",
|
||||||
|
next: "no_regex"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string.regexp"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"regex_character_class": [
|
||||||
|
{
|
||||||
|
token: "regexp.charclass.keyword.operator",
|
||||||
|
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
|
||||||
|
}, {
|
||||||
|
token: "constant.language.escape",
|
||||||
|
regex: "]",
|
||||||
|
next: "regex"
|
||||||
|
}, {
|
||||||
|
token: "constant.language.escape",
|
||||||
|
regex: "-"
|
||||||
|
}, {
|
||||||
|
token: "empty",
|
||||||
|
regex: "$",
|
||||||
|
next: "no_regex"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string.regexp.charachterclass"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"function_arguments": [
|
||||||
|
{
|
||||||
|
token: "variable.parameter",
|
||||||
|
regex: identifierRe
|
||||||
|
}, {
|
||||||
|
token: "punctuation.operator",
|
||||||
|
regex: "[, ]+"
|
||||||
|
}, {
|
||||||
|
token: "punctuation.operator",
|
||||||
|
regex: "$"
|
||||||
|
}, {
|
||||||
|
token: "empty",
|
||||||
|
regex: "",
|
||||||
|
next: "no_regex"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"qqstring" : [
|
||||||
|
{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : escapedRe
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : "\\\\$",
|
||||||
|
consumeLineEnd : true
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : '"|$',
|
||||||
|
next : "no_regex"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"qstring" : [
|
||||||
|
{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : escapedRe
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : "\\\\$",
|
||||||
|
consumeLineEnd : true
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : "'|$",
|
||||||
|
next : "no_regex"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (!options || !options.noES6) {
|
||||||
|
this.$rules.no_regex.unshift({
|
||||||
|
regex: "[{}]", onMatch: function(val, state, stack) {
|
||||||
|
this.next = val == "{" ? this.nextState : "";
|
||||||
|
if (val == "{" && stack.length) {
|
||||||
|
stack.unshift("start", state);
|
||||||
|
}
|
||||||
|
else if (val == "}" && stack.length) {
|
||||||
|
stack.shift();
|
||||||
|
this.next = stack.shift();
|
||||||
|
if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
|
||||||
|
return "paren.quasi.end";
|
||||||
|
}
|
||||||
|
return val == "{" ? "paren.lparen" : "paren.rparen";
|
||||||
|
},
|
||||||
|
nextState: "start"
|
||||||
|
}, {
|
||||||
|
token : "string.quasi.start",
|
||||||
|
regex : /`/,
|
||||||
|
push : [{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : escapedRe
|
||||||
|
}, {
|
||||||
|
token : "paren.quasi.start",
|
||||||
|
regex : /\${/,
|
||||||
|
push : "start"
|
||||||
|
}, {
|
||||||
|
token : "string.quasi.end",
|
||||||
|
regex : /`/,
|
||||||
|
next : "pop"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string.quasi"
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!options || options.jsx != false)
|
||||||
|
JSX.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||||
|
[ DocCommentHighlightRules.getEndRule("no_regex") ]);
|
||||||
|
|
||||||
|
this.normalizeRules();
|
||||||
|
};
|
||||||
|
|
||||||
|
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
|
function JSX() {
|
||||||
|
var tagRegex = identifierRe.replace("\\d", "\\d\\-");
|
||||||
|
var jsxTag = {
|
||||||
|
onMatch : function(val, state, stack) {
|
||||||
|
var offset = val.charAt(1) == "/" ? 2 : 1;
|
||||||
|
if (offset == 1) {
|
||||||
|
if (state != this.nextState)
|
||||||
|
stack.unshift(this.next, this.nextState, 0);
|
||||||
|
else
|
||||||
|
stack.unshift(this.next);
|
||||||
|
stack[2]++;
|
||||||
|
} else if (offset == 2) {
|
||||||
|
if (state == this.nextState) {
|
||||||
|
stack[1]--;
|
||||||
|
if (!stack[1] || stack[1] < 0) {
|
||||||
|
stack.shift();
|
||||||
|
stack.shift();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [{
|
||||||
|
type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
|
||||||
|
value: val.slice(0, offset)
|
||||||
|
}, {
|
||||||
|
type: "meta.tag.tag-name.xml",
|
||||||
|
value: val.substr(offset)
|
||||||
|
}];
|
||||||
|
},
|
||||||
|
regex : "</?" + tagRegex + "",
|
||||||
|
next: "jsxAttributes",
|
||||||
|
nextState: "jsx"
|
||||||
|
};
|
||||||
|
this.$rules.start.unshift(jsxTag);
|
||||||
|
var jsxJsRule = {
|
||||||
|
regex: "{",
|
||||||
|
token: "paren.quasi.start",
|
||||||
|
push: "start"
|
||||||
|
};
|
||||||
|
this.$rules.jsx = [
|
||||||
|
jsxJsRule,
|
||||||
|
jsxTag,
|
||||||
|
{include : "reference"},
|
||||||
|
{defaultToken: "string"}
|
||||||
|
];
|
||||||
|
this.$rules.jsxAttributes = [{
|
||||||
|
token : "meta.tag.punctuation.tag-close.xml",
|
||||||
|
regex : "/?>",
|
||||||
|
onMatch : function(value, currentState, stack) {
|
||||||
|
if (currentState == stack[0])
|
||||||
|
stack.shift();
|
||||||
|
if (value.length == 2) {
|
||||||
|
if (stack[0] == this.nextState)
|
||||||
|
stack[1]--;
|
||||||
|
if (!stack[1] || stack[1] < 0) {
|
||||||
|
stack.splice(0, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.next = stack[0] || "start";
|
||||||
|
return [{type: this.token, value: value}];
|
||||||
|
},
|
||||||
|
nextState: "jsx"
|
||||||
|
},
|
||||||
|
jsxJsRule,
|
||||||
|
comments("jsxAttributes"),
|
||||||
|
{
|
||||||
|
token : "entity.other.attribute-name.xml",
|
||||||
|
regex : tagRegex
|
||||||
|
}, {
|
||||||
|
token : "keyword.operator.attribute-equals.xml",
|
||||||
|
regex : "="
|
||||||
|
}, {
|
||||||
|
token : "text.tag-whitespace.xml",
|
||||||
|
regex : "\\s+"
|
||||||
|
}, {
|
||||||
|
token : "string.attribute-value.xml",
|
||||||
|
regex : "'",
|
||||||
|
stateName : "jsx_attr_q",
|
||||||
|
push : [
|
||||||
|
{token : "string.attribute-value.xml", regex: "'", next: "pop"},
|
||||||
|
{include : "reference"},
|
||||||
|
{defaultToken : "string.attribute-value.xml"}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
token : "string.attribute-value.xml",
|
||||||
|
regex : '"',
|
||||||
|
stateName : "jsx_attr_qq",
|
||||||
|
push : [
|
||||||
|
{token : "string.attribute-value.xml", regex: '"', next: "pop"},
|
||||||
|
{include : "reference"},
|
||||||
|
{defaultToken : "string.attribute-value.xml"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
jsxTag
|
||||||
|
];
|
||||||
|
this.$rules.reference = [{
|
||||||
|
token : "constant.language.escape.reference.xml",
|
||||||
|
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
function comments(next) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
token : "comment", // multi line comment
|
||||||
|
regex : /\/\*/,
|
||||||
|
next: [
|
||||||
|
DocCommentHighlightRules.getTagRule(),
|
||||||
|
{token : "comment", regex : "\\*\\/", next : next || "pop"},
|
||||||
|
{defaultToken : "comment", caseInsensitive: true}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
token : "comment",
|
||||||
|
regex : "\\/\\/",
|
||||||
|
next: [
|
||||||
|
DocCommentHighlightRules.getTagRule(),
|
||||||
|
{token : "comment", regex : "$|^", next : next || "pop"},
|
||||||
|
{defaultToken : "comment", caseInsensitive: true}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
|
||||||
|
});
|
||||||
|
|
||||||
|
define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
|
var MatchingBraceOutdent = function() {};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.checkOutdent = function(line, input) {
|
||||||
|
if (! /^\s+$/.test(line))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return /^\s*\}/.test(input);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(doc, row) {
|
||||||
|
var line = doc.getLine(row);
|
||||||
|
var match = line.match(/^(\s*\})/);
|
||||||
|
|
||||||
|
if (!match) return 0;
|
||||||
|
|
||||||
|
var column = match[1].length;
|
||||||
|
var openBracePos = doc.findMatchingBracket({row: row, column: column});
|
||||||
|
|
||||||
|
if (!openBracePos || openBracePos.row == row) return 0;
|
||||||
|
|
||||||
|
var indent = this.$getIndent(doc.getLine(openBracePos.row));
|
||||||
|
doc.replace(new Range(row, 0, row, column-1), indent);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$getIndent = function(line) {
|
||||||
|
return line.match(/^\s*/)[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(MatchingBraceOutdent.prototype);
|
||||||
|
|
||||||
|
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||||
|
});
|
||||||
|
|
||||||
|
define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../../lib/oop");
|
||||||
|
var Range = require("../../range").Range;
|
||||||
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||||
|
|
||||||
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
||||||
|
if (commentRegex) {
|
||||||
|
this.foldingStartMarker = new RegExp(
|
||||||
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
||||||
|
);
|
||||||
|
this.foldingStopMarker = new RegExp(
|
||||||
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
oop.inherits(FoldMode, BaseFoldMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
|
||||||
|
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
|
||||||
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
||||||
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
||||||
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
||||||
|
this._getFoldWidgetBase = this.getFoldWidget;
|
||||||
|
this.getFoldWidget = function(session, foldStyle, row) {
|
||||||
|
var line = session.getLine(row);
|
||||||
|
|
||||||
|
if (this.singleLineBlockCommentRe.test(line)) {
|
||||||
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
||||||
|
|
||||||
|
if (!fw && this.startRegionRe.test(line))
|
||||||
|
return "start"; // lineCommentRegionStart
|
||||||
|
|
||||||
|
return fw;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
||||||
|
var line = session.getLine(row);
|
||||||
|
|
||||||
|
if (this.startRegionRe.test(line))
|
||||||
|
return this.getCommentRegionBlock(session, line, row);
|
||||||
|
|
||||||
|
var match = line.match(this.foldingStartMarker);
|
||||||
|
if (match) {
|
||||||
|
var i = match.index;
|
||||||
|
|
||||||
|
if (match[1])
|
||||||
|
return this.openingBracketBlock(session, match[1], row, i);
|
||||||
|
|
||||||
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
||||||
|
|
||||||
|
if (range && !range.isMultiLine()) {
|
||||||
|
if (forceMultiline) {
|
||||||
|
range = this.getSectionRange(session, row);
|
||||||
|
} else if (foldStyle != "all")
|
||||||
|
range = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return range;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foldStyle === "markbegin")
|
||||||
|
return;
|
||||||
|
|
||||||
|
var match = line.match(this.foldingStopMarker);
|
||||||
|
if (match) {
|
||||||
|
var i = match.index + match[0].length;
|
||||||
|
|
||||||
|
if (match[1])
|
||||||
|
return this.closingBracketBlock(session, match[1], row, i);
|
||||||
|
|
||||||
|
return session.getCommentFoldRange(row, i, -1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getSectionRange = function(session, row) {
|
||||||
|
var line = session.getLine(row);
|
||||||
|
var startIndent = line.search(/\S/);
|
||||||
|
var startRow = row;
|
||||||
|
var startColumn = line.length;
|
||||||
|
row = row + 1;
|
||||||
|
var endRow = row;
|
||||||
|
var maxRow = session.getLength();
|
||||||
|
while (++row < maxRow) {
|
||||||
|
line = session.getLine(row);
|
||||||
|
var indent = line.search(/\S/);
|
||||||
|
if (indent === -1)
|
||||||
|
continue;
|
||||||
|
if (startIndent > indent)
|
||||||
|
break;
|
||||||
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
||||||
|
|
||||||
|
if (subRange) {
|
||||||
|
if (subRange.start.row <= startRow) {
|
||||||
|
break;
|
||||||
|
} else if (subRange.isMultiLine()) {
|
||||||
|
row = subRange.end.row;
|
||||||
|
} else if (startIndent == indent) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endRow = row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
||||||
|
};
|
||||||
|
this.getCommentRegionBlock = function(session, line, row) {
|
||||||
|
var startColumn = line.search(/\s*$/);
|
||||||
|
var maxRow = session.getLength();
|
||||||
|
var startRow = row;
|
||||||
|
|
||||||
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
||||||
|
var depth = 1;
|
||||||
|
while (++row < maxRow) {
|
||||||
|
line = session.getLine(row);
|
||||||
|
var m = re.exec(line);
|
||||||
|
if (!m) continue;
|
||||||
|
if (m[1]) depth--;
|
||||||
|
else depth++;
|
||||||
|
|
||||||
|
if (!depth) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var endRow = row;
|
||||||
|
if (endRow > startRow) {
|
||||||
|
return new Range(startRow, startColumn, endRow, line.length);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}).call(FoldMode.prototype);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var oop = require("../lib/oop");
|
||||||
|
var TextMode = require("./text").Mode;
|
||||||
|
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||||
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
|
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||||
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||||
|
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||||
|
|
||||||
|
var Mode = function() {
|
||||||
|
this.HighlightRules = JavaScriptHighlightRules;
|
||||||
|
|
||||||
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
|
this.$behaviour = new CstyleBehaviour();
|
||||||
|
this.foldingRules = new CStyleFoldMode();
|
||||||
|
};
|
||||||
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.lineCommentStart = "//";
|
||||||
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
this.$quotes = {'"': '"', "'": "'", "`": "`"};
|
||||||
|
|
||||||
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||||
|
var tokens = tokenizedLine.tokens;
|
||||||
|
var endState = tokenizedLine.state;
|
||||||
|
|
||||||
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
|
return indent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == "start" || state == "no_regex") {
|
||||||
|
var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);
|
||||||
|
if (match) {
|
||||||
|
indent += tab;
|
||||||
|
}
|
||||||
|
} else if (state == "doc-start") {
|
||||||
|
if (endState == "start" || endState == "no_regex") {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
var match = line.match(/^\s*(\/?)\*/);
|
||||||
|
if (match) {
|
||||||
|
if (match[1]) {
|
||||||
|
indent += " ";
|
||||||
|
}
|
||||||
|
indent += "* ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return indent;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
return this.$outdent.checkOutdent(line, input);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.createWorker = function(session) {
|
||||||
|
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
|
||||||
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
||||||
|
worker.on("annotate", function(results) {
|
||||||
|
session.setAnnotations(results.data);
|
||||||
|
});
|
||||||
|
|
||||||
|
worker.on("terminate", function() {
|
||||||
|
session.clearAnnotations();
|
||||||
|
});
|
||||||
|
|
||||||
|
return worker;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$id = "ace/mode/javascript";
|
||||||
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
exports.Mode = Mode;
|
||||||
|
});
|
105
chrome/content/scaffold/ace/theme-monokai.js
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
define("ace/theme/monokai",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
|
||||||
|
|
||||||
|
exports.isDark = true;
|
||||||
|
exports.cssClass = "ace-monokai";
|
||||||
|
exports.cssText = ".ace-monokai .ace_gutter {\
|
||||||
|
background: #2F3129;\
|
||||||
|
color: #8F908A\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_print-margin {\
|
||||||
|
width: 1px;\
|
||||||
|
background: #555651\
|
||||||
|
}\
|
||||||
|
.ace-monokai {\
|
||||||
|
background-color: #272822;\
|
||||||
|
color: #F8F8F2\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_cursor {\
|
||||||
|
color: #F8F8F0\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_marker-layer .ace_selection {\
|
||||||
|
background: #49483E\
|
||||||
|
}\
|
||||||
|
.ace-monokai.ace_multiselect .ace_selection.ace_start {\
|
||||||
|
box-shadow: 0 0 3px 0px #272822;\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_marker-layer .ace_step {\
|
||||||
|
background: rgb(102, 82, 0)\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_marker-layer .ace_bracket {\
|
||||||
|
margin: -1px 0 0 -1px;\
|
||||||
|
border: 1px solid #49483E\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_marker-layer .ace_active-line {\
|
||||||
|
background: #202020\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_gutter-active-line {\
|
||||||
|
background-color: #272727\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_marker-layer .ace_selected-word {\
|
||||||
|
border: 1px solid #49483E\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_invisible {\
|
||||||
|
color: #52524d\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_entity.ace_name.ace_tag,\
|
||||||
|
.ace-monokai .ace_keyword,\
|
||||||
|
.ace-monokai .ace_meta.ace_tag,\
|
||||||
|
.ace-monokai .ace_storage {\
|
||||||
|
color: #F92672\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_punctuation,\
|
||||||
|
.ace-monokai .ace_punctuation.ace_tag {\
|
||||||
|
color: #fff\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_constant.ace_character,\
|
||||||
|
.ace-monokai .ace_constant.ace_language,\
|
||||||
|
.ace-monokai .ace_constant.ace_numeric,\
|
||||||
|
.ace-monokai .ace_constant.ace_other {\
|
||||||
|
color: #AE81FF\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_invalid {\
|
||||||
|
color: #F8F8F0;\
|
||||||
|
background-color: #F92672\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_invalid.ace_deprecated {\
|
||||||
|
color: #F8F8F0;\
|
||||||
|
background-color: #AE81FF\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_support.ace_constant,\
|
||||||
|
.ace-monokai .ace_support.ace_function {\
|
||||||
|
color: #66D9EF\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_fold {\
|
||||||
|
background-color: #A6E22E;\
|
||||||
|
border-color: #F8F8F2\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_storage.ace_type,\
|
||||||
|
.ace-monokai .ace_support.ace_class,\
|
||||||
|
.ace-monokai .ace_support.ace_type {\
|
||||||
|
font-style: italic;\
|
||||||
|
color: #66D9EF\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_entity.ace_name.ace_function,\
|
||||||
|
.ace-monokai .ace_entity.ace_other,\
|
||||||
|
.ace-monokai .ace_entity.ace_other.ace_attribute-name,\
|
||||||
|
.ace-monokai .ace_variable {\
|
||||||
|
color: #A6E22E\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_variable.ace_parameter {\
|
||||||
|
font-style: italic;\
|
||||||
|
color: #FD971F\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_string {\
|
||||||
|
color: #E6DB74\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_comment {\
|
||||||
|
color: #75715E\
|
||||||
|
}\
|
||||||
|
.ace-monokai .ace_indent-guide {\
|
||||||
|
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ0FD0ZXBzd/wPAAjVAoxeSgNeAAAAAElFTkSuQmCC) right repeat-y\
|
||||||
|
}";
|
||||||
|
|
||||||
|
var dom = require("../lib/dom");
|
||||||
|
dom.importCssString(exports.cssText, exports.cssClass);
|
||||||
|
});
|
12528
chrome/content/scaffold/ace/worker-javascript.js
Normal file
42
chrome/content/scaffold/aceWrapper.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2011 Center for History and New Media
|
||||||
|
George Mason University, Fairfax, Virginia, USA
|
||||||
|
http://zotero.org
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
var editor, JavaScriptMode, TextMode, EditSession;
|
||||||
|
window.addEventListener("DOMContentLoaded", function(e) {
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.style.position = "absolute";
|
||||||
|
div.style.top = "0px";
|
||||||
|
div.style.left = "0px";
|
||||||
|
div.style.right = "0px";
|
||||||
|
div.style.bottom = "0px";
|
||||||
|
div.id = "ace-div";
|
||||||
|
document.getElementById("body").appendChild(div);
|
||||||
|
|
||||||
|
JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||||
|
TextMode = require("ace/mode/text").Mode;
|
||||||
|
EditSession = require("ace/edit_session").EditSession;
|
||||||
|
editor = ace.edit('ace-div');
|
||||||
|
editor.setTheme("ace/theme/monokai");
|
||||||
|
}, false);
|
76
chrome/content/scaffold/load.js
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2011 Center for History and New Media
|
||||||
|
George Mason University, Fairfax, Virginia, USA
|
||||||
|
http://zotero.org
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
var Scaffold_Load = new function() {
|
||||||
|
this.onLoad = Zotero.Promise.coroutine(function* () {
|
||||||
|
var listitem, translator, listcell, set;
|
||||||
|
var listbox = document.getElementById("listbox");
|
||||||
|
var translators = {};
|
||||||
|
|
||||||
|
// Get the matching translators
|
||||||
|
var translatorProvider = window.arguments[0].translatorProvider;
|
||||||
|
var url = window.arguments[0].url;
|
||||||
|
var rootUrl = window.arguments[0].rootUrl
|
||||||
|
url = Zotero.Proxies.proxyToProper(url);
|
||||||
|
translators["Matching Translators"] = (yield translatorProvider.getWebTranslatorsForLocation(url, rootUrl))[0];
|
||||||
|
translators["Web Translators"] = (yield translatorProvider.getAllForType("web"))
|
||||||
|
.sort((a, b) => a.label.localeCompare(b.label));
|
||||||
|
translators["Import Translators"] = (yield translatorProvider.getAllForType("import"))
|
||||||
|
.sort((a, b) => a.label.localeCompare(b.label));
|
||||||
|
|
||||||
|
for (set in translators) {
|
||||||
|
// Make a separator
|
||||||
|
listitem = document.createElement("listitem");
|
||||||
|
listitem.setAttribute("disabled", true);
|
||||||
|
listitem.setAttribute("label", set);
|
||||||
|
listbox.appendChild(listitem);
|
||||||
|
for (var j=0; j<translators[set].length; j++) {
|
||||||
|
var translator = translators[set][j];
|
||||||
|
listitem = document.createElement("listitem");
|
||||||
|
// set label for type-to-find functionality. This is not displayed.
|
||||||
|
listitem.setAttribute("label", translator.label);
|
||||||
|
// And the ID goes in DOM user data
|
||||||
|
listitem.setUserData("zotero-id", translator.translatorID, null);
|
||||||
|
|
||||||
|
listcell = document.createElement("listcell");
|
||||||
|
listcell.setAttribute("label", translator.label);
|
||||||
|
listitem.appendChild(listcell);
|
||||||
|
listcell = document.createElement("listcell");
|
||||||
|
listcell.setAttribute("label", translator.creator);
|
||||||
|
listitem.appendChild(listcell);
|
||||||
|
|
||||||
|
listbox.appendChild(listitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.accept = function () {
|
||||||
|
var translatorID = document.getElementById("listbox").selectedItem.getUserData("zotero-id");
|
||||||
|
var translator = window.arguments[0].translatorProvider.get(translatorID);
|
||||||
|
|
||||||
|
Zotero.debug(translatorID);
|
||||||
|
window.arguments[0].dataOut = translator;
|
||||||
|
}
|
||||||
|
}
|
48
chrome/content/scaffold/load.xul
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2011 Center for History and New Media
|
||||||
|
George Mason University, Fairfax, Virginia, USA
|
||||||
|
http://zotero.org
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
-->
|
||||||
|
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://scaffold/skin/scaffold.css" type="text/css"?>
|
||||||
|
|
||||||
|
<!DOCTYPE window SYSTEM "chrome://scaffold/locale/scaffold.dtd">
|
||||||
|
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
|
title="&scaffold.load.title;" width="400" height="330" buttons="cancel,accept"
|
||||||
|
ondialogaccept="Scaffold_Load.accept()" onload="Scaffold_Load.onLoad()"
|
||||||
|
id="scaffold-load">
|
||||||
|
|
||||||
|
<script src="chrome://zotero/content/include.js"/>
|
||||||
|
<script src="load.js"/>
|
||||||
|
|
||||||
|
<listbox id="listbox" flex="1">
|
||||||
|
<listhead>
|
||||||
|
<listheader label="&scaffold.load.label.label;"/>
|
||||||
|
<listheader label="&scaffold.load.creator.label;"/>
|
||||||
|
</listhead>
|
||||||
|
<listcols>
|
||||||
|
<listcol flex="1"/>
|
||||||
|
<listcol width="130"/>
|
||||||
|
</listcols>
|
||||||
|
</listbox>
|
||||||
|
</dialog>
|
1373
chrome/content/scaffold/scaffold.js
Normal file
260
chrome/content/scaffold/scaffold.xul
Normal file
|
@ -0,0 +1,260 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!--
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2011 Center for History and New Media
|
||||||
|
George Mason University, Fairfax, Virginia, USA
|
||||||
|
http://zotero.org
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
-->
|
||||||
|
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://scaffold/skin/scaffold.css" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://zotero-platform/content/overlay.css" type="text/css"?>
|
||||||
|
|
||||||
|
<!DOCTYPE window SYSTEM "chrome://scaffold/locale/scaffold.dtd">
|
||||||
|
|
||||||
|
<window id="scaffold" width="600" height="600" minheight="600" persist="screenX screenY width height"
|
||||||
|
title="Scaffold"
|
||||||
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
|
<script src="chrome://zotero/content/include.js"/>
|
||||||
|
<script src="chrome://zotero/content/tools/testTranslators/translatorTester.js"/>
|
||||||
|
<script src="translators.js"/>
|
||||||
|
<script src="scaffold.js"/>
|
||||||
|
|
||||||
|
<keyset>
|
||||||
|
<key id="run-do-web" modifiers="accel" key="R" oncommand="Scaffold.run('do')"/>
|
||||||
|
<key id="detect-web" modifiers="accel" key="T" oncommand="Scaffold.run('detect')"/>
|
||||||
|
<key id="save" modifiers="accel" key="S" oncommand="Scaffold.save()"/>
|
||||||
|
<key id="increase-font-size" modifiers="accel" key="+" oncommand="Scaffold.increaseFontSize()"/>
|
||||||
|
<key id="decrease-font-size" modifiers="accel" key="-" oncommand="Scaffold.decreaseFontSize()"/>
|
||||||
|
<key id="restore-font-size" modifiers="accel" key="0" oncommand="Scaffold.setFontSize(11)"/>
|
||||||
|
</keyset>
|
||||||
|
|
||||||
|
<popupset>
|
||||||
|
<menupopup id="testing-context-menue">
|
||||||
|
<menuitem label="&scaffold.testing.edit.import;" tooltiptext="Edit the input data for the current test" oncommand="Scaffold.editImportFromTest()"/>
|
||||||
|
<menuitem label="&scaffold.testing.copyToClipboard;" tooltiptext="Copy the URL or data for the current test to the clipboard" oncommand="Scaffold.copyToClipboard()"/>
|
||||||
|
<menuitem label="&scaffold.testing.openUrl;" tooltiptext="Open the URL for the current test in the browser" oncommand="Scaffold.openURL()"/>
|
||||||
|
</menupopup>
|
||||||
|
</popupset>
|
||||||
|
|
||||||
|
<vbox flex="1" id="scaffold-pane">
|
||||||
|
|
||||||
|
<menubar id="mb">
|
||||||
|
<menu id="mb-help" label="&scaffold.menu.help;">
|
||||||
|
<menupopup id="mb-help-popup">
|
||||||
|
<menuitem id="mb-help-types" label="&scaffold.toolbar.template.itemTypes.label;" oncommand="Scaffold.addTemplate('templateAllTypes')"/>
|
||||||
|
<menu id="mb-help-fields" label="&scaffold.toolbar.template.newItem.label;">
|
||||||
|
<menupopup id="mb-help-fields-popup">
|
||||||
|
<menuitem id="mb-help-fields-book" label="book" oncommand="Scaffold.addTemplate('templateNewItem', 'book')"/>
|
||||||
|
<menuitem id="mb-help-fields-booksection" label="bookSection" oncommand="Scaffold.addTemplate('templateNewItem', 'bookSection')"/>
|
||||||
|
<menuitem id="mb-help-fields-conferencepaper" label="conferencePaper" oncommand="Scaffold.addTemplate('templateNewItem', 'conferencePaper')"/>
|
||||||
|
<menuitem id="mb-help-fields-journalarticle" label="journalArticle" oncommand="Scaffold.addTemplate('templateNewItem', 'journalArticle')"/>
|
||||||
|
<menuitem id="mb-help-fields-magazinearticle" label="magazineArticle" oncommand="Scaffold.addTemplate('templateNewItem', 'magazineArticle')"/>
|
||||||
|
<menuitem id="mb-help-fields-newspaperarticle" label="newspaperArticle" oncommand="Scaffold.addTemplate('templateNewItem', 'newspaperArticle')"/>
|
||||||
|
<menu id="mb-help-fields-more" label="&scaffold.toolbar.template.more.label;">
|
||||||
|
<menupopup id="mb-help-fields-more-popup">
|
||||||
|
<!-- This will be filled on load with all other item types -->
|
||||||
|
</menupopup>
|
||||||
|
</menu>
|
||||||
|
</menupopup>
|
||||||
|
</menu>
|
||||||
|
<menuitem id="mb-help-shortcuts" label="&scaffold.toolbar.help.shortcuts;" oncommand="Scaffold.addTemplate('shortcuts')"/>
|
||||||
|
</menupopup>
|
||||||
|
</menu>
|
||||||
|
</menubar>
|
||||||
|
|
||||||
|
<toolbar id="tb" align="center">
|
||||||
|
<toolbarbutton id="tb-load" tooltiptext="&scaffold.toolbar.load.label;" oncommand="Scaffold.load()" />
|
||||||
|
<toolbarbutton id="tb-save" tooltiptext="&scaffold.toolbar.save.label;" oncommand="Scaffold.save()" />
|
||||||
|
<toolbarbutton id="tb-saveToZotero" tooltiptext="&scaffold.toolbar.saveToZotero.label;" oncommand="Scaffold.save(true)" />
|
||||||
|
<toolbarseparator/>
|
||||||
|
<toolbarbutton id="tb-detectWeb" tooltiptext="&scaffold.toolbar.detectWeb.label;" oncommand="Scaffold.run('detectWeb')" />
|
||||||
|
<toolbarbutton id="tb-doWeb" tooltiptext="&scaffold.toolbar.doWeb.label;" oncommand="Scaffold.run('doWeb')" />
|
||||||
|
<toolbarseparator/>
|
||||||
|
<toolbarbutton id="tb-detectImport" tooltiptext="&scaffold.toolbar.detectImport.label;" oncommand="Scaffold.run('detectImport')" />
|
||||||
|
<toolbarbutton id="tb-doImport" tooltiptext="&scaffold.toolbar.doImport.label;" oncommand="Scaffold.run('doImport')" />
|
||||||
|
<toolbarseparator/>
|
||||||
|
<toolbarbutton id="tb-setTranslatorsDir" tooltiptext="&scaffold.toolbar.setTranslatorsDir.label;" oncommand="Scaffold.promptForTranslatorsDirectory()" />
|
||||||
|
</toolbar>
|
||||||
|
<hbox flex="1">
|
||||||
|
<tabbox id="left-tabbox" flex="1" width="300">
|
||||||
|
<tabs id="tabs">
|
||||||
|
<tab id="tab-metadata" label="&scaffold.tabs.metadata.label;"/>
|
||||||
|
<tab id="tab-code" label="&scaffold.tabs.code.label;"/>
|
||||||
|
<tab id="tab-import" label="&scaffold.tabs.import.label;"/>
|
||||||
|
<tab id="tab-tests" label="&scaffold.tabs.tests.label;"/>
|
||||||
|
<tab id="tab-testing" label="&scaffold.tabs.testing.label;"/>
|
||||||
|
<tab id="tab-browser" label="Browser"/>
|
||||||
|
</tabs>
|
||||||
|
<tabpanels flex="1">
|
||||||
|
<tabpanel flex="1" id="tabpanel-metadata">
|
||||||
|
<vbox flex="1">
|
||||||
|
<hbox>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.translatorID.label;" control="textbox-translatorID"/>
|
||||||
|
<textbox id="textbox-translatorID" flex="1"/>
|
||||||
|
<button label="&scaffold.metadata.translatorID.generate;" oncommand="Scaffold.generateTranslatorID()"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.label.label;" control="textbox-label"/>
|
||||||
|
<textbox id="textbox-label" flex="1" value="&scaffold.metadata.label.default;"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.creator.label;" control="textbox-creator"/>
|
||||||
|
<textbox id="textbox-creator" flex="1"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.target.label;" control="textbox-target"/>
|
||||||
|
<textbox id="textbox-target" flex="1"/>
|
||||||
|
<button label="&scaffold.metadata.target.testRegex;" oncommand="Scaffold.testTargetRegex()"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox style="display:none">
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.targetAll.label;" control="textbox-target-all"/>
|
||||||
|
<textbox id="textbox-target-all" flex="1"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.configOptions.label;" control="textbox-configOptions"/>
|
||||||
|
<textbox id="textbox-configOptions" flex="1"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.displayOptions.label;" control="textbox-displayOptions"/>
|
||||||
|
<textbox id="textbox-displayOptions" flex="1"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.minVersion.label;" control="textbox-minVersion"/>
|
||||||
|
<textbox id="textbox-minVersion" flex="1" value="3.0"/>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.maxVersion.label;" control="textbox-maxVersion"/>
|
||||||
|
<textbox id="textbox-maxVersion" flex="1"/>
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.priority.label;" control="textbox-priority"/>
|
||||||
|
<textbox id="textbox-priority" flex="1" value="&scaffold.metadata.priority.default;"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox style="display:none">
|
||||||
|
<label class="label-metadata" value="&scaffold.metadata.hiddenPrefs.label;" control="textbox-hidden-prefs"/>
|
||||||
|
<textbox id="textbox-hidden-prefs" flex="1"/>
|
||||||
|
</hbox>
|
||||||
|
<grid flex="1">
|
||||||
|
<columns>
|
||||||
|
<column flex="2"/>
|
||||||
|
<column flex="1"/>
|
||||||
|
</columns>
|
||||||
|
<rows><row><groupbox>
|
||||||
|
<caption label="&scaffold.metadata.translatorType.label;"/>
|
||||||
|
<checkbox id="checkbox-import" label="&scaffold.metadata.translatorType.import;"/>
|
||||||
|
<checkbox id="checkbox-export" label="&scaffold.metadata.translatorType.export;"/>
|
||||||
|
<checkbox id="checkbox-web" label="&scaffold.metadata.translatorType.web;" checked="true"/>
|
||||||
|
<checkbox id="checkbox-search" label="&scaffold.metadata.translatorType.search;"/>
|
||||||
|
</groupbox>
|
||||||
|
<groupbox>
|
||||||
|
<caption label="&scaffold.metadata.browserSupport.label;"/>
|
||||||
|
<checkbox id="checkbox-gecko" label="&scaffold.metadata.browserSupport.gecko;" checked="true"/>
|
||||||
|
<checkbox id="checkbox-chrome" label="&scaffold.metadata.browserSupport.chrome;" checked="true"/>
|
||||||
|
<checkbox id="checkbox-safari" label="&scaffold.metadata.browserSupport.safari;" checked="true"/>
|
||||||
|
<checkbox id="checkbox-ie" label="&scaffold.metadata.browserSupport.ie;" checked="true"/>
|
||||||
|
<checkbox id="checkbox-bookmarklet" label="&scaffold.metadata.browserSupport.bookmarklet;" checked="true"/>
|
||||||
|
<checkbox id="checkbox-server" label="&scaffold.metadata.browserSupport.server;" checked="true"/>
|
||||||
|
</groupbox></row></rows>
|
||||||
|
</grid>
|
||||||
|
</vbox>
|
||||||
|
</tabpanel>
|
||||||
|
<tabpanel flex="1" id="tabpanel-code">
|
||||||
|
<vbox flex="1">
|
||||||
|
<hbox id="editor-toolbar" align="center">
|
||||||
|
<toolbarbutton id="tb-template" tooltiptext="&scaffold.toolbar.template.label;" type="menu">
|
||||||
|
<menupopup id="tb-template-popup">
|
||||||
|
<menuitem id="tb-template-new-web-add" label="&scaffold.toolbar.template.newWeb.label;" oncommand="Scaffold.addTemplate('newWeb')"/>
|
||||||
|
<menu id="tb-template-scrape-add" label="&scaffold.toolbar.template.scrape.label;">
|
||||||
|
<menupopup id="tb-template-scrape-popup">
|
||||||
|
<menuitem id="tb-template-scrape-em" label="Embedded Metadata" oncommand="Scaffold.addTemplate('scrapeEM')"/>
|
||||||
|
<menuitem id="tb-template-scrape-ris" label="RIS" oncommand="Scaffold.addTemplate('scrapeRIS')"/>
|
||||||
|
<menuitem id="tb-template-scrape-bibtex" label="BibTeX" oncommand="Scaffold.addTemplate('scrapeBibTeX')"/>
|
||||||
|
<menuitem id="tb-template-scrape-marc" label="MARC" oncommand="Scaffold.addTemplate('scrapeMARC')"/>
|
||||||
|
</menupopup>
|
||||||
|
</menu>
|
||||||
|
</menupopup>
|
||||||
|
</toolbarbutton>
|
||||||
|
</hbox>
|
||||||
|
<iframe src="data:text/html,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.1//EN%22%20%22http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/ace.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/mode-javascript.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/aceWrapper.js%22%3E%3C/script%3E%3C/head%3E%3Cbody%20id=%22body%22%3E%3C/body%3E%3C/html%3E" id="editor-code" flex="1"/>
|
||||||
|
<hbox id="editor-external-box" align="center">
|
||||||
|
<checkbox id="checkbox-editor-external"/>
|
||||||
|
<label class="label-metadata" value="&scaffold.editor.external.label;" control="checkbox-editor-external"/>
|
||||||
|
</hbox>
|
||||||
|
</vbox>
|
||||||
|
</tabpanel>
|
||||||
|
<tabpanel flex="1" id="tabpanel-import">
|
||||||
|
<iframe src="data:text/html,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.1//EN%22%20%22http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/ace.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/mode-javascript.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/aceWrapper.js%22%3E%3C/script%3E%3C/head%3E%3Cbody%20id=%22body%22%3E%3C/body%3E%3C/html%3E" id="editor-import" flex="1"/>
|
||||||
|
</tabpanel>
|
||||||
|
<tabpanel flex="1" id="tabpanel-tests">
|
||||||
|
<iframe src="data:text/html,%3C!DOCTYPE%20html%20PUBLIC%20%22-//W3C//DTD%20XHTML%201.1//EN%22%20%22http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd%22%3E%3Chtml%20xmlns=%22http://www.w3.org/1999/xhtml%22%3E%3Chead%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/ace.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/ace/mode-javascript.js%22%3E%3C/script%3E%3Cscript%20type=%22text/javascript%22%20src=%22chrome://scaffold/content/aceWrapper.js%22%3E%3C/script%3E%3C/head%3E%3Cbody%20id=%22body%22%3E%3C/body%3E%3C/html%3E" id="editor-tests" flex="1"/>
|
||||||
|
</tabpanel>
|
||||||
|
<tabpanel flex="1" id="tabpanel-testing">
|
||||||
|
<vbox flex="1"><hbox><description>&scaffold.testing.description;</description></hbox>
|
||||||
|
<hbox flex="1" context="testing-context-menue">
|
||||||
|
<listbox id="testing-listbox" flex="1" seltype="multiple">
|
||||||
|
<listhead>
|
||||||
|
<listheader label="&scaffold.testing.input.label;"/>
|
||||||
|
<listheader label="&scaffold.testing.status.label;"/>
|
||||||
|
</listhead>
|
||||||
|
<listcols>
|
||||||
|
<listcol flex="1"/>
|
||||||
|
<listcol/>
|
||||||
|
</listcols>
|
||||||
|
</listbox>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<button label="&scaffold.testing.populate;" tooltiptext="Load test definitions from the current translator" oncommand="Scaffold.populateTests()"/>
|
||||||
|
<button label="&scaffold.testing.save;" tooltiptext="Save the above test definitions into the current translator, and save the translator" oncommand="Scaffold.saveTests()"/>
|
||||||
|
<button label="&scaffold.testing.delete;" tooltiptext="Delete the selected tests" oncommand="Scaffold.deleteSelectedTests()"/>
|
||||||
|
<button label="&scaffold.testing.run;" tooltiptext="Run the selected tests" oncommand="Scaffold.runSelectedTests()"/>
|
||||||
|
</hbox>
|
||||||
|
<hbox>
|
||||||
|
<button label="&scaffold.testing.update;" tooltiptext="Update a test to match current item" oncommand="Scaffold.updateSelectedTests()"/>
|
||||||
|
<button label="&scaffold.testing.new;" tooltiptext="Create a new test from the current page" oncommand="Scaffold.newTestFromCurrent('web')" />
|
||||||
|
<button label="&scaffold.testing.new.import;" tooltiptext="Create a new test from the current import" oncommand="Scaffold.newTestFromCurrent('import')" />
|
||||||
|
</hbox>
|
||||||
|
</vbox>
|
||||||
|
</tabpanel>
|
||||||
|
<tabpanel>
|
||||||
|
<vbox flex="1">
|
||||||
|
<hbox align="center">
|
||||||
|
<label control="textbox-tabUrl" value="&scaffold.tabUrl.label;"/>
|
||||||
|
<menulist id="browser-url" editable="true" flex="1">
|
||||||
|
<menupopup></menupopup>
|
||||||
|
</menulist>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<browser src="about:blank" type="content" flex="1"></browser>
|
||||||
|
</vbox>
|
||||||
|
</tabpanel>
|
||||||
|
</tabpanels>
|
||||||
|
</tabbox>
|
||||||
|
<splitter resizeafter="farthest" oncommand="Scaffold.onResize();" />
|
||||||
|
|
||||||
|
<vbox id="right-pane" flex="1">
|
||||||
|
|
||||||
|
<hbox id="hbox-testFrame" width="300">
|
||||||
|
<label control="menulist-testFrame" id="label-testFrame" value="&scaffold.testFrame.label;"/>
|
||||||
|
<menulist id="menulist-testFrame"/>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
<textbox flex="1" id="output" multiline="true" readonly="true"/>
|
||||||
|
</vbox>
|
||||||
|
</hbox>
|
||||||
|
|
||||||
|
</vbox>
|
||||||
|
</window>
|
63
chrome/content/scaffold/templates/newWeb.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2019 YOUR_NAME <- TODO
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function detectWeb(doc, url) {
|
||||||
|
// TODO: adjust the logic here
|
||||||
|
if (url.includes('/article/')) {
|
||||||
|
return "newspaperArticle";
|
||||||
|
}
|
||||||
|
else if (getSearchResults(doc, true)) {
|
||||||
|
return "multiple";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSearchResults(doc, checkOnly) {
|
||||||
|
var items = {};
|
||||||
|
var found = false;
|
||||||
|
// TODO: adjust the CSS selector
|
||||||
|
var rows = doc.querySelectorAll('h2>a.title[href*="/article/"]');
|
||||||
|
for (let row of rows) {
|
||||||
|
// TODO: check and maybe adjust
|
||||||
|
let href = row.href;
|
||||||
|
// TODO: check and maybe adjust
|
||||||
|
let title = ZU.trimInternal(row.textContent);
|
||||||
|
if (!href || !title) continue;
|
||||||
|
if (checkOnly) return true;
|
||||||
|
found = true;
|
||||||
|
items[href] = title;
|
||||||
|
}
|
||||||
|
return found ? items : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function doWeb(doc, url) {
|
||||||
|
if (detectWeb(doc, url) == "multiple") {
|
||||||
|
Zotero.selectItems(getSearchResults(doc, false), function (items) {
|
||||||
|
if (items) ZU.processDocuments(Object.keys(items), scrape);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scrape(doc, url);
|
||||||
|
}
|
||||||
|
}
|
21
chrome/content/scaffold/templates/scrapeBibTeX.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
function scrape(doc, url) {
|
||||||
|
// TODO adjust the url building
|
||||||
|
var m = url.match(/FId=([\w\d]+)&/);
|
||||||
|
if (m) {
|
||||||
|
// e.g. http://www.fachportal-paedagogik.de/fis_bildung/suche/fis_ausg.html?FId=A18196&lart=BibTeX&Speichern=Speichern&senden_an=+E-Mail-Adresse
|
||||||
|
var bibUrl = "/fis_bildung/suche/fis_ausg.html?FId=" + m[1] + "&lart=BibTeX";
|
||||||
|
ZU.doGet(bibUrl, function (text) {
|
||||||
|
var translator = Zotero.loadTranslator("import");
|
||||||
|
translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||||
|
translator.setString(text);
|
||||||
|
translator.setHandler("itemDone", function (obj, item) {
|
||||||
|
item.attachments.push({
|
||||||
|
title: "Snapshot",
|
||||||
|
document: doc
|
||||||
|
});
|
||||||
|
item.complete();
|
||||||
|
});
|
||||||
|
translator.translate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
21
chrome/content/scaffold/templates/scrapeEM.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
function scrape(doc, url) {
|
||||||
|
var translator = Zotero.loadTranslator('web');
|
||||||
|
// Embedded Metadata
|
||||||
|
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
|
||||||
|
// translator.setDocument(doc);
|
||||||
|
|
||||||
|
translator.setHandler('itemDone', function (obj, item) {
|
||||||
|
// TODO adjust if needed:
|
||||||
|
item.section = "News";
|
||||||
|
item.complete();
|
||||||
|
});
|
||||||
|
|
||||||
|
translator.getTranslatorObject(function (trans) {
|
||||||
|
trans.itemType = "newspaperArticle";
|
||||||
|
// TODO map additional meta tags here, or delete completely
|
||||||
|
trans.addCustomFields({
|
||||||
|
'twitter:description': 'abstractNote'
|
||||||
|
});
|
||||||
|
trans.doWeb(doc, url);
|
||||||
|
});
|
||||||
|
}
|
36
chrome/content/scaffold/templates/scrapeMARC.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
function scrape(doc, url) {
|
||||||
|
// TODO adjust the selector for the lines here
|
||||||
|
var lines = doc.querySelectorAll('#cntPlcPortal_grdMrc tr');
|
||||||
|
|
||||||
|
// call MARC translator
|
||||||
|
var translator = Zotero.loadTranslator("import");
|
||||||
|
translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973");
|
||||||
|
translator.getTranslatorObject(function (marc) {
|
||||||
|
var record = new marc.record();
|
||||||
|
var newItem = new Zotero.Item();
|
||||||
|
// ignore the table headings in lines[0]
|
||||||
|
record.leader = text(lines[1], 'td', 4);
|
||||||
|
var fieldTag, indicators, fieldContent;
|
||||||
|
for (let line of Array.from(lines).slice(2)) {
|
||||||
|
// multiple lines with same fieldTag do not repeat the tag
|
||||||
|
// i.e. in these cases we will just take same value as before
|
||||||
|
if (text(line, 'td', 0).trim().length > 0) {
|
||||||
|
fieldTag = text(line, 'td', 0);
|
||||||
|
}
|
||||||
|
indicators = text(line, 'td', 1) + text(line, 'td', 2);
|
||||||
|
fieldContent = '';
|
||||||
|
if (text(line, 'td', 3).trim().length > 0) {
|
||||||
|
fieldContent = marc.subfieldDelimiter + text(line, 'td', 3);
|
||||||
|
}
|
||||||
|
fieldContent += text(line, 'td', 4);
|
||||||
|
|
||||||
|
record.addField(fieldTag, indicators, fieldContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
record.translate(newItem);
|
||||||
|
|
||||||
|
// possibly clean newItem further here
|
||||||
|
|
||||||
|
newItem.complete();
|
||||||
|
});
|
||||||
|
}
|
31
chrome/content/scaffold/templates/scrapeRIS.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
function scrape(doc, url) {
|
||||||
|
var DOI = url.match(/\/(10\.[^#?]+)/)[1];
|
||||||
|
// TODO adjust the url here
|
||||||
|
var risURL = "http://citation-needed.services.springer.com/v2/references/" + DOI + "?format=refman&flavour=citation";
|
||||||
|
// Z.debug(risURL)
|
||||||
|
|
||||||
|
// TODO adjust the url here
|
||||||
|
var pdfURL = doc.getElementById("articlePdf");
|
||||||
|
// Z.debug("pdfURL: " + pdfURL);
|
||||||
|
ZU.doGet(risURL, function (text) {
|
||||||
|
var translator = Zotero.loadTranslator("import");
|
||||||
|
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||||
|
translator.setString(text);
|
||||||
|
translator.setHandler("itemDone", function (obj, item) {
|
||||||
|
// TODO tweak some of the output here
|
||||||
|
if (pdfURL) {
|
||||||
|
item.attachments.push({
|
||||||
|
url: pdfURL.href,
|
||||||
|
title: "Full Text PDF",
|
||||||
|
mimeType: "application/pdf"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
item.attachments.push({
|
||||||
|
title: "Snapshot",
|
||||||
|
document: doc
|
||||||
|
});
|
||||||
|
item.complete();
|
||||||
|
});
|
||||||
|
translator.translate();
|
||||||
|
});
|
||||||
|
}
|
11
chrome/content/scaffold/templates/shortcuts.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Keyboard Shortcuts
|
||||||
|
=============
|
||||||
|
|
||||||
|
Ctrl/Cmd S : Save
|
||||||
|
|
||||||
|
Ctrl/Cmd R : Run doWeb/doImport
|
||||||
|
Ctrl/Cmd T : DetectWeb/detectImport
|
||||||
|
|
||||||
|
Ctrl/Cmd + : Increase Font Size
|
||||||
|
Ctrl/Cmd - : Decrease Font Size
|
||||||
|
Ctrl/Cmd 0 : Restore Font Size
|
138
chrome/content/scaffold/translators.js
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||||
|
|
||||||
|
var Scaffold_Translators = {
|
||||||
|
// Keep in sync with translator.js
|
||||||
|
TRANSLATOR_TYPES: { import: 1, export: 2, web: 4, search: 8 },
|
||||||
|
|
||||||
|
_provider: null,
|
||||||
|
_translators: new Map(),
|
||||||
|
_translatorFiles: new Map(),
|
||||||
|
|
||||||
|
load: Zotero.serial(async function (reload, filenames) {
|
||||||
|
if (this._translators.size && !reload) {
|
||||||
|
Zotero.debug("Scaffold: Translators already loaded");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filenames) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var t = new Date();
|
||||||
|
var dir = this.getDirectory();
|
||||||
|
var numLoaded = 0;
|
||||||
|
var deletedTranslators = new Set(this._translatorFiles.keys());
|
||||||
|
await Zotero.File.iterateDirectory(dir, function* (iterator) {
|
||||||
|
while (true) {
|
||||||
|
let entries = yield iterator.nextBatch(50);
|
||||||
|
if (!entries.length) break;
|
||||||
|
for (let entry of entries) {
|
||||||
|
if (entry.isDir || entry.name.startsWith('.') || !entry.name.endsWith('.js')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
deletedTranslators.delete(entry.name);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let fmtime;
|
||||||
|
if ('winLastWriteDate' in entry) {
|
||||||
|
fmtime = entry.winLastWriteDate.getTime();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fmtime = (yield OS.File.stat(entry.path)).lastModificationDate.getTime();
|
||||||
|
}
|
||||||
|
let translatorID = this._translatorFiles.get(entry.name);
|
||||||
|
let loadFile = true;
|
||||||
|
// If translator is already loaded, see if mtime has changed
|
||||||
|
if (translatorID) {
|
||||||
|
let mtime = this._translators.get(translatorID).mtime;
|
||||||
|
if (mtime == fmtime) {
|
||||||
|
loadFile = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (loadFile) {
|
||||||
|
let translator = yield Zotero.Translators.loadFromFile(entry.path);
|
||||||
|
this._translators.set(
|
||||||
|
translator.translatorID,
|
||||||
|
{
|
||||||
|
translator,
|
||||||
|
filename: entry.name,
|
||||||
|
mtime: fmtime,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this._translatorFiles.set(entry.name, translator.translatorID);
|
||||||
|
numLoaded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.logError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
Zotero.debug(`Scaffold: Loaded ${numLoaded} ${Zotero.Utilities.pluralize(numLoaded, 'translator')} `
|
||||||
|
+ `in ${new Date() - t} ms`);
|
||||||
|
|
||||||
|
for (let filename of deletedTranslators) {
|
||||||
|
let id = this._translatorFiles.get(filename);
|
||||||
|
let translator = this._translators.get(id);
|
||||||
|
this._translatorFiles.delete(filename);
|
||||||
|
// Filename won't match if translator was renamed
|
||||||
|
if (translator.filename == filename) {
|
||||||
|
this._translators.delete(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
deleteByID: async function (translatorID) {
|
||||||
|
var translator = this._translators.get(translatorID);
|
||||||
|
if (!translator) {
|
||||||
|
Zotero.debug("Scaffold: Can't delete missing translator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await OS.File.delete(OS.Path.join(this.getDirectory(), translator.filename));
|
||||||
|
this._translators.delete(translatorID);
|
||||||
|
this._translatorFiles.delete(translator.filename);
|
||||||
|
},
|
||||||
|
|
||||||
|
getDirectory: function () {
|
||||||
|
return Zotero.Prefs.get('scaffold.translatorsDir');
|
||||||
|
},
|
||||||
|
|
||||||
|
getProvider: function () {
|
||||||
|
if (this._provider) {
|
||||||
|
return this._provider;
|
||||||
|
}
|
||||||
|
this._provider = Zotero.Translators.makeTranslatorProvider({
|
||||||
|
get: function (translatorID) {
|
||||||
|
if (!this._translators.size) {
|
||||||
|
throw new Error("Scaffold: Translators not loaded");
|
||||||
|
}
|
||||||
|
var translator = this._translators.get(translatorID);
|
||||||
|
return translator ? translator.translator : false;
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
getAllForType: async function (type) {
|
||||||
|
if (!this._translators.size) {
|
||||||
|
await this.load();
|
||||||
|
}
|
||||||
|
return [...this._translators.values()]
|
||||||
|
.map(x => x.translator)
|
||||||
|
.filter(translator => translator.translatorType & this.TRANSLATOR_TYPES[type]);
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
getTranslatorsDirectory: function () {
|
||||||
|
return this.getDirectory();
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
reinit: async function (options = {}) {
|
||||||
|
return this.load(
|
||||||
|
true,
|
||||||
|
options.filenames
|
||||||
|
);
|
||||||
|
}.bind(this)
|
||||||
|
});
|
||||||
|
return this._provider;
|
||||||
|
}
|
||||||
|
};
|
|
@ -453,6 +453,10 @@ function openRunJSWindow() {
|
||||||
window.open('chrome://zotero/content/runJS.html', 'run-js', 'width=900,height=700,resizable');
|
window.open('chrome://zotero/content/runJS.html', 'run-js', 'width=900,height=700,resizable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openScaffold() {
|
||||||
|
window.open('chrome://scaffold/content/scaffold.xul', 'scaffold', 'chrome,resizable');
|
||||||
|
}
|
||||||
|
|
||||||
function toOpenWindowByType(inType, uri, features)
|
function toOpenWindowByType(inType, uri, features)
|
||||||
{
|
{
|
||||||
var topWindow = Services.wm.getMostRecentWindow(inType);
|
var topWindow = Services.wm.getMostRecentWindow(inType);
|
||||||
|
|
|
@ -203,6 +203,7 @@
|
||||||
<menupopup>
|
<menupopup>
|
||||||
<menuitem id="menu_errorConsole" label="Error Console" oncommand="toJavaScriptConsole()"/>
|
<menuitem id="menu_errorConsole" label="Error Console" oncommand="toJavaScriptConsole()"/>
|
||||||
<menuitem id="menu_runJS" label="Run JavaScript" oncommand="openRunJSWindow()"/>
|
<menuitem id="menu_runJS" label="Run JavaScript" oncommand="openRunJSWindow()"/>
|
||||||
|
<menuitem id="scaffold-menu-item" label="Translator Editor" oncommand="openScaffold()"/>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
</menu>
|
</menu>
|
||||||
</menupopup>
|
</menupopup>
|
||||||
|
|
76
chrome/locale/en-US/scaffold/scaffold.dtd
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<!ENTITY scaffold.toolbar.load.label "Load">
|
||||||
|
<!ENTITY scaffold.toolbar.save.label "Save">
|
||||||
|
<!ENTITY scaffold.toolbar.saveToZotero.label "Save to Zotero">
|
||||||
|
<!ENTITY scaffold.toolbar.template.label "Add a template">
|
||||||
|
<!ENTITY scaffold.toolbar.template.newWeb.label "Add web translator template">
|
||||||
|
<!ENTITY scaffold.toolbar.template.scrape.label "Add scrape function using…">
|
||||||
|
<!ENTITY scaffold.toolbar.export.label "Export">
|
||||||
|
<!ENTITY scaffold.toolbar.detectWeb.label "Run detectWeb">
|
||||||
|
<!ENTITY scaffold.toolbar.doWeb.label "Run doWeb">
|
||||||
|
<!ENTITY scaffold.toolbar.detectImport.label "Run detectImport">
|
||||||
|
<!ENTITY scaffold.toolbar.doImport.label "Run doImport">
|
||||||
|
<!ENTITY scaffold.toolbar.setTranslatorsDir.label "Set translators directory">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.tabs.metadata.label "Metadata">
|
||||||
|
<!ENTITY scaffold.tabs.code.label "Code">
|
||||||
|
<!ENTITY scaffold.tabs.import.label "Import">
|
||||||
|
<!ENTITY scaffold.tabs.tests.label "Tests">
|
||||||
|
<!ENTITY scaffold.tabs.testing.label "Testing">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.menu.help "Help">
|
||||||
|
<!ENTITY scaffold.toolbar.template.itemTypes.label "List all item types">
|
||||||
|
<!ENTITY scaffold.toolbar.template.newItem.label "List all fields for item type">
|
||||||
|
<!ENTITY scaffold.toolbar.template.more.label "More">
|
||||||
|
<!ENTITY scaffold.toolbar.help.shortcuts "Keyboard Shortcuts">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.tabUrl.label "URL:">
|
||||||
|
<!ENTITY scaffold.testFrame.label "Test Frame:">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.metadata.translatorID.label "Translator ID:">
|
||||||
|
<!ENTITY scaffold.metadata.translatorID.generate "Generate">
|
||||||
|
<!ENTITY scaffold.metadata.label.label "Label:">
|
||||||
|
<!ENTITY scaffold.metadata.creator.label "Creator:">
|
||||||
|
<!ENTITY scaffold.metadata.target.label "Target:">
|
||||||
|
<!ENTITY scaffold.metadata.target.testRegex "Test Regex">
|
||||||
|
<!ENTITY scaffold.metadata.configOptions.label "Config Options:">
|
||||||
|
<!ENTITY scaffold.metadata.displayOptions.label "Display Options:">
|
||||||
|
<!ENTITY scaffold.metadata.minVersion.label "Min. Version:">
|
||||||
|
<!ENTITY scaffold.metadata.maxVersion.label "Max. Version:">
|
||||||
|
<!ENTITY scaffold.metadata.priority.label "Priority:">
|
||||||
|
<!ENTITY scaffold.metadata.translatorType.label "Translator Type:">
|
||||||
|
<!ENTITY scaffold.metadata.translatorType.import "Import">
|
||||||
|
<!ENTITY scaffold.metadata.translatorType.export "Export">
|
||||||
|
<!ENTITY scaffold.metadata.translatorType.web "Web">
|
||||||
|
<!ENTITY scaffold.metadata.translatorType.search "Search">
|
||||||
|
<!ENTITY scaffold.metadata.browserSupport.label "Browser Support:">
|
||||||
|
<!ENTITY scaffold.metadata.browserSupport.gecko "Gecko (Firefox)">
|
||||||
|
<!ENTITY scaffold.metadata.browserSupport.chrome "Chrome">
|
||||||
|
<!ENTITY scaffold.metadata.browserSupport.safari "Safari">
|
||||||
|
<!ENTITY scaffold.metadata.browserSupport.ie "Internet Explorer">
|
||||||
|
<!ENTITY scaffold.metadata.browserSupport.bookmarklet "Bookmarklet">
|
||||||
|
<!ENTITY scaffold.metadata.browserSupport.server "Server">
|
||||||
|
<!ENTITY scaffold.metadata.targetAll.label "Target All:">
|
||||||
|
<!ENTITY scaffold.metadata.hiddenPrefs.label "Hidden Preferences:">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.metadata.label.default "Untitled">
|
||||||
|
<!ENTITY scaffold.metadata.priority.default "100">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.load.title "Load Translator">
|
||||||
|
<!ENTITY scaffold.load.label.label "Label">
|
||||||
|
<!ENTITY scaffold.load.creator.label "Creator">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.editor.external.label "Use external editor">
|
||||||
|
|
||||||
|
<!ENTITY scaffold.testing.description "Select a test to run">
|
||||||
|
<!ENTITY scaffold.testing.input.label "Input">
|
||||||
|
<!ENTITY scaffold.testing.status.label "Status">
|
||||||
|
<!ENTITY scaffold.testing.populate "Populate">
|
||||||
|
<!ENTITY scaffold.testing.save "Save">
|
||||||
|
<!ENTITY scaffold.testing.delete "Delete">
|
||||||
|
<!ENTITY scaffold.testing.run "Run">
|
||||||
|
<!ENTITY scaffold.testing.update "Update">
|
||||||
|
<!ENTITY scaffold.testing.new "New Web">
|
||||||
|
<!ENTITY scaffold.testing.new.import "New Import">
|
||||||
|
<!ENTITY scaffold.testing.edit.import "Edit Import">
|
||||||
|
<!ENTITY scaffold.testing.copyToClipboard "Copy to Clipboard">
|
||||||
|
<!ENTITY scaffold.testing.openUrl "Open URL">
|
0
chrome/locale/en-US/scaffold/scaffold.properties
Normal file
BIN
chrome/skin/default/scaffold/add.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
chrome/skin/default/scaffold/checkSyntax.png
Normal file
After Width: | Height: | Size: 537 B |
BIN
chrome/skin/default/scaffold/copy.png
Normal file
After Width: | Height: | Size: 415 B |
BIN
chrome/skin/default/scaffold/detectImport.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
chrome/skin/default/scaffold/detectWeb.png
Normal file
After Width: | Height: | Size: 750 B |
BIN
chrome/skin/default/scaffold/doImport.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
chrome/skin/default/scaffold/doWeb.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
chrome/skin/default/scaffold/fields.png
Normal file
After Width: | Height: | Size: 797 B |
BIN
chrome/skin/default/scaffold/load.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
chrome/skin/default/scaffold/reference.png
Normal file
After Width: | Height: | Size: 825 B |
BIN
chrome/skin/default/scaffold/save.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
chrome/skin/default/scaffold/saveToZotero.png
Normal file
After Width: | Height: | Size: 3 KiB |
102
chrome/skin/default/scaffold/scaffold.css
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||||
|
@namespace html url("http://www.w3.org/1999/xhtml");
|
||||||
|
|
||||||
|
toolbar {
|
||||||
|
height: 32px;
|
||||||
|
padding-left: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbarbutton-text {
|
||||||
|
margin:0 2px;
|
||||||
|
}
|
||||||
|
.toolbarbutton-menu-dropmarker {
|
||||||
|
margin-right:4px;
|
||||||
|
}
|
||||||
|
.toolbarbutton-text {
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
.toolbarbutton-icon {
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
toolbarseparator {
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tb-load {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/load.png');
|
||||||
|
}
|
||||||
|
#tb-save {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/save.png');
|
||||||
|
}
|
||||||
|
#tb-saveToZotero {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/saveToZotero.png');
|
||||||
|
}
|
||||||
|
#tb-template {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/add.png');
|
||||||
|
}
|
||||||
|
#tb-import {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/import.png');
|
||||||
|
}
|
||||||
|
#tb-export {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/export.png');
|
||||||
|
}
|
||||||
|
#tb-copy {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/copy.png');
|
||||||
|
}
|
||||||
|
#tb-checkSyntax {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/checkSyntax.png');
|
||||||
|
}
|
||||||
|
#tb-detectWeb {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/detectWeb.png');
|
||||||
|
}
|
||||||
|
#tb-doWeb {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/doWeb.png');
|
||||||
|
}
|
||||||
|
#tb-detectImport {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/detectImport.png');
|
||||||
|
}
|
||||||
|
#tb-doImport {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/doImport.png');
|
||||||
|
}
|
||||||
|
#tb-setTranslatorsDir {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/setTranslatorsDir.png');
|
||||||
|
}
|
||||||
|
#tb-reference {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/reference.png');
|
||||||
|
}
|
||||||
|
#tb-fields {
|
||||||
|
list-style-image: url('chrome://scaffold/skin/fields.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
#tabpanel-metadata textbox {
|
||||||
|
height:2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#tabpanel-metadata hbox, #hbox-testFrame {
|
||||||
|
-moz-box-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#output {
|
||||||
|
height:200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
listbox {
|
||||||
|
min-width:200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#editor-toolbar {
|
||||||
|
margin-bottom: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#editor-external-box {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#editor-external-box label {
|
||||||
|
margin-left: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
browser {
|
||||||
|
background: white;
|
||||||
|
}
|
BIN
chrome/skin/default/scaffold/setTranslatorsDir.png
Normal file
After Width: | Height: | Size: 1.2 KiB |