1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

JSHint-prompted tweaks

This commit is contained in:
Jeremy Ruston 2012-05-19 15:13:17 +01:00
parent 3e899d8daf
commit 6a7a5a2591
10 changed files with 62 additions and 79 deletions

View File

@ -649,7 +649,7 @@ $tw.plugins.loadPluginsFromFolder(path.resolve($tw.boot.wikiPath,"./tiddlers"),n
$tw.plugins.registerPluginModules(); $tw.plugins.registerPluginModules();
// Run any startup plugin modules // Run any startup plugin modules
var mainModules = $tw.plugins.moduleTypes["startup"]; var mainModules = $tw.plugins.moduleTypes.startup;
for(var m=0; m<mainModules.length; m++) { for(var m=0; m<mainModules.length; m++) {
mainModules[m].startup.call($tw); mainModules[m].startup.call($tw);
} }

View File

@ -30,6 +30,6 @@ exports.htmlEntities = {quot:34, amp:38, apos:39, lt:60, gt:62, nbsp:160, iexcl:
exports.preferences = { exports.preferences = {
animationDuration: 400 animationDuration: 400
} };
})(); })();

View File

@ -21,15 +21,14 @@ exports.info = {
}; };
exports.handleEvent = function(event) { exports.handleEvent = function(event) {
switch(event.type) { if(event.type === "click") {
case "click": var buttonEvent = document.createEvent("Event");
var buttonEvent = document.createEvent("Event"); buttonEvent.initEvent("tw-" + this.params.name,true,true);
buttonEvent.initEvent("tw-" + this.params.name,true,true); buttonEvent.tiddlerTitle = this.tiddlerTitle;
buttonEvent.tiddlerTitle = this.tiddlerTitle; buttonEvent.commandOrigin = this;
buttonEvent.commandOrigin = this; event.target.dispatchEvent(buttonEvent);
event.target.dispatchEvent(buttonEvent); event.preventDefault();
event.preventDefault(); return false;
return false;
} }
return true; return true;
}; };

View File

@ -22,15 +22,14 @@ exports.info = {
}; };
exports.handleEvent = function(event) { exports.handleEvent = function(event) {
switch(event.type) { if(event.type === "click") {
case "click": var text = this.wiki.renderTiddler(this.downloadType,this.downloadTitle),
var text = this.wiki.renderTiddler(this.downloadType,this.downloadTitle), link = document.createElement("a");
link = document.createElement("a"); link.setAttribute("download",this.downloadFilename);
link.setAttribute("download",this.downloadFilename); link.setAttribute("href","data:" + this.downloadType + "," + encodeURIComponent(text));
link.setAttribute("href","data:" + this.downloadType + "," + encodeURIComponent(text)); link.click();
link.click(); event.preventDefault();
event.preventDefault(); return false;
return false;
} }
return true; return true;
}; };

View File

@ -27,20 +27,19 @@ exports.info = {
}; };
exports.handleEvent = function (event) { exports.handleEvent = function (event) {
switch(event.type) { if(event.type === "click") {
case "click": if(isLinkExternal(this.params.to)) {
if(isLinkExternal(this.params.to)) { event.target.setAttribute("target","_blank");
event.target.setAttribute("target","_blank"); return true;
return true; } else {
} else { var navEvent = document.createEvent("Event");
var navEvent = document.createEvent("Event"); navEvent.initEvent("tw-navigate",true,true);
navEvent.initEvent("tw-navigate",true,true); navEvent.navigateTo = this.params.to;
navEvent.navigateTo = this.params.to; navEvent.navigateFrom = this;
navEvent.navigateFrom = this; event.target.dispatchEvent(navEvent);
event.target.dispatchEvent(navEvent); event.preventDefault();
event.preventDefault(); return false;
return false; }
}
} }
}; };

View File

