1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-27 07:43:14 +00:00

JSHint obeisance for plugins folder

Also add a jshintignore file to skip the various imported modules
This commit is contained in:
Jermolene 2014-08-30 21:32:55 +01:00
parent 3a67fdb768
commit 9c74afdd1a
29 changed files with 63 additions and 57 deletions

7
.jshintignore Normal file
View File

@ -0,0 +1,7 @@
plugins/tiddlywiki/browser-sniff/files
plugins/tiddlywiki/codemirror/files/
plugins/tiddlywiki/d3/files/
plugins/tiddlywiki/highlight/files/
plugins/tiddlywiki/jasmine/files/
plugins/tiddlywiki/markdown/files/
plugins/tiddlywiki/markdown/files/

View File

@ -13,7 +13,7 @@ Initialise $:/info/browser tiddlers
"use strict"; "use strict";
exports.getInfoTiddlerFields = function() { exports.getInfoTiddlerFields = function() {
var mapBoolean = function(value) {return value ? "yes" : "no"}, var mapBoolean = function(value) {return value ? "yes" : "no";},
infoTiddlerFields = []; infoTiddlerFields = [];
// Basics // Basics
if($tw.browser) { if($tw.browser) {

View File

@ -113,7 +113,7 @@ CecilyStoryView.prototype.lookupTiddlerInMap = function(title,domNode) {
if(tiddler) { if(tiddler) {
var draftOf = tiddler.fields["draft.of"]; var draftOf = tiddler.fields["draft.of"];
if(draftOf && this.map.positions[draftOf]) { if(draftOf && this.map.positions[draftOf]) {
return this.map.positions[draftOf] return this.map.positions[draftOf];
} }
} }
// Try looking the target tiddler up in the map // Try looking the target tiddler up in the map

View File

@ -25,14 +25,14 @@ Config options "$:/config/CodeMirror" e.g. to allow vim key bindings
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
var CODEMIRROR_OPTIONS = "$:/config/CodeMirror" var CODEMIRROR_OPTIONS = "$:/config/CodeMirror";
// Install CodeMirror // Install CodeMirror
if($tw.browser && !window.CodeMirror) { if($tw.browser && !window.CodeMirror) {
window.CodeMirror = require("$:/plugins/tiddlywiki/codemirror/lib/codemirror.js"); window.CodeMirror = require("$:/plugins/tiddlywiki/codemirror/lib/codemirror.js");
// Install required CodeMirror plugins // Install required CodeMirror plugins
var configOptions = $tw.wiki.getTiddlerData(CODEMIRROR_OPTIONS,{}), var configOptions = $tw.wiki.getTiddlerData(CODEMIRROR_OPTIONS,{}),
req = configOptions["require"]; req = configOptions.require;
if(req) { if(req) {
if($tw.utils.isArray(req)) { if($tw.utils.isArray(req)) {
for(var index=0; index<req.length; index++) { for(var index=0; index<req.length; index++) {

View File

@ -57,7 +57,7 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
n = 4; // number of layers n = 4; // number of layers
m = 58; // number of samples per layer m = 58; // number of samples per layer
stack = d3.layout.stack(); stack = d3.layout.stack();
layers = stack(d3.range(n).map(function() { return bumpLayer(m, .1); })); layers = stack(d3.range(n).map(function() { return bumpLayer(m, 0.1); }));
} }
// Calculate the maximum data values // Calculate the maximum data values
var yGroupMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y; }); }), var yGroupMax = d3.max(layers, function(layer) { return d3.max(layer, function(d) { return d.y; }); }),
@ -69,7 +69,7 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
// x-scale // x-scale
var x = d3.scale.ordinal() var x = d3.scale.ordinal()
.domain(d3.range(m)) .domain(d3.range(m))
.rangeRoundBands([0, width], .08); .rangeRoundBands([0, width], 0.08);
// y-scale // y-scale
var y = d3.scale.linear() var y = d3.scale.linear()
.domain([0, yStackMax]) .domain([0, yStackMax])
@ -96,13 +96,13 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
// Create the layers // Create the layers
var layer = mainGroup.selectAll(".layer") var layer = mainGroup.selectAll(".layer")
.data(layers) .data(layers)
.enter().append("g") .enter().append("g")
.attr("class", "layer") .attr("class", "layer")
.style("fill", function(d, i) { return color(i); }); .style("fill", function(d, i) { return color(i); });
// Create the rectangles in each layer // Create the rectangles in each layer
var rect = layer.selectAll("rect") var rect = layer.selectAll("rect")
.data(function(d) { return d; }) .data(function(d) { return d; })
.enter().append("rect") .enter().append("rect")
.attr("x", function(d) { return x(d.x); }) .attr("x", function(d) { return x(d.x); })
.attr("y", height) .attr("y", height)
.attr("width", x.rangeBand()) .attr("width", x.rangeBand())
@ -131,44 +131,44 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
}; };
function transitionGrouped() { function transitionGrouped() {
y.domain([0, yGroupMax]); y.domain([0, yGroupMax]);
rect.transition() rect.transition()
.duration(500) .duration(500)
.delay(function(d, i) { return i * 10; }) .delay(function(d, i) { return i * 10; })
.attr("x", function(d, i, j) { return x(d.x) + x.rangeBand() / n * j; }) .attr("x", function(d, i, j) { return x(d.x) + x.rangeBand() / n * j; })
.attr("width", x.rangeBand() / n) .attr("width", x.rangeBand() / n)
.transition() .transition()
.attr("y", function(d) { return y(d.y); }) .attr("y", function(d) { return y(d.y); })
.attr("height", function(d) { return height - y(d.y); }); .attr("height", function(d) { return height - y(d.y); });
} }
function transitionStacked() { function transitionStacked() {
y.domain([0, yStackMax]); y.domain([0, yStackMax]);
rect.transition() rect.transition()
.duration(500) .duration(500)
.delay(function(d, i) { return i * 10; }) .delay(function(d, i) { return i * 10; })
.attr("y", function(d) { return y(d.y0 + d.y); }) .attr("y", function(d) { return y(d.y0 + d.y); })
.attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); }) .attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); })
.transition() .transition()
.attr("x", function(d) { return x(d.x); }) .attr("x", function(d) { return x(d.x); })
.attr("width", x.rangeBand()); .attr("width", x.rangeBand());
} }
// Inspired by Lee Byron's test data generator. // Inspired by Lee Byron's test data generator.
function bumpLayer(n, o) { function bumpLayer(n, o) {
function bump(a) { function bump(a) {
var x = 1 / (.1 + Math.random()), var x = 1 / (0.1 + Math.random()),
y = 2 * Math.random() - .5, y = 2 * Math.random() - 0.5,
z = 10 / (.1 + Math.random()); z = 10 / (0.1 + Math.random());
for (var i = 0; i < n; i++) { for (var i = 0; i < n; i++) {
var w = (i / n - y) * z; var w = (i / n - y) * z;
a[i] += x * Math.exp(-w * w); a[i] += x * Math.exp(-w * w);
}
} }
} var a = [], i;
var a = [], i; for (i = 0; i < n; ++i) a[i] = o + o * Math.random();
for (i = 0; i < n; ++i) a[i] = o + o * Math.random(); for (i = 0; i < 5; ++i) bump(a);
for (i = 0; i < 5; ++i) bump(a); return a.map(function(d, i) { return {x: i, y: Math.max(0, d)}; });
return a.map(function(d, i) { return {x: i, y: Math.max(0, d)}; });
} }
}; };

