1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-07-17 09:22:51 +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,8 +21,7 @@ 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;

View File

@ -22,8 +22,7 @@ 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);

View File

@ -27,8 +27,7 @@ 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;

View File

@ -90,8 +90,7 @@ 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()) {

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,28 +139,24 @@ 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);}";
} }
break; } else {
default:
throw "Unknown operand for 'is' filter operator"; 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 "";
} }
break; } else {
default:
throw "Unknown operand for 'is' filter operator"; 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