@ -90,18 +90,17 @@ exports.getSliderChildren = function() {
}; };
exports.handleEvent = function(event) { exports.handleEvent = function(event) {
switch(event.type) { if(event.type === "click") {
case "click": if(event.target === this.domNode.firstChild.firstChild) {
if(event.target === this.domNode.firstChild.firstChild) { this.isOpen = !this.isOpen;
this.isOpen = !this.isOpen; if(!this.saveOpenState()) {
if(!this.saveOpenState()) { this.refreshInDom({});
this.refreshInDom({});
}
event.preventDefault();
return false;
} else {
return true;
} }
event.preventDefault();
return false;
} else {
return true;
}
} }
return true; return true;
}; };

View File

@ -163,9 +163,9 @@ exports.postRenderInDom = function() {
var StoryView = this.wiki.macros.story.viewers[this.params.storyview]; var StoryView = this.wiki.macros.story.viewers[this.params.storyview];
if(StoryView) { if(StoryView) {
this.storyview = new StoryView(this); this.storyview = new StoryView(this);
}; }
if(!this.storyview) { if(!this.storyview) {
StoryView = this.wiki.macros.story.viewers["scroller"]; StoryView = this.wiki.macros.story.viewers.scroller;
if(StoryView) { if(StoryView) {
this.storyview = new StoryView(this); this.storyview = new StoryView(this);
} }

View File

@ -90,7 +90,7 @@ exports.compileFilter = function(filterString) {
operator = operation.operators[p]; operator = operation.operators[p];
operatorInfo = this.operators[operator.operator]; operatorInfo = this.operators[operator.operator];
if(!operatorInfo) { // Check for it being a field operator if(!operatorInfo) { // Check for it being a field operator
operatorInfo = this.operators["field"]; operatorInfo = this.operators.field;
} }
output.push(operatorInfo[type](operator)); output.push(operatorInfo[type](operator));
type = "filter"; type = "filter";
@ -139,29 +139,25 @@ exports.operators = {
}, },
"is": { "is": {
selector: function(operator) { selector: function(operator) {
switch(operator.operand) { if(operator.operand === "tiddler") {
case "tiddler": if(operator.prefix === "!") {
if(operator.prefix === "!") { return "subResults = [];";
return "subResults = [];"; } else {
} else { return "for(var title in source) {$tw.utils.pushTop(subResults,title);}";
return "for(var title in source) {$tw.utils.pushTop(subResults,title);}"; }
} } else {
break; throw "Unknown operand for 'is' filter operator";
default:
throw "Unknown operand for 'is' filter operator";
} }
}, },
filter: function(operator) { filter: function(operator) {
switch(operator.operand) { if(operator.operand === "tiddler") {
case "tiddler": if(operator.prefix === "!") {
if(operator.prefix === "!") { return "subResults = [];";
return "subResults = [];"; } else {
} else { return "";
return ""; }
} } else {
break; throw "Unknown operand for 'is' filter operator";
default:
throw "Unknown operand for 'is' filter operator";
} }
} }
}, },

View File

@ -248,7 +248,7 @@ exports.initParsers = function(moduleType) {
} }
} }
// Install the wikitext rules // Install the wikitext rules
modules = $tw.plugins.moduleTypes["wikitextrule"]; modules = $tw.plugins.moduleTypes.wikitextrule;
var wikitextparser = this.parsers["text/x-tiddlywiki"]; var wikitextparser = this.parsers["text/x-tiddlywiki"];
if(modules && wikitextparser) { if(modules && wikitextparser) {
for(n=0; n<modules.length; n++) { for(n=0; n<modules.length; n++) {

11
run.sh
View File

@ -12,13 +12,4 @@ node ../core/boot.js \
popd > /dev/null popd > /dev/null
# run jshint # run jshint
jshint ./core/*.js jshint core
jshint ./core/modules/*.js
jshint ./core/modules/commands/*.js
jshint ./core/modules/macros/*.js
jshint ./core/modules/macros/edit/*.js
jshint ./core/modules/macros/edit/editors/*.js
jshint ./core/modules/parsers/*.js
jshint ./core/modules/parsers/wikitextparser/*.js
jshint ./core/modules/parsers/wikitextparser/rules/*.js
jshint ./core/modules/treenodes/*.js