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

Some delayed JSHint obeisance

This commit is contained in:
Jeremy Ruston 2012-05-04 18:49:04 +01:00
parent afc4824307
commit fa0e16eef5
48 changed files with 131 additions and 74 deletions

View File

@ -24,8 +24,8 @@ In practice, each module is wrapped in a separate script block.
\*/
(function() {
/*jslint node: true */
/*global modules: false */
/*jslint node: true, browser: true */
/*global modules: false, $tw: false */
"use strict";
/////////////////////////// Setting up $tw
@ -40,7 +40,7 @@ $tw.boot = {};
// Modules store registers all the modules the system has seen
$tw.modules = $tw.modules || {};
$tw.modules.titles = $tw.modules.titles || {} // hashmap by module title of {fn:, exports:, moduleType:}
$tw.modules.titles = $tw.modules.titles || {}; // hashmap by module title of {fn:, exports:, moduleType:}
// Plugins store organises module exports by module type
$tw.plugins = $tw.plugins || {};
@ -75,7 +75,7 @@ Determine if a value is an array
*/
$tw.utils.isArray = function(value) {
return Object.prototype.toString.call(value) == "[object Array]";
}
};
// Convert "&amp;" to &, "&lt;" to <, "&gt;" to > and "&quot;" to "
$tw.utils.htmlDecode = function(s) {
@ -88,8 +88,9 @@ Pad a string to a given length with "0"s. Length defaults to 2
$tw.utils.pad = function(value,length) {
length = length || 2;
var s = value.toString();
if(s.length < length)
if(s.length < length) {
s = "000000000000000000000000000".substr(0,length - s.length) + s;
}
return s;
};
@ -367,8 +368,8 @@ $tw.Wiki.prototype.deserializeTiddlers = function(type,text,srcFields) {
deserializer = $tw.Wiki.tiddlerDeserializerPlugins[type];
}
for(var f in srcFields) {
fields[f] = srcFields[f]
};
fields[f] = srcFields[f];
}
if(deserializer) {
return deserializer.call(this,text,fields);
} else {
@ -564,7 +565,7 @@ $tw.plugins.loadPlugins = function(filepath,basetitle,excludeRegExp) {
$tw.plugins.loadTiddlersFromFile(filepath,basetitle);
}
}
}
};
/*
Execute the module named 'moduleName'. The name can optionally be relative to the module named 'moduleRoot'
@ -599,7 +600,7 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
}
// Return the exports of the module
return module.exports;
}
};
// Load plugins from the plugins directory
$tw.plugins.loadPlugins(path.resolve($tw.boot.bootPath,$tw.config.bootModuleSubDir));

View File

@ -9,6 +9,7 @@ The $tw.Commander class is a command interpreter
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*

View File

@ -8,13 +8,14 @@ Dump command
\*/
(function(){
/*jslint node: true, browser: true */
/*jshint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "dump",
synchronous: true
}
};
var Command = function(params,commander) {
this.params = params;
@ -32,13 +33,13 @@ Command.prototype.execute = function() {
} else {
return "Unknown subcommand (" + this.params[0] + ") for dump command";
}
}
};
Command.prototype.subcommands = {};
Command.prototype.subcommands.tiddlers = function() {
var tiddlers = this.commander.wiki.sortTiddlers()
var tiddlers = this.commander.wiki.sortTiddlers();
this.output.write("Wiki contains these tiddlers:\n");
for(var t=0; t<tiddlers.length; t++) {
this.output.write(tiddlers[t] + "\n");
@ -47,7 +48,7 @@ Command.prototype.subcommands.tiddlers = function() {
};
Command.prototype.subcommands.shadows = function() {
var tiddlers = this.commander.wiki.shadows.sortTiddlers()
var tiddlers = this.commander.wiki.shadows.sortTiddlers();
this.output.write("Wiki contains these shadow tiddlers:\n");
for(var t=0; t<tiddlers.length; t++) {
this.output.write(tiddlers[t] + "\n");

View File

@ -9,6 +9,7 @@ Load tiddlers command
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -9,6 +9,7 @@ Save tiddlers command
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -9,12 +9,13 @@ Verbose command
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "verbose",
synchronous: true
}
};
var Command = function(params,commander) {
this.params = params;
@ -24,7 +25,7 @@ var Command = function(params,commander) {
Command.prototype.execute = function() {
this.commander.verbose = true;
return null; // No error
}
};
exports.Command = Command;

View File

@ -9,12 +9,13 @@ Version command
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "version",
synchronous: true
}
};
var Command = function(params,commander) {
this.params = params;
@ -24,7 +25,7 @@ var Command = function(params,commander) {
Command.prototype.execute = function() {
this.commander.streams.output.write($tw.utils.getVersionString() + "\n");
return null; // No error
}
};
exports.Command = Command;

View File

@ -9,6 +9,7 @@ wikitest command
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -8,7 +8,8 @@ Core configuration constants
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.dateFormats = {

View File

@ -12,7 +12,8 @@ Represents the dependencies of a tiddler or a parser node as these fields:
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Dependencies = function(skinnyTiddlers,fatTiddlers,dependentAll) {

View File

@ -12,7 +12,8 @@ Represents the dependencies of a tiddler or a parser node as these fields:
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports["text/plain"] = function(text,fields) {

View File

@ -7,6 +7,7 @@ module-type: macro
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -7,6 +7,7 @@ module-type: macro
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
@ -48,14 +49,14 @@ exports.select = function(y) {
$tw.utils.addClass(target,"selected");
}
}
}
};
exports.deselect = function() {
if(this.selectedNode) {
$tw.utils.removeClass(this.selectedNode,"selected");
this.selectedNode = null;
}
}
};
exports.action = function() {
if(this.selectedNode) {
@ -64,7 +65,7 @@ exports.action = function() {
navEvent.navigateTo = this.selectedNode.getAttribute("data-link");
this.domNode.dispatchEvent(navEvent);
}
}
};
/*
Set the position of the chooser panel within its wrapper given a touch/mouse position in screen coordinates
@ -92,7 +93,7 @@ exports.hoverChooser = function(x,y) {
domPanel.style.webkitTransform =
domPanel.style.MozTransform = "scale(" + scale + ") translateX(" + translateX + "px) translateY(" + translateY + "px)";
}
}
};
exports.hideChooser = function() {
if(this.chooserDisplayed) {
@ -101,7 +102,7 @@ exports.hideChooser = function() {
this.domNode.removeChild(this.children[0].domNode);
this.children = [];
}
}
};
exports.handleEvent = function(event) {
switch(event.type) {

View File

@ -6,7 +6,8 @@ module-type: macro
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -7,6 +7,7 @@ module-type: macro
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -7,6 +7,7 @@ module-type: editor
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
function BitmapEditor(macroNode) {

View File

@ -7,6 +7,7 @@ module-type: editor
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
function TextEditor(macroNode) {

View File

@ -6,7 +6,8 @@ module-type: macro
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -9,6 +9,7 @@ Implements the link macro.
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var isLinkExternal = function(to) {

View File

@ -6,7 +6,8 @@ module-type: macro
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var handlers = {

View File

@ -35,7 +35,8 @@ The slider is a good study example of a simple interactive macro.
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -6,7 +6,8 @@ module-type: macro
\*/
(function(){
/*jslint node: true, jquery: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
function scrollToTop(duration) {
@ -30,9 +31,8 @@ exports.info = {
events: ["tw-navigate","tw-EditTiddler","tw-SaveTiddler"]
};
exports.handleEvent = function(event) {
var template, storyTiddler, story, storyRecord, tiddler, storyTiddlerModified;
var template, storyTiddler, story, storyRecord, tiddler, storyTiddlerModified, t;
switch(event.type) {
case "tw-navigate":
// Navigate to a specified tiddler
@ -55,12 +55,12 @@ exports.handleEvent = function(event) {
if(storyTiddler && storyTiddler.fields.hasOwnProperty("text")) {
story = JSON.parse(storyTiddler.fields.text);
}
for(var t=0; t<story.tiddlers.length; t++) {
var storyRecord = story.tiddlers[t];
for(t=0; t<story.tiddlers.length; t++) {
storyRecord = story.tiddlers[t];
if(storyRecord.title === event.tiddlerTitle && storyRecord.template !== template) {
storyRecord.title = "Draft " + (new Date()) + " of " + event.tiddlerTitle;
storyRecord.template = template;
var tiddler = this.wiki.getTiddler(event.tiddlerTitle);
tiddler = this.wiki.getTiddler(event.tiddlerTitle);
this.wiki.addTiddler(new $tw.Tiddler(
{
text: "Type the text for the tiddler '" + event.tiddlerTitle + "'"
@ -84,10 +84,10 @@ exports.handleEvent = function(event) {
if(storyTiddler && storyTiddler.fields.hasOwnProperty("text")) {
story = JSON.parse(storyTiddler.fields.text);
}
for(var t=0; t<story.tiddlers.length; t++) {
var storyRecord = story.tiddlers[t];
for(t=0; t<story.tiddlers.length; t++) {
storyRecord = story.tiddlers[t];
if(storyRecord.title === event.tiddlerTitle && storyRecord.template !== template) {
var tiddler = this.wiki.getTiddler(storyRecord.title);
tiddler = this.wiki.getTiddler(storyRecord.title);
if(tiddler && tiddler.fields.hasOwnProperty("draft.title")) {
// Save the draft tiddler as the real tiddler
this.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: tiddler.fields["draft.title"],"draft.title": undefined, "draft.of": undefined}));

View File

@ -41,7 +41,8 @@ the `template` parameter or, if that parameter is missing, the tiddler named in
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
@ -66,7 +67,7 @@ exports.evaluateDependencies = function() {
dependencies.addDependency(template,true);
}
return dependencies;
}
};
exports.executeMacro = function() {
var renderTitle = this.params.target,
@ -124,7 +125,7 @@ exports.executeMacro = function() {
}
// Return the children
return [$tw.Tree.Element("div",attributes,childrenClone)];
}
};
exports.refreshInDom = function(changes) {
var t;

View File

@ -6,14 +6,15 @@ module-type: macro
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "version",
params: {
}
}
};
exports.executeMacro = function() {
return [$tw.Tree.Text($tw.utils.getVersionString())];

View File

@ -6,7 +6,8 @@ module-type: macro
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -6,7 +6,8 @@ module-type: macro
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {

View File

@ -7,6 +7,7 @@ module-type: macro
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
@ -22,7 +23,7 @@ exports.startZoomer = function(x,y) {
this.startX = x;
this.startY = y;
$tw.utils.addClass(document.body,"in-zoomer");
}
};
exports.stopZoomer = function() {
var newScrollY = this.yFactor * (this.bodyHeight - this.windowHeight);
@ -33,7 +34,7 @@ exports.stopZoomer = function() {
"translateY(" + ((this.windowHeight / this.scale) - this.bodyHeight) * this.yFactor * this.xFactor + "px)";
$tw.utils.removeClass(document.body,"in-zoomer");
document.body.style.webkitTransform = "translateY(0) scale(1) translateY(0)";
}
};
/*
Zoom the body element given a touch/mouse position in screen coordinates

View File

@ -8,7 +8,8 @@ Parses an image into a parse tree containing an HTML img element
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var ImageParser = function(options) {

View File

@ -8,7 +8,8 @@ Parses a JSON object into a parse tree
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var renderObject = function(obj) {
@ -41,7 +42,7 @@ var JSONParser = function(options) {
};
JSONParser.prototype.parse = function(type,text) {
return new $tw.Renderer([renderObject(JSON.parse(text))],new Dependencies());
return new $tw.Renderer([renderObject(JSON.parse(text))],new $tw.Dependencies());
};
exports["application/json"] = JSONParser;

View File

@ -8,7 +8,8 @@ Renders plain text tiddlers
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var PlainTextParser = function(options) {

View File

@ -16,7 +16,8 @@ The syntax for macros is:
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var TiddlyTextParser = function(options) {

View File

@ -6,7 +6,8 @@ module-type: wikitextrule
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var textPrimitives = {

View File

@ -30,7 +30,8 @@ HTML nodes look like this:
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*

View File

@ -8,7 +8,8 @@ Represents a parse tree and associated data
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Renderer = function(tree,dependencies) {

View File

@ -9,6 +9,7 @@ This is the main application logic for both the client and server
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.startup = function() {
@ -56,6 +57,6 @@ if($tw.isBrowser) {
commander.execute();
}
}
};
})();

View File

@ -8,7 +8,8 @@ Extension methods for the $tw.Tiddler object
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.hasTag = function(tag) {

View File

@ -19,7 +19,8 @@ themselves with `new` when required.
\*/
(function(){
/*jshint node: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.Tree = {};

View File

@ -8,7 +8,8 @@ Static utility methods for the $tw.Tree class
\*/
(function(){
/*jshint node: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
@ -18,7 +19,7 @@ exports.errorNode = function(text) {
return $tw.Tree.Element("span",{
"class": ["label","label-important"]
},[
new TextNode(text)
new $tw.Tree.Text(text)
]);
};

View File

@ -8,7 +8,8 @@ Element nodes
\*/
(function(){
/*jshint node: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Node = require("./node.js").Node;

View File

@ -8,7 +8,8 @@ Entity nodes
\*/
(function(){
/*jshint node: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Node = require("./node.js").Node;

View File

@ -9,6 +9,7 @@ Macro node, used as the base class for macros
(function(){
/*jshint node: true, browser: true */
/*global $tw: false */
"use strict";
var Node = require("./node.js").Node;
@ -46,8 +47,7 @@ var Macro = function(macroName,srcParams,content,wiki,dependencies) {
this.info = MacroClass.prototype.info;
}
} else {
// If Macro() has been called without new then lookup the macro class to instantiate
var MacroClass = wiki.macros[macroName];
// If Macro() has been called without 'new' then instantiate the right macro class
return new MacroClass(macroName,srcParams,content,wiki,dependencies);
}
};
@ -123,7 +123,7 @@ Macro.prototype.cloneContent = function() {
contentClones.push(this.content[t].clone());
}
return contentClones;
}
};
Macro.prototype.clone = function() {
return new this.MacroClass(this.macroName,this.srcParams,this.cloneContent(),this.wiki,this.dependencies);

View File

@ -8,7 +8,8 @@ Base class for all other tree nodes
\*/
(function(){
/*jshint node: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*

View File

@ -8,7 +8,8 @@ Raw, unparsed HTML nodes
\*/
(function(){
/*jshint node: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Node = require("./node.js").Node;

View File

@ -8,7 +8,8 @@ Text nodes
\*/
(function(){
/*jshint node: true, browser: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Node = require("./node.js").Node;

View File

@ -23,7 +23,8 @@ Options and their defaults are:
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var ArgParser = function(argString,options) {

View File

@ -10,7 +10,8 @@ This file is a bit of a dumping ground; the expectation is that most of these fu
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.deepCopy = function(object) {
@ -33,7 +34,7 @@ exports.deepCopy = function(object) {
exports.extendDeepCopy = function(object,extendedProperties) {
var result = $tw.utils.deepCopy(object),t;
for(var t in extendedProperties) {
for(t in extendedProperties) {
if(object[t] !== undefined) {
result[t] = $tw.utils.deepCopy(object[t]);
}

View File

@ -21,7 +21,8 @@ last dispatched. Each entry is a hashmap containing two fields:
\*/
(function(){
/*jslint node: true */
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.getTiddlerText = function(title,defaultText) {
@ -124,7 +125,7 @@ exports.sortTiddlers = function(sortField,excludeTag) {
sortField = sortField || "title";
var tiddlers = [], t, titles = [];
for(t in this.tiddlers) {
tiddlers.push(this.tiddlers[t])
tiddlers.push(this.tiddlers[t]);
}
tiddlers.sort(function(a,b) {
var aa = a.fields[sortField] || 0,

View File

@ -3,3 +3,15 @@
# run TiddlyWiki5
node ../core/boot.js --verbose --wikitest ../../test/wikitests/ --dump shadows || exit 1
# run jshint
jshint ../core/*.js
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