1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +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";
exports.getInfoTiddlerFields = function() {
var mapBoolean = function(value) {return value ? "yes" : "no"},
var mapBoolean = function(value) {return value ? "yes" : "no";},
infoTiddlerFields = [];
// Basics
if($tw.browser) {

View File

@ -113,7 +113,7 @@ CecilyStoryView.prototype.lookupTiddlerInMap = function(title,domNode) {
if(tiddler) {
var draftOf = tiddler.fields["draft.of"];
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

View File

@ -25,14 +25,14 @@ Config options "$:/config/CodeMirror" e.g. to allow vim key bindings
/*global $tw: false */
"use strict";
var CODEMIRROR_OPTIONS = "$:/config/CodeMirror"
var CODEMIRROR_OPTIONS = "$:/config/CodeMirror";
// Install CodeMirror
if($tw.browser && !window.CodeMirror) {
window.CodeMirror = require("$:/plugins/tiddlywiki/codemirror/lib/codemirror.js");
// Install required CodeMirror plugins
var configOptions = $tw.wiki.getTiddlerData(CODEMIRROR_OPTIONS,{}),
req = configOptions["require"];
req = configOptions.require;
if(req) {
if($tw.utils.isArray(req)) {
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
m = 58; // number of samples per layer
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
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
var x = d3.scale.ordinal()
.domain(d3.range(m))
.rangeRoundBands([0, width], .08);
.rangeRoundBands([0, width], 0.08);
// y-scale
var y = d3.scale.linear()
.domain([0, yStackMax])
@ -96,13 +96,13 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
// Create the layers
var layer = mainGroup.selectAll(".layer")
.data(layers)
.enter().append("g")
.enter().append("g")
.attr("class", "layer")
.style("fill", function(d, i) { return color(i); });
// Create the rectangles in each layer
var rect = layer.selectAll("rect")
.data(function(d) { return d; })
.enter().append("rect")
.enter().append("rect")
.attr("x", function(d) { return x(d.x); })
.attr("y", height)
.attr("width", x.rangeBand())
@ -131,44 +131,44 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
};
function transitionGrouped() {
y.domain([0, yGroupMax]);
rect.transition()
.duration(500)
.delay(function(d, i) { return i * 10; })
.attr("x", function(d, i, j) { return x(d.x) + x.rangeBand() / n * j; })
.attr("width", x.rangeBand() / n)
.transition()
.attr("y", function(d) { return y(d.y); })
.attr("height", function(d) { return height - y(d.y); });
y.domain([0, yGroupMax]);
rect.transition()
.duration(500)
.delay(function(d, i) { return i * 10; })
.attr("x", function(d, i, j) { return x(d.x) + x.rangeBand() / n * j; })
.attr("width", x.rangeBand() / n)
.transition()
.attr("y", function(d) { return y(d.y); })
.attr("height", function(d) { return height - y(d.y); });
}
function transitionStacked() {
y.domain([0, yStackMax]);
rect.transition()
.duration(500)
.delay(function(d, i) { return i * 10; })
.attr("y", function(d) { return y(d.y0 + d.y); })
.attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); })
.transition()
.attr("x", function(d) { return x(d.x); })
.attr("width", x.rangeBand());
y.domain([0, yStackMax]);
rect.transition()
.duration(500)
.delay(function(d, i) { return i * 10; })
.attr("y", function(d) { return y(d.y0 + d.y); })
.attr("height", function(d) { return y(d.y0) - y(d.y0 + d.y); })
.transition()
.attr("x", function(d) { return x(d.x); })
.attr("width", x.rangeBand());
}
// Inspired by Lee Byron's test data generator.
function bumpLayer(n, o) {
function bump(a) {
var x = 1 / (.1 + Math.random()),
y = 2 * Math.random() - .5,
z = 10 / (.1 + Math.random());
for (var i = 0; i < n; i++) {
var w = (i / n - y) * z;
a[i] += x * Math.exp(-w * w);
function bump(a) {
var x = 1 / (0.1 + Math.random()),
y = 2 * Math.random() - 0.5,
z = 10 / (0.1 + Math.random());
for (var i = 0; i < n; i++) {
var w = (i / n - y) * z;
a[i] += x * Math.exp(-w * w);
}
}
}
var a = [], i;
for (i = 0; i < n; ++i) a[i] = o + o * Math.random();
for (i = 0; i < 5; ++i) bump(a);
return a.map(function(d, i) { return {x: i, y: Math.max(0, d)}; });
var a = [], i;
for (i = 0; i < n; ++i) a[i] = o + o * Math.random();
for (i = 0; i < 5; ++i) bump(a);
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.setwatcher = function(filename, title) {
return undefined;
return this.watchers[filename] = this.watchers[filename] ||
fs.watch(filename, {persistent: false}, function(e) {
self.logger.log("Error:",e,filename);
if(e === "change") {
var tiddlers = $tw.loadTiddlersFromFile(filename).tiddlers;
for(var t in tiddlers) {
if(tiddlers[t].title) {
self.wiki.addTiddler(tiddlers[t]);
}
}
}
});
}
//return this.watchers[filename] = this.watchers[filename] ||
// fs.watch(filename, {persistent: false}, function(e) {
// self.logger.log("Error:",e,filename);
// if(e === "change") {
// var tiddlers = $tw.loadTiddlersFromFile(filename).tiddlers;
// for(var t in tiddlers) {
// if(tiddlers[t].title) {
// self.wiki.addTiddler(tiddlers[t]);
// }
// }
// }
// });
};
for(var f in $tw.boot.files) {
var fileInfo = $tw.boot.files[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) {
// 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
if(baseFilename.length > 200) {
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
jasmine.jasmine.TerminalVerboseReporter = reporterExports.jasmineNode.TerminalVerboseReporter;
jasmine.jasmine.TerminalReporter = reporterExports.jasmineNode.TerminalReporter;
jasmineEnv.addReporter(new jasmine.jasmine.TerminalVerboseReporter({
jasmineEnv.addReporter(new jasmine.jasmine.TerminalVerboseReporter({
print: require("util").print,
color: 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) {
// 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) {
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
if(result.type === "text/x-tiddlywiki") {
result.type = null;
};
}
result.type = result.type || "text/vnd.tiddlywiki";
return JSON.stringify(result,null,$tw.config.preferences.jsonSpaces);
};