View File

@ -24,20 +24,19 @@ function FileSystemAdaptor(options) {
this.logger = new $tw.utils.Logger("FileSystem"); this.logger = new $tw.utils.Logger("FileSystem");
this.setwatcher = function(filename, title) { this.setwatcher = function(filename, title) {
return undefined; return undefined;
return this.watchers[filename] = this.watchers[filename] || //return this.watchers[filename] = this.watchers[filename] ||
fs.watch(filename, {persistent: false}, function(e) { // fs.watch(filename, {persistent: false}, function(e) {
self.logger.log("Error:",e,filename); // self.logger.log("Error:",e,filename);
if(e === "change") { // if(e === "change") {
var tiddlers = $tw.loadTiddlersFromFile(filename).tiddlers; // var tiddlers = $tw.loadTiddlersFromFile(filename).tiddlers;
for(var t in tiddlers) { // for(var t in tiddlers) {
if(tiddlers[t].title) { // if(tiddlers[t].title) {
self.wiki.addTiddler(tiddlers[t]); // self.wiki.addTiddler(tiddlers[t]);
} // }
} // }
} // }
}); // });
} };
for(var f in $tw.boot.files) { for(var f in $tw.boot.files) {
var fileInfo = $tw.boot.files[f]; var fileInfo = $tw.boot.files[f];
this.setwatcher(fileInfo.filepath, f); this.setwatcher(fileInfo.filepath, f);
@ -108,7 +107,7 @@ Given a tiddler title and an array of existing filenames, generate a new legal f
*/ */
FileSystemAdaptor.prototype.generateTiddlerFilename = function(title,extension,existingFilenames) { FileSystemAdaptor.prototype.generateTiddlerFilename = function(title,extension,existingFilenames) {
// First remove any of the characters that are illegal in Windows filenames // First remove any of the characters that are illegal in Windows filenames
var baseFilename = title.replace(/\<|\>|\:|\"|\/|\\|\||\?|\*|\^/g,"_"); var baseFilename = title.replace(/<|>|\:|\"|\/|\\|\||\?|\*|\^/g,"_");
// Truncate the filename if it is too long // Truncate the filename if it is too long
if(baseFilename.length > 200) { if(baseFilename.length > 200) {
baseFilename = baseFilename.substr(0,200) + extension; baseFilename = baseFilename.substr(0,200) + extension;

View File

@ -51,7 +51,7 @@ exports.startup = function() {
// The HTMLReporter links itself into the jasmine object automatically, but we have to manually add the node reporter // The HTMLReporter links itself into the jasmine object automatically, but we have to manually add the node reporter
jasmine.jasmine.TerminalVerboseReporter = reporterExports.jasmineNode.TerminalVerboseReporter; jasmine.jasmine.TerminalVerboseReporter = reporterExports.jasmineNode.TerminalVerboseReporter;
jasmine.jasmine.TerminalReporter = reporterExports.jasmineNode.TerminalReporter; jasmine.jasmine.TerminalReporter = reporterExports.jasmineNode.TerminalReporter;
jasmineEnv.addReporter(new jasmine.jasmine.TerminalVerboseReporter({ jasmineEnv.addReporter(new jasmine.jasmine.TerminalVerboseReporter({
print: require("util").print, print: require("util").print,
color: true, color: true,
includeStackTrace: true includeStackTrace: true

View File

@ -48,7 +48,7 @@ Static method that returns true if this saver is capable of working
*/ */
exports.canSave = function(wiki) { exports.canSave = function(wiki) {
// Check if we're running under node-webkit // Check if we're running under node-webkit
return (typeof process == "object") return (typeof process == "object");
}; };
/* /*

View File

@ -37,7 +37,7 @@ TiddlyWebAdaptor.prototype.getHost = function() {
TiddlyWebAdaptor.prototype.getTiddlerInfo = function(tiddler) { TiddlyWebAdaptor.prototype.getTiddlerInfo = function(tiddler) {
return { return {
bag: tiddler.fields["bag"] bag: tiddler.fields.bag
}; };
}; };
@ -248,7 +248,7 @@ TiddlyWebAdaptor.prototype.convertTiddlerToTiddlyWebFormat = function(tiddler) {
// Default the content type and convert the type "text/x-tiddlywiki" into null // Default the content type and convert the type "text/x-tiddlywiki" into null
if(result.type === "text/x-tiddlywiki") { if(result.type === "text/x-tiddlywiki") {
result.type = null; result.type = null;
}; }
result.type = result.type || "text/vnd.tiddlywiki"; result.type = result.type || "text/vnd.tiddlywiki";
return JSON.stringify(result,null,$tw.config.preferences.jsonSpaces); return JSON.stringify(result,null,$tw.config.preferences.jsonSpaces);
}; };