1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-21 03:39:43 +00:00

Fix whitespace in all plugins for v5.3.6 (#8285)

* Fix whitespace in all plugins for v5.3.5

* remove const to var chanes
This commit is contained in:
Mario Pietsch 2024-08-20 17:33:07 +02:00 committed by GitHub
parent 014f302af3
commit 231a39e743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 58 additions and 58 deletions

View File

@ -27,10 +27,10 @@ var BrowserStorageUtil = require("$:/plugins/tiddlywiki/browser-storage/util.js"
exports.startup = function() {
var self = this;
// If not exists, add ENABLED tiddler with default value "yes"
if(!$tw.wiki.getTiddler(ENABLED_TITLE)) {
$tw.wiki.addTiddler({title: ENABLED_TITLE, text: "yes"});
}
// If not exists, add ENABLED tiddler with default value "yes"
if(!$tw.wiki.getTiddler(ENABLED_TITLE)) {
$tw.wiki.addTiddler({title: ENABLED_TITLE, text: "yes"});
}
// Compute our prefix for local storage keys
var prefix = "tw5#" + window.location.pathname + "#";
// Make a logger
@ -68,11 +68,11 @@ exports.startup = function() {
persistPermissionRequested = false,
requestPersistenceOnFirstSave = function() {
$tw.hooks.addHook("th-saving-tiddler", function(tiddler) {
if (!persistPermissionRequested) {
if(!persistPermissionRequested) {
var filteredChanges = filterFn.call($tw.wiki, function(iterator) {
iterator(tiddler,tiddler.getFieldString("title"));
});
if (filteredChanges.length > 0) {
if(filteredChanges.length > 0) {
// The tiddler will be saved to local storage, so request persistence
requestPersistence();
persistPermissionRequested = true;
@ -84,9 +84,9 @@ exports.startup = function() {
// Request the browser to never evict the localstorage. Some browsers such as firefox
// will prompt the user. To make the decision easier for the user only prompt them
// when they click the save button on a tiddler which will be stored to localstorage.
if (navigator.storage && navigator.storage.persist) {
if(navigator.storage && navigator.storage.persist) {
navigator.storage.persisted().then(function(isPersisted) {
if (!isPersisted) {
if(!isPersisted) {
setPersistedState("not requested yet");
requestPersistenceOnFirstSave();
} else {

View File

@ -53,7 +53,7 @@ BrowserStorageUtil.prototype.saveTiddlerToLocalStorage = function(title) {
// Get the tiddler
var tiddler = $tw.wiki.getTiddler(title);
if(tiddler) {
if (this.wiki.tiddlerExists(title)) {
if(this.wiki.tiddlerExists(title)) {
// This is not a shadow tiddler
console.log("browser-storage: Saving",title);
// Get the JSON of the tiddler

View File

@ -122,7 +122,7 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
return {
domNode: svgElement[0][0],
updateChart: function() {
if (self.barGrouped !== "no") {
if(self.barGrouped !== "no") {
transitionGrouped();
} else {
transitionStacked();
@ -160,14 +160,14 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
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++) {
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);
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

@ -84,7 +84,7 @@ FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
}
$tw.utils.saveTiddlerToFile(tiddler,fileInfo,function(err,fileInfo) {
if(err) {
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "open") {
if((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "open") {
fileInfo = fileInfo || self.boot.files[tiddler.fields.title];
fileInfo.writeError = true;
self.boot.files[tiddler.fields.title] = fileInfo;
@ -131,7 +131,7 @@ FileSystemAdaptor.prototype.deleteTiddler = function(title,callback,options) {
if(fileInfo) {
$tw.utils.deleteTiddlerFile(fileInfo,function(err,fileInfo) {
if(err) {
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
if((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
// Error deleting the file on disk, should fail gracefully
$tw.syncer.displayError("Server desynchronized. Error deleting file for deleted tiddler \"" + title + "\"",err);
return callback(null,fileInfo);

View File

@ -21,7 +21,7 @@ katex.updateMacros = function() {
var tiddlers = $tw.wiki.getTiddlersWithTag("$:/tags/KaTeX/Macro"),
regex = /#\d/g, // Remove the arguments like #1#2
tid, macro, cmd;
for (var i=0; i < tiddlers.length; i++) {
for(var i=0; i < tiddlers.length; i++) {
tid = $tw.wiki.getTiddler(tiddlers[i]);
try {
macro = tid.fields["caption"];

View File

@ -31,17 +31,17 @@ function isValidDelim(state, pos) {
// Check non-whitespace conditions for opening and closing, and
// check that closing delimeter isn't followed by a number
if (prevChar === 0x20/* " " */ || prevChar === 0x09/* \t */ ||
if(prevChar === 0x20/* " " */ || prevChar === 0x09/* \t */ ||
prevChar === 0x0d/* "\r" */ || prevChar === 0x0a/* \n */ ||
(nextChar >= 0x30/* "0" */ && nextChar <= 0x39/* "9" */)) {
can_close = false;
}
if (nextChar === 0x20/* " " */ || nextChar === 0x09/* \t */ ||
if(nextChar === 0x20/* " " */ || nextChar === 0x09/* \t */ ||
nextChar === 0x0d/* "\r" */ || nextChar === 0x0a/* \ns */) {
can_open = false;
}
if (state.src.substring(pos,pos+3) === "$:/") {
if(state.src.substring(pos,pos+3) === "$:/") {
can_open = false;
can_close = false;
}
@ -55,11 +55,11 @@ function isValidDelim(state, pos) {
function math_inline(state, silent) {
var start, match, token, res, pos, esc_count;
if (state.src[state.pos] !== "$") { return false; }
if(state.src[state.pos] !== "$") { return false; }
res = isValidDelim(state, state.pos);
if (!res.can_open) {
if (!silent) { state.pending += "$"; }
if(!res.can_open) {
if(!silent) { state.pending += "$"; }
state.pos += 1;
return true;
}
@ -70,40 +70,40 @@ function math_inline(state, silent) {
// we have found an opening delimieter already.
start = state.pos + 1;
match = start;
while ( (match = state.src.indexOf("$", match)) !== -1) {
while( (match = state.src.indexOf("$", match)) !== -1) {
// Found potential $, look for escapes, pos will point to
// first non escape when complete
pos = match - 1;
while (state.src[pos] === "\\") { pos -= 1; }
while(state.src[pos] === "\\") { pos -= 1; }
// Even number of escapes, potential closing delimiter found
if ( ((match - pos) % 2) == 1 ) { break; }
if( ((match - pos) % 2) == 1 ) { break; }
match += 1;
}
// No closing delimter found. Consume $ and continue.
if (match === -1) {
if (!silent) { state.pending += "$"; }
if(match === -1) {
if(!silent) { state.pending += "$"; }
state.pos = start;
return true;
}
// Check if we have empty content, ie: $$. Do not parse.
if (match - start === 0) {
if (!silent) { state.pending += "$$"; }
if(match - start === 0) {
if(!silent) { state.pending += "$$"; }
state.pos = start + 1;
return true;
}
// Check for valid closing delimiter
res = isValidDelim(state, match);
if (!res.can_close) {
if (!silent) { state.pending += "$"; }
if(!res.can_close) {
if(!silent) { state.pending += "$"; }
state.pos = start;
return true;
}
if (!silent) {
if(!silent) {
token = state.push('math_inline', '$latex', 0);
token.markup = "$";
token.content = state.src.slice(start, match);
@ -126,32 +126,32 @@ function math_inline_block(state, silent) {
// we have found an opening delimieter already.
start = state.pos + 2;
match = start;
while ( (match = state.src.indexOf("$$", match)) !== -1) {
while( (match = state.src.indexOf("$$", match)) !== -1) {
// Found potential $$, look for escapes, pos will point to
// first non escape when complete
pos = match - 1;
while (state.src[pos] === "\\") { pos -= 1; }
while(state.src[pos] === "\\") { pos -= 1; }
// Even number of escapes, potential closing delimiter found
if ( ((match - pos) % 2) == 1 ) { break; }
if( ((match - pos) % 2) == 1 ) { break; }
match += 2;
}
// No closing delimter found. Consume $$ and continue.
if (match === -1) {
if (!silent) { state.pending += "$$"; }
if(match === -1) {
if(!silent) { state.pending += "$$"; }
state.pos = start;
return true;
}
// Check if we have empty content, ie: $$$$. Do not parse.
if (match - start === 0) {
if (!silent) { state.pending += "$$$$"; }
if(match - start === 0) {
if(!silent) { state.pending += "$$$$"; }
state.pos = start + 2;
return true;
}
if (!silent) {
if(!silent) {
token = state.push('math_inline_block', '$latex', 0);
token.block = true;
token.markup = "$$";

View File

@ -234,12 +234,12 @@ function MarkdownParser(type,text,options) {
rules: { pragma: {}, block: this.blockRuleClasses, inline: this.inlineRuleClasses }
});
}
catch (err) {
catch(err) {
wikiParser = $tw.wiki.parseText("text/vnd.tiddlywiki",
"<strong>Error encountered while parsing the tiddler:</strong><p>" + err.message + "</p>",
{parseAsInline: false, wiki: options.wiki});
}
finally {
finally{
$tw.utils.parseStringLiteral = origParseStringLiteral;
}
if(wikiParser.tree.length > 0) {

View File

@ -37,7 +37,7 @@ exports.run = function(text,size,errorCorrectLevel,fallback) {
var result;
try {
result = generateQrCode(text,{size: size, errorCorrectLevel: errorCorrectLevel});
} catch (ex) {
} catch(ex) {
console.log("makeqr error: " + ex);
result = fallback || ("data:image/svg+xml," + encodeURI(QRCODE_GENERATION_ERROR_PREFIX + ex + QRCODE_GENERATION_ERROR_SUFFIX));
}
@ -54,7 +54,7 @@ function generateQrCode(text,options) {
qr = qrcode(typeNumber,errorCorrectLevel);
qr.addData(text);
qr.make();
} catch (e) {
} catch(e) {
if(typeNumber >= 40) {
throw new Error("Text too long to encode");
} else {

View File

@ -377,7 +377,7 @@ Parser.prototype.tokenise = function(source) {
// Skip whitespace
pos = $tw.utils.skipWhiteSpace(source,pos);
// Avoid falling off the end of the string
if (pos >= source.length) {
if(pos >= source.length) {
break;
}
// Examine the next character

View File

@ -365,7 +365,7 @@ Slicer.prototype.onCloseTag = function(name) {
// Render the tag
if(actions.isAnchor) {
this.onCloseAnchor(e);
} else if (!actions.dontRenderTag && !selfClosing) {
} else if(!actions.dontRenderTag && !selfClosing) {
var markupInfo = actions.markup && actions.markup[this.outputMode];
if(markupInfo) {
this.addTextToCurrentChunk(markupInfo.suffix);

View File

@ -84,7 +84,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) {
var json = null;
try {
json = JSON.parse(data);
} catch (e) {
} catch(e) {
}
if(json) {
self.logger.log("Status:",data);
@ -164,7 +164,7 @@ TiddlyWebAdaptor.prototype.getCsrfToken = function() {
var regex = /^(?:.*; )?csrf_token=([^(;|$)]*)(?:;|$)/,
match = regex.exec(document.cookie),
csrf = null;
if (match && (match.length === 2)) {
if(match && (match.length === 2)) {
csrf = match[1];
}
return csrf;

View File

@ -21,7 +21,7 @@ exports.params = [
Run the macro
*/
exports.run = function(key,map) {
try{
try {
return JSON.parse(map)[key];
} catch(e) {
return "";

View File

@ -70,7 +70,7 @@ var WikiTextParser = function(type,text,options) {
var root = JSON.parse(JSON.stringify(parser.tree));
// macros are defined in a linear tree; walk down the tree and append the source's parsed content
var baseroot = root;
while (root[0] && root[0].children && root[0].children.length !== 0 ){
while(root[0] && root[0].children && root[0].children.length !== 0 ){
root = root[0].children;
}
root[0].children[0] = this.tree[0];

View File

@ -249,7 +249,7 @@ var rules = [
}
applyCssHelper(cell,styles);
w.subWikifyTerm(cell.children,this.cellTermRegExp);
if (!cell.attributes) cell.attributes ={};
if(!cell.attributes) cell.attributes ={};
if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
$tw.utils.addAttributeToParseTreeNode(cell,"align",spaceLeft ? "center" : "left");
else if(spaceLeft)
@ -370,9 +370,9 @@ var rules = [
var f = stack[stack.length-1];
e = {type:"element",tag:this.element,children: []};
stack.push(e);
if (t ===0){
if(t ===0){
w.output.push(e);
}else {
} else {
f.children.push(e);
}
@ -458,7 +458,7 @@ var rules = [
w.source = oldSource;
w.nextMatch = oldNextMatch;
w.children = oldChildren;
for (var i=0; i<parser.tree.length; i++) {
for(var i=0; i<parser.tree.length; i++) {
w.output.push(parser.tree[i]);
}
w.nextMatch = this.lookaheadRegExp.lastIndex;
@ -488,12 +488,12 @@ var rules = [
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
name = lookaheadMatch[1] || lookaheadMatch[2];
var params = lookaheadMatch[3], nameold =name;
if (name) {
if (!!macroadapter.paramadapter[name]) {
if(name) {
if(!!macroadapter.paramadapter[name]) {
params=macroadapter.paramadapter[name](params);
//alert("going out as "+params);
}
if (!!macroadapter.namedapter[name]) {
if(!!macroadapter.namedapter[name]) {
name=macroadapter.namedapter[name];
}
w.nextMatch = this.lookaheadRegExp.lastIndex;