From 231a39e743625ff53665206783a4504c517ed198 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Tue, 20 Aug 2024 17:33:07 +0200 Subject: [PATCH] Fix whitespace in all plugins for v5.3.6 (#8285) * Fix whitespace in all plugins for v5.3.5 * remove const to var chanes --- plugins/tiddlywiki/browser-storage/startup.js | 18 +++---- plugins/tiddlywiki/browser-storage/util.js | 2 +- plugins/tiddlywiki/d3/barwidget.js | 8 ++-- .../filesystem/filesystemadaptor.js | 4 +- plugins/tiddlywiki/katex/wrapper.js | 2 +- .../tiddlywiki/markdown/markdown-it-katex.js | 48 +++++++++---------- plugins/tiddlywiki/markdown/wrapper.js | 4 +- plugins/tiddlywiki/qrcode/makeqr.js | 4 +- plugins/tiddlywiki/railroad/parser.js | 2 +- .../tiddlywiki/text-slicer/modules/slicer.js | 2 +- .../tiddlywiki/tiddlyweb/tiddlywebadaptor.js | 4 +- plugins/tiddlywiki/tw2parser/entry.js | 2 +- .../tiddlywiki/tw2parser/wikitextparser.js | 2 +- plugins/tiddlywiki/tw2parser/wikitextrules.js | 14 +++--- 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/plugins/tiddlywiki/browser-storage/startup.js b/plugins/tiddlywiki/browser-storage/startup.js index 552de93d2..e06d7bf48 100644 --- a/plugins/tiddlywiki/browser-storage/startup.js +++ b/plugins/tiddlywiki/browser-storage/startup.js @@ -26,11 +26,11 @@ 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 { diff --git a/plugins/tiddlywiki/browser-storage/util.js b/plugins/tiddlywiki/browser-storage/util.js index 7474a367c..0f55ada7d 100644 --- a/plugins/tiddlywiki/browser-storage/util.js +++ b/plugins/tiddlywiki/browser-storage/util.js @@ -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 diff --git a/plugins/tiddlywiki/d3/barwidget.js b/plugins/tiddlywiki/d3/barwidget.js index 18ada16c9..08b71cff2 100644 --- a/plugins/tiddlywiki/d3/barwidget.js +++ b/plugins/tiddlywiki/d3/barwidget.js @@ -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)}; }); } }; diff --git a/plugins/tiddlywiki/filesystem/filesystemadaptor.js b/plugins/tiddlywiki/filesystem/filesystemadaptor.js index 1779855df..5e704031e 100644 --- a/plugins/tiddlywiki/filesystem/filesystemadaptor.js +++ b/plugins/tiddlywiki/filesystem/filesystemadaptor.js @@ -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); diff --git a/plugins/tiddlywiki/katex/wrapper.js b/plugins/tiddlywiki/katex/wrapper.js index ceda68c84..1b41655ca 100644 --- a/plugins/tiddlywiki/katex/wrapper.js +++ b/plugins/tiddlywiki/katex/wrapper.js @@ -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"]; diff --git a/plugins/tiddlywiki/markdown/markdown-it-katex.js b/plugins/tiddlywiki/markdown/markdown-it-katex.js index 4bbd5c655..dc70f829a 100644 --- a/plugins/tiddlywiki/markdown/markdown-it-katex.js +++ b/plugins/tiddlywiki/markdown/markdown-it-katex.js @@ -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 = "$$"; diff --git a/plugins/tiddlywiki/markdown/wrapper.js b/plugins/tiddlywiki/markdown/wrapper.js index 98c5c2ae3..708b932e3 100755 --- a/plugins/tiddlywiki/markdown/wrapper.js +++ b/plugins/tiddlywiki/markdown/wrapper.js @@ -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", "Error encountered while parsing the tiddler:

" + err.message + "

", {parseAsInline: false, wiki: options.wiki}); } - finally { + finally{ $tw.utils.parseStringLiteral = origParseStringLiteral; } if(wikiParser.tree.length > 0) { diff --git a/plugins/tiddlywiki/qrcode/makeqr.js b/plugins/tiddlywiki/qrcode/makeqr.js index 2a4e37273..0328a8468 100644 --- a/plugins/tiddlywiki/qrcode/makeqr.js +++ b/plugins/tiddlywiki/qrcode/makeqr.js @@ -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 { diff --git a/plugins/tiddlywiki/railroad/parser.js b/plugins/tiddlywiki/railroad/parser.js index 013d898d7..02256524d 100644 --- a/plugins/tiddlywiki/railroad/parser.js +++ b/plugins/tiddlywiki/railroad/parser.js @@ -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 diff --git a/plugins/tiddlywiki/text-slicer/modules/slicer.js b/plugins/tiddlywiki/text-slicer/modules/slicer.js index c3e3328e4..2fc2238bb 100644 --- a/plugins/tiddlywiki/text-slicer/modules/slicer.js +++ b/plugins/tiddlywiki/text-slicer/modules/slicer.js @@ -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); diff --git a/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js b/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js index 15fbaa4fd..b91ea3560 100644 --- a/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js +++ b/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js @@ -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; diff --git a/plugins/tiddlywiki/tw2parser/entry.js b/plugins/tiddlywiki/tw2parser/entry.js index f97cf4cdc..073221b8b 100644 --- a/plugins/tiddlywiki/tw2parser/entry.js +++ b/plugins/tiddlywiki/tw2parser/entry.js @@ -21,7 +21,7 @@ exports.params = [ Run the macro */ exports.run = function(key,map) { - try{ + try { return JSON.parse(map)[key]; } catch(e) { return ""; diff --git a/plugins/tiddlywiki/tw2parser/wikitextparser.js b/plugins/tiddlywiki/tw2parser/wikitextparser.js index 947519bb9..fec58f3bd 100644 --- a/plugins/tiddlywiki/tw2parser/wikitextparser.js +++ b/plugins/tiddlywiki/tw2parser/wikitextparser.js @@ -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]; diff --git a/plugins/tiddlywiki/tw2parser/wikitextrules.js b/plugins/tiddlywiki/tw2parser/wikitextrules.js index d7f809723..068bb9757 100755 --- a/plugins/tiddlywiki/tw2parser/wikitextrules.js +++ b/plugins/tiddlywiki/tw2parser/wikitextrules.js @@ -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