From fc36b2e6935d29a5b83939f14e7d05bef256e224 Mon Sep 17 00:00:00 2001 From: pmario Date: Fri, 7 Jul 2023 13:15:03 +0200 Subject: [PATCH] remove blks first try --- core/modules/commander.js | 3 +- core/modules/commands/build.js | 3 - core/modules/commands/clearpassword.js | 3 - core/modules/commands/commands.js | 4 - core/modules/commands/deletetiddlers.js | 3 - core/modules/commands/editions.js | 3 +- core/modules/commands/fetch.js | 3 +- core/modules/commands/help.js | 3 +- core/modules/commands/import.js | 3 +- core/modules/commands/init.js | 3 +- core/modules/commands/listen.js | 3 +- core/modules/commands/load.js | 3 +- core/modules/commands/makelibrary.js | 3 +- core/modules/commands/output.js | 3 +- core/modules/commands/password.js | 3 +- core/modules/commands/render.js | 108 +- core/modules/commands/rendertiddler.js | 3 +- core/modules/commands/rendertiddlers.js | 3 +- core/modules/commands/save.js | 108 +- core/modules/commands/savelibrarytiddlers.js | 3 +- core/modules/commands/savetiddler.js | 3 +- core/modules/commands/savetiddlers.js | 3 +- core/modules/commands/savewikifolder.js | 7 +- core/modules/commands/server.js | 3 +- core/modules/commands/setfield.js | 3 +- core/modules/commands/unpackplugin.js | 3 +- core/modules/commands/verbose.js | 3 +- core/modules/commands/version.js | 3 +- core/modules/config.js | 3 +- core/modules/deserializers.js | 3 +- core/modules/editor/engines/framed.js | 5 +- core/modules/editor/engines/simple.js | 3 +- core/modules/editor/factory.js | 5 +- .../modules/editor/operations/bitmap/clear.js | 3 +- .../editor/operations/bitmap/resize.js | 3 +- .../editor/operations/bitmap/rotate-left.js | 3 +- core/modules/editor/operations/text/excise.js | 3 +- .../editor/operations/text/focus-editor.js | 4 +- .../editor/operations/text/insert-text.js | 3 +- .../editor/operations/text/make-link.js | 3 +- .../editor/operations/text/prefix-lines.js | 3 +- .../editor/operations/text/replace-all.js | 3 +- .../operations/text/replace-selection.js | 3 +- .../editor/operations/text/save-selection.js | 3 +- .../editor/operations/text/wrap-lines.js | 5 +- .../editor/operations/text/wrap-selection.js | 3 +- core/modules/filterrunprefixes/all.js | 3 +- core/modules/filterrunprefixes/and.js | 3 +- core/modules/filterrunprefixes/cascade.js | 4 +- core/modules/filterrunprefixes/else.js | 3 +- core/modules/filterrunprefixes/except.js | 3 +- core/modules/filterrunprefixes/filter.js | 3 +- .../modules/filterrunprefixes/intersection.js | 3 +- core/modules/filterrunprefixes/map.js | 4 +- core/modules/filterrunprefixes/or.js | 3 +- core/modules/filterrunprefixes/reduce.js | 3 +- core/modules/filterrunprefixes/sort.js | 4 +- core/modules/filterrunprefixes/then.js | 3 +- core/modules/filters.js | 5 +- core/modules/filters/addprefix.js | 3 +- core/modules/filters/addsuffix.js | 3 +- core/modules/filters/after.js | 3 +- core/modules/filters/all.js | 3 +- core/modules/filters/all/current.js | 3 +- core/modules/filters/all/missing.js | 3 +- core/modules/filters/all/orphans.js | 3 +- core/modules/filters/all/shadows.js | 3 +- core/modules/filters/all/tags.js | 3 +- core/modules/filters/all/tiddlers.js | 3 +- core/modules/filters/backlinks.js | 3 +- core/modules/filters/before.js | 3 +- core/modules/filters/commands.js | 3 +- core/modules/filters/compare.js | 3 +- core/modules/filters/contains.js | 3 +- core/modules/filters/count.js | 3 +- core/modules/filters/crypto.js | 3 +- core/modules/filters/days.js | 3 +- core/modules/filters/deserialize.js | 4 +- core/modules/filters/deserializers.js | 4 +- core/modules/filters/duplicateslugs.js | 3 +- core/modules/filters/each.js | 3 +- core/modules/filters/eachday.js | 3 +- core/modules/filters/editiondescription.js | 3 +- core/modules/filters/editions.js | 3 +- core/modules/filters/else.js | 3 +- core/modules/filters/encodings.js | 2 - core/modules/filters/enlist.js | 3 +- core/modules/filters/field.js | 3 +- core/modules/filters/fields.js | 5 +- core/modules/filters/filter.js | 3 +- core/modules/filters/format.js | 4 +- core/modules/filters/format/date.js | 4 +- core/modules/filters/format/json.js | 4 +- core/modules/filters/format/relativedate.js | 4 +- core/modules/filters/format/timestamp.js | 7 +- core/modules/filters/format/titlelist.js | 3 +- core/modules/filters/function.js | 3 +- core/modules/filters/get.js | 3 +- core/modules/filters/getindex.js | 3 +- core/modules/filters/getvariable.js | 3 +- core/modules/filters/has.js | 3 +- core/modules/filters/haschanged.js | 3 +- core/modules/filters/indexes.js | 3 +- core/modules/filters/insertafter.js | 3 +- core/modules/filters/insertbefore.js | 3 +- core/modules/filters/is.js | 4 +- core/modules/filters/is/binary.js | 3 +- core/modules/filters/is/blank.js | 3 +- core/modules/filters/is/current.js | 3 +- core/modules/filters/is/draft.js | 3 +- core/modules/filters/is/image.js | 3 +- core/modules/filters/is/missing.js | 3 +- core/modules/filters/is/orphan.js | 3 +- core/modules/filters/is/shadow.js | 3 +- core/modules/filters/is/system.js | 3 +- core/modules/filters/is/tag.js | 3 +- core/modules/filters/is/tiddler.js | 3 +- core/modules/filters/is/variable.js | 3 +- core/modules/filters/json-ops.js | 3 +- core/modules/filters/limit.js | 3 +- core/modules/filters/links.js | 3 +- core/modules/filters/list.js | 3 +- core/modules/filters/listed.js | 3 +- core/modules/filters/listops.js | 3 +- core/modules/filters/lookup.js | 3 +- core/modules/filters/match.js | 3 +- core/modules/filters/math.js | 3 +- core/modules/filters/minlength.js | 3 +- core/modules/filters/moduleproperty.js | 3 +- core/modules/filters/modules.js | 3 +- core/modules/filters/moduletypes.js | 3 +- core/modules/filters/next.js | 3 +- core/modules/filters/plugintiddlers.js | 3 +- core/modules/filters/prefix.js | 3 +- core/modules/filters/previous.js | 3 +- core/modules/filters/range.js | 11 +- core/modules/filters/reduce.js | 3 +- core/modules/filters/regexp.js | 3 +- core/modules/filters/removeprefix.js | 3 +- core/modules/filters/removesuffix.js | 5 +- core/modules/filters/sameday.js | 3 +- core/modules/filters/search.js | 3 +- core/modules/filters/shadowsource.js | 3 +- core/modules/filters/slugify.js | 3 +- core/modules/filters/sort.js | 3 +- core/modules/filters/sortsub.js | 3 +- core/modules/filters/splitbefore.js | 3 +- core/modules/filters/storyviews.js | 3 +- core/modules/filters/strings.js | 8 +- core/modules/filters/subfilter.js | 3 +- core/modules/filters/substitute.js | 3 +- core/modules/filters/subtiddlerfields.js | 3 +- core/modules/filters/suffix.js | 5 +- core/modules/filters/tag.js | 3 +- core/modules/filters/tagging.js | 3 +- core/modules/filters/tags.js | 3 +- core/modules/filters/then.js | 3 +- core/modules/filters/title.js | 3 +- core/modules/filters/unknown.js | 3 +- core/modules/filters/untagged.js | 3 +- core/modules/filters/variables.js | 3 +- core/modules/filters/wikiparserrules.js | 3 +- core/modules/filters/x-listops.js | 411 ++- core/modules/indexers/backlinks-index.js | 3 +- core/modules/indexers/field-indexer.js | 3 +- core/modules/indexers/tag-indexer.js | 3 +- core/modules/info/platform.js | 3 +- core/modules/keyboard.js | 3 +- core/modules/language.js | 3 +- core/modules/macros/changecount.js | 3 +- core/modules/macros/contrastcolour.js | 3 +- core/modules/macros/csvtiddlers.js | 3 +- core/modules/macros/displayshortcuts.js | 3 +- core/modules/macros/jsontiddler.js | 3 +- core/modules/macros/jsontiddlers.js | 3 +- core/modules/macros/makedatauri.js | 3 +- core/modules/macros/now.js | 3 +- core/modules/macros/qualify.js | 3 +- core/modules/macros/resolvepath.js | 3 +- core/modules/macros/unusedtitle.js | 3 +- core/modules/macros/version.js | 3 +- core/modules/parsers/audioparser.js | 3 +- core/modules/parsers/binaryparser.js | 3 +- core/modules/parsers/csvparser.js | 5 +- core/modules/parsers/htmlparser.js | 3 +- core/modules/parsers/imageparser.js | 3 +- core/modules/parsers/parseutils.js | 3 +- core/modules/parsers/pdfparser.js | 3 +- core/modules/parsers/textparser.js | 3 +- core/modules/parsers/videoparser.js | 3 +- .../parsers/wikiparser/rules/codeblock.js | 3 +- .../parsers/wikiparser/rules/codeinline.js | 3 +- .../parsers/wikiparser/rules/commentblock.js | 3 +- .../parsers/wikiparser/rules/commentinline.js | 3 +- core/modules/parsers/wikiparser/rules/dash.js | 3 +- .../parsers/wikiparser/rules/emphasis/bold.js | 4 +- .../wikiparser/rules/emphasis/italic.js | 4 +- .../rules/emphasis/strikethrough.js | 3 +- .../wikiparser/rules/emphasis/subscript.js | 3 +- .../wikiparser/rules/emphasis/superscript.js | 4 +- .../wikiparser/rules/emphasis/underscore.js | 4 +- .../parsers/wikiparser/rules/entity.js | 3 +- .../parsers/wikiparser/rules/extlink.js | 3 +- .../rules/filteredtranscludeblock.js | 3 +- .../rules/filteredtranscludeinline.js | 3 +- .../parsers/wikiparser/rules/fnprocdef.js | 3 +- .../wikiparser/rules/hardlinebreaks.js | 3 +- .../parsers/wikiparser/rules/heading.js | 3 +- .../parsers/wikiparser/rules/horizrule.js | 3 +- core/modules/parsers/wikiparser/rules/html.js | 3 +- .../modules/parsers/wikiparser/rules/image.js | 3 +- .../parsers/wikiparser/rules/import.js | 3 +- core/modules/parsers/wikiparser/rules/list.js | 3 +- .../wikiparser/rules/macrocallblock.js | 5 +- .../wikiparser/rules/macrocallinline.js | 3 +- .../parsers/wikiparser/rules/macrodef.js | 3 +- .../parsers/wikiparser/rules/parameters.js | 3 +- .../parsers/wikiparser/rules/parsermode.js | 3 +- .../parsers/wikiparser/rules/prettyextlink.js | 3 +- .../parsers/wikiparser/rules/prettylink.js | 3 +- .../parsers/wikiparser/rules/quoteblock.js | 3 +- .../modules/parsers/wikiparser/rules/rules.js | 3 +- .../parsers/wikiparser/rules/styleblock.js | 3 +- .../parsers/wikiparser/rules/styleinline.js | 3 +- .../parsers/wikiparser/rules/syslink.js | 4 +- .../modules/parsers/wikiparser/rules/table.js | 3 +- .../wikiparser/rules/transcludeblock.js | 3 +- .../wikiparser/rules/transcludeinline.js | 3 +- .../parsers/wikiparser/rules/typedblock.js | 3 +- .../parsers/wikiparser/rules/whitespace.js | 3 +- .../parsers/wikiparser/rules/wikilink.js | 3 +- .../wikiparser/rules/wikilinkprefix.js | 3 +- core/modules/parsers/wikiparser/wikiparser.js | 3 +- .../parsers/wikiparser/wikirulebase.js | 3 +- core/modules/pluginswitcher.js | 3 +- core/modules/saver-handler.js | 3 +- core/modules/savers/andtidwiki.js | 13 +- core/modules/savers/custom.js | 5 +- core/modules/savers/download.js | 3 +- core/modules/savers/fsosaver.js | 3 +- core/modules/savers/gitea.js | 5 +- core/modules/savers/github.js | 3 +- core/modules/savers/gitlab.js | 3 +- core/modules/savers/manualdownload.js | 3 +- core/modules/savers/msdownload.js | 3 +- core/modules/savers/put.js | 5 +- core/modules/savers/tiddlyfox.js | 3 +- core/modules/savers/tiddlyie.js | 3 +- core/modules/savers/twedit.js | 3 +- core/modules/savers/upload.js | 5 +- core/modules/server/authenticators/basic.js | 3 +- core/modules/server/authenticators/header.js | 3 +- core/modules/server/server.js | 7 +- core/modules/startup/browser-messaging.js | 3 +- core/modules/startup/commands.js | 3 +- core/modules/startup/favicon.js | 3 +- core/modules/startup/info.js | 3 +- core/modules/startup/load-modules.js | 3 +- core/modules/startup/password.js | 3 +- core/modules/startup/plugins.js | 3 +- core/modules/startup/render.js | 3 +- core/modules/startup/rootwidget.js | 3 +- core/modules/startup/startup.js | 3 +- core/modules/startup/story.js | 3 +- core/modules/startup/windows.js | 3 +- core/modules/story.js | 3 +- core/modules/storyviews/classic.js | 3 +- core/modules/storyviews/pop.js | 3 +- core/modules/storyviews/zoomin.js | 9 +- core/modules/syncer.js | 3 +- core/modules/tiddler.js | 3 +- core/modules/upgraders/plugins.js | 3 +- core/modules/upgraders/system.js | 3 +- core/modules/upgraders/themetweaks.js | 3 +- core/modules/utils/crypto.js | 3 +- core/modules/utils/csv.js | 35 +- core/modules/utils/dom/animations/slide.js | 3 +- core/modules/utils/dom/animator.js | 3 +- core/modules/utils/dom/browser.js | 3 +- core/modules/utils/dom/dom.js | 13 +- core/modules/utils/dom/dragndrop.js | 5 +- core/modules/utils/dom/http.js | 3 +- core/modules/utils/dom/keyboard.js | 3 +- core/modules/utils/dom/modal.js | 3 +- core/modules/utils/dom/notifier.js | 3 +- core/modules/utils/dom/popup.js | 5 +- core/modules/utils/dom/scroller.js | 3 +- core/modules/utils/edition-info.js | 3 +- core/modules/utils/escapecss.js | 18 +- core/modules/utils/fakedom.js | 3 +- core/modules/utils/filesystem.js | 9 +- core/modules/utils/linked-list.js | 7 +- core/modules/utils/logger.js | 3 +- core/modules/utils/parsetree.js | 3 +- core/modules/utils/performance.js | 5 +- core/modules/utils/pluginmaker.js | 3 +- core/modules/utils/transliterate.js | 3 +- core/modules/utils/utils.js | 7 +- core/modules/widgets/action-confirm.js | 3 +- core/modules/widgets/action-createtiddler.js | 9 +- core/modules/widgets/action-deletefield.js | 3 +- core/modules/widgets/action-deletetiddler.js | 3 +- core/modules/widgets/action-listops.js | 3 - core/modules/widgets/action-log.js | 3 +- core/modules/widgets/action-navigate.js | 3 +- core/modules/widgets/action-popup.js | 3 +- core/modules/widgets/action-sendmessage.js | 3 +- core/modules/widgets/action-setfield.js | 3 +- .../widgets/action-setmultiplefields.js | 3 +- core/modules/widgets/browse.js | 3 +- core/modules/widgets/button.js | 5 +- core/modules/widgets/checkbox.js | 5 +- core/modules/widgets/codeblock.js | 3 +- core/modules/widgets/count.js | 3 +- core/modules/widgets/diff-text.js | 3 +- core/modules/widgets/draggable.js | 4 +- core/modules/widgets/droppable.js | 4 +- core/modules/widgets/dropzone.js | 3 +- core/modules/widgets/edit-binary.js | 3 +- core/modules/widgets/edit-bitmap.js | 3 +- core/modules/widgets/edit-shortcut.js | 3 +- core/modules/widgets/edit-text.js | 3 +- core/modules/widgets/edit.js | 3 +- core/modules/widgets/element.js | 3 +- core/modules/widgets/encrypt.js | 3 +- core/modules/widgets/entity.js | 3 +- core/modules/widgets/error.js | 3 +- core/modules/widgets/eventcatcher.js | 3 +- core/modules/widgets/fieldmangler.js | 3 +- core/modules/widgets/fields.js | 9 +- core/modules/widgets/fill.js | 3 +- core/modules/widgets/genesis.js | 3 +- core/modules/widgets/image.js | 3 +- core/modules/widgets/importvariables.js | 7 +- core/modules/widgets/jsontiddler.js | 4 +- core/modules/widgets/keyboard.js | 5 +- core/modules/widgets/let.js | 7 +- core/modules/widgets/link.js | 3 +- core/modules/widgets/linkcatcher.js | 3 +- core/modules/widgets/list.js | 5 +- core/modules/widgets/log.js | 4 +- core/modules/widgets/macrocall.js | 3 +- core/modules/widgets/messagecatcher.js | 3 +- core/modules/widgets/navigator.js | 5 +- core/modules/widgets/parameters.js | 3 +- core/modules/widgets/password.js | 3 +- core/modules/widgets/qualify.js | 3 +- core/modules/widgets/radio.js | 3 +- core/modules/widgets/range.js | 9 +- core/modules/widgets/raw.js | 3 +- core/modules/widgets/reveal.js | 7 +- core/modules/widgets/scrollable.js | 3 +- core/modules/widgets/select.js | 9 +- core/modules/widgets/setmultiplevariables.js | 3 +- core/modules/widgets/setvariable.js | 3 +- core/modules/widgets/slot.js | 3 +- core/modules/widgets/text.js | 3 +- core/modules/widgets/tiddler.js | 3 +- core/modules/widgets/transclude.js | 3 +- core/modules/widgets/vars.js | 3 +- core/modules/widgets/view.js | 3 +- core/modules/widgets/widget.js | 5 +- core/modules/widgets/wikify.js | 3 +- core/modules/wiki-bulkops.js | 3 +- core/modules/wiki.js | 9 +- .../javascript-widget-tutorial/domwidget.js | 1 - .../javascript-widget-tutorial/donothing.js | 3 +- .../hello-attribute-optimized.js | 1 - .../hello-attribute.js | 1 - .../javascript-widget-tutorial/hello.js | 3 +- .../refreshcount.js | 1 - .../tiddlerfield-norefresh.js | 1 - .../tiddlerfield.js | 1 - .../tiddlers/tests/modules/utils/test-csv.js | 5 +- .../tiddlers/tests/test-action-widgets.js | 3 +- .../test/tiddlers/tests/test-backlinks.js | 3 +- .../tiddlers/tests/test-checkbox-widget.js | 3 +- .../tiddlers/tests/test-compare-filter.js | 3 +- .../tests/test-deserialize-operator.js | 3 +- .../test/tiddlers/tests/test-deserializers.js | 46 +- editions/test/tiddlers/tests/test-filters.js | 2251 ++++++++--------- .../test/tiddlers/tests/test-html-parser.js | 3 +- .../test/tiddlers/tests/test-json-filters.js | 3 +- .../test/tiddlers/tests/test-linked-list.js | 3 +- .../tiddlers/tests/test-parsetextreference.js | 3 +- editions/test/tiddlers/tests/test-popup.js | 3 +- .../tiddlers/tests/test-prefixes-filter.js | 4 +- editions/test/tiddlers/tests/test-tags.js | 3 +- editions/test/tiddlers/tests/test-tiddler.js | 3 +- editions/test/tiddlers/tests/test-utils.js | 4 +- editions/test/tiddlers/tests/test-widget.js | 7 +- .../tiddlers/tests/test-wikitext-parser.js | 3 +- .../tests/test-wikitext-tabs-macro.js | 3 +- editions/test/tiddlers/tests/test-wikitext.js | 3 +- .../tiddlers/system/dropbox-url-macro.js | 3 +- editions/tw5.com/tiddlers/system/if-macro.js | 3 +- editions/tw5.com/tiddlers/system/theme.tid | 3 + plugins/tiddlywiki/aws/modules/command.js | 3 +- plugins/tiddlywiki/aws/modules/encodings.js | 3 +- plugins/tiddlywiki/aws/modules/init.js | 3 +- plugins/tiddlywiki/aws/modules/utils.js | 3 +- plugins/tiddlywiki/bibtex/deserializer.js | 3 +- plugins/tiddlywiki/browser-sniff/browser.js | 3 +- .../tiddlywiki/browser-storage/rawmarkup.js | 1 - plugins/tiddlywiki/browser-storage/startup.js | 11 +- plugins/tiddlywiki/browser-storage/util.js | 5 +- plugins/tiddlywiki/cecily/cecily.js | 3 +- .../tiddlywiki/classictools/modules/recipe.js | 3 +- .../tiddlywiki/codemirror/edit-codemirror.js | 3 +- plugins/tiddlywiki/codemirror/engine.js | 3 +- .../tiddlywiki/consent-banner/raw-widget.js | 3 +- plugins/tiddlywiki/consent-banner/startup.js | 3 +- plugins/tiddlywiki/d3/barwidget.js | 11 +- plugins/tiddlywiki/d3/cloudwidget.js | 3 +- .../dynannotate/modules/dynannotate.js | 3 +- .../modules/legacy-selection-tracker.js | 3 +- .../dynannotate/modules/selection-tracker.js | 3 +- .../tiddlywiki/dynannotate/modules/startup.js | 3 +- .../tiddlywiki/dynannotate/modules/textmap.js | 3 +- plugins/tiddlywiki/dynaview/dynaview.js | 3 +- .../evernote/modules/enex-deserializer.js | 3 +- .../external-attachments/startup.js | 3 +- .../filesystem/filesystemadaptor.js | 7 +- plugins/tiddlywiki/freelinks/plain-text.js | 3 +- plugins/tiddlywiki/freelinks/text.js | 3 +- .../googleanalytics/googleanalytics.js | 3 +- .../highlight-legacy/highlightblock.js | 1 - .../tiddlywiki/highlight/highlightblock.js | 8 +- plugins/tiddlywiki/innerwiki/data.js | 3 +- plugins/tiddlywiki/innerwiki/innerwiki.js | 3 +- plugins/tiddlywiki/innerwiki/screenshot.js | 3 +- plugins/tiddlywiki/jasmine/jasmine-plugin.js | 5 +- .../jasmine/run-wiki-based-tests.js | 3 +- plugins/tiddlywiki/jasmine/startup.js | 3 +- plugins/tiddlywiki/jszip/startup.js | 3 +- plugins/tiddlywiki/katex/latex-parser.js | 3 +- plugins/tiddlywiki/katex/wrapper.js | 5 +- .../editor-operations/make-markdown-link.js | 3 +- plugins/tiddlywiki/markdown-legacy/wrapper.js | 3 +- .../editor-operations/make-markdown-link.js | 3 +- .../tiddlywiki/markdown/markdown-it-katex.js | 53 +- .../markdown/markdown-it-tiddlywiki.js | 3 +- plugins/tiddlywiki/markdown/wrapper.js | 7 +- plugins/tiddlywiki/mobiledragdrop/startup.js | 3 +- .../tiddlywiki/nodewebkitsaver/nodewebkit.js | 3 +- .../tiddlywiki/pluginlibrary/libraryserver.js | 3 +- plugins/tiddlywiki/qrcode/makeqr.js | 7 +- plugins/tiddlywiki/railroad/components.js | 4 +- plugins/tiddlywiki/railroad/parser.js | 6 +- plugins/tiddlywiki/railroad/typed-parser.js | 3 +- plugins/tiddlywiki/railroad/wrapper.js | 4 +- plugins/tiddlywiki/savetrail/savetrail.js | 3 +- plugins/tiddlywiki/share/rawmarkup.js | 3 +- plugins/tiddlywiki/stacked-view/stacked.js | 4 +- plugins/tiddlywiki/tahoelafs/saver.js | 3 +- .../text-slicer/modules/commands/slice.js | 3 +- .../modules/filters/list-children.js | 3 +- .../tiddlywiki/text-slicer/modules/slicer.js | 5 +- .../modules/startup/slicer-startup.js | 3 +- .../tiddlywiki/tiddlyweb/tiddlywebadaptor.js | 7 +- .../tiddlywiki/tw2parser/classictransclude.js | 7 +- plugins/tiddlywiki/tw2parser/entry.js | 5 +- .../tiddlywiki/tw2parser/parameteradapter.js | 3 +- .../tiddlywiki/tw2parser/wikitextparser.js | 5 +- plugins/tiddlywiki/tw2parser/wikitextrules.js | 17 +- .../tiddlywiki/twitter-archivist/archivist.js | 3 +- .../twitter-archivist/loadtwitterarchive.js | 3 +- .../tiddlywiki/twitter-archivist/startup.js | 3 +- plugins/tiddlywiki/twitter/startup.js | 3 +- plugins/tiddlywiki/twitter/twitter-widget.js | 3 +- plugins/tiddlywiki/upgrade/config.js | 3 +- plugins/tiddlywiki/xlsx-utils/deserializer.js | 3 +- plugins/tiddlywiki/xlsx-utils/importer.js | 3 +- plugins/tiddlywiki/xlsx-utils/startup.js | 3 +- .../xlsx-utils/xlsx-import-command.js | 3 +- 475 files changed, 2068 insertions(+), 2599 deletions(-) diff --git a/core/modules/commander.js b/core/modules/commander.js index b55679a2e..f282a1600 100644 --- a/core/modules/commander.js +++ b/core/modules/commander.js @@ -6,7 +6,7 @@ module-type: global The $tw.Commander class is a command interpreter \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -174,4 +174,3 @@ Commander.initCommands = function(moduleType) { exports.Commander = Commander; -})(); diff --git a/core/modules/commands/build.js b/core/modules/commands/build.js index 8471119d7..472248823 100644 --- a/core/modules/commands/build.js +++ b/core/modules/commands/build.js @@ -6,7 +6,6 @@ module-type: command Command to build a build target \*/ -(function(){ /*jslint node: true, browser: true */ /*global $tw: false */ @@ -48,5 +47,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/clearpassword.js b/core/modules/commands/clearpassword.js index 9f714a3ef..bd3c696c1 100644 --- a/core/modules/commands/clearpassword.js +++ b/core/modules/commands/clearpassword.js @@ -6,7 +6,6 @@ module-type: command Clear password for crypto operations \*/ -(function(){ /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,5 +28,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/commands.js b/core/modules/commands/commands.js index 813f19064..79a4129ef 100644 --- a/core/modules/commands/commands.js +++ b/core/modules/commands/commands.js @@ -7,8 +7,6 @@ Runs the commands returned from a filter \*/ -(function() { - /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; @@ -38,5 +36,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/deletetiddlers.js b/core/modules/commands/deletetiddlers.js index 3d8b855d9..bdd38deb4 100644 --- a/core/modules/commands/deletetiddlers.js +++ b/core/modules/commands/deletetiddlers.js @@ -6,7 +6,6 @@ module-type: command Command to delete tiddlers \*/ -(function(){ /*jslint node: true, browser: true */ /*global $tw: false */ @@ -38,5 +37,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/editions.js b/core/modules/commands/editions.js index cc802b9f5..2d47107f0 100644 --- a/core/modules/commands/editions.js +++ b/core/modules/commands/editions.js @@ -6,7 +6,7 @@ module-type: command Command to list the available editions \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -36,4 +36,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/fetch.js b/core/modules/commands/fetch.js index 07cda691c..54de9937f 100644 --- a/core/modules/commands/fetch.js +++ b/core/modules/commands/fetch.js @@ -6,7 +6,7 @@ module-type: command Commands to fetch external tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -172,4 +172,3 @@ Command.prototype.processBody = function(body,type,options,url) { exports.Command = Command; -})(); diff --git a/core/modules/commands/help.js b/core/modules/commands/help.js index 90c190829..1a3bd5ba3 100644 --- a/core/modules/commands/help.js +++ b/core/modules/commands/help.js @@ -6,7 +6,7 @@ module-type: command Help command \*/ -(function(){ + /*jshint node: true, browser: true */ /*global $tw: false */ @@ -38,4 +38,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/import.js b/core/modules/commands/import.js index 9465c3da1..2d85dda4f 100644 --- a/core/modules/commands/import.js +++ b/core/modules/commands/import.js @@ -6,7 +6,7 @@ module-type: command Command to import tiddlers from a file \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -45,4 +45,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/init.js b/core/modules/commands/init.js index 2d053ae3c..a2320be3e 100644 --- a/core/modules/commands/init.js +++ b/core/modules/commands/init.js @@ -6,7 +6,7 @@ module-type: command Command to initialise an empty wiki folder \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -56,4 +56,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/listen.js b/core/modules/commands/listen.js index 3c5f6a63a..dc385806c 100644 --- a/core/modules/commands/listen.js +++ b/core/modules/commands/listen.js @@ -6,7 +6,7 @@ module-type: command Listen for HTTP requests and serve tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -45,4 +45,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/load.js b/core/modules/commands/load.js index 8fd9cba10..41ca53175 100644 --- a/core/modules/commands/load.js +++ b/core/modules/commands/load.js @@ -6,7 +6,7 @@ module-type: command Command to load tiddlers from a file or directory \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -48,4 +48,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/makelibrary.js b/core/modules/commands/makelibrary.js index 36a1399a2..40e96c908 100644 --- a/core/modules/commands/makelibrary.js +++ b/core/modules/commands/makelibrary.js @@ -6,7 +6,7 @@ module-type: command Command to pack all of the plugins in the library into a plugin tiddler of type "library" \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -67,4 +67,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/output.js b/core/modules/commands/output.js index 0532f58d7..33eb27751 100644 --- a/core/modules/commands/output.js +++ b/core/modules/commands/output.js @@ -6,7 +6,7 @@ module-type: command Command to set the default output location (defaults to current working directory) \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -35,4 +35,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/password.js b/core/modules/commands/password.js index 85d53fa33..efd4f3954 100644 --- a/core/modules/commands/password.js +++ b/core/modules/commands/password.js @@ -6,7 +6,7 @@ module-type: command Save password for crypto operations \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/render.js b/core/modules/commands/render.js index b396deef9..7f192a734 100644 --- a/core/modules/commands/render.js +++ b/core/modules/commands/render.js @@ -6,61 +6,57 @@ module-type: command Render individual tiddlers and save the results to the specified files \*/ -(function(){ - /*jslint node: true, browser: true */ - /*global $tw: false */ - "use strict"; - - var widget = require("$:/core/modules/widgets/widget.js"); - - exports.info = { - name: "render", - synchronous: true - }; - - var Command = function(params,commander,callback) { - this.params = params; - this.commander = commander; - this.callback = callback; - }; - - Command.prototype.execute = function() { - if(this.params.length < 1) { - return "Missing tiddler filter"; +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +var widget = require("$:/core/modules/widgets/widget.js"); + +exports.info = { + name: "render", + synchronous: true +}; + +var Command = function(params,commander,callback) { + this.params = params; + this.commander = commander; + this.callback = callback; +}; + +Command.prototype.execute = function() { + if(this.params.length < 1) { + return "Missing tiddler filter"; + } + var self = this, + fs = require("fs"), + path = require("path"), + wiki = this.commander.wiki, + tiddlerFilter = this.params[0], + filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]", + type = this.params[2] || "text/html", + template = this.params[3], + variableList = this.params.slice(4), + tiddlers = wiki.filterTiddlers(tiddlerFilter), + variables = Object.create(null); + while(variableList.length >= 2) { + variables[variableList[0]] = variableList[1]; + variableList = variableList.slice(2); } - var self = this, - fs = require("fs"), - path = require("path"), - wiki = this.commander.wiki, - tiddlerFilter = this.params[0], - filenameFilter = this.params[1] || "[is[tiddler]addsuffix[.html]]", - type = this.params[2] || "text/html", - template = this.params[3], - variableList = this.params.slice(4), - tiddlers = wiki.filterTiddlers(tiddlerFilter), - variables = Object.create(null); - while(variableList.length >= 2) { - variables[variableList[0]] = variableList[1]; - variableList = variableList.slice(2); - } - $tw.utils.each(tiddlers,function(title) { - var filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]); - if(self.commander.verbose) { - console.log("Rendering \"" + title + "\" to \"" + filepath + "\""); - } - var parser = wiki.parseTiddler(template || title), - widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title,storyTiddler: title})}), - container = $tw.fakeDocument.createElement("div"); - widgetNode.render(container,null); - var text = type === "text/html" ? container.innerHTML : container.textContent; - $tw.utils.createFileDirectories(filepath); - fs.writeFileSync(filepath,text,"utf8"); - }); - return null; - }; - - exports.Command = Command; - - })(); - \ No newline at end of file + $tw.utils.each(tiddlers,function(title) { + var filepath = path.resolve(self.commander.outputPath,wiki.filterTiddlers(filenameFilter,$tw.rootWidget,wiki.makeTiddlerIterator([title]))[0]); + if(self.commander.verbose) { + console.log("Rendering \"" + title + "\" to \"" + filepath + "\""); + } + var parser = wiki.parseTiddler(template || title), + widgetNode = wiki.makeWidget(parser,{variables: $tw.utils.extend({},variables,{currentTiddler: title,storyTiddler: title})}), + container = $tw.fakeDocument.createElement("div"); + widgetNode.render(container,null); + var text = type === "text/html" ? container.innerHTML : container.textContent; + $tw.utils.createFileDirectories(filepath); + fs.writeFileSync(filepath,text,"utf8"); + }); + return null; +}; + +exports.Command = Command; diff --git a/core/modules/commands/rendertiddler.js b/core/modules/commands/rendertiddler.js index 41812aea1..eb98e965a 100755 --- a/core/modules/commands/rendertiddler.js +++ b/core/modules/commands/rendertiddler.js @@ -6,7 +6,7 @@ module-type: command Command to render a tiddler and save it to a file \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -54,4 +54,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/rendertiddlers.js b/core/modules/commands/rendertiddlers.js index 78272cc33..1d50330b6 100644 --- a/core/modules/commands/rendertiddlers.js +++ b/core/modules/commands/rendertiddlers.js @@ -6,7 +6,7 @@ module-type: command Command to render several tiddlers to a folder of files \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -66,4 +66,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/save.js b/core/modules/commands/save.js index 9769cec69..6a14779e8 100644 --- a/core/modules/commands/save.js +++ b/core/modules/commands/save.js @@ -6,62 +6,58 @@ module-type: command Saves individual tiddlers in their raw text or binary format to the specified files \*/ -(function(){ - /*jslint node: true, browser: true */ - /*global $tw: false */ - "use strict"; - - exports.info = { - name: "save", - synchronous: true - }; - - var Command = function(params,commander,callback) { - this.params = params; - this.commander = commander; - this.callback = callback; - }; - - Command.prototype.execute = function() { - if(this.params.length < 1) { - return "Missing filename filter"; - } - var self = this, - fs = require("fs"), - path = require("path"), - result = null, - wiki = this.commander.wiki, - tiddlerFilter = this.params[0], - filenameFilter = this.params[1] || "[is[tiddler]]", - tiddlers = wiki.filterTiddlers(tiddlerFilter); - $tw.utils.each(tiddlers,function(title) { - if(!result) { - var tiddler = self.commander.wiki.getTiddler(title); - if(tiddler) { - var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{ - directory: path.resolve(self.commander.outputPath), - pathFilters: [filenameFilter], - wiki: wiki, - fileInfo: {} - }); - if(self.commander.verbose) { - console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\""); - } - try { - $tw.utils.saveTiddlerToFileSync(tiddler,fileInfo); - } catch (err) { - result = "Error saving tiddler \"" + title + "\", to file: \"" + fileInfo.filepath + "\""; - } - } else { - result = "Tiddler '" + title + "' not found"; +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.info = { + name: "save", + synchronous: true +}; + +var Command = function(params,commander,callback) { + this.params = params; + this.commander = commander; + this.callback = callback; +}; + +Command.prototype.execute = function() { + if(this.params.length < 1) { + return "Missing filename filter"; + } + var self = this, + fs = require("fs"), + path = require("path"), + result = null, + wiki = this.commander.wiki, + tiddlerFilter = this.params[0], + filenameFilter = this.params[1] || "[is[tiddler]]", + tiddlers = wiki.filterTiddlers(tiddlerFilter); + $tw.utils.each(tiddlers,function(title) { + if(!result) { + var tiddler = self.commander.wiki.getTiddler(title); + if(tiddler) { + var fileInfo = $tw.utils.generateTiddlerFileInfo(tiddler,{ + directory: path.resolve(self.commander.outputPath), + pathFilters: [filenameFilter], + wiki: wiki, + fileInfo: {} + }); + if(self.commander.verbose) { + console.log("Saving \"" + title + "\" to \"" + fileInfo.filepath + "\""); } + try { + $tw.utils.saveTiddlerToFileSync(tiddler,fileInfo); + } catch(err) { + result = "Error saving tiddler \"" + title + "\", to file: \"" + fileInfo.filepath + "\""; + } + } else { + result = "Tiddler '" + title + "' not found"; } - }); - return result; - }; - - exports.Command = Command; - - })(); - \ No newline at end of file + } + }); + return result; +}; + +exports.Command = Command; diff --git a/core/modules/commands/savelibrarytiddlers.js b/core/modules/commands/savelibrarytiddlers.js index af42d7c8a..b8f0c6390 100644 --- a/core/modules/commands/savelibrarytiddlers.js +++ b/core/modules/commands/savelibrarytiddlers.js @@ -16,7 +16,7 @@ The pathname specifies the pathname to the folder in which the JSON files should The skinnylisting specifies the title of the tiddler to which a JSON catalogue of the subtiddlers will be saved. The JSON file contains the same data as the bundle tiddler but with the `text` field removed. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -95,4 +95,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/savetiddler.js b/core/modules/commands/savetiddler.js index efc484ec7..97a2cc11e 100644 --- a/core/modules/commands/savetiddler.js +++ b/core/modules/commands/savetiddler.js @@ -6,7 +6,7 @@ module-type: command Command to save the content of a tiddler to a file \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -48,4 +48,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/savetiddlers.js b/core/modules/commands/savetiddlers.js index d3b82d726..2c4279764 100644 --- a/core/modules/commands/savetiddlers.js +++ b/core/modules/commands/savetiddlers.js @@ -6,7 +6,7 @@ module-type: command Command to save several tiddlers to a folder of files \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -53,4 +53,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/savewikifolder.js b/core/modules/commands/savewikifolder.js index c0fccd775..eecb7a0fb 100644 --- a/core/modules/commands/savewikifolder.js +++ b/core/modules/commands/savewikifolder.js @@ -15,7 +15,7 @@ The following options are supported: Supports backward compatibility with --savewikifolder [] [ [=] ]* \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,7 +46,7 @@ Command.prototype.execute = function() { namedParames, tiddlerFilter, options = {}; - if (regFilter.test(this.params[1])) { + if(regFilter.test(this.params[1])) { namedParames = this.commander.extractNamedParameters(this.params.slice(1)); tiddlerFilter = namedParames.filter || "[all[tiddlers]]"; } else { @@ -198,7 +198,7 @@ WikiFolderMaker.prototype.saveTiddler = function(directory,tiddler) { }); try { $tw.utils.saveTiddlerToFileSync(tiddler,fileInfo); - } catch (err) { + } catch(err) { console.log("SaveWikiFolder: Error saving file '" + fileInfo.filepath + "', tiddler: '" + tiddler.fields.title); } }; @@ -219,4 +219,3 @@ WikiFolderMaker.prototype.saveFile = function(filename,encoding,data) { exports.Command = Command; -})(); diff --git a/core/modules/commands/server.js b/core/modules/commands/server.js index 507d1281d..6063a84f3 100644 --- a/core/modules/commands/server.js +++ b/core/modules/commands/server.js @@ -6,7 +6,7 @@ module-type: command Deprecated legacy command for serving tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -52,4 +52,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/setfield.js b/core/modules/commands/setfield.js index 3f8ec1d14..3a4b97461 100644 --- a/core/modules/commands/setfield.js +++ b/core/modules/commands/setfield.js @@ -6,7 +6,7 @@ module-type: command Command to modify selected tiddlers to set a field to the text of a template tiddler that has been wikified with the selected tiddler as the current tiddler. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -55,4 +55,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/unpackplugin.js b/core/modules/commands/unpackplugin.js index 6f85c066f..dd4bf5466 100644 --- a/core/modules/commands/unpackplugin.js +++ b/core/modules/commands/unpackplugin.js @@ -6,7 +6,7 @@ module-type: command Command to extract the shadow tiddlers from within a plugin \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -41,4 +41,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/verbose.js b/core/modules/commands/verbose.js index 6b0117829..2518c627d 100644 --- a/core/modules/commands/verbose.js +++ b/core/modules/commands/verbose.js @@ -6,7 +6,7 @@ module-type: command Verbose command \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,4 +31,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/commands/version.js b/core/modules/commands/version.js index 24edc97f7..cf3013d61 100644 --- a/core/modules/commands/version.js +++ b/core/modules/commands/version.js @@ -6,7 +6,7 @@ module-type: command Version command \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/core/modules/config.js b/core/modules/config.js index 399af598b..1847b976d 100644 --- a/core/modules/config.js +++ b/core/modules/config.js @@ -6,7 +6,7 @@ module-type: config Core configuration constants \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -38,4 +38,3 @@ exports.htmlBlockElements = "address,article,aside,audio,blockquote,canvas,dd,de exports.htmlUnsafeElements = "script".split(","); -})(); diff --git a/core/modules/deserializers.js b/core/modules/deserializers.js index bff4aaea1..7531e4c9c 100644 --- a/core/modules/deserializers.js +++ b/core/modules/deserializers.js @@ -6,7 +6,7 @@ module-type: tiddlerdeserializer Functions to deserialise tiddlers from a block of text \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -182,4 +182,3 @@ var deserializeTiddlerDiv = function(text /* [,fields] */) { return undefined; }; -})(); diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index a4cf983b0..ca28f12c5 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -6,7 +6,7 @@ module-type: library Text editor engine based on a simple input or textarea within an iframe. This is done so that the selection is preserved even when clicking away from the textarea \*/ -(function(){ + /*jslint node: true,browser: true */ /*global $tw: false */ @@ -200,7 +200,7 @@ FramedEngine.prototype.handleFocusEvent = function(event) { Handle a keydown event */ FramedEngine.prototype.handleKeydownEvent = function(event) { - if ($tw.keyboardManager.handleKeydownEvent(event, {onlyPriority: true})) { + if($tw.keyboardManager.handleKeydownEvent(event, {onlyPriority: true})) { return true; } @@ -274,4 +274,3 @@ FramedEngine.prototype.executeTextOperation = function(operation) { exports.FramedEngine = FramedEngine; -})(); diff --git a/core/modules/editor/engines/simple.js b/core/modules/editor/engines/simple.js index 9840cb623..107f9c362 100644 --- a/core/modules/editor/engines/simple.js +++ b/core/modules/editor/engines/simple.js @@ -6,7 +6,7 @@ module-type: library Text editor engine based on a simple input or textarea tag \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -173,4 +173,3 @@ SimpleEngine.prototype.executeTextOperation = function(operation) { exports.SimpleEngine = SimpleEngine; -})(); diff --git a/core/modules/editor/factory.js b/core/modules/editor/factory.js index 6157ec67f..673fb3bdd 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -6,7 +6,7 @@ module-type: library Factory for constructing text editor widgets with specified engines for the toolbar and non-toolbar cases \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -223,7 +223,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) { this.refreshSelf(); return true; - } else if (changedTiddlers[this.editRefreshTitle]) { + } else if(changedTiddlers[this.editRefreshTitle]) { this.engine.updateDomNodeText(this.getEditInfo().value); } else if(changedTiddlers[this.editTitle]) { var editInfo = this.getEditInfo(); @@ -387,4 +387,3 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { exports.editTextWidgetFactory = editTextWidgetFactory; -})(); diff --git a/core/modules/editor/operations/bitmap/clear.js b/core/modules/editor/operations/bitmap/clear.js index cb86b43a1..71263d88d 100644 --- a/core/modules/editor/operations/bitmap/clear.js +++ b/core/modules/editor/operations/bitmap/clear.js @@ -6,7 +6,7 @@ module-type: bitmapeditoroperation Bitmap editor operation to clear the image \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -21,4 +21,3 @@ exports["clear"] = function(event) { this.strokeEnd(); }; -})(); diff --git a/core/modules/editor/operations/bitmap/resize.js b/core/modules/editor/operations/bitmap/resize.js index 12059a5cb..75c15d31d 100644 --- a/core/modules/editor/operations/bitmap/resize.js +++ b/core/modules/editor/operations/bitmap/resize.js @@ -6,7 +6,7 @@ module-type: bitmapeditoroperation Bitmap editor operation to resize the image \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -26,4 +26,3 @@ exports["resize"] = function(event) { this.saveChanges(); }; -})(); diff --git a/core/modules/editor/operations/bitmap/rotate-left.js b/core/modules/editor/operations/bitmap/rotate-left.js index 6e1b15d3e..379355ef1 100644 --- a/core/modules/editor/operations/bitmap/rotate-left.js +++ b/core/modules/editor/operations/bitmap/rotate-left.js @@ -6,7 +6,7 @@ module-type: bitmapeditoroperation Bitmap editor operation to rotate the image left by 90 degrees \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -21,4 +21,3 @@ exports["rotate-left"] = function(event) { this.saveChanges(); }; -})(); diff --git a/core/modules/editor/operations/text/excise.js b/core/modules/editor/operations/text/excise.js index ced771719..18584dce4 100644 --- a/core/modules/editor/operations/text/excise.js +++ b/core/modules/editor/operations/text/excise.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to excise the selection to a new tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,4 +46,3 @@ exports["excise"] = function(event,operation) { operation.newSelEnd = operation.selStart + operation.replacement.length; }; -})(); diff --git a/core/modules/editor/operations/text/focus-editor.js b/core/modules/editor/operations/text/focus-editor.js index 0b36f731c..aced033fd 100644 --- a/core/modules/editor/operations/text/focus-editor.js +++ b/core/modules/editor/operations/text/focus-editor.js @@ -4,7 +4,7 @@ type: application/javascript module-type: texteditoroperation Simply focus the Text editor \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -13,5 +13,3 @@ Simply focus the Text editor exports["focus-editor"] = function(event,operation) { operation = null; }; - -})(); \ No newline at end of file diff --git a/core/modules/editor/operations/text/insert-text.js b/core/modules/editor/operations/text/insert-text.js index 784714968..63c16efa0 100644 --- a/core/modules/editor/operations/text/insert-text.js +++ b/core/modules/editor/operations/text/insert-text.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation insert text at the caret position. If there is a selection it is replaced. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -20,4 +20,3 @@ exports["insert-text"] = function(event,operation) { operation.newSelEnd = operation.newSelStart; }; -})(); diff --git a/core/modules/editor/operations/text/make-link.js b/core/modules/editor/operations/text/make-link.js index e8caf21c5..9dce7f7a2 100644 --- a/core/modules/editor/operations/text/make-link.js +++ b/core/modules/editor/operations/text/make-link.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to make a link \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -26,4 +26,3 @@ exports["make-link"] = function(event,operation) { operation.newSelEnd = operation.newSelStart; }; -})(); diff --git a/core/modules/editor/operations/text/prefix-lines.js b/core/modules/editor/operations/text/prefix-lines.js index 0a005c96f..a8256853e 100644 --- a/core/modules/editor/operations/text/prefix-lines.js +++ b/core/modules/editor/operations/text/prefix-lines.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to add a prefix to the selected lines \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -52,4 +52,3 @@ exports["prefix-lines"] = function(event,operation) { } }; -})(); diff --git a/core/modules/editor/operations/text/replace-all.js b/core/modules/editor/operations/text/replace-all.js index fc1541935..0334ebfcd 100644 --- a/core/modules/editor/operations/text/replace-all.js +++ b/core/modules/editor/operations/text/replace-all.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to replace the entire text \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -20,4 +20,3 @@ exports["replace-all"] = function(event,operation) { operation.newSelEnd = operation.replacement.length; }; -})(); diff --git a/core/modules/editor/operations/text/replace-selection.js b/core/modules/editor/operations/text/replace-selection.js index 740a41fb1..8e354eed0 100644 --- a/core/modules/editor/operations/text/replace-selection.js +++ b/core/modules/editor/operations/text/replace-selection.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to replace the selection \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -20,4 +20,3 @@ exports["replace-selection"] = function(event,operation) { operation.newSelEnd = operation.selStart + operation.replacement.length; }; -})(); diff --git a/core/modules/editor/operations/text/save-selection.js b/core/modules/editor/operations/text/save-selection.js index 484e6ff3c..2b98a70de 100644 --- a/core/modules/editor/operations/text/save-selection.js +++ b/core/modules/editor/operations/text/save-selection.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to save the current selection in a specified tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -20,4 +20,3 @@ exports["save-selection"] = function(event,operation) { } }; -})(); diff --git a/core/modules/editor/operations/text/wrap-lines.js b/core/modules/editor/operations/text/wrap-lines.js index 2e4f22943..91ac89b3d 100644 --- a/core/modules/editor/operations/text/wrap-lines.js +++ b/core/modules/editor/operations/text/wrap-lines.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to wrap the selected lines with a prefix and suffix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -22,7 +22,7 @@ exports["wrap-lines"] = function(event,operation) { operation.cutStart = operation.selStart - (prefix.length + 1); operation.cutEnd = operation.selEnd + suffix.length + 1; // Also cut the following newline (if there is any) - if (operation.text[operation.cutEnd] === "\n") { + if(operation.text[operation.cutEnd] === "\n") { operation.cutEnd++; } // Replace with selection @@ -44,4 +44,3 @@ exports["wrap-lines"] = function(event,operation) { } }; -})(); diff --git a/core/modules/editor/operations/text/wrap-selection.js b/core/modules/editor/operations/text/wrap-selection.js index 6800cbe5b..0276fd573 100644 --- a/core/modules/editor/operations/text/wrap-selection.js +++ b/core/modules/editor/operations/text/wrap-selection.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to wrap the selection with the specified prefix and suffix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -47,4 +47,3 @@ exports["wrap-selection"] = function(event,operation) { } }; -})(); diff --git a/core/modules/filterrunprefixes/all.js b/core/modules/filterrunprefixes/all.js index 652936de0..ceb224a6b 100644 --- a/core/modules/filterrunprefixes/all.js +++ b/core/modules/filterrunprefixes/all.js @@ -7,7 +7,7 @@ Union of sets without de-duplication. Equivalent to = filter run prefix. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -22,4 +22,3 @@ exports.all = function(operationSubFunction) { }; }; -})(); diff --git a/core/modules/filterrunprefixes/and.js b/core/modules/filterrunprefixes/and.js index 309c228e6..d4f372029 100644 --- a/core/modules/filterrunprefixes/and.js +++ b/core/modules/filterrunprefixes/and.js @@ -7,7 +7,7 @@ Intersection of sets. Equivalent to + filter run prefix. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -25,4 +25,3 @@ exports.and = function(operationSubFunction,options) { }; }; -})(); diff --git a/core/modules/filterrunprefixes/cascade.js b/core/modules/filterrunprefixes/cascade.js index 486e75f45..ba4d413ff 100644 --- a/core/modules/filterrunprefixes/cascade.js +++ b/core/modules/filterrunprefixes/cascade.js @@ -3,7 +3,7 @@ title: $:/core/modules/filterrunprefixes/cascade.js type: application/javascript module-type: filterrunprefix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -39,5 +39,3 @@ exports.cascade = function(operationSubFunction,options) { } } }; - -})(); \ No newline at end of file diff --git a/core/modules/filterrunprefixes/else.js b/core/modules/filterrunprefixes/else.js index 6e9ef29b3..953fc37a2 100644 --- a/core/modules/filterrunprefixes/else.js +++ b/core/modules/filterrunprefixes/else.js @@ -6,7 +6,7 @@ module-type: filterrunprefix Equivalent to ~ filter run prefix. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,4 +24,3 @@ exports.else = function(operationSubFunction) { }; }; -})(); diff --git a/core/modules/filterrunprefixes/except.js b/core/modules/filterrunprefixes/except.js index 659f14228..21e0a67f6 100644 --- a/core/modules/filterrunprefixes/except.js +++ b/core/modules/filterrunprefixes/except.js @@ -7,7 +7,7 @@ Difference of sets. Equivalent to - filter run prefix. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -22,4 +22,3 @@ exports.except = function(operationSubFunction) { }; }; -})(); diff --git a/core/modules/filterrunprefixes/filter.js b/core/modules/filterrunprefixes/filter.js index 4ab057109..9f2aa5a61 100644 --- a/core/modules/filterrunprefixes/filter.js +++ b/core/modules/filterrunprefixes/filter.js @@ -4,7 +4,7 @@ type: application/javascript module-type: filterrunprefix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -36,4 +36,3 @@ exports.filter = function(operationSubFunction,options) { } }; -})(); diff --git a/core/modules/filterrunprefixes/intersection.js b/core/modules/filterrunprefixes/intersection.js index 34d36066f..ef908e196 100644 --- a/core/modules/filterrunprefixes/intersection.js +++ b/core/modules/filterrunprefixes/intersection.js @@ -4,7 +4,7 @@ type: application/javascript module-type: filterrunprefix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.intersection = function(operationSubFunction) { }; }; -})(); diff --git a/core/modules/filterrunprefixes/map.js b/core/modules/filterrunprefixes/map.js index b756d6699..10a34e20a 100644 --- a/core/modules/filterrunprefixes/map.js +++ b/core/modules/filterrunprefixes/map.js @@ -3,7 +3,7 @@ title: $:/core/modules/filterrunprefixes/map.js type: application/javascript module-type: filterrunprefix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -40,5 +40,3 @@ exports.map = function(operationSubFunction,options) { } } }; - -})(); \ No newline at end of file diff --git a/core/modules/filterrunprefixes/or.js b/core/modules/filterrunprefixes/or.js index 82eff083a..5b3995a20 100644 --- a/core/modules/filterrunprefixes/or.js +++ b/core/modules/filterrunprefixes/or.js @@ -6,7 +6,7 @@ module-type: filterrunprefix Equivalent to a filter run with no prefix. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -21,4 +21,3 @@ exports.or = function(operationSubFunction) { }; }; -})(); diff --git a/core/modules/filterrunprefixes/reduce.js b/core/modules/filterrunprefixes/reduce.js index ee2998837..153c1dedb 100644 --- a/core/modules/filterrunprefixes/reduce.js +++ b/core/modules/filterrunprefixes/reduce.js @@ -3,7 +3,7 @@ title: $:/core/modules/filterrunprefixes/reduce.js type: application/javascript module-type: filterrunprefix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -37,4 +37,3 @@ exports.reduce = function(operationSubFunction,options) { } }; -})(); diff --git a/core/modules/filterrunprefixes/sort.js b/core/modules/filterrunprefixes/sort.js index d8d376126..fbcc52e0b 100644 --- a/core/modules/filterrunprefixes/sort.js +++ b/core/modules/filterrunprefixes/sort.js @@ -4,7 +4,7 @@ type: application/javascript module-type: filterrunprefix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -48,5 +48,3 @@ exports.sort = function(operationSubFunction,options) { } } }; - -})(); \ No newline at end of file diff --git a/core/modules/filterrunprefixes/then.js b/core/modules/filterrunprefixes/then.js index 9f6d5c76a..694d43bda 100644 --- a/core/modules/filterrunprefixes/then.js +++ b/core/modules/filterrunprefixes/then.js @@ -6,7 +6,7 @@ module-type: filterrunprefix Replace results of previous runs unless empty \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.then = function(operationSubFunction) { }; }; -})(); diff --git a/core/modules/filters.js b/core/modules/filters.js index aa82a352a..70281fd3e 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -6,7 +6,7 @@ module-type: wikimethod Adds tiddler filtering methods to the $tw.Wiki object. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -70,7 +70,7 @@ function parseFilterOperation(operators,filterString,p) { operator.operands = []; var parseOperand = function(bracketType) { var operand = {}; - switch (bracketType) { + switch(bracketType) { case "{": // Curly brackets operand.indirect = true; nextBracketPos = filterString.indexOf("}",p); @@ -368,4 +368,3 @@ exports.compileFilter = function(filterString) { return fnMeasured; }; -})(); diff --git a/core/modules/filters/addprefix.js b/core/modules/filters/addprefix.js index d1f0a822b..af4da96d1 100644 --- a/core/modules/filters/addprefix.js +++ b/core/modules/filters/addprefix.js @@ -8,7 +8,7 @@ especially useful in contexts where only a filter expression is allowed and macro substitution isn't available. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -25,4 +25,3 @@ exports.addprefix = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/addsuffix.js b/core/modules/filters/addsuffix.js index fb80c2573..829f73019 100644 --- a/core/modules/filters/addsuffix.js +++ b/core/modules/filters/addsuffix.js @@ -8,7 +8,7 @@ especially useful in contexts where only a filter expression is allowed and macro substitution isn't available. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -25,4 +25,3 @@ exports.addsuffix = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/after.js b/core/modules/filters/after.js index 6e5f3c77c..4ab2e3957 100644 --- a/core/modules/filters/after.js +++ b/core/modules/filters/after.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning the tiddler from the current list that is after the tiddler named in the operand. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.after = function(source,operator,options) { } }; -})(); diff --git a/core/modules/filters/all.js b/core/modules/filters/all.js index a36749e92..c69ec0b6d 100644 --- a/core/modules/filters/all.js +++ b/core/modules/filters/all.js @@ -8,7 +8,7 @@ Filter operator for selecting tiddlers [all[shadows+tiddlers]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -55,4 +55,3 @@ exports.all = function(source,operator,options) { return results.makeTiddlerIterator(options.wiki); }; -})(); diff --git a/core/modules/filters/all/current.js b/core/modules/filters/all/current.js index 82ad8cca3..39b020dab 100644 --- a/core/modules/filters/all/current.js +++ b/core/modules/filters/all/current.js @@ -6,7 +6,7 @@ module-type: allfilteroperator Filter function for [all[current]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,4 +24,3 @@ exports.current = function(source,prefix,options) { } }; -})(); diff --git a/core/modules/filters/all/missing.js b/core/modules/filters/all/missing.js index 4ba932089..2a065cdb9 100644 --- a/core/modules/filters/all/missing.js +++ b/core/modules/filters/all/missing.js @@ -6,7 +6,7 @@ module-type: allfilteroperator Filter function for [all[missing]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -19,4 +19,3 @@ exports.missing = function(source,prefix,options) { return options.wiki.getMissingTitles(); }; -})(); diff --git a/core/modules/filters/all/orphans.js b/core/modules/filters/all/orphans.js index d5b4fc270..50927669f 100644 --- a/core/modules/filters/all/orphans.js +++ b/core/modules/filters/all/orphans.js @@ -6,7 +6,7 @@ module-type: allfilteroperator Filter function for [all[orphans]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -19,4 +19,3 @@ exports.orphans = function(source,prefix,options) { return options.wiki.getOrphanTitles(); }; -})(); diff --git a/core/modules/filters/all/shadows.js b/core/modules/filters/all/shadows.js index 51654fee2..b24dd19b2 100644 --- a/core/modules/filters/all/shadows.js +++ b/core/modules/filters/all/shadows.js @@ -6,7 +6,7 @@ module-type: allfilteroperator Filter function for [all[shadows]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -19,4 +19,3 @@ exports.shadows = function(source,prefix,options) { return options.wiki.allShadowTitles(); }; -})(); diff --git a/core/modules/filters/all/tags.js b/core/modules/filters/all/tags.js index 2aaa9dec2..501a84cfa 100644 --- a/core/modules/filters/all/tags.js +++ b/core/modules/filters/all/tags.js @@ -6,7 +6,7 @@ module-type: allfilteroperator Filter function for [all[tags]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -19,4 +19,3 @@ exports.tags = function(source,prefix,options) { return Object.keys(options.wiki.getTagMap()); }; -})(); diff --git a/core/modules/filters/all/tiddlers.js b/core/modules/filters/all/tiddlers.js index 9a6e43875..d3826c61a 100644 --- a/core/modules/filters/all/tiddlers.js +++ b/core/modules/filters/all/tiddlers.js @@ -6,7 +6,7 @@ module-type: allfilteroperator Filter function for [all[tiddlers]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -19,4 +19,3 @@ exports.tiddlers = function(source,prefix,options) { return options.wiki.allTitles(); }; -})(); diff --git a/core/modules/filters/backlinks.js b/core/modules/filters/backlinks.js index f066d936a..7df81b8ca 100644 --- a/core/modules/filters/backlinks.js +++ b/core/modules/filters/backlinks.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning all the backlinks from a tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,4 +23,3 @@ exports.backlinks = function(source,operator,options) { return results.makeTiddlerIterator(options.wiki); }; -})(); diff --git a/core/modules/filters/before.js b/core/modules/filters/before.js index 292cc619d..ce98496d0 100644 --- a/core/modules/filters/before.js +++ b/core/modules/filters/before.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning the tiddler from the current list that is before the tiddler named in the operand. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.before = function(source,operator,options) { } }; -})(); diff --git a/core/modules/filters/commands.js b/core/modules/filters/commands.js index 5ab575a78..8383b0004 100644 --- a/core/modules/filters/commands.js +++ b/core/modules/filters/commands.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the commands available in this wiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,4 +24,3 @@ exports.commands = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/compare.js b/core/modules/filters/compare.js index fd509a28e..4140660fe 100644 --- a/core/modules/filters/compare.js +++ b/core/modules/filters/compare.js @@ -6,7 +6,7 @@ module-type: filteroperator General purpose comparison operator \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -37,4 +37,3 @@ var modes = { "lt": function(value) {return value < 0;} } -})(); diff --git a/core/modules/filters/contains.js b/core/modules/filters/contains.js index 918f415cd..eff1ee2da 100644 --- a/core/modules/filters/contains.js +++ b/core/modules/filters/contains.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for finding values in array fields \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -42,4 +42,3 @@ exports.contains = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/count.js b/core/modules/filters/count.js index 638b135df..5289c5915 100644 --- a/core/modules/filters/count.js +++ b/core/modules/filters/count.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning the number of entries in the current list. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,4 +23,3 @@ exports.count = function(source,operator,options) { return [count + ""]; }; -})(); diff --git a/core/modules/filters/crypto.js b/core/modules/filters/crypto.js index 24f1a0df9..afad6641b 100644 --- a/core/modules/filters/crypto.js +++ b/core/modules/filters/crypto.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operators for cryptography, using the Stanford JavaScript library \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,4 +24,3 @@ exports.sha256 = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/days.js b/core/modules/filters/days.js index 318d72567..df8aba141 100644 --- a/core/modules/filters/days.js +++ b/core/modules/filters/days.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator that selects tiddlers with a specified date field within a specified date interval. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -47,4 +47,3 @@ exports.days = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/deserialize.js b/core/modules/filters/deserialize.js index 5511f29e8..9966be800 100644 --- a/core/modules/filters/deserialize.js +++ b/core/modules/filters/deserialize.js @@ -4,7 +4,7 @@ type: application/javascript module-type: filteroperator Filter operator for deserializing string data into JSON representing tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -35,5 +35,3 @@ exports["deserialize"] = function(source,operator,options) { } return results; } - -})(); \ No newline at end of file diff --git a/core/modules/filters/deserializers.js b/core/modules/filters/deserializers.js index ddca998ea..47d8e6f43 100644 --- a/core/modules/filters/deserializers.js +++ b/core/modules/filters/deserializers.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the deserializers in this wiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,5 +23,3 @@ exports.deserializers = function(source,operator,options) { results.sort(); return results; }; - -})(); \ No newline at end of file diff --git a/core/modules/filters/duplicateslugs.js b/core/modules/filters/duplicateslugs.js index dbd2f23e7..5f543d3f5 100644 --- a/core/modules/filters/duplicateslugs.js +++ b/core/modules/filters/duplicateslugs.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter function for [duplicateslugs[]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.duplicateslugs = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/each.js b/core/modules/filters/each.js index 5c2c29077..3113cc2c9 100644 --- a/core/modules/filters/each.js +++ b/core/modules/filters/each.js @@ -7,7 +7,7 @@ Filter operator that selects one tiddler for each unique value of the specified With suffix "list", selects all tiddlers that are values in a specified list field. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -64,4 +64,3 @@ exports.each = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/eachday.js b/core/modules/filters/eachday.js index 6fdccf879..fa3e33453 100644 --- a/core/modules/filters/eachday.js +++ b/core/modules/filters/eachday.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator that selects one tiddler for each unique day covered by the specified date field \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -36,4 +36,3 @@ exports.eachday = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/editiondescription.js b/core/modules/filters/editiondescription.js index 2ee387163..556efd716 100644 --- a/core/modules/filters/editiondescription.js +++ b/core/modules/filters/editiondescription.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the descriptions of the specified edition names \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -30,4 +30,3 @@ exports.editiondescription = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/editions.js b/core/modules/filters/editions.js index 05ae57c31..4f2b42954 100644 --- a/core/modules/filters/editions.js +++ b/core/modules/filters/editions.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the available editions in this wiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.editions = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/else.js b/core/modules/filters/else.js index c3829371e..ee0234246 100644 --- a/core/modules/filters/else.js +++ b/core/modules/filters/else.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for replacing an empty input list with a constant, passing a non-empty input list straight through \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -27,4 +27,3 @@ exports.else = function(source,operator,options) { } }; -})(); diff --git a/core/modules/filters/encodings.js b/core/modules/filters/encodings.js index 23c743a03..506faec87 100644 --- a/core/modules/filters/encodings.js +++ b/core/modules/filters/encodings.js @@ -6,7 +6,6 @@ module-type: filteroperator Filter operator for applying decodeURIComponent() to each item. \*/ -(function(){ /*jslint node: true, browser: true */ /*global $tw: false */ @@ -113,4 +112,3 @@ exports.escapecss = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/enlist.js b/core/modules/filters/enlist.js index 0baaa9366..af2fa615a 100644 --- a/core/modules/filters/enlist.js +++ b/core/modules/filters/enlist.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning its operand parsed as a list \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -39,4 +39,3 @@ exports.enlist = function(source,operator,options) { } }; -})(); diff --git a/core/modules/filters/field.js b/core/modules/filters/field.js index 3a07c0c27..715bd37e2 100644 --- a/core/modules/filters/field.js +++ b/core/modules/filters/field.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for comparing fields for equality \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -72,4 +72,3 @@ exports.field = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/fields.js b/core/modules/filters/fields.js index 2f0bf26dc..81607b9b7 100644 --- a/core/modules/filters/fields.js +++ b/core/modules/filters/fields.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the fields on the selected tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -27,7 +27,7 @@ exports.fields = function(source,operator,options) { for(fieldName in tiddler.fields) { (operand.indexOf(fieldName) !== -1) ? $tw.utils.pushTop(results,fieldName) : ""; } - } else if (suffixes.indexOf("exclude") !== -1) { + } else if(suffixes.indexOf("exclude") !== -1) { for(fieldName in tiddler.fields) { (operand.indexOf(fieldName) !== -1) ? "" : $tw.utils.pushTop(results,fieldName); } @@ -42,4 +42,3 @@ exports.fields = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/filter.js b/core/modules/filters/filter.js index f15cbefc5..dd6efd7fd 100644 --- a/core/modules/filters/filter.js +++ b/core/modules/filters/filter.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning those input titles that pass a subfilter \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,4 +31,3 @@ exports.filter = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/format.js b/core/modules/filters/format.js index 2fc786d88..46518564d 100644 --- a/core/modules/filters/format.js +++ b/core/modules/filters/format.js @@ -4,7 +4,7 @@ type: application/javascript module-type: filteroperator Filter operator for formatting strings \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -42,5 +42,3 @@ exports.format = function(source,operator,options) { return results; } }; - -})(); \ No newline at end of file diff --git a/core/modules/filters/format/date.js b/core/modules/filters/format/date.js index fcf1a5cad..87a7df041 100644 --- a/core/modules/filters/format/date.js +++ b/core/modules/filters/format/date.js @@ -3,7 +3,7 @@ title: $:/core/modules/filters/format/date.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -22,5 +22,3 @@ exports.date = function(source,operand,options) { }); return results; }; - -})(); \ No newline at end of file diff --git a/core/modules/filters/format/json.js b/core/modules/filters/format/json.js index 2130a76ed..2818162f2 100644 --- a/core/modules/filters/format/json.js +++ b/core/modules/filters/format/json.js @@ -3,7 +3,7 @@ title: $:/core/modules/filters/format/json.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,5 +31,3 @@ exports.json = function(source,operand,options) { }); return results; }; - -})(); \ No newline at end of file diff --git a/core/modules/filters/format/relativedate.js b/core/modules/filters/format/relativedate.js index f771bb339..4d38ec35b 100644 --- a/core/modules/filters/format/relativedate.js +++ b/core/modules/filters/format/relativedate.js @@ -3,7 +3,7 @@ title: $:/core/modules/filters/format/relativedate.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -22,5 +22,3 @@ exports.relativedate = function(source,operand,options) { }); return results; }; - -})(); \ No newline at end of file diff --git a/core/modules/filters/format/timestamp.js b/core/modules/filters/format/timestamp.js index d6f5afe30..4dad477ce 100644 --- a/core/modules/filters/format/timestamp.js +++ b/core/modules/filters/format/timestamp.js @@ -3,7 +3,7 @@ title: $:/core/modules/filters/format/timestamp.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -15,11 +15,10 @@ Export our filter function exports.timestamp = function(source,operand,options) { var results = []; source(function(tiddler,title) { - if (title.match(/^-?\d+$/)) { + if(title.match(/^-?\d+$/)) { var value = new Date(Number(title)); results.push($tw.utils.formatDateString(value,operand || "[UTC]YYYY0MM0DD0hh0mm0ss0XXX")); } }); return results; -}; -})(); \ No newline at end of file +}; \ No newline at end of file diff --git a/core/modules/filters/format/titlelist.js b/core/modules/filters/format/titlelist.js index 47608323d..5de1a6c7d 100644 --- a/core/modules/filters/format/titlelist.js +++ b/core/modules/filters/format/titlelist.js @@ -3,7 +3,7 @@ title: $:/core/modules/filters/format/titlelist.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -22,4 +22,3 @@ exports.titlelist = function(source,operand,options) { return results; }; -})(); diff --git a/core/modules/filters/function.js b/core/modules/filters/function.js index 79210fb78..c4e90f7c4 100644 --- a/core/modules/filters/function.js +++ b/core/modules/filters/function.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning those input titles that are returned from a function \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.function = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/get.js b/core/modules/filters/get.js index feae6684e..8e7b0c66d 100644 --- a/core/modules/filters/get.js +++ b/core/modules/filters/get.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for replacing tiddler titles by the value of the field specified in the operand. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.get = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/getindex.js b/core/modules/filters/getindex.js index b604d4ec8..4d9d5c304 100644 --- a/core/modules/filters/getindex.js +++ b/core/modules/filters/getindex.js @@ -6,7 +6,7 @@ module-type: filteroperator returns the value at a given index of datatiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.getindex = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/getvariable.js b/core/modules/filters/getvariable.js index 43451abed..0a5cc6b83 100644 --- a/core/modules/filters/getvariable.js +++ b/core/modules/filters/getvariable.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for replacing input values by the value of the variable with the same name, or blank if the variable is missing \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,4 +23,3 @@ exports.getvariable = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/has.js b/core/modules/filters/has.js index f081809a3..aedf878ec 100644 --- a/core/modules/filters/has.js +++ b/core/modules/filters/has.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for checking if a tiddler has the specified field or index \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -67,4 +67,3 @@ exports.has = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/haschanged.js b/core/modules/filters/haschanged.js index 4c63b7758..e876517a2 100644 --- a/core/modules/filters/haschanged.js +++ b/core/modules/filters/haschanged.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returns tiddlers from the list that have a non-zero changecount. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.haschanged = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/indexes.js b/core/modules/filters/indexes.js index 3bbb22659..577b894ab 100644 --- a/core/modules/filters/indexes.js +++ b/core/modules/filters/indexes.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the indexes of a data tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -27,4 +27,3 @@ exports.indexes = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/insertafter.js b/core/modules/filters/insertafter.js index 79c84cb95..5d2270333 100644 --- a/core/modules/filters/insertafter.js +++ b/core/modules/filters/insertafter.js @@ -6,7 +6,7 @@ module-type: filteroperator Insert an item after another item in a list \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -43,4 +43,3 @@ exports.insertafter = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/insertbefore.js b/core/modules/filters/insertbefore.js index 4a032daf9..5be541b4b 100644 --- a/core/modules/filters/insertbefore.js +++ b/core/modules/filters/insertbefore.js @@ -6,7 +6,7 @@ module-type: filteroperator Insert an item before another item in a list \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -43,4 +43,3 @@ exports.insertbefore = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/is.js b/core/modules/filters/is.js index b75943786..f737c1f41 100644 --- a/core/modules/filters/is.js +++ b/core/modules/filters/is.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for checking tiddler properties \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -44,5 +44,3 @@ exports.is = function(source,operator,options) { return results; } }; - -})(); \ No newline at end of file diff --git a/core/modules/filters/is/binary.js b/core/modules/filters/is/binary.js index 01b9aabd3..8caf91dda 100644 --- a/core/modules/filters/is/binary.js +++ b/core/modules/filters/is/binary.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[binary]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.binary = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/blank.js b/core/modules/filters/is/blank.js index 8f500da45..15166da6e 100644 --- a/core/modules/filters/is/blank.js +++ b/core/modules/filters/is/blank.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[blank]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.blank = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/current.js b/core/modules/filters/is/current.js index b5b88f616..2bee6df4d 100644 --- a/core/modules/filters/is/current.js +++ b/core/modules/filters/is/current.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[current]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -34,4 +34,3 @@ exports.current = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/draft.js b/core/modules/filters/is/draft.js index 016da3f49..a62319a89 100644 --- a/core/modules/filters/is/draft.js +++ b/core/modules/filters/is/draft.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[draft]] analagous to [has[draft.of]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.draft = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/image.js b/core/modules/filters/is/image.js index 3527540d3..400a94093 100644 --- a/core/modules/filters/is/image.js +++ b/core/modules/filters/is/image.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[image]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.image = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/missing.js b/core/modules/filters/is/missing.js index 8ebf90d41..b6ee8d3f2 100644 --- a/core/modules/filters/is/missing.js +++ b/core/modules/filters/is/missing.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[missing]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.missing = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/orphan.js b/core/modules/filters/is/orphan.js index 94d09ad61..4c40c31ac 100644 --- a/core/modules/filters/is/orphan.js +++ b/core/modules/filters/is/orphan.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[orphan]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -34,4 +34,3 @@ exports.orphan = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/shadow.js b/core/modules/filters/is/shadow.js index cfb6b926c..87b0fcc15 100644 --- a/core/modules/filters/is/shadow.js +++ b/core/modules/filters/is/shadow.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[shadow]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.shadow = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/system.js b/core/modules/filters/is/system.js index 84d0656fd..0e6e5f026 100644 --- a/core/modules/filters/is/system.js +++ b/core/modules/filters/is/system.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[system]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.system = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/tag.js b/core/modules/filters/is/tag.js index d614029c4..b64b99e8b 100644 --- a/core/modules/filters/is/tag.js +++ b/core/modules/filters/is/tag.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[tag]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -34,4 +34,3 @@ exports.tag = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/tiddler.js b/core/modules/filters/is/tiddler.js index d97cd7892..cfe10edbb 100644 --- a/core/modules/filters/is/tiddler.js +++ b/core/modules/filters/is/tiddler.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[tiddler]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.tiddler = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/is/variable.js b/core/modules/filters/is/variable.js index 110d9a7c8..98837e03a 100644 --- a/core/modules/filters/is/variable.js +++ b/core/modules/filters/is/variable.js @@ -6,7 +6,7 @@ module-type: isfilteroperator Filter function for [is[variable]] \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.variable = function(source,prefix,options) { return results; }; -})(); diff --git a/core/modules/filters/json-ops.js b/core/modules/filters/json-ops.js index 2be9ec754..a79017cf0 100644 --- a/core/modules/filters/json-ops.js +++ b/core/modules/filters/json-ops.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operators for JSON operations \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -186,5 +186,4 @@ function getDataItem(data,indexes) { return item; } -})(); \ No newline at end of file diff --git a/core/modules/filters/limit.js b/core/modules/filters/limit.js index c878c1ac7..6764da9cd 100644 --- a/core/modules/filters/limit.js +++ b/core/modules/filters/limit.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for chopping the results to a specified maximum number of entries \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,4 +31,3 @@ exports.limit = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/links.js b/core/modules/filters/links.js index 0305f4b7f..16197b449 100644 --- a/core/modules/filters/links.js +++ b/core/modules/filters/links.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning all the links from a tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,4 +23,3 @@ exports.links = function(source,operator,options) { return results.makeTiddlerIterator(options.wiki); }; -})(); diff --git a/core/modules/filters/list.js b/core/modules/filters/list.js index 1b23b9382..8ed79178e 100644 --- a/core/modules/filters/list.js +++ b/core/modules/filters/list.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning the tiddlers whose title is listed in the operand tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -32,4 +32,3 @@ exports.list = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/listed.js b/core/modules/filters/listed.js index 8cb1c2f68..9a1a5cb77 100644 --- a/core/modules/filters/listed.js +++ b/core/modules/filters/listed.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning all tiddlers that have the selected tiddlers in a list \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,4 +24,3 @@ exports.listed = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/listops.js b/core/modules/filters/listops.js index 02d92831a..e5de7b978 100644 --- a/core/modules/filters/listops.js +++ b/core/modules/filters/listops.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operators for manipulating the current selection list \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -116,4 +116,3 @@ exports.zth = function(source,operator,options) { return results.slice(count,count + 1); }; -})(); diff --git a/core/modules/filters/lookup.js b/core/modules/filters/lookup.js index aaf81729d..6a84cc4b2 100644 --- a/core/modules/filters/lookup.js +++ b/core/modules/filters/lookup.js @@ -12,7 +12,7 @@ field or index value. If the 2nd suffix does not exist, it defaults to field. If the second operand is missing it defaults to "text" for fields, and "0" for indexes \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -50,4 +50,3 @@ exports.lookup = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/match.js b/core/modules/filters/match.js index 34caf487e..6f55032d4 100644 --- a/core/modules/filters/match.js +++ b/core/modules/filters/match.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for checking if a title matches a string \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -50,4 +50,3 @@ exports.match = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/math.js b/core/modules/filters/math.js index ed8e5eed6..80624cc9e 100644 --- a/core/modules/filters/math.js +++ b/core/modules/filters/math.js @@ -13,7 +13,7 @@ Note that strings are converted to numbers automatically. Trailing non-digits ar * "12kk" converts to 12 \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -244,4 +244,3 @@ function makeNumericArrayOperator(fnCalc) { }; }; -})(); diff --git a/core/modules/filters/minlength.js b/core/modules/filters/minlength.js index d4e679bef..68f99cb69 100644 --- a/core/modules/filters/minlength.js +++ b/core/modules/filters/minlength.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for filtering out titles that don't meet the minimum length in the operand \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -26,4 +26,3 @@ exports.minlength = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/moduleproperty.js b/core/modules/filters/moduleproperty.js index 8f3559b09..2a146be99 100644 --- a/core/modules/filters/moduleproperty.js +++ b/core/modules/filters/moduleproperty.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter [[module-name]moduleproperty[name]] retrieve a module property \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -27,4 +27,3 @@ exports.moduleproperty = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/modules.js b/core/modules/filters/modules.js index a9e185018..aa0bb2641 100644 --- a/core/modules/filters/modules.js +++ b/core/modules/filters/modules.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the titles of the modules of a given type in this wiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -38,4 +38,3 @@ exports.modules = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/moduletypes.js b/core/modules/filters/moduletypes.js index 67321caea..b85b08e2b 100644 --- a/core/modules/filters/moduletypes.js +++ b/core/modules/filters/moduletypes.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the module types in this wiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,4 +24,3 @@ exports.moduletypes = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/next.js b/core/modules/filters/next.js index c12295bf5..241f37434 100644 --- a/core/modules/filters/next.js +++ b/core/modules/filters/next.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning the tiddler whose title occurs next in the list supplied in the operand tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.next = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/plugintiddlers.js b/core/modules/filters/plugintiddlers.js index 489ec52e5..4ec221227 100644 --- a/core/modules/filters/plugintiddlers.js +++ b/core/modules/filters/plugintiddlers.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the titles of the shadow tiddlers within a plugin \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.plugintiddlers = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/prefix.js b/core/modules/filters/prefix.js index 97dd56f4e..5ce7b151b 100644 --- a/core/modules/filters/prefix.js +++ b/core/modules/filters/prefix.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for checking if a title starts with a prefix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -51,4 +51,3 @@ exports.prefix = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/previous.js b/core/modules/filters/previous.js index ed975458c..b1b51157d 100644 --- a/core/modules/filters/previous.js +++ b/core/modules/filters/previous.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning the tiddler whose title occurs immediately prior in the list supplied in the operand tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.previous = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/range.js b/core/modules/filters/range.js index 09b8d0334..c0c4cff81 100644 --- a/core/modules/filters/range.js +++ b/core/modules/filters/range.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for generating a numeric range. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,7 +24,7 @@ exports.range = function(source,operator,options) { } // Process the parts var beg, end, inc, i, fixed = 0; - for (i=0; i= 1) { + if(end >= 1) { beg = 1; } - else if (end <= -1) { + else if(end <= -1) { beg = -1; } else { @@ -75,7 +75,7 @@ exports.range = function(source,operator,options) { end += direction * 0.5 * Math.pow(0.1,fixed); var safety = 10010; // Enumerate the range - if (endend; i+=inc) { results.push(i.toFixed(fixed)); if(--safety<0) { @@ -100,4 +100,3 @@ exports.range = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/reduce.js b/core/modules/filters/reduce.js index efe8aea4a..b020ff823 100644 --- a/core/modules/filters/reduce.js +++ b/core/modules/filters/reduce.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator evaluates a subfilter for each item, making the running total available in the variable `accumulator`, and the current index available in the variable `index` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -45,4 +45,3 @@ exports.reduce = function(source,operator,options) { } }; -})(); diff --git a/core/modules/filters/regexp.js b/core/modules/filters/regexp.js index 837e77575..452afc0a1 100644 --- a/core/modules/filters/regexp.js +++ b/core/modules/filters/regexp.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for regexp matching \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -69,4 +69,3 @@ exports.regexp = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/removeprefix.js b/core/modules/filters/removeprefix.js index 185e1fc87..13d4932da 100644 --- a/core/modules/filters/removeprefix.js +++ b/core/modules/filters/removeprefix.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for removing a prefix from each title in the list. Titles that do not start with the prefix are removed. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -35,4 +35,3 @@ exports.removeprefix = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/removesuffix.js b/core/modules/filters/removesuffix.js index 76c0c7b35..2d3dc81f6 100644 --- a/core/modules/filters/removesuffix.js +++ b/core/modules/filters/removesuffix.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for removing a suffix from each title in the list. Titles that do not end with the suffix are removed. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -18,7 +18,7 @@ Export our filter function exports.removesuffix = function(source,operator,options) { var results = [], suffixes = (operator.suffixes || [])[0] || []; - if (!operator.operand) { + if(!operator.operand) { source(function(tiddler,title) { results.push(title); }); @@ -39,4 +39,3 @@ exports.removesuffix = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/sameday.js b/core/modules/filters/sameday.js index 5dfc35128..1677ebad4 100644 --- a/core/modules/filters/sameday.js +++ b/core/modules/filters/sameday.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator that selects tiddlers with a modified date field on the same day as the provided value. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -30,4 +30,3 @@ exports.sameday = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/search.js b/core/modules/filters/search.js index dcb534c07..99c9e01e8 100644 --- a/core/modules/filters/search.js +++ b/core/modules/filters/search.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for searching for the text in the operand tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -56,4 +56,3 @@ exports.search = function(source,operator,options) { } }; -})(); diff --git a/core/modules/filters/shadowsource.js b/core/modules/filters/shadowsource.js index f16e2bcc7..a11cfa0e7 100644 --- a/core/modules/filters/shadowsource.js +++ b/core/modules/filters/shadowsource.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the source plugins for shadow tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -27,4 +27,3 @@ exports.shadowsource = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/slugify.js b/core/modules/filters/slugify.js index afc12423e..6035ab2b4 100644 --- a/core/modules/filters/slugify.js +++ b/core/modules/filters/slugify.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for slugifying a tiddler title \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -20,4 +20,3 @@ exports.slugify = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/sort.js b/core/modules/filters/sort.js index 176cd4740..83e609e51 100644 --- a/core/modules/filters/sort.js +++ b/core/modules/filters/sort.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for sorting \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -53,4 +53,3 @@ var prepare_results = function (source) { return results; }; -})(); diff --git a/core/modules/filters/sortsub.js b/core/modules/filters/sortsub.js index d328be09c..dc3260945 100644 --- a/core/modules/filters/sortsub.js +++ b/core/modules/filters/sortsub.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for sorting by a subfilter \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -49,4 +49,3 @@ exports.sortsub = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/splitbefore.js b/core/modules/filters/splitbefore.js index 071cead3e..b00c0fd9a 100644 --- a/core/modules/filters/splitbefore.js +++ b/core/modules/filters/splitbefore.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator that splits each result on the first occurance of the specified separator and returns the unique values. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.splitbefore = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/storyviews.js b/core/modules/filters/storyviews.js index 41fffed92..d0c195c21 100644 --- a/core/modules/filters/storyviews.js +++ b/core/modules/filters/storyviews.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the story views in this wiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -26,4 +26,3 @@ exports.storyviews = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/strings.js b/core/modules/filters/strings.js index 538dd0597..1c2095272 100644 --- a/core/modules/filters/strings.js +++ b/core/modules/filters/strings.js @@ -8,7 +8,7 @@ Filter operators for strings. Unary/binary operators work on each item in turn, Sum/product/maxall/minall operate on the entire list, returning a single item. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -127,7 +127,7 @@ function diffPartsToChars(text1,text2,mode) { if(lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : (lineHash[line] !== undefined)) { chars += String.fromCharCode(lineHash[line]); } else { - if (lineArrayLength == maxLines) { + if(lineArrayLength == maxLines) { line = text.substring(lineStart); lineEnd = text.length; } @@ -264,7 +264,7 @@ exports.pad = function(source,operator,options) { } else { var padString = "", padStringLength = targetLength - title.length; - while (padStringLength > padString.length) { + while(padStringLength > padString.length) { padString += fill; } //make sure we do not exceed the specified length @@ -290,5 +290,3 @@ exports.charcode = function(source,operator,options) { }); return [chars.join("")]; }; - -})(); \ No newline at end of file diff --git a/core/modules/filters/subfilter.js b/core/modules/filters/subfilter.js index 79ae82777..78f963999 100644 --- a/core/modules/filters/subfilter.js +++ b/core/modules/filters/subfilter.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning its operand evaluated as a filter \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -30,4 +30,3 @@ exports.subfilter = function(source,operator,options) { } }; -})(); diff --git a/core/modules/filters/substitute.js b/core/modules/filters/substitute.js index 655ef7321..f72e052b1 100644 --- a/core/modules/filters/substitute.js +++ b/core/modules/filters/substitute.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for substituting variables and embedded filter expressions with their corresponding values \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -32,5 +32,4 @@ exports.substitute = function(source,operator,options) { return results; }; -})(); \ No newline at end of file diff --git a/core/modules/filters/subtiddlerfields.js b/core/modules/filters/subtiddlerfields.js index 681dd243d..b9707380a 100644 --- a/core/modules/filters/subtiddlerfields.js +++ b/core/modules/filters/subtiddlerfields.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the fields on the selected subtiddlers of the plugin named in the operand \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.subtiddlerfields = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/suffix.js b/core/modules/filters/suffix.js index 96b32c4a9..e4fcfbb9f 100644 --- a/core/modules/filters/suffix.js +++ b/core/modules/filters/suffix.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for checking if a title ends with a suffix \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -18,7 +18,7 @@ Export our filter function exports.suffix = function(source,operator,options) { var results = [], suffixes = (operator.suffixes || [])[0] || []; - if (!operator.operand) { + if(!operator.operand) { source(function(tiddler,title) { results.push(title); }); @@ -55,4 +55,3 @@ exports.suffix = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/tag.js b/core/modules/filters/tag.js index 951a28c6b..f2f61fa44 100644 --- a/core/modules/filters/tag.js +++ b/core/modules/filters/tag.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for checking for the presence of a tag \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -55,4 +55,3 @@ exports.tag = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/tagging.js b/core/modules/filters/tagging.js index a7fea68ec..1c91fe2cf 100644 --- a/core/modules/filters/tagging.js +++ b/core/modules/filters/tagging.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning all tiddlers that are tagged with the selected tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,4 +23,3 @@ exports.tagging = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/tags.js b/core/modules/filters/tags.js index 4a73fd83f..0fe0c9c72 100644 --- a/core/modules/filters/tags.js +++ b/core/modules/filters/tags.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning all the tags of the selected tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.tags = function(source,operator,options) { return Object.keys(tags); }; -})(); diff --git a/core/modules/filters/then.js b/core/modules/filters/then.js index 994775c08..a7c69d980 100644 --- a/core/modules/filters/then.js +++ b/core/modules/filters/then.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for replacing any titles with a constant \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,4 +23,3 @@ exports.then = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/title.js b/core/modules/filters/title.js index 88ac6f132..d40333a43 100644 --- a/core/modules/filters/title.js +++ b/core/modules/filters/title.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for comparing title fields for equality \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.title = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/unknown.js b/core/modules/filters/unknown.js index 6ae5baaf0..4371d9ebf 100644 --- a/core/modules/filters/unknown.js +++ b/core/modules/filters/unknown.js @@ -8,7 +8,7 @@ Filter operator for handling unknown filter operators. Not intended to be used directly by end users, hence the square brackets around the name. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,4 +46,3 @@ exports["[unknown]"] = function(source,operator,options) { return fieldFilterOperatorFn(source,operator,options); }; -})(); diff --git a/core/modules/filters/untagged.js b/core/modules/filters/untagged.js index d16de87f8..478f22d40 100644 --- a/core/modules/filters/untagged.js +++ b/core/modules/filters/untagged.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning all the selected tiddlers that are untagged \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -26,4 +26,3 @@ exports.untagged = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/variables.js b/core/modules/filters/variables.js index c92b780d2..c3bf573e9 100644 --- a/core/modules/filters/variables.js +++ b/core/modules/filters/variables.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the active variables \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.variables = function(source,operator,options) { return names.sort(); }; -})(); diff --git a/core/modules/filters/wikiparserrules.js b/core/modules/filters/wikiparserrules.js index 213298515..95b2c62b7 100644 --- a/core/modules/filters/wikiparserrules.js +++ b/core/modules/filters/wikiparserrules.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the wiki parser rules in this wiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -28,4 +28,3 @@ exports.wikiparserrules = function(source,operator,options) { return results; }; -})(); diff --git a/core/modules/filters/x-listops.js b/core/modules/filters/x-listops.js index 760f581a1..aa5b3c5a2 100644 --- a/core/modules/filters/x-listops.js +++ b/core/modules/filters/x-listops.js @@ -6,230 +6,227 @@ module-type: filteroperator Extended filter operators to manipulate the current list. \*/ -(function () { - /*jslint node: true, browser: true */ - /*global $tw: false */ - "use strict"; +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; - /* - Fetch titles from the current list - */ - var prepare_results = function (source) { - var results = []; - source(function (tiddler, title) { - results.push(title); - }); - return results; - }; +/* +Fetch titles from the current list +*/ +var prepare_results = function (source) { +var results = []; + source(function (tiddler, title) { + results.push(title); + }); + return results; +}; - /* - Moves a number of items from the tail of the current list before the item named in the operand - */ - exports.putbefore = function (source, operator) { - var results = prepare_results(source), - index = results.indexOf(operator.operand), - count = $tw.utils.getInt(operator.suffix,1); - return (index === -1) ? - results.slice(0, -1) : - results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index, -count)); - }; +/* +Moves a number of items from the tail of the current list before the item named in the operand +*/ +exports.putbefore = function (source, operator) { + var results = prepare_results(source), + index = results.indexOf(operator.operand), + count = $tw.utils.getInt(operator.suffix,1); + return (index === -1) ? + results.slice(0, -1) : + results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index, -count)); +}; - /* - Moves a number of items from the tail of the current list after the item named in the operand - */ - exports.putafter = function (source, operator) { - var results = prepare_results(source), - index = results.indexOf(operator.operand), - count = $tw.utils.getInt(operator.suffix,1); - return (index === -1) ? - results.slice(0, -1) : - results.slice(0, index + 1).concat(results.slice(-count)).concat(results.slice(index + 1, -count)); - }; +/* +Moves a number of items from the tail of the current list after the item named in the operand +*/ +exports.putafter = function (source, operator) { + var results = prepare_results(source), + index = results.indexOf(operator.operand), + count = $tw.utils.getInt(operator.suffix,1); + return (index === -1) ? + results.slice(0, -1) : + results.slice(0, index + 1).concat(results.slice(-count)).concat(results.slice(index + 1, -count)); +}; - /* - Replaces the item named in the operand with a number of items from the tail of the current list - */ - exports.replace = function (source, operator) { - var results = prepare_results(source), - index = results.indexOf(operator.operand), - count = $tw.utils.getInt(operator.suffix,1); - return (index === -1) ? - results.slice(0, -count) : - results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index + 1, -count)); - }; +/* +Replaces the item named in the operand with a number of items from the tail of the current list +*/ +exports.replace = function (source, operator) { + var results = prepare_results(source), + index = results.indexOf(operator.operand), + count = $tw.utils.getInt(operator.suffix,1); + return (index === -1) ? + results.slice(0, -count) : + results.slice(0, index).concat(results.slice(-count)).concat(results.slice(index + 1, -count)); +}; - /* - Moves a number of items from the tail of the current list to the head of the list - */ - exports.putfirst = function (source, operator) { - var results = prepare_results(source), - count = $tw.utils.getInt(operator.suffix,1); - return results.slice(-count).concat(results.slice(0, -count)); - }; +/* +Moves a number of items from the tail of the current list to the head of the list +*/ +exports.putfirst = function (source, operator) { + var results = prepare_results(source), + count = $tw.utils.getInt(operator.suffix,1); + return results.slice(-count).concat(results.slice(0, -count)); +}; - /* - Moves a number of items from the head of the current list to the tail of the list - */ - exports.putlast = function (source, operator) { - var results = prepare_results(source), - count = $tw.utils.getInt(operator.suffix,1); - return results.slice(count).concat(results.slice(0, count)); - }; +/* +Moves a number of items from the head of the current list to the tail of the list +*/ +exports.putlast = function (source, operator) { + var results = prepare_results(source), + count = $tw.utils.getInt(operator.suffix,1); + return results.slice(count).concat(results.slice(0, count)); +}; - /* - Moves the item named in the operand a number of places forward or backward in the list - */ - exports.move = function (source, operator) { - var results = prepare_results(source), - index = results.indexOf(operator.operand), - count = $tw.utils.getInt(operator.suffix,1), - marker = results.splice(index, 1), - offset = (index + count) > 0 ? index + count : 0; - return results.slice(0, offset).concat(marker).concat(results.slice(offset)); - }; +/* +Moves the item named in the operand a number of places forward or backward in the list +*/ +exports.move = function (source, operator) { + var results = prepare_results(source), + index = results.indexOf(operator.operand), + count = $tw.utils.getInt(operator.suffix,1), + marker = results.splice(index, 1), + offset = (index + count) > 0 ? index + count : 0; + return results.slice(0, offset).concat(marker).concat(results.slice(offset)); +}; - /* - Returns the items from the current list that are after the item named in the operand - */ - exports.allafter = function (source, operator) { - var results = prepare_results(source), - index = results.indexOf(operator.operand); - return (index === -1) ? [] : - (operator.suffix) ? results.slice(index) : - results.slice(index + 1); - }; +/* +Returns the items from the current list that are after the item named in the operand +*/ +exports.allafter = function (source, operator) { + var results = prepare_results(source), + index = results.indexOf(operator.operand); + return (index === -1) ? [] : + (operator.suffix) ? results.slice(index) : + results.slice(index + 1); +}; - /* - Returns the items from the current list that are before the item named in the operand - */ - exports.allbefore = function (source, operator) { - var results = prepare_results(source), - index = results.indexOf(operator.operand); - return (index === -1) ? [] : - (operator.suffix) ? results.slice(0, index + 1) : - results.slice(0, index); - }; +/* +Returns the items from the current list that are before the item named in the operand +*/ +exports.allbefore = function (source, operator) { + var results = prepare_results(source), + index = results.indexOf(operator.operand); + return (index === -1) ? [] : + (operator.suffix) ? results.slice(0, index + 1) : + results.slice(0, index); +}; - /* - Appends the items listed in the operand array to the tail of the current list - */ - exports.append = function (source, operator) { - var append = $tw.utils.parseStringArray(operator.operand, "true"), - results = prepare_results(source), - count = parseInt(operator.suffix) || append.length; - return (append.length === 0) ? results : - (operator.prefix) ? results.concat(append.slice(-count)) : - results.concat(append.slice(0, count)); - }; +/* +Appends the items listed in the operand array to the tail of the current list +*/ +exports.append = function (source, operator) { + var append = $tw.utils.parseStringArray(operator.operand, "true"), + results = prepare_results(source), + count = parseInt(operator.suffix) || append.length; + return (append.length === 0) ? results : + (operator.prefix) ? results.concat(append.slice(-count)) : + results.concat(append.slice(0, count)); +}; - /* - Prepends the items listed in the operand array to the head of the current list - */ - exports.prepend = function (source, operator) { - var prepend = $tw.utils.parseStringArray(operator.operand, "true"), - results = prepare_results(source), - count = $tw.utils.getInt(operator.suffix,prepend.length); - return (prepend.length === 0) ? results : - (operator.prefix) ? prepend.slice(-count).concat(results) : - prepend.slice(0, count).concat(results); - }; +/* +Prepends the items listed in the operand array to the head of the current list +*/ +exports.prepend = function (source, operator) { + var prepend = $tw.utils.parseStringArray(operator.operand, "true"), + results = prepare_results(source), + count = $tw.utils.getInt(operator.suffix,prepend.length); + return (prepend.length === 0) ? results : + (operator.prefix) ? prepend.slice(-count).concat(results) : + prepend.slice(0, count).concat(results); +}; - /* - Returns all items from the current list except the items listed in the operand array - */ - exports.remove = function (source, operator) { - var array = $tw.utils.parseStringArray(operator.operand, "true"), - results = prepare_results(source), - count = parseInt(operator.suffix) || array.length, - p, - len, - index; - len = array.length - 1; - for (p = 0; p < count; ++p) { - if (operator.prefix) { - index = results.indexOf(array[len - p]); - } else { - index = results.indexOf(array[p]); - } - if (index !== -1) { - results.splice(index, 1); - } - } - return results; - }; - - /* - Returns all items from the current list sorted in the order of the items in the operand array - */ - exports.sortby = function (source, operator) { - var results = prepare_results(source); - if (!results || results.length < 2) { - return results; - } - var lookup = $tw.utils.parseStringArray(operator.operand, "true"); - results.sort(function (a, b) { - return lookup.indexOf(a) - lookup.indexOf(b); - }); - return results; - }; - - /* - Removes all duplicate items from the current list - */ - exports.unique = function (source, operator) { - var results = prepare_results(source); - var set = results.reduce(function (a, b) { - if (a.indexOf(b) < 0) { - a.push(b); - } - return a; - }, []); - return set; - }; - - var cycleValueInArray = function(results,operands,stepSize) { - var resultsIndex, - step = stepSize || 1, - i = 0, - opLength = operands.length, - nextOperandIndex; - for(i; i < opLength; i++) { - resultsIndex = results.indexOf(operands[i]); - if(resultsIndex !== -1) { - break; - } - } - if(resultsIndex !== -1) { - i = i + step; - nextOperandIndex = (i < opLength ? i : i - opLength); - if(operands.length > 1) { - results.splice(resultsIndex,1,operands[nextOperandIndex]); - } else { - results.splice(resultsIndex,1); - } +/* +Returns all items from the current list except the items listed in the operand array +*/ +exports.remove = function (source, operator) { + var array = $tw.utils.parseStringArray(operator.operand, "true"), + results = prepare_results(source), + count = parseInt(operator.suffix) || array.length, + p, + len, + index; + len = array.length - 1; + for(p = 0; p < count; ++p) { + if(operator.prefix) { + index = results.indexOf(array[len - p]); } else { - results.push(operands[0]); + index = results.indexOf(array[p]); } + if(index !== -1) { + results.splice(index, 1); + } + } + return results; +}; + +/* +Returns all items from the current list sorted in the order of the items in the operand array +*/ +exports.sortby = function (source, operator) { + var results = prepare_results(source); + if(!results || results.length < 2) { return results; } + var lookup = $tw.utils.parseStringArray(operator.operand, "true"); + results.sort(function (a, b) { + return lookup.indexOf(a) - lookup.indexOf(b); + }); + return results; +}; - /* - Toggles an item in the current list. - */ - exports.toggle = function(source,operator) { - return cycleValueInArray(prepare_results(source),operator.operands); - } - - exports.cycle = function(source,operator) { - var results = prepare_results(source), - operands = (operator.operand.length ? $tw.utils.parseStringArray(operator.operand, "true") : [""]), - step = $tw.utils.getInt(operator.operands[1]||"",1); - if(step < 0) { - operands.reverse(); - step = Math.abs(step); +/* +Removes all duplicate items from the current list +*/ +exports.unique = function (source, operator) { + var results = prepare_results(source); + var set = results.reduce(function (a, b) { + if(a.indexOf(b) < 0) { + a.push(b); } - return cycleValueInArray(results,operands,step); - } + return a; + }, []); + return set; +}; -})(); +var cycleValueInArray = function(results,operands,stepSize) { + var resultsIndex, + step = stepSize || 1, + i = 0, + opLength = operands.length, + nextOperandIndex; + for(i; i < opLength; i++) { + resultsIndex = results.indexOf(operands[i]); + if(resultsIndex !== -1) { + break; + } + } + if(resultsIndex !== -1) { + i = i + step; + nextOperandIndex = (i < opLength ? i : i - opLength); + if(operands.length > 1) { + results.splice(resultsIndex,1,operands[nextOperandIndex]); + } else { + results.splice(resultsIndex,1); + } + } else { + results.push(operands[0]); + } + return results; +} + +/* +Toggles an item in the current list. +*/ +exports.toggle = function(source,operator) { + return cycleValueInArray(prepare_results(source),operator.operands); +} + +exports.cycle = function(source,operator) { + var results = prepare_results(source), + operands = (operator.operand.length ? $tw.utils.parseStringArray(operator.operand, "true") : [""]), + step = $tw.utils.getInt(operator.operands[1]||"",1); + if(step < 0) { + operands.reverse(); + step = Math.abs(step); + } + return cycleValueInArray(results,operands,step); +} diff --git a/core/modules/indexers/backlinks-index.js b/core/modules/indexers/backlinks-index.js index 5902e2829..0a7c7b208 100644 --- a/core/modules/indexers/backlinks-index.js +++ b/core/modules/indexers/backlinks-index.js @@ -6,7 +6,7 @@ module-type: indexer Indexes the tiddlers' backlinks \*/ -(function(){ + /*jslint node: true, browser: true */ /*global modules: false */ @@ -83,4 +83,3 @@ BacklinksIndexer.prototype.lookup = function(title) { exports.BacklinksIndexer = BacklinksIndexer; -})(); diff --git a/core/modules/indexers/field-indexer.js b/core/modules/indexers/field-indexer.js index 3aefc99ac..259f8092c 100644 --- a/core/modules/indexers/field-indexer.js +++ b/core/modules/indexers/field-indexer.js @@ -6,7 +6,7 @@ module-type: indexer Indexes the tiddlers with each field value \*/ -(function(){ + /*jslint node: true, browser: true */ /*global modules: false */ @@ -140,4 +140,3 @@ FieldIndexer.prototype.lookup = function(name,value) { exports.FieldIndexer = FieldIndexer; -})(); diff --git a/core/modules/indexers/tag-indexer.js b/core/modules/indexers/tag-indexer.js index 4721fea08..7dc4ac6d7 100644 --- a/core/modules/indexers/tag-indexer.js +++ b/core/modules/indexers/tag-indexer.js @@ -6,7 +6,7 @@ module-type: indexer Indexes the tiddlers with each tag \*/ -(function(){ + /*jslint node: true, browser: true */ /*global modules: false */ @@ -95,4 +95,3 @@ TagSubIndexer.prototype.lookup = function(tag) { exports.TagIndexer = TagIndexer; -})(); diff --git a/core/modules/info/platform.js b/core/modules/info/platform.js index 0eb0b9ea8..8c108e17a 100644 --- a/core/modules/info/platform.js +++ b/core/modules/info/platform.js @@ -6,7 +6,7 @@ module-type: info Initialise basic platform $:/info/ tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -49,4 +49,3 @@ exports.getInfoTiddlerFields = function(updateInfoTiddlersCallback) { return infoTiddlerFields; }; -})(); diff --git a/core/modules/keyboard.js b/core/modules/keyboard.js index 1740ba35b..755314814 100644 --- a/core/modules/keyboard.js +++ b/core/modules/keyboard.js @@ -6,7 +6,7 @@ module-type: global Keyboard handling utilities \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -384,4 +384,3 @@ KeyboardManager.prototype.handleShortcutChanges = function(changedTiddlers) { exports.KeyboardManager = KeyboardManager; -})(); diff --git a/core/modules/language.js b/core/modules/language.js index 5e44d6696..01622ac78 100644 --- a/core/modules/language.js +++ b/core/modules/language.js @@ -6,7 +6,7 @@ module-type: global The $tw.Language() manages translateable strings \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -42,4 +42,3 @@ Language.prototype.getRawString = function(title) { exports.Language = Language; -})(); diff --git a/core/modules/macros/changecount.js b/core/modules/macros/changecount.js index 2d0f62e5a..cfc5fc7bb 100644 --- a/core/modules/macros/changecount.js +++ b/core/modules/macros/changecount.js @@ -6,7 +6,7 @@ module-type: macro Macro to return the changecount for the current tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -27,4 +27,3 @@ exports.run = function() { return this.wiki.getChangeCount(this.getVariable("currentTiddler")) + ""; }; -})(); diff --git a/core/modules/macros/contrastcolour.js b/core/modules/macros/contrastcolour.js index eab6f0108..54f76b2ca 100644 --- a/core/modules/macros/contrastcolour.js +++ b/core/modules/macros/contrastcolour.js @@ -6,7 +6,7 @@ module-type: macro Macro to choose which of two colours has the highest contrast with a base colour \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -52,4 +52,3 @@ exports.run = function(target,fallbackTarget,colourA,colourB) { return Math.abs(brightnessTarget - brightnessA) > Math.abs(brightnessTarget - brightnessB) ? colourA : colourB; }; -})(); diff --git a/core/modules/macros/csvtiddlers.js b/core/modules/macros/csvtiddlers.js index 7b34ce04d..0b144567d 100644 --- a/core/modules/macros/csvtiddlers.js +++ b/core/modules/macros/csvtiddlers.js @@ -6,7 +6,7 @@ module-type: macro Macro to output tiddlers matching a filter to CSV \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -72,4 +72,3 @@ function quoteAndEscape(value) { return "\"" + value.replace(/"/mg,"\"\"") + "\""; } -})(); diff --git a/core/modules/macros/displayshortcuts.js b/core/modules/macros/displayshortcuts.js index b18297238..580c99ee6 100644 --- a/core/modules/macros/displayshortcuts.js +++ b/core/modules/macros/displayshortcuts.js @@ -6,7 +6,7 @@ module-type: macro Macro to display a list of keyboard shortcuts in human readable form. Notably, it resolves named shortcuts like `((bold))` to the underlying keystrokes. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -42,4 +42,3 @@ exports.run = function(shortcuts,prefix,separator,suffix) { } }; -})(); diff --git a/core/modules/macros/jsontiddler.js b/core/modules/macros/jsontiddler.js index 509fd5559..f7ebd4e1b 100644 --- a/core/modules/macros/jsontiddler.js +++ b/core/modules/macros/jsontiddler.js @@ -6,7 +6,7 @@ module-type: macro Macro to output a single tiddler to JSON \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -37,4 +37,3 @@ exports.run = function(title) { return JSON.stringify(fields,null,$tw.config.preferences.jsonSpaces); }; -})(); diff --git a/core/modules/macros/jsontiddlers.js b/core/modules/macros/jsontiddlers.js index eeaf70d3a..16270d79e 100644 --- a/core/modules/macros/jsontiddlers.js +++ b/core/modules/macros/jsontiddlers.js @@ -6,7 +6,7 @@ module-type: macro Macro to output tiddlers matching a filter to JSON \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -30,4 +30,3 @@ exports.run = function(filter,spaces) { return this.wiki.getTiddlersAsJson(filter,$tw.utils.parseInt(spaces)); }; -})(); diff --git a/core/modules/macros/makedatauri.js b/core/modules/macros/makedatauri.js index 0ff862df1..eaac1e11a 100644 --- a/core/modules/macros/makedatauri.js +++ b/core/modules/macros/makedatauri.js @@ -8,7 +8,7 @@ Macro to convert a string of text to a data URI <> \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -33,4 +33,3 @@ exports.run = function(text,type,_canonical_uri) { return $tw.utils.makeDataUri(text,type,_canonical_uri); }; -})(); diff --git a/core/modules/macros/now.js b/core/modules/macros/now.js index d0a15dce2..0364b7e85 100644 --- a/core/modules/macros/now.js +++ b/core/modules/macros/now.js @@ -6,7 +6,7 @@ module-type: macro Macro to return a formatted version of the current time \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.run = function(format) { return $tw.utils.formatDateString(new Date(),format || "0hh:0mm, DDth MMM YYYY"); }; -})(); diff --git a/core/modules/macros/qualify.js b/core/modules/macros/qualify.js index de9dc6c8e..0d8a400d6 100644 --- a/core/modules/macros/qualify.js +++ b/core/modules/macros/qualify.js @@ -6,7 +6,7 @@ module-type: macro Macro to qualify a state tiddler title according \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.run = function(title) { return title + "-" + this.getStateQualifier(); }; -})(); diff --git a/core/modules/macros/resolvepath.js b/core/modules/macros/resolvepath.js index d84d87563..fb908bcc5 100644 --- a/core/modules/macros/resolvepath.js +++ b/core/modules/macros/resolvepath.js @@ -6,7 +6,7 @@ module-type: macro Resolves a relative path for an absolute rootpath. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -26,4 +26,3 @@ exports.run = function(source, root) { return $tw.utils.resolvePath(source, root); }; -})(); diff --git a/core/modules/macros/unusedtitle.js b/core/modules/macros/unusedtitle.js index 952bd0264..36684e9a2 100644 --- a/core/modules/macros/unusedtitle.js +++ b/core/modules/macros/unusedtitle.js @@ -5,7 +5,7 @@ module-type: macro Macro to return a new title that is unused in the wiki. It can be given a name as a base. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -32,4 +32,3 @@ exports.run = function(baseName,separator,template) { return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template}); }; -})(); diff --git a/core/modules/macros/version.js b/core/modules/macros/version.js index b0dd0b0d5..9be692e1c 100644 --- a/core/modules/macros/version.js +++ b/core/modules/macros/version.js @@ -6,7 +6,7 @@ module-type: macro Macro to return the TiddlyWiki core version number \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -27,4 +27,3 @@ exports.run = function() { return $tw.version; }; -})(); diff --git a/core/modules/parsers/audioparser.js b/core/modules/parsers/audioparser.js index 5eb2ff985..b46b84cbb 100644 --- a/core/modules/parsers/audioparser.js +++ b/core/modules/parsers/audioparser.js @@ -6,7 +6,7 @@ module-type: parser The audio parser parses an audio tiddler into an embeddable HTML element \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -37,5 +37,4 @@ exports["audio/mpeg"] = AudioParser; exports["audio/mp3"] = AudioParser; exports["audio/mp4"] = AudioParser; -})(); diff --git a/core/modules/parsers/binaryparser.js b/core/modules/parsers/binaryparser.js index 60e7b5ef0..6d9c2a23b 100644 --- a/core/modules/parsers/binaryparser.js +++ b/core/modules/parsers/binaryparser.js @@ -6,7 +6,7 @@ module-type: parser The binary parser parses a binary tiddler into a warning message and download link \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -70,5 +70,4 @@ var BinaryParser = function(type,text,options) { exports["application/octet-stream"] = BinaryParser; -})(); diff --git a/core/modules/parsers/csvparser.js b/core/modules/parsers/csvparser.js index f40b5f0e5..03a637605 100644 --- a/core/modules/parsers/csvparser.js +++ b/core/modules/parsers/csvparser.js @@ -6,7 +6,7 @@ module-type: parser The CSV text parser processes CSV files into a table wrapped in a scrollable widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -14,7 +14,7 @@ The CSV text parser processes CSV files into a table wrapped in a scrollable wid var CsvParser = function(type,text,options) { // Special handler for tab-delimited files - if (type === 'text/tab-delimited-values' && !options.separator) { + if(type === 'text/tab-delimited-values' && !options.separator) { options.separator = "\t"; } @@ -59,5 +59,4 @@ var CsvParser = function(type,text,options) { exports["text/csv"] = CsvParser; exports["text/tab-delimited-values"] = CsvParser; -})(); diff --git a/core/modules/parsers/htmlparser.js b/core/modules/parsers/htmlparser.js index 24c9f5d3e..b6bd12051 100644 --- a/core/modules/parsers/htmlparser.js +++ b/core/modules/parsers/htmlparser.js @@ -6,7 +6,7 @@ module-type: parser The HTML parser displays text as raw HTML \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -35,5 +35,4 @@ var HtmlParser = function(type,text,options) { exports["text/html"] = HtmlParser; -})(); diff --git a/core/modules/parsers/imageparser.js b/core/modules/parsers/imageparser.js index a964a4ba8..3dd49f8b2 100644 --- a/core/modules/parsers/imageparser.js +++ b/core/modules/parsers/imageparser.js @@ -6,7 +6,7 @@ module-type: parser The image parser parses an image into an embeddable HTML element \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -43,5 +43,4 @@ exports["image/heif"] = ImageParser; exports["image/x-icon"] = ImageParser; exports["image/vnd.microsoft.icon"] = ImageParser; -})(); diff --git a/core/modules/parsers/parseutils.js b/core/modules/parsers/parseutils.js index 1f86dd909..eeeebffd3 100644 --- a/core/modules/parsers/parseutils.js +++ b/core/modules/parsers/parseutils.js @@ -22,7 +22,7 @@ Most functions have the following pattern: The exception is `skipWhiteSpace`, which just returns the position after the whitespace. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -385,4 +385,3 @@ exports.parseAttribute = function(source,pos) { return node; }; -})(); diff --git a/core/modules/parsers/pdfparser.js b/core/modules/parsers/pdfparser.js index c7830bf69..a276c2851 100644 --- a/core/modules/parsers/pdfparser.js +++ b/core/modules/parsers/pdfparser.js @@ -6,7 +6,7 @@ module-type: parser The PDF parser embeds a PDF viewer \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,5 +31,4 @@ var ImageParser = function(type,text,options) { exports["application/pdf"] = ImageParser; -})(); diff --git a/core/modules/parsers/textparser.js b/core/modules/parsers/textparser.js index 06b08f30f..1c9c78bd8 100644 --- a/core/modules/parsers/textparser.js +++ b/core/modules/parsers/textparser.js @@ -6,7 +6,7 @@ module-type: parser The plain text parser processes blocks of source text into a degenerate parse tree consisting of a single text node \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,5 +31,4 @@ exports["application/json"] = TextParser; exports["text/css"] = TextParser; exports["application/x-tiddler-dictionary"] = TextParser; -})(); diff --git a/core/modules/parsers/videoparser.js b/core/modules/parsers/videoparser.js index 1c8a38bb2..ea3ff11aa 100644 --- a/core/modules/parsers/videoparser.js +++ b/core/modules/parsers/videoparser.js @@ -6,7 +6,7 @@ module-type: parser The video parser parses a video tiddler into an embeddable HTML element \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -37,4 +37,3 @@ exports["video/webm"] = VideoParser; exports["video/mp4"] = VideoParser; exports["video/quicktime"] = VideoParser; -})(); diff --git a/core/modules/parsers/wikiparser/rules/codeblock.js b/core/modules/parsers/wikiparser/rules/codeblock.js index 262038f87..f61184d4f 100644 --- a/core/modules/parsers/wikiparser/rules/codeblock.js +++ b/core/modules/parsers/wikiparser/rules/codeblock.js @@ -12,7 +12,7 @@ Wiki text rule for code blocks. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -54,4 +54,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/codeinline.js b/core/modules/parsers/wikiparser/rules/codeinline.js index ee9149833..2201b3375 100644 --- a/core/modules/parsers/wikiparser/rules/codeinline.js +++ b/core/modules/parsers/wikiparser/rules/codeinline.js @@ -11,7 +11,7 @@ Wiki text inline rule for code runs. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -52,4 +52,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/commentblock.js b/core/modules/parsers/wikiparser/rules/commentblock.js index 1c303f38f..3c0ee4347 100644 --- a/core/modules/parsers/wikiparser/rules/commentblock.js +++ b/core/modules/parsers/wikiparser/rules/commentblock.js @@ -18,7 +18,7 @@ xxxx Note that the syntax for comments is simplified to an opening "" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html) \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -53,4 +53,3 @@ exports.parse = function() { return []; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/commentinline.js b/core/modules/parsers/wikiparser/rules/commentinline.js index 671bd79d6..1fcfefee9 100644 --- a/core/modules/parsers/wikiparser/rules/commentinline.js +++ b/core/modules/parsers/wikiparser/rules/commentinline.js @@ -12,7 +12,7 @@ Wiki text inline rule for HTML comments. For example: Note that the syntax for comments is simplified to an opening "" sequence -- HTML itself implements a more complex format (see http://ostermiller.org/findhtmlcomment.html) \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -47,4 +47,3 @@ exports.parse = function() { return []; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/dash.js b/core/modules/parsers/wikiparser/rules/dash.js index 45481bf07..4e5847d8b 100644 --- a/core/modules/parsers/wikiparser/rules/dash.js +++ b/core/modules/parsers/wikiparser/rules/dash.js @@ -12,7 +12,7 @@ This is an em-dash: --- ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -37,4 +37,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/bold.js b/core/modules/parsers/wikiparser/rules/emphasis/bold.js index 3799feeb5..0b7ed9c55 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/bold.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/bold.js @@ -17,7 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,5 +46,3 @@ exports.parse = function() { children: tree }]; }; - -})(); \ No newline at end of file diff --git a/core/modules/parsers/wikiparser/rules/emphasis/italic.js b/core/modules/parsers/wikiparser/rules/emphasis/italic.js index 3e0744c4d..7e4fccd77 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/italic.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/italic.js @@ -17,7 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,5 +46,3 @@ exports.parse = function() { children: tree }]; }; - -})(); \ No newline at end of file diff --git a/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js b/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js index 0fb34fc52..edd12846f 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js @@ -17,7 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -47,4 +47,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/subscript.js b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js index 12be0fbbc..59aa5b5b4 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/subscript.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js @@ -17,7 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -47,4 +47,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/superscript.js b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js index 5a5330d8c..eb12fe7cc 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/superscript.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js @@ -17,7 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,5 +46,3 @@ exports.parse = function() { children: tree }]; }; - -})(); \ No newline at end of file diff --git a/core/modules/parsers/wikiparser/rules/emphasis/underscore.js b/core/modules/parsers/wikiparser/rules/emphasis/underscore.js index d36bd242d..bf8297d3a 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/underscore.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/underscore.js @@ -17,7 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,5 +46,3 @@ exports.parse = function() { children: tree }]; }; - -})(); \ No newline at end of file diff --git a/core/modules/parsers/wikiparser/rules/entity.js b/core/modules/parsers/wikiparser/rules/entity.js index dc3917daf..8c2301194 100644 --- a/core/modules/parsers/wikiparser/rules/entity.js +++ b/core/modules/parsers/wikiparser/rules/entity.js @@ -10,7 +10,7 @@ Wiki text inline rule for HTML entities. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -37,4 +37,3 @@ exports.parse = function() { return [{type: "entity", entity: this.match[0]}]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/extlink.js b/core/modules/parsers/wikiparser/rules/extlink.js index e06f88d8d..0c0d42fda 100644 --- a/core/modules/parsers/wikiparser/rules/extlink.js +++ b/core/modules/parsers/wikiparser/rules/extlink.js @@ -14,7 +14,7 @@ A suppressed external link: ~http://www.tiddlyspace.com/ External links can be suppressed by preceding them with `~`. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -52,4 +52,3 @@ exports.parse = function() { } }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js b/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js index 7ab4801bf..696f0b7d4 100644 --- a/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js +++ b/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js @@ -14,7 +14,7 @@ Wiki text rule for block-level filtered transclusion. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -61,4 +61,3 @@ exports.parse = function() { return [node]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js b/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js index 029fd6802..20e4c45b9 100644 --- a/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js +++ b/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js @@ -14,7 +14,7 @@ Wiki text rule for inline filtered transclusion. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -60,4 +60,3 @@ exports.parse = function() { return [node]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/fnprocdef.js b/core/modules/parsers/wikiparser/rules/fnprocdef.js index 5d0a8878b..c3033a332 100644 --- a/core/modules/parsers/wikiparser/rules/fnprocdef.js +++ b/core/modules/parsers/wikiparser/rules/fnprocdef.js @@ -20,7 +20,7 @@ definition text ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -93,5 +93,4 @@ exports.parse = function() { return parseTreeNodes; }; -})(); \ No newline at end of file diff --git a/core/modules/parsers/wikiparser/rules/hardlinebreaks.js b/core/modules/parsers/wikiparser/rules/hardlinebreaks.js index c278686b4..b4b01a31f 100644 --- a/core/modules/parsers/wikiparser/rules/hardlinebreaks.js +++ b/core/modules/parsers/wikiparser/rules/hardlinebreaks.js @@ -17,7 +17,7 @@ Not ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -56,4 +56,3 @@ exports.parse = function() { return tree; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/heading.js b/core/modules/parsers/wikiparser/rules/heading.js index de4e45c27..1ce39f5d3 100644 --- a/core/modules/parsers/wikiparser/rules/heading.js +++ b/core/modules/parsers/wikiparser/rules/heading.js @@ -6,7 +6,7 @@ module-type: wikirule Wiki text block rule for headings \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -43,4 +43,3 @@ exports.parse = function() { children: tree }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/horizrule.js b/core/modules/parsers/wikiparser/rules/horizrule.js index bacad06ed..480d10819 100644 --- a/core/modules/parsers/wikiparser/rules/horizrule.js +++ b/core/modules/parsers/wikiparser/rules/horizrule.js @@ -10,7 +10,7 @@ Wiki text block rule for rules. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,4 +31,3 @@ exports.parse = function() { return [{type: "element", tag: "hr"}]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/html.js b/core/modules/parsers/wikiparser/rules/html.js index 4dbd6a07c..c164dd077 100644 --- a/core/modules/parsers/wikiparser/rules/html.js +++ b/core/modules/parsers/wikiparser/rules/html.js @@ -17,7 +17,7 @@ This is a widget invocation }}} \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -170,4 +170,3 @@ exports.isLegalTag = function(tag) { } }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/image.js b/core/modules/parsers/wikiparser/rules/image.js index 6b379d9c5..ebc762a6a 100644 --- a/core/modules/parsers/wikiparser/rules/image.js +++ b/core/modules/parsers/wikiparser/rules/image.js @@ -17,7 +17,7 @@ Wiki text inline rule for embedding images. For example: Generates the `<$image>` widget. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -130,4 +130,3 @@ exports.parseImage = function(source,pos) { return node; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/import.js b/core/modules/parsers/wikiparser/rules/import.js index a66df7057..566b76c67 100644 --- a/core/modules/parsers/wikiparser/rules/import.js +++ b/core/modules/parsers/wikiparser/rules/import.js @@ -10,7 +10,7 @@ Wiki pragma rule for importing variable definitions ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -50,4 +50,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/list.js b/core/modules/parsers/wikiparser/rules/list.js index 17eab6dad..c162be433 100644 --- a/core/modules/parsers/wikiparser/rules/list.js +++ b/core/modules/parsers/wikiparser/rules/list.js @@ -40,7 +40,7 @@ A CSS class can be applied to a list item as follows: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -128,4 +128,3 @@ exports.parse = function() { return [listStack[0]]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/macrocallblock.js b/core/modules/parsers/wikiparser/rules/macrocallblock.js index a2c10e04a..a7664d76a 100644 --- a/core/modules/parsers/wikiparser/rules/macrocallblock.js +++ b/core/modules/parsers/wikiparser/rules/macrocallblock.js @@ -10,7 +10,7 @@ Wiki rule for block macro calls ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -32,7 +32,7 @@ exports.findNextMatch = function(startPos) { var c = this.parser.source.charAt(nextCall.end); // Ensure EOL after parsed macro // If we didn't need to support IE, we'd just use /(?:\r?\n|$)/ym - if ((c === "") || (c === "\n") || ((c === "\r") && this.parser.source.charAt(nextCall.end+1) === "\n")) { + if((c === "") || (c === "\n") || ((c === "\r") && this.parser.source.charAt(nextCall.end+1) === "\n")) { this.nextCall = nextCall; return nextStart; } @@ -53,4 +53,3 @@ exports.parse = function() { return [call]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/macrocallinline.js b/core/modules/parsers/wikiparser/rules/macrocallinline.js index e9f79f09e..4abc85295 100644 --- a/core/modules/parsers/wikiparser/rules/macrocallinline.js +++ b/core/modules/parsers/wikiparser/rules/macrocallinline.js @@ -10,7 +10,7 @@ Wiki rule for macro calls ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -46,4 +46,3 @@ exports.parse = function() { return [call]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/macrodef.js b/core/modules/parsers/wikiparser/rules/macrodef.js index 74a94a385..5ec94bfe9 100644 --- a/core/modules/parsers/wikiparser/rules/macrodef.js +++ b/core/modules/parsers/wikiparser/rules/macrodef.js @@ -12,7 +12,7 @@ definition text, including $param$ markers ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -89,4 +89,3 @@ exports.parse = function() { return parseTreeNodes; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/parameters.js b/core/modules/parsers/wikiparser/rules/parameters.js index f288740aa..1e7bd3bca 100644 --- a/core/modules/parsers/wikiparser/rules/parameters.js +++ b/core/modules/parsers/wikiparser/rules/parameters.js @@ -11,7 +11,7 @@ definition text ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -57,4 +57,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/parsermode.js b/core/modules/parsers/wikiparser/rules/parsermode.js index 72a6de067..1185a889a 100644 --- a/core/modules/parsers/wikiparser/rules/parsermode.js +++ b/core/modules/parsers/wikiparser/rules/parsermode.js @@ -11,7 +11,7 @@ Wiki pragma rule for parser mode specifications ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -65,4 +65,3 @@ exports.parse = function() { return []; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/prettyextlink.js b/core/modules/parsers/wikiparser/rules/prettyextlink.js index 4c497c257..152473ac0 100644 --- a/core/modules/parsers/wikiparser/rules/prettyextlink.js +++ b/core/modules/parsers/wikiparser/rules/prettyextlink.js @@ -11,7 +11,7 @@ Wiki text inline rule for external links. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -112,4 +112,3 @@ exports.parseLink = function(source,pos) { return node; }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/prettylink.js b/core/modules/parsers/wikiparser/rules/prettylink.js index 56a2850a3..72eea3347 100644 --- a/core/modules/parsers/wikiparser/rules/prettylink.js +++ b/core/modules/parsers/wikiparser/rules/prettylink.js @@ -12,7 +12,7 @@ Wiki text inline rule for pretty links. For example: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -60,4 +60,3 @@ exports.parse = function() { } }; -})(); diff --git a/core/modules/parsers/wikiparser/rules/quoteblock.js b/core/modules/parsers/wikiparser/rules/quoteblock.js index 71b689680..3192ef269 100644 --- a/core/modules/parsers/wikiparser/rules/quoteblock.js +++ b/core/modules/parsers/wikiparser/rules/quoteblock.js @@ -29,7 +29,7 @@ Quotes can be quoted by putting more } - indirect through a macro invocation \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -436,5 +436,4 @@ WikiParser.prototype.amendRules = function(type,names) { exports["text/vnd.tiddlywiki"] = WikiParser; -})(); diff --git a/core/modules/parsers/wikiparser/wikirulebase.js b/core/modules/parsers/wikiparser/wikirulebase.js index 8aa960ef7..13a70b67f 100644 --- a/core/modules/parsers/wikiparser/wikirulebase.js +++ b/core/modules/parsers/wikiparser/wikirulebase.js @@ -6,7 +6,7 @@ module-type: global Base class for wiki parser rules \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -36,4 +36,3 @@ WikiRuleBase.prototype.findNextMatch = function(startPos) { exports.WikiRuleBase = WikiRuleBase; -})(); diff --git a/core/modules/pluginswitcher.js b/core/modules/pluginswitcher.js index 2915de95a..c2277f25f 100644 --- a/core/modules/pluginswitcher.js +++ b/core/modules/pluginswitcher.js @@ -6,7 +6,7 @@ module-type: global Manages switching plugins for themes and languages. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -76,4 +76,3 @@ PluginSwitcher.prototype.switchPlugins = function() { exports.PluginSwitcher = PluginSwitcher; -})(); diff --git a/core/modules/saver-handler.js b/core/modules/saver-handler.js index 119c3e67a..bfbe7bcc5 100644 --- a/core/modules/saver-handler.js +++ b/core/modules/saver-handler.js @@ -6,7 +6,7 @@ module-type: global The saver handler tracks changes to the store and handles saving the entire wiki via saver modules. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -209,4 +209,3 @@ SaverHandler.prototype.updateDirtyStatus = function() { exports.SaverHandler = SaverHandler; -})(); diff --git a/core/modules/savers/andtidwiki.js b/core/modules/savers/andtidwiki.js index 9ab405e37..26d8f2227 100644 --- a/core/modules/savers/andtidwiki.js +++ b/core/modules/savers/andtidwiki.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes via the AndTidWiki Android app \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false, netscape: false, Components: false */ @@ -17,27 +17,27 @@ var AndTidWiki = function(wiki) { AndTidWiki.prototype.save = function(text,method,callback,options) { var filename = options && options.variables ? options.variables.filename : null; - if (method === "download") { + if(method === "download") { // Support download - if (window.twi.saveDownload) { + if(window.twi.saveDownload) { try { window.twi.saveDownload(text,filename); } catch(err) { - if (err.message === "Method not found") { + if(err.message === "Method not found") { window.twi.saveDownload(text); } } } else { var link = document.createElement("a"); link.setAttribute("href","data:text/plain," + encodeURIComponent(text)); - if (filename) { + if(filename) { link.setAttribute("download",filename); } document.body.appendChild(link); link.click(); document.body.removeChild(link); } - } else if (window.twi.saveWiki) { + } else if(window.twi.saveWiki) { // Direct save in Tiddloid window.twi.saveWiki(text); } else { @@ -87,4 +87,3 @@ exports.create = function(wiki) { return new AndTidWiki(wiki); }; -})(); diff --git a/core/modules/savers/custom.js b/core/modules/savers/custom.js index 836691204..6a7aba379 100644 --- a/core/modules/savers/custom.js +++ b/core/modules/savers/custom.js @@ -9,7 +9,7 @@ on the parent window (of an iframe). If present, the saver must define and the saver may define priority: number \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -18,7 +18,7 @@ and the saver may define var findSaver = function(window) { try { return window && window.$tw && window.$tw.customSaver; - } catch (err) { + } catch(err) { // Catching the exception is the most reliable way to detect cross-origin iframe errors. // For example, instead of saying that `window.parent.$tw` is undefined, Firefox will throw // Uncaught DOMException: Permission denied to access property "$tw" on cross-origin object @@ -57,4 +57,3 @@ Create an instance of this saver exports.create = function(wiki) { return new CustomSaver(wiki); }; -})(); diff --git a/core/modules/savers/download.js b/core/modules/savers/download.js index 0a1d565ce..9849d9ab0 100644 --- a/core/modules/savers/download.js +++ b/core/modules/savers/download.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes via HTML5's download APIs \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -81,4 +81,3 @@ exports.create = function(wiki) { return new DownloadSaver(wiki); }; -})(); diff --git a/core/modules/savers/fsosaver.js b/core/modules/savers/fsosaver.js index 37224e42a..5d0939212 100644 --- a/core/modules/savers/fsosaver.js +++ b/core/modules/savers/fsosaver.js @@ -9,7 +9,7 @@ Note: Since TiddlyWiki's markup contains the MOTW, the FileSystemObject normally However, if the wiki is loaded as an .HTA file (Windows HTML Applications) then the FSO can be used. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -71,4 +71,3 @@ exports.create = function(wiki) { return new FSOSaver(wiki); }; -})(); diff --git a/core/modules/savers/gitea.js b/core/modules/savers/gitea.js index 826719ee9..38a5827de 100644 --- a/core/modules/savers/gitea.js +++ b/core/modules/savers/gitea.js @@ -6,7 +6,7 @@ module-type: saver Saves wiki by pushing a commit to the gitea \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -83,7 +83,7 @@ GiteaSaver.prototype.save = function(text,method,callback) { callback: function(err,getResponseDataJson,xhr) { if(xhr.status === 404) { callback("Please ensure the branch in the Gitea repo exists"); - }else{ + } else { data["branch"] = branch; self.upload(uri + filename, use_put?"PUT":"POST", headers, data, callback); } @@ -133,4 +133,3 @@ exports.create = function(wiki) { return new GiteaSaver(wiki); }; -})(); diff --git a/core/modules/savers/github.js b/core/modules/savers/github.js index f9b87263d..584932831 100644 --- a/core/modules/savers/github.js +++ b/core/modules/savers/github.js @@ -6,7 +6,7 @@ module-type: saver Saves wiki by pushing a commit to the GitHub v3 REST API \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -116,4 +116,3 @@ exports.create = function(wiki) { return new GitHubSaver(wiki); }; -})(); diff --git a/core/modules/savers/gitlab.js b/core/modules/savers/gitlab.js index 243aab8a5..1ff419f5b 100644 --- a/core/modules/savers/gitlab.js +++ b/core/modules/savers/gitlab.js @@ -6,7 +6,7 @@ module-type: saver Saves wiki by pushing a commit to the GitLab REST API \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: true */ @@ -114,4 +114,3 @@ exports.create = function(wiki) { return new GitLabSaver(wiki); }; -})(); diff --git a/core/modules/savers/manualdownload.js b/core/modules/savers/manualdownload.js index af9bcd743..2d5e12260 100644 --- a/core/modules/savers/manualdownload.js +++ b/core/modules/savers/manualdownload.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes via HTML5's download APIs \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -53,4 +53,3 @@ exports.create = function(wiki) { return new ManualDownloadSaver(wiki); }; -})(); diff --git a/core/modules/savers/msdownload.js b/core/modules/savers/msdownload.js index 6cb55c334..5fc52478f 100644 --- a/core/modules/savers/msdownload.js +++ b/core/modules/savers/msdownload.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes via window.navigator.msSaveBlob() \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -56,4 +56,3 @@ exports.create = function(wiki) { return new MsDownloadSaver(wiki); }; -})(); diff --git a/core/modules/savers/put.js b/core/modules/savers/put.js index de9ba9465..0493343fb 100644 --- a/core/modules/savers/put.js +++ b/core/modules/savers/put.js @@ -9,7 +9,7 @@ Works with any server which accepts a PUT request to the current URL, such as a WebDAV server. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -97,7 +97,7 @@ PutSaver.prototype.save = function(text,method,callback) { } else if(status === 403) { // permission denied errorMsg = $tw.language.getString("Error/PutForbidden"); } - if (xhr.responseText) { + if(xhr.responseText) { // treat any server response like a plain text error explanation errorMsg = errorMsg + "\n\n" + xhr.responseText; } @@ -137,4 +137,3 @@ exports.create = function(wiki) { return new PutSaver(wiki); }; -})(); diff --git a/core/modules/savers/tiddlyfox.js b/core/modules/savers/tiddlyfox.js index 81b373d42..0a6a77fe0 100644 --- a/core/modules/savers/tiddlyfox.js +++ b/core/modules/savers/tiddlyfox.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes via the TiddlyFox file extension \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false, netscape: false, Components: false */ @@ -83,4 +83,3 @@ exports.create = function(wiki) { return new TiddlyFoxSaver(wiki); }; -})(); diff --git a/core/modules/savers/tiddlyie.js b/core/modules/savers/tiddlyie.js index d6d49db45..60551fd6f 100644 --- a/core/modules/savers/tiddlyie.js +++ b/core/modules/savers/tiddlyie.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes via Internet Explorer BHO extenion (TiddlyIE) \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -68,4 +68,3 @@ exports.create = function(wiki) { return new TiddlyIESaver(wiki); }; -})(); diff --git a/core/modules/savers/twedit.js b/core/modules/savers/twedit.js index ec125bf94..54e1bc69d 100644 --- a/core/modules/savers/twedit.js +++ b/core/modules/savers/twedit.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes via the TWEdit iOS app \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false, netscape: false, Components: false */ @@ -88,4 +88,3 @@ if($tw.browser) { window.version = {title: "TiddlyWiki"}; } -})(); diff --git a/core/modules/savers/upload.js b/core/modules/savers/upload.js index ade545000..e78223ed3 100644 --- a/core/modules/savers/upload.js +++ b/core/modules/savers/upload.js @@ -8,7 +8,7 @@ Handles saving changes via upload to a server. Designed to be compatible with BidiX's UploadPlugin at http://tiddlywiki.bidix.info/#UploadPlugin \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -31,7 +31,7 @@ UploadSaver.prototype.save = function(text,method,callback) { uploadWithUrlOnly = this.wiki.getTextReference("$:/UploadWithUrlOnly") || "no", url = this.wiki.getTextReference("$:/UploadURL"); // Bail out if we don't have the bits we need - if (uploadWithUrlOnly === "yes") { + if(uploadWithUrlOnly === "yes") { // The url is good enough. No need for a username and password. // Assume the server uses some other kind of auth mechanism. if(!url || url.toString().trim() === "") { @@ -108,4 +108,3 @@ exports.create = function(wiki) { return new UploadSaver(wiki); }; -})(); diff --git a/core/modules/server/authenticators/basic.js b/core/modules/server/authenticators/basic.js index cd528c485..e469b5d96 100644 --- a/core/modules/server/authenticators/basic.js +++ b/core/modules/server/authenticators/basic.js @@ -6,7 +6,7 @@ module-type: authenticator Authenticator for WWW basic authentication \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -91,4 +91,3 @@ BasicAuthenticator.prototype.authenticateRequest = function(request,response,sta exports.AuthenticatorClass = BasicAuthenticator; -})(); diff --git a/core/modules/server/authenticators/header.js b/core/modules/server/authenticators/header.js index 9d9990d31..32a9ddfe1 100644 --- a/core/modules/server/authenticators/header.js +++ b/core/modules/server/authenticators/header.js @@ -6,7 +6,7 @@ module-type: authenticator Authenticator for trusted header authentication \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -44,4 +44,3 @@ HeaderAuthenticator.prototype.authenticateRequest = function(request,response,st exports.AuthenticatorClass = HeaderAuthenticator; -})(); diff --git a/core/modules/server/server.js b/core/modules/server/server.js index 258ddfa31..5980b35b0 100644 --- a/core/modules/server/server.js +++ b/core/modules/server/server.js @@ -6,7 +6,7 @@ module-type: library Serve tiddlers over http \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -340,8 +340,8 @@ Server.prototype.listen = function(port,host,prefix) { } // Warn if required plugins are missing var missing = []; - for (var index=0; index= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F || @@ -64,7 +64,7 @@ exports.escapeCSS = (function() { continue; } - if ( + if( // If the character is the first character and is a `-` (U+002D), and // there is no second character, […] index == 0 && @@ -79,7 +79,7 @@ exports.escapeCSS = (function() { // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to // U+005A), or [a-z] (U+0061 to U+007A), […] - if ( + if( codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || @@ -100,5 +100,3 @@ exports.escapeCSS = (function() { return result; }; })(); - -})(); diff --git a/core/modules/utils/fakedom.js b/core/modules/utils/fakedom.js index d28161ac6..e9c3b81e1 100755 --- a/core/modules/utils/fakedom.js +++ b/core/modules/utils/fakedom.js @@ -6,7 +6,7 @@ module-type: global A barebones implementation of DOM interfaces needed by the rendering mechanism. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -322,4 +322,3 @@ var document = { exports.fakeDocument = document; -})(); diff --git a/core/modules/utils/filesystem.js b/core/modules/utils/filesystem.js index 1ba34323e..2ab19d18d 100644 --- a/core/modules/utils/filesystem.js +++ b/core/modules/utils/filesystem.js @@ -6,7 +6,7 @@ module-type: utils-node File system utilities \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -86,7 +86,7 @@ exports.copyFile = function(srcPath,dstPath) { dstFile = fs.openSync(dstPath,"w"), bytesRead = 1, pos = 0; - while (bytesRead > 0) { + while(bytesRead > 0) { bytesRead = fs.readSync(srcFile,fileBuffer,0,FILE_BUFFER_LENGTH,pos); fs.writeSync(dstFile,fileBuffer,0,bytesRead); pos += bytesRead; @@ -258,7 +258,7 @@ exports.generateTiddlerFileInfo = function(tiddler,options) { // Overriding to the .tid extension needs special handling fileInfo.type = "application/x-tiddler"; fileInfo.hasMetaFile = false; - } else if (metaExt === ".json") { + } else if(metaExt === ".json") { // Overriding to the .json extension needs special handling fileInfo.type = "application/json"; fileInfo.hasMetaFile = false; @@ -526,7 +526,7 @@ exports.cleanupTiddlerFiles = function(options,callback) { if(adaptorInfo.filepath && bootInfo.filepath && adaptorInfo.filepath !== bootInfo.filepath) { $tw.utils.deleteTiddlerFile(adaptorInfo,function(err) { 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 previous file on disk, should fail gracefully $tw.syncer.displayError("Server desynchronized. Error cleaning up previous file for tiddler: \""+title+"\"",err); return callback(null,bootInfo); @@ -541,4 +541,3 @@ exports.cleanupTiddlerFiles = function(options,callback) { } }; -})(); diff --git a/core/modules/utils/linked-list.js b/core/modules/utils/linked-list.js index 917069d16..bf351e442 100644 --- a/core/modules/utils/linked-list.js +++ b/core/modules/utils/linked-list.js @@ -1,13 +1,12 @@ /*\ -module-type: utils title: $:/core/modules/utils/linkedlist.js type: application/javascript +module-type: utils This is a doubly-linked indexed list intended for manipulation, particularly pushTop, which it does with significantly better performance than an array. \*/ -(function(){ function LinkedList() { this.clear(); @@ -58,7 +57,7 @@ LinkedList.prototype.push = function(/* values */) { LinkedList.prototype.pushTop = function(value) { var t; if($tw.utils.isArray(value)) { - for (t=0; t self.measures[b].time) { return -1; - } else if (self.measures[a].time < self.measures[b].time) { + } else if(self.measures[a].time < self.measures[b].time) { return + 1; } else { return 0; @@ -88,4 +88,3 @@ Performance.prototype.measure = function(name,fn) { exports.Performance = Performance; -})(); diff --git a/core/modules/utils/pluginmaker.js b/core/modules/utils/pluginmaker.js index e7426d62b..c90fd569d 100644 --- a/core/modules/utils/pluginmaker.js +++ b/core/modules/utils/pluginmaker.js @@ -6,7 +6,7 @@ module-type: utils A quick and dirty way to pack up plugins within the browser. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -76,4 +76,3 @@ exports.repackPlugin = function(title,additionalTiddlers,excludeTiddlers) { return "Plugin " + title + " successfully saved"; }; -})(); diff --git a/core/modules/utils/transliterate.js b/core/modules/utils/transliterate.js index 4e91de234..0409891b0 100644 --- a/core/modules/utils/transliterate.js +++ b/core/modules/utils/transliterate.js @@ -6,7 +6,7 @@ module-type: utils Transliteration static utility functions. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -929,4 +929,3 @@ exports.transliterateToSafeASCII = function(str) { }); }; -})(); diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index aaf83ae74..8b2315e5d 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -6,7 +6,7 @@ module-type: utils Various static utility functions. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -899,7 +899,7 @@ IE does not have sign function */ exports.sign = Math.sign || function(x) { x = +x; // convert to a number - if (x === 0 || isNaN(x)) { + if(x === 0 || isNaN(x)) { return x; } return x > 0 ? 1 : -1; @@ -912,7 +912,7 @@ exports.strEndsWith = function(str,ending,position) { if(str.endsWith) { return str.endsWith(ending,position); } else { - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > str.length) { + if(typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > str.length) { position = str.length; } position -= ending.length; @@ -1005,4 +1005,3 @@ exports.makeCompareFunction = function(type,options) { return (types[type] || types[options.defaultType] || types.number); }; -})(); diff --git a/core/modules/widgets/action-confirm.js b/core/modules/widgets/action-confirm.js index 68d8c447e..233c63008 100644 --- a/core/modules/widgets/action-confirm.js +++ b/core/modules/widgets/action-confirm.js @@ -5,7 +5,7 @@ type: application/javascript module-type: widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -75,4 +75,3 @@ ConfirmWidget.prototype.allowActionPropagation = function() { exports["action-confirm"] = ConfirmWidget; -})(); diff --git a/core/modules/widgets/action-createtiddler.js b/core/modules/widgets/action-createtiddler.js index b49eaad20..94cb62d4c 100644 --- a/core/modules/widgets/action-createtiddler.js +++ b/core/modules/widgets/action-createtiddler.js @@ -6,7 +6,7 @@ module-type: widget Action widget to create a new tiddler with a unique name and specified fields. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw:false, require:false, exports:false */ @@ -82,14 +82,14 @@ CreateTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) { } if(this.hasBase && this.actionOverwrite === "no") { title = this.wiki.generateNewTitle(this.actionBaseTitle); - } else if (this.hasBase && this.actionOverwrite === "yes") { + } else if(this.hasBase && this.actionOverwrite === "yes") { title = this.actionBaseTitle } // NO $basetitle BUT $template parameter is available // the title MUST be unique, otherwise the template would be overwritten - if (!this.hasBase && this.useTemplate) { + if(!this.hasBase && this.useTemplate) { title = this.wiki.generateNewTitle(this.actionTemplate); - } else if (!this.hasBase && !this.useTemplate) { + } else if(!this.hasBase && !this.useTemplate) { // If no $basetitle and no $template then use initial title title = this.wiki.generateNewTitle(title); } @@ -110,4 +110,3 @@ CreateTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) { exports["action-createtiddler"] = CreateTiddlerWidget; -})(); diff --git a/core/modules/widgets/action-deletefield.js b/core/modules/widgets/action-deletefield.js index 54068471e..1e6adb416 100644 --- a/core/modules/widgets/action-deletefield.js +++ b/core/modules/widgets/action-deletefield.js @@ -6,7 +6,7 @@ module-type: widget Action widget to delete fields of a tiddler. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -81,4 +81,3 @@ DeleteFieldWidget.prototype.invokeAction = function(triggeringWidget,event) { exports["action-deletefield"] = DeleteFieldWidget; -})(); diff --git a/core/modules/widgets/action-deletetiddler.js b/core/modules/widgets/action-deletetiddler.js index 816f9f55e..cd83546f6 100644 --- a/core/modules/widgets/action-deletetiddler.js +++ b/core/modules/widgets/action-deletetiddler.js @@ -6,7 +6,7 @@ module-type: widget Action widget to delete a tiddler. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -70,4 +70,3 @@ DeleteTiddlerWidget.prototype.invokeAction = function(triggeringWidget,event) { exports["action-deletetiddler"] = DeleteTiddlerWidget; -})(); diff --git a/core/modules/widgets/action-listops.js b/core/modules/widgets/action-listops.js index b3d93a657..9787a7cf7 100644 --- a/core/modules/widgets/action-listops.js +++ b/core/modules/widgets/action-listops.js @@ -6,7 +6,6 @@ module-type: widget Action widget to apply list operations to any tiddler field (defaults to the 'list' field of the current tiddler) \*/ -(function() { /*jslint node: true, browser: true */ /*global $tw: false */ @@ -87,5 +86,3 @@ ActionListopsWidget.prototype.invokeAction = function(triggeringWidget, }; exports["action-listops"] = ActionListopsWidget; - -})(); diff --git a/core/modules/widgets/action-log.js b/core/modules/widgets/action-log.js index fc8412006..40734e0bb 100644 --- a/core/modules/widgets/action-log.js +++ b/core/modules/widgets/action-log.js @@ -6,7 +6,7 @@ module-type: widget Action widget to log debug messages \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -90,4 +90,3 @@ LogWidget.prototype.log = function() { exports["action-log"] = LogWidget; -})(); diff --git a/core/modules/widgets/action-navigate.js b/core/modules/widgets/action-navigate.js index 2df6a011f..1b06ee31c 100644 --- a/core/modules/widgets/action-navigate.js +++ b/core/modules/widgets/action-navigate.js @@ -6,7 +6,7 @@ module-type: widget Action widget to navigate to a tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -88,4 +88,3 @@ NavigateWidget.prototype.invokeAction = function(triggeringWidget,event) { exports["action-navigate"] = NavigateWidget; -})(); diff --git a/core/modules/widgets/action-popup.js b/core/modules/widgets/action-popup.js index a3ce20165..35ad4800a 100644 --- a/core/modules/widgets/action-popup.js +++ b/core/modules/widgets/action-popup.js @@ -6,7 +6,7 @@ module-type: widget Action widget to trigger a popup. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -82,4 +82,3 @@ ActionPopupWidget.prototype.invokeAction = function(triggeringWidget,event) { exports["action-popup"] = ActionPopupWidget; -})(); diff --git a/core/modules/widgets/action-sendmessage.js b/core/modules/widgets/action-sendmessage.js index d1e800c91..493ccddb2 100644 --- a/core/modules/widgets/action-sendmessage.js +++ b/core/modules/widgets/action-sendmessage.js @@ -6,7 +6,7 @@ module-type: widget Action widget to send a message \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -96,4 +96,3 @@ SendMessageWidget.prototype.invokeAction = function(triggeringWidget,event) { exports["action-sendmessage"] = SendMessageWidget; -})(); diff --git a/core/modules/widgets/action-setfield.js b/core/modules/widgets/action-setfield.js index f853484cd..308bbd396 100644 --- a/core/modules/widgets/action-setfield.js +++ b/core/modules/widgets/action-setfield.js @@ -6,7 +6,7 @@ module-type: widget Action widget to set a single field or index on a tiddler. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -72,4 +72,3 @@ SetFieldWidget.prototype.invokeAction = function(triggeringWidget,event) { exports["action-setfield"] = SetFieldWidget; -})(); diff --git a/core/modules/widgets/action-setmultiplefields.js b/core/modules/widgets/action-setmultiplefields.js index 174c72889..b2adb00dd 100644 --- a/core/modules/widgets/action-setmultiplefields.js +++ b/core/modules/widgets/action-setmultiplefields.js @@ -6,7 +6,7 @@ module-type: widget Action widget to set multiple fields or indexes on a tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -82,5 +82,4 @@ SetMultipleFieldsWidget.prototype.invokeAction = function(triggeringWidget,event exports["action-setmultiplefields"] = SetMultipleFieldsWidget; -})(); \ No newline at end of file diff --git a/core/modules/widgets/browse.js b/core/modules/widgets/browse.js index de3c91fb8..73b0dd059 100644 --- a/core/modules/widgets/browse.js +++ b/core/modules/widgets/browse.js @@ -6,7 +6,7 @@ module-type: widget Browse widget for browsing for files to import \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -100,4 +100,3 @@ BrowseWidget.prototype.refresh = function(changedTiddlers) { exports.browse = BrowseWidget; -})(); diff --git a/core/modules/widgets/button.js b/core/modules/widgets/button.js index a724d8448..e3d5e484e 100644 --- a/core/modules/widgets/button.js +++ b/core/modules/widgets/button.js @@ -6,7 +6,7 @@ module-type: widget Button widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -69,7 +69,7 @@ ButtonWidget.prototype.render = function(parent,nextSibling) { if(this["aria-label"]) { domNode.setAttribute("aria-label",this["aria-label"]); } - if (this.role) { + if(this.role) { domNode.setAttribute("role", this.role); } if(this.popup || this.popupTitle) { @@ -268,4 +268,3 @@ ButtonWidget.prototype.refresh = function(changedTiddlers) { exports.button = ButtonWidget; -})(); diff --git a/core/modules/widgets/checkbox.js b/core/modules/widgets/checkbox.js index e2df3185c..4d756dbe8 100644 --- a/core/modules/widgets/checkbox.js +++ b/core/modules/widgets/checkbox.js @@ -6,7 +6,7 @@ module-type: widget Checkbox widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -116,7 +116,7 @@ CheckboxWidget.prototype.getValue = function() { } else { list = $tw.utils.parseStringArray(this.checkboxDefault || "") || []; } - } else if (this.checkboxListIndex) { + } else if(this.checkboxListIndex) { list = $tw.utils.parseStringArray(this.wiki.extractTiddlerDataItem(tiddler,this.checkboxListIndex,this.checkboxDefault || "")) || []; } else { list = this.wiki.filterTiddlers(this.checkboxFilter,this) || []; @@ -329,4 +329,3 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) { exports.checkbox = CheckboxWidget; -})(); diff --git a/core/modules/widgets/codeblock.js b/core/modules/widgets/codeblock.js index aa7910cf8..63664dce9 100644 --- a/core/modules/widgets/codeblock.js +++ b/core/modules/widgets/codeblock.js @@ -6,7 +6,7 @@ module-type: widget Code block node widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -63,4 +63,3 @@ CodeBlockWidget.prototype.refresh = function(changedTiddlers) { exports.codeblock = CodeBlockWidget; -})(); diff --git a/core/modules/widgets/count.js b/core/modules/widgets/count.js index b7ee45452..c827df972 100644 --- a/core/modules/widgets/count.js +++ b/core/modules/widgets/count.js @@ -6,7 +6,7 @@ module-type: widget Count widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -69,4 +69,3 @@ CountWidget.prototype.refresh = function(changedTiddlers) { exports.count = CountWidget; -})(); diff --git a/core/modules/widgets/diff-text.js b/core/modules/widgets/diff-text.js index 47a47e259..ecda352cb 100644 --- a/core/modules/widgets/diff-text.js +++ b/core/modules/widgets/diff-text.js @@ -6,7 +6,7 @@ module-type: widget Widget to display a diff between two texts \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -145,4 +145,3 @@ DiffTextWidget.prototype.refresh = function(changedTiddlers) { exports["diff-text"] = DiffTextWidget; -})(); diff --git a/core/modules/widgets/draggable.js b/core/modules/widgets/draggable.js index f759ab121..f374dbc45 100644 --- a/core/modules/widgets/draggable.js +++ b/core/modules/widgets/draggable.js @@ -6,7 +6,7 @@ module-type: widget Draggable widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -120,5 +120,3 @@ DraggableWidget.prototype.refresh = function(changedTiddlers) { }; exports.draggable = DraggableWidget; - -})(); \ No newline at end of file diff --git a/core/modules/widgets/droppable.js b/core/modules/widgets/droppable.js index 104503b25..a4c382deb 100644 --- a/core/modules/widgets/droppable.js +++ b/core/modules/widgets/droppable.js @@ -6,7 +6,7 @@ module-type: widget Droppable widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -173,5 +173,3 @@ DroppableWidget.prototype.refresh = function(changedTiddlers) { }; exports.droppable = DroppableWidget; - -})(); \ No newline at end of file diff --git a/core/modules/widgets/dropzone.js b/core/modules/widgets/dropzone.js index 043b2557f..16f48d1ad 100644 --- a/core/modules/widgets/dropzone.js +++ b/core/modules/widgets/dropzone.js @@ -6,7 +6,7 @@ module-type: widget Dropzone widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -329,4 +329,3 @@ DropZoneWidget.prototype.refresh = function(changedTiddlers) { exports.dropzone = DropZoneWidget; -})(); diff --git a/core/modules/widgets/edit-binary.js b/core/modules/widgets/edit-binary.js index a4a18f63d..2e3bf6d89 100644 --- a/core/modules/widgets/edit-binary.js +++ b/core/modules/widgets/edit-binary.js @@ -6,7 +6,7 @@ module-type: widget Edit-binary widget; placeholder for editing binary tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -104,4 +104,3 @@ EditBinaryWidget.prototype.refresh = function(changedTiddlers) { exports["edit-binary"] = EditBinaryWidget; -})(); diff --git a/core/modules/widgets/edit-bitmap.js b/core/modules/widgets/edit-bitmap.js index 5065127d8..190fb34b1 100644 --- a/core/modules/widgets/edit-bitmap.js +++ b/core/modules/widgets/edit-bitmap.js @@ -6,7 +6,7 @@ module-type: widget Edit-bitmap widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -340,4 +340,3 @@ EditBitmapWidget.prototype.saveChanges = function() { exports["edit-bitmap"] = EditBitmapWidget; -})(); diff --git a/core/modules/widgets/edit-shortcut.js b/core/modules/widgets/edit-shortcut.js index 31d81b6b8..3839c3b41 100644 --- a/core/modules/widgets/edit-shortcut.js +++ b/core/modules/widgets/edit-shortcut.js @@ -6,7 +6,7 @@ module-type: widget Widget to display an editable keyboard shortcut \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -151,4 +151,3 @@ EditShortcutWidget.prototype.refresh = function(changedTiddlers) { exports["edit-shortcut"] = EditShortcutWidget; -})(); diff --git a/core/modules/widgets/edit-text.js b/core/modules/widgets/edit-text.js index bc7b77490..4f4a1ac41 100644 --- a/core/modules/widgets/edit-text.js +++ b/core/modules/widgets/edit-text.js @@ -6,7 +6,7 @@ module-type: widget Edit-text widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -18,4 +18,3 @@ var editTextWidgetFactory = require("$:/core/modules/editor/factory.js").editTex exports["edit-text"] = editTextWidgetFactory(FramedEngine,SimpleEngine); -})(); diff --git a/core/modules/widgets/edit.js b/core/modules/widgets/edit.js index e7bd49b93..f31c613f1 100644 --- a/core/modules/widgets/edit.js +++ b/core/modules/widgets/edit.js @@ -6,7 +6,7 @@ module-type: widget Edit widget is a meta-widget chooses the appropriate actual editting widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -100,4 +100,3 @@ EditWidget.prototype.refresh = function(changedTiddlers) { exports.edit = EditWidget; -})(); diff --git a/core/modules/widgets/element.js b/core/modules/widgets/element.js index 716886e5b..16725715c 100755 --- a/core/modules/widgets/element.js +++ b/core/modules/widgets/element.js @@ -6,7 +6,7 @@ module-type: widget Element widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -102,4 +102,3 @@ ElementWidget.prototype.refresh = function(changedTiddlers) { exports.element = ElementWidget; -})(); diff --git a/core/modules/widgets/encrypt.js b/core/modules/widgets/encrypt.js index 28dfdaf78..6149595c9 100644 --- a/core/modules/widgets/encrypt.js +++ b/core/modules/widgets/encrypt.js @@ -6,7 +6,7 @@ module-type: widget Encrypt widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -66,4 +66,3 @@ EncryptWidget.prototype.refresh = function(changedTiddlers) { exports.encrypt = EncryptWidget; -})(); diff --git a/core/modules/widgets/entity.js b/core/modules/widgets/entity.js index 6f1a66fed..7cbfbea85 100755 --- a/core/modules/widgets/entity.js +++ b/core/modules/widgets/entity.js @@ -6,7 +6,7 @@ module-type: widget HTML entity widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -57,4 +57,3 @@ EntityWidget.prototype.refresh = function(changedTiddlers) { exports.entity = EntityWidget; -})(); diff --git a/core/modules/widgets/error.js b/core/modules/widgets/error.js index 6a4a607f1..25391ec4f 100644 --- a/core/modules/widgets/error.js +++ b/core/modules/widgets/error.js @@ -6,7 +6,7 @@ module-type: widget Error widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -60,4 +60,3 @@ ErrorWidget.prototype.refresh = function(changedTiddlers) { exports.error = ErrorWidget; -})(); diff --git a/core/modules/widgets/eventcatcher.js b/core/modules/widgets/eventcatcher.js index dad9503c6..4129cba22 100644 --- a/core/modules/widgets/eventcatcher.js +++ b/core/modules/widgets/eventcatcher.js @@ -6,7 +6,7 @@ module-type: widget Event handler widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -156,4 +156,3 @@ EventWidget.prototype.refresh = function(changedTiddlers) { exports.eventcatcher = EventWidget; -})(); diff --git a/core/modules/widgets/fieldmangler.js b/core/modules/widgets/fieldmangler.js index 5a7e43659..0622b4e92 100644 --- a/core/modules/widgets/fieldmangler.js +++ b/core/modules/widgets/fieldmangler.js @@ -6,7 +6,7 @@ module-type: widget Field mangler widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -131,4 +131,3 @@ FieldManglerWidget.prototype.handleAddTagEvent = function(event) { exports.fieldmangler = FieldManglerWidget; -})(); diff --git a/core/modules/widgets/fields.js b/core/modules/widgets/fields.js index 0e32443ad..f63ed403a 100755 --- a/core/modules/widgets/fields.js +++ b/core/modules/widgets/fields.js @@ -6,7 +6,7 @@ module-type: widget Fields widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -59,7 +59,7 @@ FieldsWidget.prototype.execute = function() { var text = []; if(this.template && tiddler) { var fields = []; - if (includeArr) { // Include takes precedence + if(includeArr) { // Include takes precedence for(var i=0; i\n', type: 'text/html' } ]); +describe("deserializer tests", function() { - executeTestCase("dezerializer test data case 2",[ { text: '\n\n\n\t\n\tTest Data\n\n\n\n\n', type: 'text/html' } ]); + function executeTestCase(title,expectedOutput) { + it("test case " + title, function() { + var tiddler = $tw.wiki.getTiddler(title); + expect($tw.wiki.deserializeTiddlers(tiddler.fields.type,tiddler.fields.text)).toEqual(expectedOutput); + }); + } - executeTestCase("dezerializer test data case 3",[ { title: 'Hello "There"', text: 'Abacus', type: 'text/vnd.tiddlywiki' } ]); + executeTestCase("dezerializer test data case 1",[ { text: '\n', type: 'text/html' } ]); - executeTestCase("dezerializer test data case 4",[ { title: 'Hello "There"', text: 'Abacus', type: 'text/vnd.tiddlywiki' }, { title: 'Hello "There"', text: 'Calculator'} ]); + executeTestCase("dezerializer test data case 2",[ { text: '\n\n\n\t\n\tTest Data\n\n\n\n\n', type: 'text/html' } ]); - executeTestCase("dezerializer test data case 5",[ { title: 'Hello "There"', text: 'Abacus', type: 'text/vnd.tiddlywiki' }, { title: 'Hello "There"', text: 'Calculator'} , { title: 'Hello "There"', text: 'Protractor'} ]); - - }); - - })(); - \ No newline at end of file + executeTestCase("dezerializer test data case 3",[ { title: 'Hello "There"', text: 'Abacus', type: 'text/vnd.tiddlywiki' } ]); + + executeTestCase("dezerializer test data case 4",[ { title: 'Hello "There"', text: 'Abacus', type: 'text/vnd.tiddlywiki' }, { title: 'Hello "There"', text: 'Calculator'} ]); + + executeTestCase("dezerializer test data case 5",[ { title: 'Hello "There"', text: 'Abacus', type: 'text/vnd.tiddlywiki' }, { title: 'Hello "There"', text: 'Calculator'} , { title: 'Hello "There"', text: 'Protractor'} ]); + +}); diff --git a/editions/test/tiddlers/tests/test-filters.js b/editions/test/tiddlers/tests/test-filters.js index 811bbaa55..ebccaf90a 100644 --- a/editions/test/tiddlers/tests/test-filters.js +++ b/editions/test/tiddlers/tests/test-filters.js @@ -6,1136 +6,1133 @@ tags: [[$:/tags/test-spec]] Tests the filtering mechanism. \*/ -(function(){ - /* jslint node: true, browser: true */ - /* eslint-env node, browser, jasmine */ - /* eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/ - /* global $tw, require */ - "use strict"; - - describe("Filter tests", function() { - - // Test filter parsing - it("should parse new-style rich operator suffixes", function() { - expect($tw.wiki.parseFilter("[search:: four, , five,, six [operand]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'search', suffix : ': four, , five,, six ', suffixes : [ [ ], [ 'four', 'five', 'six' ] ], operands: [ { text:'operand' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[search: one, two ,three :[operand]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'search', suffix : ' one, two ,three :', suffixes : [ [ 'one', 'two', 'three' ], [ ] ], operands: [ { text:'operand' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[search: one, two ,three :[operand]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'search', suffix : ' one, two ,three :', suffixes : [ [ 'one', 'two', 'three' ], [ ] ], operands: [ { text:'operand' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[search: one, two ,three : four, , five,, six [operand]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'search', suffix : ' one, two ,three : four, , five,, six ', suffixes : [ [ 'one', 'two', 'three' ], [ 'four', 'five', 'six' ] ], operands: [ { text:'operand' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[search: , : [operand]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'search', suffix : ' , : ', suffixes : [ [ ], [ ] ], operands: [ { text:'operand' } ] } ] } ] - ); - }); - - - it("should parse multiple operands for operators", function() { - expect($tw.wiki.parseFilter("[search: , : [operand],[operand2]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'search', suffix : ' , : ', suffixes : [ [ ], [ ] ], operands: [ { text:'operand' }, { text:'operand2' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[search: , : [oper,and],[operand2]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'search', suffix : ' , : ', suffixes : [ [ ], [ ] ], operands: [ { text:'oper,and' }, { text:'operand2' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[[GettingStarted]replace:[operand],[operand2]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'title', operands: [ { text:'GettingStarted' } ] }, { operator : 'replace', suffix : '', suffixes : [[]], operands: [ { text:'operand' }, { text:'operand2' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[[GettingStarted]replace[operand],[operand2]split[-]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'title', operands: [{ text:'GettingStarted' }] }, { operator : 'replace', operands: [{ text:'operand' }, { text:'operand2' }] }, { operator : 'split', operands: [ { text:'-' } ] } ] } ] - ); - expect($tw.wiki.parseFilter("[[GettingStarted]replace[operand],[operand2]split[-]split2[a],[b]]")).toEqual( - [ { prefix : '', operators : [ { operator : 'title', operands: [{ text:'GettingStarted' }] }, { operator : 'replace', operands: [ { text:'operand' }, { text:'operand2' } ] }, { operator : 'split', operands: [ {text:'-'} ] }, { operator : 'split2', operands: [ { text:'a' }, { text: 'b' }] } ] } ] - ); - expect($tw.wiki.parseFilter("[[GettingStarted]replace[operand],[operand2]split[-]split2[a],,{c}]")).toEqual( - [ { prefix : '', operators : [ { operator : 'title', operands: [{ text:'GettingStarted' }] }, { operator : 'replace', operands: [ { text:'operand' }, { text:'operand2' } ] }, { operator : 'split', operands: [ {text:'-'} ] }, { operator : 'split2', operands: [ { text:'a' }, { variable: true, text: 'b' }, { indirect: true, text: 'c' }] } ] } ] - ); - }); - - describe("With tiddlers in the store unsorted",function() { - testWithAndWithoutIndexers(); - }); - describe("With tiddlers in the store sorted ascending",function() { - testWithAndWithoutIndexers({sort: "ascending"}); - }); - describe("With tiddlers in the store sorted descending",function() { - testWithAndWithoutIndexers({sort: "descending"}); - }); +/* jslint node: true, browser: true */ +/* eslint-env node, browser, jasmine */ +/* eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/ +/* global $tw, require */ +"use strict"; - function testWithAndWithoutIndexers(options) { - describe("With no indexers", function() { - var wiki = setupWiki(Object.assign({},options,{enableIndexers: []})); - it("should not create indexes when requested not to",function() { - expect(wiki.getIndexer("FieldIndexer")).toBe(null); - }); - runTests(wiki); - }); - - describe("With all indexers", function() { - var wiki = setupWiki(options); - if(wiki.getIndexer("FieldIndexer")) { - wiki.getIndexer("FieldIndexer").setMaxIndexedValueLength(8); // Note that JoeBloggs is 9, and John is 5 - } - runTests(wiki); - }); - } - - function setupWiki(wikiOptions) { - wikiOptions = wikiOptions || {}; - // Create a wiki - var wiki = new $tw.Wiki(wikiOptions); - // Add a plugin containing some shadow tiddlers - var shadowTiddlers = { - tiddlers: { - "$:/TiddlerFive": { - title: "$:/TiddlerFive", - text: "Everything in federation", - tags: ["two"] - }, - "TiddlerSix": { - title: "TiddlerSix", - text: "Missing inaction from [[TiddlerOne]]", - filter: "[[one]] [[a a]] [subfilter{hasList!!list}]", - tags: [] - }, - "TiddlerSeventh": { - title: "TiddlerSeventh", - text: "", - list: "[[TiddlerOne]] [[Tiddler Three]] [[a fourth tiddler]] [[MissingTiddler]]", - tags: ["one"] - }, - "Tiddler8": { - title: "Tiddler8", - text: "Tidd", - tags: ["one"], - "test-field": "JoeBloggs" - } - } - }; - var tiddlers = [{ - title: "$:/ShadowPlugin", - text: JSON.stringify(shadowTiddlers), - "plugin-type": "plugin", - type: "application/json" - },{ - title: "TiddlerOne", - text: "The quick brown fox in $:/TiddlerTwo", - tags: ["one"], - cost: "123", - value: "120", - slug: "tiddler-one", - authors: "Joe Bloggs", - modifier: "JoeBloggs", - modified: "201304152222" - },{ - title: "$:/TiddlerTwo", - text: "The rain in Spain\nfalls mainly on the plain and [[a fourth tiddler]]", - tags: ["two"], - cost: "42", - value: "190", - slug: "tiddler-two", - authors: "[[John Doe]]", - modifier: "John", - modified: "201304152211" - },{ - title: "Tiddler Three", - text: "The speed of sound in light\n\nThere is no [[TiddlerZero]] but [[TiddlerSix]]", - tags: ["one","two"], - cost: "56", - value: "80", - modifier: "John", - modified: "201304162202" - },{ - title: "a fourth tiddler", - text: "The quality of mercy is not drained by [[Tiddler Three]]", - tags: [], - cost: "82", - value: "72", - empty: "not", - modifier: "John" - },{ - title: "one", - text: "This is the text of tiddler [[one]]", - list: "[[Tiddler Three]] [[TiddlerOne]]", - empty: "", - modifier: "John" - },{ - title: "hasList", - text: "This is the text of tiddler [[hasList]]", - list: "[[Tiddler Three]] [[TiddlerOne]]", - modifier: "PMario" - },{ - title: "has filter", - text: "This is the text of tiddler [[has filter]]", - filter: "[[Tiddler Three]] [[TiddlerOne]] [subfilter{hasList!!list}]", - modifier: "PMario" - },{ - title: "filter regexp test", - text: "Those strings have been used to create the `regexp = /[+|\-|~]?([[](?:[^\]])*\]+)|([+|-|~|\S]\S*)/;`", - filter: "+aaa -bbb ~ccc aaaaaabbbbbbbbaa \"bb'b\" 'cc\"c' [[abc]] [[tiddler with spaces]] [is[test]] [is[te st]] a s df [enlist] +[enlist:raw{test with spaces}] [enlist:raw{test with spaces}] [[a a]] [[ ] [ ]] [[ [hugo]] [subfilter{Story/Tower of Hanoi/A-C Sequence}]", - modifier: "PMario" - }]; - // Load the tiddlers in the required order - var fnCompare; - switch(wikiOptions.sort) { - case "ascending": - fnCompare = function(a,b) { - if(a.title < b.title) { - return -1; - } else if(a.title > b.title) { - return +1; - } else { - return 0; - } - }; - break; - case "descending": - fnCompare = function(a,b) { - if(a.title < b.title) { - return +1; - } else if(a.title > b.title) { - return -1; - } else { - return 0; - } - }; - break; - } - if(fnCompare) { - tiddlers.sort(fnCompare); - } - wiki.addTiddlers(tiddlers); - // Unpack plugin tiddlers - wiki.readPluginInfo(); - wiki.registerPluginTiddlers("plugin"); - wiki.unpackPluginTiddlers(); - wiki.addIndexersToWiki(); - return wiki; - } - - // Our tests - function runTests(wiki) { - - it("should handle the enlist operator", function() { - expect(wiki.filterTiddlers("[enlist[one two three]addsuffix[!]]").join(",")).toBe("one!,two!,three!"); - }); - - it("should handle the enlist-input operator", function() { - expect(wiki.filterTiddlers("[[one two three]enlist-input[]]").join(",")).toBe("one,two,three"); - expect(wiki.filterTiddlers("[[one two two three]enlist-input[]]").join(",")).toBe("one,two,three"); - expect(wiki.filterTiddlers("[[one two two three]enlist-input:dedupe[]]").join(",")).toBe("one,two,three"); - expect(wiki.filterTiddlers("[[one two two three]enlist-input:raw[]]").join(",")).toBe("one,two,two,three"); - expect(wiki.filterTiddlers("[[one two three]] [[four five six]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six"); - expect(wiki.filterTiddlers("[[one two three]] [[four five six]] [[seven eight]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six,seven,eight"); - expect(wiki.filterTiddlers("[[]] +[enlist-input[]]").join(",")).toBe(""); - }); - - it("should handle the then and else operators", function() { - expect(wiki.filterTiddlers("[modifier[JoeBloggs]then[Susi]]").join(",")).toBe("Susi"); - expect(wiki.filterTiddlers("[!modifier[JoeBloggs]then[Susi]]").join(",")).toBe("Susi,Susi,Susi,Susi,Susi,Susi,Susi,Susi"); - expect(wiki.filterTiddlers("[modifier[DaveBloggs]then[Susi]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[modifier[JoeBloggs]else[Susi]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[!modifier[JoeBloggs]else[Susi]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[modifier[DaveBloggs]else[Susi]]").join(",")).toBe("Susi"); - }); - - it("should handle the ~ prefix", function() { - expect(wiki.filterTiddlers("[modifier[JoeBloggs]] ~[[No such tiddler]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[modifier[Susi]] ~[[No such tiddler]]").join(",")).toBe("No such tiddler"); - expect(wiki.filterTiddlers("~[[No such tiddler]]").join(",")).toBe("No such tiddler"); - expect(wiki.filterTiddlers("[my-field[present]] ~[[No such tiddler]]").join(",")).toBe("No such tiddler"); - }); - - it("should handle the lookup operator", function() { - expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],,Tidd"); - expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],8,Tidd"); - expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler],[text]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],8,Tidd"); - expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler],[tags]]").join(",")).toBe(",one,one"); - }); - - it("should retrieve shadow tiddlers", function() { - expect(wiki.getTiddlerText("Tiddler8")).toBe("Tidd"); - }); - - it("should handle the title operator", function() { - expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three"); - expect(wiki.filterTiddlers("[!title[Tiddler Three]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,TiddlerOne"); - expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]] [[A Missing Tiddler]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,A Missing Tiddler"); - }); - - it("should handle the field operator", function() { - expect(wiki.filterTiddlers("[modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[!modifier[JoeBloggs]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[!is[system]!modifier[JoeBloggs]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[field:modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[!field:modifier[JoeBloggs]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[!is[system]!field:modifier[JoeBloggs]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[modifier[John]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three"); - expect(wiki.filterTiddlers("[!modifier[John]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,TiddlerOne"); - expect(wiki.filterTiddlers("[!is[system]!modifier[John]]").join(",")).toBe("filter regexp test,has filter,hasList,TiddlerOne"); - expect(wiki.filterTiddlers("[field:modifier[John]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three"); - expect(wiki.filterTiddlers("[!field:modifier[John]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,TiddlerOne"); - expect(wiki.filterTiddlers("[!is[system]!field:modifier[John]]").join(",")).toBe("filter regexp test,has filter,hasList,TiddlerOne"); - }); - - it("should handle the regexp operator", function() { - expect(wiki.filterTiddlers("[regexp[id]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[!regexp[id]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,one"); - expect(wiki.filterTiddlers("[regexp[Tid]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[regexp[(?i)Tid]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[!regexp[Tid(?i)]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,one"); - }); - - // The following 2 tests should write a log -> WARNING: Filter modifier has a deprecated regexp operand XXXX - // The test should pass anyway. - it("should handle the field operator with a regular expression operand", function() { - spyOn(console, 'log'); - expect(wiki.filterTiddlers("[modifier/JoeBloggs/]").join(",")).toBe("TiddlerOne"); - expect(console.log).toHaveBeenCalledWith("WARNING: Filter", "modifier", "has a deprecated regexp operand", /JoeBloggs/); - console.log.calls.reset(); - expect(wiki.filterTiddlers("[modifier/Jo/]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne"); - expect(console.log).toHaveBeenCalledWith("WARNING: Filter", "modifier", "has a deprecated regexp operand", /Jo/); - }); +describe("Filter tests", function() { - it("should handle regular expression operands without crashing", function() { - spyOn(console, 'log'); - // We don't really care about the results. Just don't get RSoD. - expect(() => wiki.filterTiddlers("[all/current/]")).not.toThrow(); - expect(() => wiki.filterTiddlers("[prefix/anything/]")).not.toThrow(); - expect(() => wiki.filterTiddlers("[title/anything/]")).not.toThrow(); - expect(() => wiki.filterTiddlers("[/anything/]")).not.toThrow(); - expect(() => wiki.filterTiddlers("[//]")).not.toThrow(); - }); - - it("should handle the prefix operator", function() { - expect(wiki.filterTiddlers("[prefix[Tiddler]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[prefix:casesensitive[tiddler]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[prefix:caseinsensitive[tiddler]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[prefix[nothing]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]prefix[]]").join(",")).toBe("ABCDE,abcde"); - }); - - it("should handle the suffix operator", function() { - expect(wiki.filterTiddlers("[suffix[One]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[suffix:casesensitive[one]]").join(",")).toBe("one"); - expect(wiki.filterTiddlers("[suffix:caseinsensitive[one]]").join(",")).toBe("one,TiddlerOne"); - expect(wiki.filterTiddlers("[suffix[nothing]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]suffix[]]").join(",")).toBe("ABCDE,abcde"); - }); - - it("should handle the removeprefix operator", function() { - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix[ABC]]").join(",")).toBe("DE"); - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix:casesensitive[ABC]]").join(",")).toBe("DE"); - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix:caseinsensitive[abc]]").join(",")).toBe("DE,de"); - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix[]]").join(",")).toBe("ABCDE,abcde"); - }); - - it("should handle the removesuffix operator", function() { - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix[DE]]").join(",")).toBe("ABC"); - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix:casesensitive[DE]]").join(",")).toBe("ABC"); - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix:caseinsensitive[de]]").join(",")).toBe("ABC,abc") - expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix[]]").join(",")).toBe("ABCDE,abcde"); - }); - - it("should handle the sort and sortcs operators", function() { - expect(wiki.filterTiddlers("[sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[!sort[title]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,hasList,has filter,filter regexp test,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin"); - expect(wiki.filterTiddlers("[sort[modified]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one,$:/TiddlerTwo,TiddlerOne,Tiddler Three"); - expect(wiki.filterTiddlers("[!sort[modified]]").join(",")).toBe("Tiddler Three,TiddlerOne,$:/TiddlerTwo,$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); - // Temporarily commenting out the following two lines because of platform differences for localeCompare between the browser and Node.js - // expect(wiki.filterTiddlers("[sortcs[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne,a fourth tiddler,one"); - // expect(wiki.filterTiddlers("[!sortcs[title]]").join(",")).toBe("one,a fourth tiddler,TiddlerOne,Tiddler Three,$:/TiddlerTwo"); - }); - - it("should handle the nsort and nsortcs operators", function() { - expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[nsort[]]").join(",")).toBe("0,1,2,3,5,add,Apple,beatle,Beta"); - expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[!nsort[]]").join(",")).toBe("Beta,beatle,Apple,add,5,3,2,1,0"); - expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[nsortcs[]]").join(",")).toBe("0,1,2,3,5,add,Apple,beatle,Beta"); - expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[!nsortcs[]]").join(",")).toBe("Beta,beatle,Apple,add,5,3,2,1,0"); - }); - - it("should handle the reverse, first, last, butfirst, butlast, rest and nth operators", function() { - expect(wiki.filterTiddlers("[sort[title]first[]]").join(",")).toBe("$:/ShadowPlugin"); - expect(wiki.filterTiddlers("[sort[title]first[2]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo"); - expect(wiki.filterTiddlers("[sort[title]first[8]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[sort[title]first[x]]").join(",")).toBe("$:/ShadowPlugin"); - expect(wiki.filterTiddlers("[sort[title]last[]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]last[2]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]last[8]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]last[x]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]reverse[]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,hasList,has filter,filter regexp test,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin"); - expect(wiki.filterTiddlers("[sort[title]reverse[x]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,hasList,has filter,filter regexp test,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin"); - expect(wiki.filterTiddlers("[sort[title]butlast[]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[sort[title]butlast[0]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]butlast[2]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one"); - expect(wiki.filterTiddlers("[sort[title]butlast[11]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[sort[title]butlast[x]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[sort[title]rest[]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]rest[2]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]rest[11]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[sort[title]rest[x]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[sort[title]nth[]]").join(",")).toBe("$:/ShadowPlugin"); - expect(wiki.filterTiddlers("[sort[title]nth[2]]").join(",")).toBe("$:/TiddlerTwo"); - expect(wiki.filterTiddlers("[sort[title]nth[11]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[sort[title]nth[x]]").join(",")).toBe("$:/ShadowPlugin"); - }); - - it("should handle the tag operator", function() { - expect(wiki.filterTiddlers("[tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[!tag[one]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one"); - expect(wiki.filterTiddlers("[prefix[Tidd]tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[!is[shadow]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); - expect(wiki.filterTiddlers("[all[shadows]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerFive"); - }); - - it("should handle the all operator with field, has and tag operators", function() { - expect(wiki.filterTiddlers("[all[shadows]tag[two]]").join(",")).toBe("$:/TiddlerFive"); - expect(wiki.filterTiddlers("[all[shadows+tiddlers]tag[two]]").join(",")).toBe("$:/TiddlerFive,$:/TiddlerTwo,Tiddler Three"); - expect(wiki.filterTiddlers("[all[tiddlers+shadows]tag[two]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,$:/TiddlerFive"); - expect(wiki.filterTiddlers("[all[shadows+tiddlers]]").join(",")).toBe("$:/TiddlerFive,TiddlerSix,TiddlerSeventh,Tiddler8,$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[all[tiddlers+shadows]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne,$:/TiddlerFive,TiddlerSix,TiddlerSeventh,Tiddler8"); - expect(wiki.filterTiddlers("[all[tiddlers]tag[two]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); - expect(wiki.filterTiddlers("[all[orphans+tiddlers+tags]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,Tiddler Three,TiddlerOne,two,one"); - }); - - it("should handle the tags operator", function() { - expect(wiki.filterTiddlers("[tags[]sort[title]]").join(",")).toBe("one,two"); - expect(wiki.filterTiddlers("[[TiddlerOne]tags[]sort[title]]").join(",")).toBe("one"); - }); - - it("should handle the match operator", function() { - expect(wiki.filterTiddlers("[match[TiddlerOne]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("TiddlerOne TiddlerOne =[match[TiddlerOne]]").join(",")).toBe("TiddlerOne,TiddlerOne"); - expect(wiki.filterTiddlers("[!match[TiddlerOne]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[match:casesensitive[tiddlerone]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[!match:casesensitive[tiddlerone]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[match:caseinsensitive[tiddlerone]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[!match:caseinsensitive[tiddlerone]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); - }); - - it("should handle the tagging operator", function() { - expect(wiki.filterTiddlers("[[one]tagging[]sort[title]]").join(",")).toBe("Tiddler Three,Tiddler8,TiddlerOne,TiddlerSeventh"); - expect(wiki.filterTiddlers("[[one]tagging[]]").join(",")).toBe("Tiddler Three,TiddlerOne,TiddlerSeventh,Tiddler8"); - expect(wiki.filterTiddlers("[[two]tagging[]sort[title]]").join(",")).toBe("$:/TiddlerFive,$:/TiddlerTwo,Tiddler Three"); - var fakeWidget = {wiki: wiki, getVariable: function(name) {return name === "currentTiddler" ? "one": undefined;}}; - expect(wiki.filterTiddlers("[all[current]tagging[]]",fakeWidget).join(",")).toBe("Tiddler Three,TiddlerOne,TiddlerSeventh,Tiddler8"); - }); - - it("should handle the untagged operator", function() { - expect(wiki.filterTiddlers("[untagged[]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); - expect(wiki.filterTiddlers("[!untagged[]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); - // Should consider non-existent tiddlers untagged. - expect(wiki.filterTiddlers("[enlist[a b c]untagged[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("[enlist[a b c]!untagged[]]").join(",")).toBe(""); - }); - - it("should handle the links operator", function() { - expect(wiki.filterTiddlers("[!is[shadow]links[]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,has filter,hasList,one,Tiddler Three,TiddlerSix,TiddlerZero"); - expect(wiki.filterTiddlers("[all[shadows]links[]sort[title]]").join(",")).toBe("TiddlerOne"); - }); - - it("should handle the backlinks operator", function() { - expect(wiki.filterTiddlers("[!is[shadow]backlinks[]sort[title]]").join(",")).toBe("a fourth tiddler,has filter,hasList,one,TiddlerOne"); - expect(wiki.filterTiddlers("[all[shadows]backlinks[]sort[title]]").join(",")).toBe("Tiddler Three"); - }); - - it("should handle the has operator", function() { - expect(wiki.filterTiddlers("[has[modified]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[!has[modified]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); - expect(wiki.filterTiddlers("[has[tags]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[!has[tags]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); - }); - - it("should handle the has:field operator", function() { - expect(wiki.filterTiddlers("[has:field[empty]sort[title]]").join(",")).toBe("a fourth tiddler,one"); - expect(wiki.filterTiddlers("[!has:field[empty]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,filter regexp test,has filter,hasList,Tiddler Three,TiddlerOne"); - }); - - - it("should handle the limit operator", function() { - expect(wiki.filterTiddlers("[!is[system]sort[title]limit[2]]").join(",")).toBe("a fourth tiddler,filter regexp test"); - expect(wiki.filterTiddlers("[prefix[Tid]sort[title]limit[1]]").join(",")).toBe("Tiddler Three"); - expect(wiki.filterTiddlers("[prefix[Tid]sort[title]!limit[1]]").join(",")).toBe("TiddlerOne"); - }); - - it("should handle the list operator", function() { - expect(wiki.filterTiddlers("[list[TiddlerSeventh]sort[title]]").join(",")).toBe("a fourth tiddler,MissingTiddler,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[tag[one]list[TiddlerSeventh]sort[title]]").join(",")).toBe("a fourth tiddler,MissingTiddler,Tiddler Three,TiddlerOne"); - }); - - it("should handle the listed operator", function() { - expect(wiki.filterTiddlers("TiddlerOne MissingTiddler +[listed[]]").join(",")).toBe('hasList,one'); - expect(wiki.filterTiddlers("one two +[listed[tags]]").join(",")).toBe('TiddlerOne,$:/TiddlerTwo,Tiddler Three'); - }); - - it("should handle the next operator", function() { - expect(wiki.filterTiddlers("[[Tiddler Three]next[TiddlerSeventh]]").join(",")).toBe("a fourth tiddler"); - expect(wiki.filterTiddlers("[[MissingTiddler]next[TiddlerSeventh]]").join(",")).toBe(""); - }); - - it("should handle the previous operator", function() { - expect(wiki.filterTiddlers("[[Tiddler Three]previous[TiddlerSeventh]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[[TiddlerOne]previous[TiddlerSeventh]]").join(",")).toBe(""); - }); - - it("should handle the search operator", function() { - expect(wiki.filterTiddlers("[search[the]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search{Tiddler8}sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:modifier[og]sort[title]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[Do]sort[title]]").join(",")).toBe("$:/TiddlerTwo"); - expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[do]sort[title]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[search:authors:casesensitive,whitespace[John Doe]sort[title]]").join(",")).toBe("$:/TiddlerTwo"); - expect(wiki.filterTiddlers("[search:modifier:regexp[(d|bl)o(ggs|e)]sort[title]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[search:-modifier,authors:[g]sort[title]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,Tiddler Three"); - expect(wiki.filterTiddlers("[search:*:[g]sort[title]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:text:anchored[the]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); - }); - - it("should yield search results where 'default' search finds at least 1 token", function() { - expect(wiki.filterTiddlers("[search::some[one two]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,one,Tiddler Three,TiddlerOne"); - }); - - it("should yield search results where 'title' finds at least one token", function() { - expect(wiki.filterTiddlers("[search:title:some[tiddler]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:title:some[tiddler one]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne"); - }); - - it("should yield search results where 'tags' finds at least one token", function() { - expect(wiki.filterTiddlers("[search:tags:some[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:tags:some[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); - expect(wiki.filterTiddlers("[search:tags:some[two one]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); - }); - - it("should yield search results where 'tags' finds at least one token / casesensitive", function() { - expect(wiki.filterTiddlers("[search:tags:some[ONE]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:tags:some,casesensitive[two ONE]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); - }); - - it("should yield search results where 'tags' finds at least one token / anchored", function() { - expect(wiki.filterTiddlers("[search:tags:some,anchored[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:tags:some,anchored[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); - // search:title - expect(wiki.filterTiddlers("[search:title:some,anchored[tiddler]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:title:some,anchored[tiddler one]sort[title]]").join(",")).toBe("one,Tiddler Three,TiddlerOne"); - }); - - it("should yield search results where 'tags' finds at least one token / anchored & casesensitive", function() { - expect(wiki.filterTiddlers("[search:title:some,anchored,casesensitive[Tiddler one]sort[title]]").join(",")).toBe("one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[search:title:some,anchored,casesensitive[Tiddler ONE]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - }); - - it("should yield search results that have search tokens spread across different fields", function() { - expect(wiki.filterTiddlers("[search[fox one]sort[title]]").join(",")).toBe("TiddlerOne"); - }); - - it("should handle the each operator", function() { - expect(wiki.filterTiddlers("[each[modifier]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,filter regexp test,TiddlerOne"); - expect(wiki.filterTiddlers("[each:list-item[tags]sort[title]]").join(",")).toBe("one,two"); - expect(wiki.filterTiddlers("[each:list-item[authors]sort[title]]").join(",")).toBe("Bloggs,Joe,John Doe"); - }); - - it("should handle the eachday operator", function() { - expect(wiki.filterTiddlers("[eachday[modified]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); - }); - - it("should handle the sameday operator", function() { - expect(wiki.filterTiddlers("[sameday[201304152200]sort[title]]").join(",")).toBe("$:/TiddlerTwo,TiddlerOne"); - }); - - describe("testing the is operator",function() { - - it("should handle the '[is[current]]' operator", function() { - var fakeWidget = {getVariable: function() {return "Tiddler Three";}}; - expect(wiki.filterTiddlers("[is[current]]",fakeWidget).join(",")).toBe("Tiddler Three"); - expect(wiki.filterTiddlers("[[Tiddler Three]is[current]]",fakeWidget).join(",")).toBe("Tiddler Three"); - expect(wiki.filterTiddlers("[[$:/TiddlerTwo]is[current]]",fakeWidget).join(",")).toBe(""); - expect(wiki.filterTiddlers("[!is[current]sort[title]]",fakeWidget).join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,TiddlerOne"); - }); - - it("should handle the '[is[system]]' operator", function() { - expect(wiki.filterTiddlers("[is[system]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo"); - expect(wiki.filterTiddlers("[!is[system]sort[title]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - }); - - it("should handle the '[is[shadow]]' operator", function() { - expect(wiki.filterTiddlers("[all[shadows]sort[title]]").join(",")).toBe("$:/TiddlerFive,Tiddler8,TiddlerSeventh,TiddlerSix"); - expect(wiki.filterTiddlers("[!is[shadow]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - }); - - it("should handle the '[is[missing]]' operator", function() { - expect(wiki.filterTiddlers("[all[]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[all[missing]]").join(",")).toBe("TiddlerZero"); - expect(wiki.filterTiddlers("[!is[missing]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[[TiddlerOne]is[missing]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[[TiddlerZero]is[missing]]").join(",")).toBe("TiddlerZero"); - expect(wiki.filterTiddlers("[!title[Tiddler Three]is[missing]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[missing]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,TiddlerOne"); - }); - - it("should handle the '[is[orphan]]' operator", function() { - expect(wiki.filterTiddlers("[is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,filter regexp test,TiddlerOne"); - expect(wiki.filterTiddlers("[!is[orphan]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,has filter,hasList,one,Tiddler Three"); - expect(wiki.filterTiddlers("[[TiddlerOne]is[orphan]]").join(",")).toBe("TiddlerOne"); - expect(wiki.filterTiddlers("[[TiddlerOne]!is[orphan]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[!title[Tiddler Three]is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,filter regexp test,TiddlerOne"); - expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[orphan]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,has filter,hasList,one"); - }); - - it("should handle the '[is[draft]]' operator", function() { - var wiki = new $tw.Wiki(); - wiki.addTiddlers([ - {title: "A"}, - {title: "Draft of 'A'", "draft.of": "A", "draft.title": "A"}, - {title: "B"}, - {title: "Draft of 'B'", "draft.of": "B"}, - {title: "C"}, - // Not a true draft. Doesn't have draft.of - {title: "Draft of 'C'", "draft.title": "C"}, - {title: "E"}, - // Broken. Has draft.of, but it's empty. Still a draft - {title: "Draft of 'E'", "draft.of": "", "draft.title": ""} - // Not a draft. It doesn't exist. - //{title: "F"} // This one is deliberately missing - ]); - // is analagous to [has[draft.of]], - // except they handle empty draft.of differently - expect(wiki.filterTiddlers("[all[]] F +[is[draft]]").join(",")).toEqual("Draft of 'A',Draft of 'B',Draft of 'E'"); - expect(wiki.filterTiddlers("[all[]] F +[!is[draft]]").join(",")).toEqual("A,B,C,Draft of 'C',E,F"); - // [is[draft]] and [!is[draft]] are proper complements - var included = wiki.filterTiddlers("[all[]] F +[is[draft]]") - var excluded = wiki.filterTiddlers("[all[]] F +[!is[draft]]") - var all = [].concat(included, excluded).sort(); - // combined, they should have exactly one of everything. - expect(wiki.filterTiddlers("[all[]] F +[sort[]]")).toEqual(all); - }); - - }); - - it("should handle the operand prefixes", function() { - expect(wiki.filterTiddlers("[prefix[Tiddler]] +[sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - }); - - it("should handle indirect operands", function() { - expect(wiki.filterTiddlers("[{!!missing}]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[{!!title}]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[prefix{Tiddler8}] +[sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[modifier{Tiddler8!!test-field}] +[sort[title]]").join(",")).toBe("TiddlerOne"); - var fakeWidget = {wiki: wiki, getVariable: function(name) {return name === "currentTiddler" ? "Tiddler Three": undefined;}}; - expect(wiki.filterTiddlers("[modifier{!!modifier}] +[sort[title]]",fakeWidget).join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three"); - }); - - it("should handle variable operands", function() { - - var widget = require("$:/core/modules/widgets/widget.js"); - // Create a root widget for attaching event handlers. By using it as the parentWidget for another widget tree, one can reuse the event handlers - var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, - { wiki:wiki, document:$tw.document}); - rootWidget.makeChildWidgets(); - var anchorWidget = rootWidget.children[0]; - rootWidget.setVariable("myVar","Tidd"); - rootWidget.setVariable("myVar2","JoeBloggs"); - expect(wiki.filterTiddlers("[prefix] +[sort[title]]",anchorWidget).join(",")).toBe("Tiddler Three,TiddlerOne"); - expect(wiki.filterTiddlers("[modifier] +[sort[title]]",anchorWidget).join(",")).toBe("TiddlerOne"); - }); - - it("should handle the before and after operators", function() { - expect(wiki.filterTiddlers("[list[TiddlerSeventh]after[TiddlerOne]]").join(",")).toBe("Tiddler Three"); - expect(wiki.filterTiddlers("[list[TiddlerSeventh]after[a fourth tiddler]]").join(",")).toBe("MissingTiddler"); - expect(wiki.filterTiddlers("[list[TiddlerSeventh]after[MissingTiddler]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[list[TiddlerSeventh]before[TiddlerOne]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("[list[TiddlerSeventh]before[a fourth tiddler]]").join(",")).toBe("Tiddler Three"); - expect(wiki.filterTiddlers("[list[TiddlerSeventh]before[MissingTiddler]]").join(",")).toBe("a fourth tiddler"); - }); - - it("should handle the range operator", function() { - expect(wiki.filterTiddlers("[range[10:0:2]]").join(",")).toBe("10,8,6,4,2,0"); - expect(wiki.filterTiddlers("[range[10;0;2]]").join(",")).toBe("10,8,6,4,2,0"); - expect(wiki.filterTiddlers("[range[1.001,5,1]]").join(",")).toBe("1.001,2.001,3.001,4.001"); - expect(wiki.filterTiddlers("[range[0,10]]").join(",")).toBe("0,1,2,3,4,5,6,7,8,9,10"); - expect(wiki.filterTiddlers("[range[0],[10]]").join(",")).toBe("0,1,2,3,4,5,6,7,8,9,10"); - expect(wiki.filterTiddlers("[range[10,0]]").join(",")).toBe("10,9,8,7,6,5,4,3,2,1,0"); - expect(wiki.filterTiddlers("[range[10],[0]]").join(",")).toBe("10,9,8,7,6,5,4,3,2,1,0"); - expect(wiki.filterTiddlers("[range[0,10,2]]").join(",")).toBe("0,2,4,6,8,10"); - expect(wiki.filterTiddlers("[range[0],[10],[2]]").join(",")).toBe("0,2,4,6,8,10"); - expect(wiki.filterTiddlers("[range[10,0,2]]").join(",")).toBe("10,8,6,4,2,0"); - expect(wiki.filterTiddlers("[range[10],[0],[2]]").join(",")).toBe("10,8,6,4,2,0"); - }); - - it("should handle the string operators", function() { - expect(wiki.filterTiddlers("John Paul George Ringo +[length[]]").join(",")).toBe("4,4,6,5"); - expect(wiki.filterTiddlers("John Paul George Ringo +[uppercase[]]").join(",")).toBe("JOHN,PAUL,GEORGE,RINGO"); - expect(wiki.filterTiddlers("John Paul George Ringo +[lowercase[]]").join(",")).toBe("john,paul,george,ringo"); - expect(wiki.filterTiddlers("John Paul George Ringo +[split[]]").join(",")).toBe("J,o,h,n,P,a,u,l,G,e,o,r,g,e,R,i,n,g,o"); - expect(wiki.filterTiddlers("[[John. Paul. George. Ringo.]] +[split[.]trim[]]").join(",")).toBe("John,Paul,George,Ringo,"); - expect(wiki.filterTiddlers("John Paul George Ringo +[split[e]]").join(",")).toBe("John,Paul,G,org,,Ringo"); - expect(wiki.filterTiddlers("John Paul George Ringo +[join[ ]split[e]join[ee]split[ ]]").join(",")).toBe("John,Paul,Geeorgee,Ringo"); - // Ensure that join doesn't return null if passed empty list - expect(wiki.filterTiddlers("Test +[butlast[]join[ ]]")).toEqual([]); - // Ensure that join correctly handles empty strings in source - expect(wiki.filterTiddlers("[[]] Paul +[join[-]]").join(",")).toBe("-Paul"); - expect(wiki.filterTiddlers("[[ John ]] [[Paul ]] [[ George]] Ringo +[trim[]join[-]]").join(",")).toBe("John-Paul-George-Ringo"); - expect(wiki.filterTiddlers("[[ abc ]] [[def ]] [[ ghi]] +[trim[]]").join(",")).toBe("abc,def,ghi"); - expect(wiki.filterTiddlers("[[ abc ]] [[def ]] [[ ghi]] +[trim:prefix[]]").join(",")).toBe("abc ,def ,ghi"); - expect(wiki.filterTiddlers("[[ abc ]] [[def ]] [[ ghi]] +[trim:suffix[]]").join(",")).toBe(" abc,def, ghi"); - expect(wiki.filterTiddlers("[[ abacus ]] [[ baobab ]] +[trim[ab]]").join(",")).toBe(" abacus , baobab "); - expect(wiki.filterTiddlers("[[ abacus ]] [[ baobab ]] +[trim[a]]").join(",")).toBe(" abacus , baobab "); - expect(wiki.filterTiddlers("abacus baobab +[trim[a]]").join(",")).toBe("bacus,baobab"); - expect(wiki.filterTiddlers("abacus baobab +[trim[ab]]").join(",")).toBe("acus,baob"); - expect(wiki.filterTiddlers("abacus baobab +[trim:prefix[ab]]").join(",")).toBe("acus,baobab"); - expect(wiki.filterTiddlers("abacus baobab +[trim:suffix[ab]]").join(",")).toBe("abacus,baob"); - // Trim doesn't hiccup on regexp special characters - expect(wiki.filterTiddlers("[[.*abacus.*]] [[.+baobab.+]] +[trim[.*]]").join(",")).toBe("abacus,.+baobab.+"); - expect(wiki.filterTiddlers("[[.*abacus.*]] [[.+baobab.+]] +[trim[.+]]").join(",")).toBe(".*abacus.*,baobab"); - }); - - it("should handle the mathematics operators", function() { - expect(wiki.filterTiddlers("[[2]add[2]]").join(",")).toBe("4"); - expect(wiki.filterTiddlers("[[4]subtract[2]]").join(",")).toBe("2"); - expect(wiki.filterTiddlers("[[24]divide[8]]").join(",")).toBe("3"); - expect(wiki.filterTiddlers("[[355]divide[113]sign[]multiply[4]]").join(",")).toBe("4"); - expect(wiki.filterTiddlers("[[355]divide[113]add[0.5]round[]multiply[4]]").join(",")).toBe("16"); - expect(wiki.filterTiddlers("1 2 3 4 +[sum[]]").join(",")).toBe("10"); - expect(wiki.filterTiddlers("1 2 3 4 +[product[]]").join(",")).toBe("24"); - expect(wiki.filterTiddlers("1 2 3 4 +[maxall[]]").join(",")).toBe("4"); - expect(wiki.filterTiddlers("1 2 3 4 +[minall[]]").join(",")).toBe("1"); - expect(wiki.filterTiddlers("1 2 3 4 +[max[2]]").join(",")).toBe("2,2,3,4"); - expect(wiki.filterTiddlers("1 2 3 4 +[min[2]]").join(",")).toBe("1,2,2,2"); - }); - - /* listops filters */ - - it("should handle the allafter operator", function() { - expect(wiki.filterTiddlers("1 2 3 4 +[allafter[]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter[1]]").join(",")).toBe("2,3,4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[1]]").join(",")).toBe("1,2,3,4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter[2]]").join(",")).toBe("3,4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[2]]").join(",")).toBe("2,3,4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter[3]]").join(",")).toBe("4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[3]]").join(",")).toBe("3,4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter[4]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[4]]").join(",")).toBe("4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter[5]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[5]]").join(",")).toBe(""); - }); - - it("should handle the allbefore operator", function() { - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[1]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[1]]").join(",")).toBe("1"); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[2]]").join(",")).toBe("1"); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[2]]").join(",")).toBe("1,2"); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[3]]").join(",")).toBe("1,2"); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[3]]").join(",")).toBe("1,2,3"); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[4]]").join(",")).toBe("1,2,3"); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[4]]").join(",")).toBe("1,2,3,4"); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[5]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[5]]").join(",")).toBe(""); - }); - - it("should handle the append operator", function() { - expect(wiki.filterTiddlers("a b c +[append[d e]]").join(",")).toBe("a,b,c,d,e"); - expect(wiki.filterTiddlers("a b c +[append:1[d e]]").join(",")).toBe("a,b,c,d"); - expect(wiki.filterTiddlers("a b c +[append{TiddlerSeventh!!list}]").join(",")).toBe("a,b,c,TiddlerOne,Tiddler Three,a fourth tiddler,MissingTiddler"); - expect(wiki.filterTiddlers("a b c +[append:2{TiddlerSeventh!!list}]").join(",")).toBe("a,b,c,TiddlerOne,Tiddler Three"); - - expect(wiki.filterTiddlers("a [[b c]] +[append{TiddlerSix!!filter}]").join(",")).toBe("a,b c,one,a a,[subfilter{hasList!!list}]"); - }); - - it("should handle the insertafter operator", function() { - var widget = require("$:/core/modules/widgets/widget.js"); - var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, - { wiki:wiki, document:$tw.document}); - rootWidget.makeChildWidgets(); - var anchorWidget = rootWidget.children[0]; - rootWidget.setVariable("myVar","c"); - rootWidget.setVariable("tidTitle","e"); - rootWidget.setVariable("tidList","one tid with spaces"); - - // Position title specified as suffix. - expect(wiki.filterTiddlers("a b c d e f +[insertafter:myVar[f]]",anchorWidget).join(",")).toBe("a,b,c,f,d,e"); - expect(wiki.filterTiddlers("a b c d e f +[insertafter:myVar]",anchorWidget).join(",")).toBe("a,b,c,e,d,f"); - expect(wiki.filterTiddlers("a b c d e f +[insertafter:myVar[gg gg]]",anchorWidget).join(",")).toBe("a,b,c,gg gg,d,e,f"); - expect(wiki.filterTiddlers("a b c d e +[insertafter:myVar]",anchorWidget).join(",")).toBe("a,b,c,one tid with spaces,d,e"); - expect(wiki.filterTiddlers("a b c d e f +[insertafter:tidTitle{TiddlerOne!!tags}]",anchorWidget).join(",")).toBe("a,b,c,d,e,one,f"); - - // Position title specified as parameter. - expect(wiki.filterTiddlers("a b c d e +[insertafter[f],[a]]",anchorWidget).join(",")).toBe("a,f,b,c,d,e"); - expect(wiki.filterTiddlers("a b c d e +[insertafter[f],]",anchorWidget).join(",")).toBe("a,b,c,f,d,e"); - - // Parameter takes precedence over suffix. - expect(wiki.filterTiddlers("a b c d e +[insertafter:myVar[f],[a]]",anchorWidget).join(",")).toBe("a,f,b,c,d,e"); - - // No position title. - expect(wiki.filterTiddlers("a b c [[with space]] +[insertafter[b]]").join(",")).toBe("a,c,with space,b"); - - // Position title does not exist, and no suffix given. - expect(wiki.filterTiddlers("a b c d e +[insertafter:foo[b]]").join(",")).toBe("a,c,d,e,b"); - expect(wiki.filterTiddlers("a b c d e +[insertafter[b],[foo]]").join(",")).toBe("a,c,d,e,b"); - expect(wiki.filterTiddlers("a b c d e +[insertafter[b],]").join(",")).toBe("a,c,d,e,b"); - - // Position title does not exist, but "start" or "end" given as suffix - expect(wiki.filterTiddlers("a b c d e +[insertafter:start[b],[foo]]").join(",")).toBe("b,a,c,d,e"); - expect(wiki.filterTiddlers("a b c d e +[insertafter:start[b],]").join(",")).toBe("b,a,c,d,e"); - expect(wiki.filterTiddlers("a b c d e +[insertafter:end[b],[foo]]").join(",")).toBe("a,c,d,e,b"); - expect(wiki.filterTiddlers("a b c d e +[insertafter:end[b],]").join(",")).toBe("a,c,d,e,b"); - }); - - it("should handle the insertbefore operator", function() { - var widget = require("$:/core/modules/widgets/widget.js"); - var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, - { wiki:wiki, document:$tw.document}); - rootWidget.makeChildWidgets(); - var anchorWidget = rootWidget.children[0]; - rootWidget.setVariable("myVar","c"); - rootWidget.setVariable("tidTitle","e"); - rootWidget.setVariable("tidList","one tid with spaces"); - - // Position title specified as suffix. - expect(wiki.filterTiddlers("a b c d e f +[insertbefore:myVar[f]]",anchorWidget).join(",")).toBe("a,b,f,c,d,e"); - expect(wiki.filterTiddlers("a b c d e f +[insertbefore:myVar]",anchorWidget).join(",")).toBe("a,b,e,c,d,f"); - expect(wiki.filterTiddlers("a b c d e f +[insertbefore:myVar[gg gg]]",anchorWidget).join(",")).toBe("a,b,gg gg,c,d,e,f"); - expect(wiki.filterTiddlers("a b c d e +[insertbefore:myVar]",anchorWidget).join(",")).toBe("a,b,one tid with spaces,c,d,e"); - expect(wiki.filterTiddlers("a b c d e f +[insertbefore:tidTitle{TiddlerOne!!tags}]",anchorWidget).join(",")).toBe("a,b,c,d,one,e,f"); - - // Position title specified as parameter. - expect(wiki.filterTiddlers("a b c d e +[insertbefore[f],[a]]",anchorWidget).join(",")).toBe("f,a,b,c,d,e"); - expect(wiki.filterTiddlers("a b c d e +[insertbefore[f],]",anchorWidget).join(",")).toBe("a,b,f,c,d,e"); - - // Parameter takes precedence over suffix. - expect(wiki.filterTiddlers("a b c d e +[insertbefore:myVar[f],[a]]",anchorWidget).join(",")).toBe("f,a,b,c,d,e"); - - // No position title. - expect(wiki.filterTiddlers("a b c [[with space]] +[insertbefore[b]]").join(",")).toBe("a,c,with space,b"); - - // Position title does not exist, and no suffix given. - expect(wiki.filterTiddlers("a b c d e +[insertbefore:foo[b]]").join(",")).toBe("a,c,d,e,b"); - expect(wiki.filterTiddlers("a b c d e +[insertbefore[b],[foo]]").join(",")).toBe("a,c,d,e,b"); - expect(wiki.filterTiddlers("a b c d e +[insertbefore[b],]").join(",")).toBe("a,c,d,e,b"); - - // Position title does not exist, but "start" or "end" given as suffix - expect(wiki.filterTiddlers("a b c d e +[insertbefore:start[b],[foo]]").join(",")).toBe("b,a,c,d,e"); - expect(wiki.filterTiddlers("a b c d e +[insertbefore:start[b],]").join(",")).toBe("b,a,c,d,e"); - expect(wiki.filterTiddlers("a b c d e +[insertbefore:end[b],[foo]]").join(",")).toBe("a,c,d,e,b"); - expect(wiki.filterTiddlers("a b c d e +[insertbefore:end[b],]").join(",")).toBe("a,c,d,e,b"); - }); - - it("should handle the move operator", function() { - expect(wiki.filterTiddlers("a b c d e +[move[c]]").join(",")).toBe("a,b,d,c,e"); - expect(wiki.filterTiddlers("a b c d e +[move:2[c]]").join(",")).toBe("a,b,d,e,c"); - expect(wiki.filterTiddlers("a b c d e +[move:10[c]]").join(",")).toBe("a,b,d,e,c"); - expect(wiki.filterTiddlers("a b c d e +[move:-1[c]]").join(",")).toBe("a,c,b,d,e"); - expect(wiki.filterTiddlers("a b c d e +[move:-5[c]]").join(",")).toBe("c,a,b,d,e"); - }); - - it("should handle the prepend operator", function() { - expect(wiki.filterTiddlers("a b c +[prepend[dd ee]]").join(",")).toBe("dd,ee,a,b,c"); - expect(wiki.filterTiddlers("a b c +[prepend:3[ff gg]]").join(",")).toBe("ff,gg,a,b,c"); - expect(wiki.filterTiddlers("a b c +[prepend:1[hh ii]]").join(",")).toBe("hh,a,b,c"); - expect(wiki.filterTiddlers("a b c +[prepend:0[jj kk]]").join(",")).toBe("a,b,c"); - - expect(wiki.filterTiddlers("a b c +[prepend:-0[ll mm]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[prepend:-1[nn oo pp qq]]").join(",")).toBe("nn,oo,pp,a,b,c"); - expect(wiki.filterTiddlers("a b c +[prepend:-2[rr ss tt uu]]").join(",")).toBe("rr,ss,a,b,c"); - expect(wiki.filterTiddlers("a b c +[prepend:-4[rr ss tt uu]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[prepend:-5[vv ww xx yy]]").join(",")).toBe("a,b,c"); - }); - - it("should handle the putafter operator", function() { - expect(wiki.filterTiddlers("a b c dd ee +[putafter[b]]").join(",")).toBe("a,b,ee,c,dd"); - expect(wiki.filterTiddlers("a b c dd ee +[putafter:1[b]]").join(",")).toBe("a,b,ee,c,dd"); - expect(wiki.filterTiddlers("a b c dd ee +[putafter:2[b]]").join(",")).toBe("a,b,dd,ee,c"); - expect(wiki.filterTiddlers("a b c dd ee +[putafter:3[b]]").join(",")).toBe("a,b,c,dd,ee"); - // It starts to duplicate elements - expect(wiki.filterTiddlers("a b c dd ee +[putafter:4[b]]").join(",")).toBe("a,b,b,c,dd,ee"); - expect(wiki.filterTiddlers("a b c dd ee +[putafter:5[b]]").join(",")).toBe("a,b,a,b,c,dd,ee"); - // There are only 5 elements in the input - expect(wiki.filterTiddlers("a b c ff gg +[putafter:6[b]]").join(",")).toBe("a,b,a,b,c,ff,gg"); - - // -1 starts to "eat" elements for the left and duplicates b - expect(wiki.filterTiddlers("a b c hh ii +[putafter:-1[b]]").join(",")).toBe("a,b,b,c,hh,ii"); - // -2 moves c, hh, ii behind b, which is not visible - expect(wiki.filterTiddlers("a b c hh ii +[putafter:-2[b]]").join(",")).toBe("a,b,c,hh,ii"); - // only ii is used from input and it's moved behind b - expect(wiki.filterTiddlers("a b c hh ii +[putafter:-4[b]]").join(",")).toBe("a,b,ii,c,hh"); - // wasting time, because there are only 5 elements - expect(wiki.filterTiddlers("a b c hh ii +[putafter:-5[b]]").join(",")).toBe("a,b,c,hh,ii"); - // there are only 5 elements - expect(wiki.filterTiddlers("a b c hh ii +[putafter:-10[b]]").join(",")).toBe("a,b,c,hh,ii"); - - // use NAN uses default = 1 - expect(wiki.filterTiddlers("a b c jj kk +[putafter:NAN[b]]").join(",")).toBe("a,b,kk,c,jj"); - }); - - it("should handle the putbefore operator", function() { - expect(wiki.filterTiddlers("a b c dd +[putbefore[b]]").join(",")).toBe("a,dd,b,c"); - expect(wiki.filterTiddlers("a b c ff +[putbefore:1[b]]").join(",")).toBe("a,ff,b,c"); - expect(wiki.filterTiddlers("a b c gg +[putbefore:2[b]]").join(",")).toBe("a,c,gg,b"); - - expect(wiki.filterTiddlers("a b c [[g g]] +[putbefore:2[b]]").join(",")).toBe("a,c,g g,b"); - - // this one is strange - expect(wiki.filterTiddlers("a b c ee +[putbefore:0[b]]").join(",")).toBe("a,a,b,c,ee"); - - // b is not part of the list anymore, so it will be appended at the end ??? - expect(wiki.filterTiddlers("a b c hh +[putbefore:3[b]]").join(",")).toBe("a,b,c,hh"); - expect(wiki.filterTiddlers("a b c ii +[putbefore:4[b]]").join(",")).toBe("a,a,b,c,ii"); - - // ???? - expect(wiki.filterTiddlers("a b c ii +[putbefore:10[b]]").join(",")).toBe("a,a,b,c,ii"); - - expect(wiki.filterTiddlers("a b c kk +[putbefore:-1[b]]").join(",")).toBe("a,b,c,kk"); - expect(wiki.filterTiddlers("a b c ll +[putbefore:-2[b]]").join(",")).toBe("a,c,ll,b"); - - expect(wiki.filterTiddlers("a b c mm +[putbefore:-3[b]]").join(",")).toBe("a,mm,b,c"); - - expect(wiki.filterTiddlers("a b c nn +[putbefore:-10[b]]").join(",")).toBe("a,b,c,nn"); - }); - - it("should handle the putfirst operator", function() { - expect(wiki.filterTiddlers("a b c +[putfirst[a b]]").join(",")).toBe("c,a,b"); - expect(wiki.filterTiddlers("a b c +[putfirst[]]").join(",")).toBe("c,a,b"); - expect(wiki.filterTiddlers("a b c +[putfirst:2[]]").join(",")).toBe("b,c,a"); - expect(wiki.filterTiddlers("a b c +[putfirst:3[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[putfirst:4[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[putfirst:-0[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[putfirst:-1[]]").join(",")).toBe("b,c,a"); - expect(wiki.filterTiddlers("a b c +[putfirst:-2[]]").join(",")).toBe("c,a,b"); - expect(wiki.filterTiddlers("a b c +[putfirst:-4[]]").join(",")).toBe("a,b,c"); - }); - - it("should handle the putlast operator", function() { - expect(wiki.filterTiddlers("a b c +[putlast[d e]]").join(",")).toBe("b,c,a"); - expect(wiki.filterTiddlers("a b c +[putlast[]]").join(",")).toBe("b,c,a"); - expect(wiki.filterTiddlers("a b c +[putlast:1[]]").join(",")).toBe("b,c,a"); - expect(wiki.filterTiddlers("a b c +[putlast:2[]]").join(",")).toBe("c,a,b"); - expect(wiki.filterTiddlers("a b c +[putlast:3[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[putlast:4[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[putlast:-0[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[putlast:0[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[putlast:-1[]]").join(",")).toBe("c,a,b"); - expect(wiki.filterTiddlers("a b c +[putlast:-2[]]").join(",")).toBe("b,c,a"); - expect(wiki.filterTiddlers("a b c +[putlast:-4[]]").join(",")).toBe("a,b,c"); - }); - - it("should handle the remove operator", function() { - expect(wiki.filterTiddlers("a b c +[remove[d e]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[remove[a]]").join(",")).toBe("b,c"); - expect(wiki.filterTiddlers("a b c +[remove[c b a]]").join(",")).toBe(""); - }); - - it("should handle the replace operator", function() { - expect(wiki.filterTiddlers("a b c dd +[replace[a]]").join(",")).toBe("dd,b,c"); - expect(wiki.filterTiddlers("a b c dd ee +[replace:2[a]]").join(",")).toBe("dd,ee,b,c"); - expect(wiki.filterTiddlers("a b c dd ee +[replace:5[c]]").join(",")).toBe("a,b,a,b,c,dd,ee"); - - // strange things happen. - expect(wiki.filterTiddlers("a b c dd ee +[replace:-1[c]]").join(",")).toBe("a,b,b,c,dd,ee"); - expect(wiki.filterTiddlers("a b c dd ee +[replace:-2[c]]").join(",")).toBe("a,b,c,dd,ee"); - expect(wiki.filterTiddlers("a b c dd ee +[replace:-2[ee]]").join(",")).toBe("a,b,c,dd,c,dd,ee"); - }); - - it("should handle the sortby operator", function() { - expect(wiki.filterTiddlers("a b c +[sortby[d e]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("a b c +[sortby[b c a]]").join(",")).toBe("b,c,a"); - expect(wiki.filterTiddlers("aa a b c +[sortby[b c a cc]]").join(",")).toBe("aa,b,c,a"); - expect(wiki.filterTiddlers("a bb b c +[sortby[b c a cc]]").join(",")).toBe("bb,b,c,a"); - expect(wiki.filterTiddlers("a bb cc b c +[sortby[b c a cc]]").join(",")).toBe("bb,b,c,a,cc"); - - expect(wiki.filterTiddlers("b a b c +[sortby[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("b a b c +[sortby[a b b c]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("b a b c +[sortby[b a c b]]").join(",")).toBe("b,a,c"); - }); - - it("should handle the sortan operator", function() { - expect(wiki.filterTiddlers("b a c +[sortan[]]").join(",")).toBe("a,b,c"); - expect(wiki.filterTiddlers("b2 a3 a1 b1 c2 a2 c3 b3 c1 +[sortan[]]").join(",")).toBe("a1,a2,a3,b1,b2,b3,c1,c2,c3"); - expect(wiki.filterTiddlers("b2 a10 c10 a1 b1 c2 a2 b10 c1 +[sortan[]]").join(",")).toBe("a1,a2,a10,b1,b2,b10,c1,c2,c10"); - expect(wiki.filterTiddlers("TiddlerOne $:/TiddlerTwo [[Tiddler Three]] +[sortan[]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); - }); - - it("should handle the sortan operator sorting on date fields", function() { - expect(wiki.filterTiddlers("TiddlerOne $:/TiddlerTwo [[Tiddler Three]] +[sortan[modified]]").join(",")).toBe("$:/TiddlerTwo,TiddlerOne,Tiddler Three"); - expect(wiki.filterTiddlers("hasList TiddlerOne $:/TiddlerTwo [[Tiddler Three]] +[sortan[modified]]").join(",")).toBe("hasList,$:/TiddlerTwo,TiddlerOne,Tiddler Three"); - }); - - it("should handle the slugify operator", function() { - expect(wiki.filterTiddlers("[[Joe Bloggs]slugify[]]").join(",")).toBe("joe-bloggs"); - expect(wiki.filterTiddlers("[[Joe Bloggs2]slugify[]]").join(",")).toBe("joe-bloggs2"); - expect(wiki.filterTiddlers("[[@£$%^&*((]slugify[]]").join(",")).toBe("64-163-36-37-94-38-42-40-40"); - expect(wiki.filterTiddlers("One one ONE O!N!E +[slugify[]]").join(",")).toBe("one,one,one,one"); - expect(wiki.filterTiddlers("TiddlerOne $:/TiddlerTwo +[slugify[]]").join(",")).toBe("tiddler-one,tiddler-two"); - }); - - it("should handle the sortsub operator", function() { - var widget = require("$:/core/modules/widgets/widget.js"); - var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, - { wiki:wiki, document:$tw.document}); - rootWidget.makeChildWidgets(); - var anchorWidget = rootWidget.children[0]; - rootWidget.setVariable("sort1","[length[]]"); - rootWidget.setVariable("sort2","[get[text]else[]length[]]"); - rootWidget.setVariable("sort3","[{!!value}divide{!!cost}]"); - rootWidget.setVariable("sort4","[{!!title}]"); - rootWidget.setVariable("undefined-variable","[]"); - rootWidget.setVariable("echo","$text$",[{name:"text"}],true); - rootWidget.setVariable("sort4-macro-param","[subfilter]"); - expect(wiki.filterTiddlers("[sortsub:number]",anchorWidget).join(",")).toBe("one,hasList,has filter,TiddlerOne,$:/TiddlerTwo,Tiddler Three,$:/ShadowPlugin,a fourth tiddler,filter regexp test"); - expect(wiki.filterTiddlers("[!sortsub:number]",anchorWidget).join(",")).toBe("filter regexp test,a fourth tiddler,$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,has filter,TiddlerOne,hasList,one"); - expect(wiki.filterTiddlers("[sortsub:string]",anchorWidget).join(",")).toBe("has filter,TiddlerOne,$:/TiddlerTwo,Tiddler Three,$:/ShadowPlugin,a fourth tiddler,filter regexp test,one,hasList"); - expect(wiki.filterTiddlers("[!sortsub:string]",anchorWidget).join(",")).toBe("hasList,one,filter regexp test,a fourth tiddler,$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,has filter,TiddlerOne"); - expect(wiki.filterTiddlers("[sortsub:number]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,a fourth tiddler,$:/TiddlerTwo,Tiddler Three,filter regexp test,$:/ShadowPlugin"); - expect(wiki.filterTiddlers("[!sortsub:number]",anchorWidget).join(",")).toBe("$:/ShadowPlugin,filter regexp test,Tiddler Three,$:/TiddlerTwo,a fourth tiddler,has filter,hasList,TiddlerOne,one"); - expect(wiki.filterTiddlers("[sortsub:string]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,$:/ShadowPlugin,a fourth tiddler,$:/TiddlerTwo,Tiddler Three,filter regexp test"); - expect(wiki.filterTiddlers("[!sortsub:string]",anchorWidget).join(",")).toBe("filter regexp test,Tiddler Three,$:/TiddlerTwo,a fourth tiddler,$:/ShadowPlugin,has filter,hasList,TiddlerOne,one"); - expect(wiki.filterTiddlers("[[TiddlerOne]] [[$:/TiddlerTwo]] [[Tiddler Three]] [[a fourth tiddler]] +[!sortsub:number]",anchorWidget).join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne,a fourth tiddler"); - expect(wiki.filterTiddlers("a1 a10 a2 a3 b10 b3 b1 c9 c11 c1 +[sortsub:alphanumeric]",anchorWidget).join(",")).toBe("a1,a2,a3,a10,b1,b3,b10,c1,c9,c11"); - // #7155. The order of the output is the same as the input when an undefined variable is used in the subfitler - expect(wiki.filterTiddlers("a2 a10 a1 +[sortsub:alphanumeric]",anchorWidget).join(",")).toBe("a2,a10,a1"); - expect(wiki.filterTiddlers("a1 a10 a2 a3 b10 b3 b1 c9 c11 c1 +[sortsub:alphanumeric]",anchorWidget).join(",")).toBe("a1,a2,a3,a10,b1,b3,b10,c1,c9,c11"); - }); - - it("should handle the toggle operator", function() { - expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] +[toggle[one]]").join(",")).toBe("two"); - expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] -[[one]] +[toggle[one]]").join(",")).toBe("two,one"); - expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] +[toggle[three],[four]]").join(",")).toBe("one,two,three"); - expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] [[three]] +[toggle[three],[four]]").join(",")).toBe("one,two,four"); - expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] [[three]] [[four]] +[toggle[three],[five]]").join(",")).toBe("one,two,five,four"); - }); - - it("should handle multiple operands for search-replace", function() { - var widget = require("$:/core/modules/widgets/widget.js"); - var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, - { wiki:wiki, document:$tw.document}); - rootWidget.makeChildWidgets(); - var anchorWidget = rootWidget.children[0]; - rootWidget.setVariable("var1","different"); - rootWidget.setVariable("myregexp1","e|o"); - rootWidget.setVariable("myregexp2","^Unlike "); - rootWidget.setVariable("myregexp3","^(?!Unlike).*$"); - rootWidget.setVariable("name","(\w+)\s(\w+)"); - expect(wiki.filterTiddlers("[[Welcome to TiddlyWiki, a unique non-linear webpage.]search-replace[webpage],[notebook]]").join(",")).toBe("Welcome to TiddlyWiki, a unique non-linear notebook."); - expect(wiki.filterTiddlers("[[Welcome to TiddlyWiki, a unique non-linear notebook.]search-replace[unique],]",anchorWidget).join(",")).toBe("Welcome to TiddlyWiki, a different non-linear notebook."); - expect(wiki.filterTiddlers("[[Welcome to TiddlyWiki, a unique non-linear notebook.]search-replace[TiddlyWiki],{one}]",anchorWidget).join(",")).toBe("Welcome to This is the text of tiddler [[one]], a unique non-linear notebook."); - expect(wiki.filterTiddlers("[[Hello There]search-replace:g:regexp,[]]",anchorWidget).join(",")).toBe("Hll Thr"); - expect(wiki.filterTiddlers("[[Hello There]search-replace::regexp,[]]",anchorWidget).join(",")).toBe("Hllo There"); - expect(wiki.filterTiddlers("[[Hello There]search-replace:gi[H],[]]",anchorWidget).join(",")).toBe("ello Tere"); - expect(wiki.filterTiddlers("[[Unlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data]search-replace:g:regexp,[]]",anchorWidget).join(",")).toBe("conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data"); - expect(wiki.filterTiddlers("[[Unlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data]search-replace:gm:regexp,[]]",anchorWidget).join(",")).toBe("conventional online services, TiddlyWiki lets you choose where to keep your data\nconventional online services, TiddlyWiki lets you choose where to keep your data\nconventional online services, TiddlyWiki lets you choose where to keep your data\nconventional online services, TiddlyWiki lets you choose where to keep your data"); - expect(wiki.filterTiddlers("[[Hello There\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nguaranteeing that in the decades to come you will still be able to use the notes you take today.]search-replace:gm:regexp,[]]",anchorWidget).join(",")).toBe("\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\n"); - expect(wiki.filterTiddlers("[[This is equation $$x$$ end.]search-replace[equation $$x$$ end.],[relation $$x$$ finish.]]").join(",")).toBe("This is relation $$x$$ finish."); - expect(wiki.filterTiddlers("[[This is an amazing TiddlyWiki]] [[How old is TiddlyWiki?. TiddlyWiki is great]] [[My TiddlyWiki is so fast.]] +[search-replace:g:regexp[TiddlyWiki],[TW]]").join(",")).toBe("This is an amazing TW,How old is TW?. TW is great,My TW is so fast."); - expect(wiki.filterTiddlers("[[This is an amazing TiddlyWiki]] [[How old is TiddlyWiki?. TiddlyWiki is great]] [[My TiddlyWiki is so fast.]] +[search-replace::regexp[TiddlyWiki],[TW]]").join(",")).toBe("This is an amazing TW,How old is TW?. TiddlyWiki is great,My TW is so fast."); - expect(wiki.filterTiddlers("[[This is an amazing TiddlyWiki]] [[How old is TiddlyWiki?. TiddlyWiki is great]] [[My TiddlyWiki is so fast.]] +[search-replace:g[TiddlyWiki],[TW]]").join(",")).toBe("This is an amazing TW,How old is TW?. TW is great,My TW is so fast."); - }); - - it("should handle the pad operator", function() { - expect(wiki.filterTiddlers("[[2]pad[]]").join(",")).toBe("2"); - expect(wiki.filterTiddlers("[[2]pad[0]]").join(",")).toBe("2"); - expect(wiki.filterTiddlers("[[2]pad[1]]").join(",")).toBe("2"); - expect(wiki.filterTiddlers("2 20 +[pad[3]]").join(",")).toBe("002,020"); - expect(wiki.filterTiddlers("[[2]pad[9]]").join(",")).toBe("000000002"); - expect(wiki.filterTiddlers("[[2]pad[9],[a]]").join(",")).toBe("aaaaaaaa2"); - expect(wiki.filterTiddlers("[[12]pad[9],[abc]]").join(",")).toBe("abcabca12"); - expect(wiki.filterTiddlers("[[12]pad:suffix[9],[abc]]").join(",")).toBe("12abcabca"); - }); - - it("should handle the escapecss operator", function() { - expect(wiki.filterTiddlers("[[Hello There]escapecss[]]").join(",")).toBe("Hello\\ There"); - expect(wiki.filterTiddlers('\'"Reveal.js" by Devin Weaver[1]\' +[escapecss[]]').join(",")).toBe('\\"Reveal\\.js\\"\\ by\\ Devin\\ Weaver\\[1\\]'); - expect(wiki.filterTiddlers(".foo#bar (){} '--a' 0 \0 +[escapecss[]]").join(",")).toBe("\\.foo\\#bar,\\(\\)\\{\\},--a,\\30 ,\ufffd"); - expect(wiki.filterTiddlers("'' +[escapecss[]]").join(",")).toBe(""); - expect(wiki.filterTiddlers("1234 +[escapecss[]]").join(",")).toBe("\\31 234"); - expect(wiki.filterTiddlers("'-25' +[escapecss[]]").join(",")).toBe("-\\32 5"); - expect(wiki.filterTiddlers("'-' +[escapecss[]]").join(",")).toBe("\\-"); - }); - - it("should handle the format operator", function() { - expect(wiki.filterTiddlers("[[Hello There]] [[GettingStarted]] +[format:titlelist[]]").join(" ")).toBe("[[Hello There]] GettingStarted"); - expect(wiki.filterTiddlers("[title[Hello There]] +[format:titlelist[]]").join(" ")).toBe("[[Hello There]]"); - expect(wiki.filterTiddlers("[title[HelloThere]] +[format:titlelist[]]").join(" ")).toBe("HelloThere"); - expect(wiki.filterTiddlers("0 +[format:timestamp[]]").join(",")).toBe("19700101000000000"); - expect(wiki.filterTiddlers("1603188514443 +[format:timestamp[]]").join(",")).toBe("20201020100834443"); - expect(wiki.filterTiddlers("void +[format:timestamp[]]").join(",")).toBe(""); - }); - - it("should handle the deserializers operator", function() { - var expectedDeserializers = ["application/javascript","application/json","application/x-tiddler","application/x-tiddler-html-div","application/x-tiddlers","text/css","text/html","text/plain"]; - if($tw.browser) { - expectedDeserializers.unshift("(DOM)"); - } - expect(wiki.filterTiddlers("[deserializers[]]").join(",")).toBe(expectedDeserializers.join(",")); - }); - - it("should handle the charcode operator", function() { - expect(wiki.filterTiddlers("[charcode[9]]").join(" ")).toBe(String.fromCharCode(9)); - expect(wiki.filterTiddlers("[charcode[9],[10]]").join(" ")).toBe(String.fromCharCode(9) + String.fromCharCode(10)); - expect(wiki.filterTiddlers("[charcode[]]").join(" ")).toBe(""); - }); - - it("should handle the levenshtein operator", function() { - expect(wiki.filterTiddlers("[[apple]levenshtein[apple]]").join(" ")).toBe("0"); - expect(wiki.filterTiddlers("[[apple]levenshtein[banana]]").join(" ")).toBe("9"); - expect(wiki.filterTiddlers("[[representation]levenshtein[misreprehensionisation]]").join(" ")).toBe("10"); - expect(wiki.filterTiddlers("[[the cat sat on the mat]levenshtein[the hat saw in every category]]").join(" ")).toBe("13"); - }); - - it("should handle the makepatches operator", function() { - expect(wiki.filterTiddlers("[[apple]makepatches[apple]]").join(" ")).toBe(""); - expect(wiki.filterTiddlers("[[apple]makepatches[banana]]").join(" ")).toBe("@@ -1,5 +1,6 @@\n-apple\n+banana\n"); - expect(wiki.filterTiddlers("[[representation]makepatches[misreprehensionisation]]").join(" ")).toBe("@@ -1,13 +1,21 @@\n+mis\n repre\n-sent\n+hensionis\n atio\n"); - expect(wiki.filterTiddlers("[[the cat sat on the mat]makepatches[the hat saw in every category]]").join(" ")).toBe("@@ -1,22 +1,29 @@\n the \n-c\n+h\n at sa\n-t on the mat\n+w in every category\n"); - }); - - it("should parse filter variable parameters", function(){ - expect($tw.utils.parseFilterVariable("currentTiddler")).toEqual( - { name: 'currentTiddler', params: [ ] } - ); - expect($tw.utils.parseFilterVariable("now DDMM")).toEqual( - { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: 'DDMM', end: 8 }] } - ); - expect($tw.utils.parseFilterVariable("now DDMM UTC")).toEqual( - { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: 'DDMM', end: 8 }, { type: 'macro-parameter', start: 8, value: 'UTC', end: 12 }] } - ); - expect($tw.utils.parseFilterVariable("now format:DDMM")).toEqual( - { name: 'now', params: [{ type: 'macro-parameter', name:'format', start: 3, value: 'DDMM', end: 15 }] } - ); - expect($tw.utils.parseFilterVariable("now format:'DDMM'")).toEqual( - { name: 'now', params: [{ type: 'macro-parameter', name:'format', start: 3, value: 'DDMM', end: 17 }] } - ); - expect($tw.utils.parseFilterVariable("nowformat:'DDMM'")).toEqual( - { name: 'nowformat:\'DDMM\'', params: [] } - ); - expect($tw.utils.parseFilterVariable("nowformat:'DD MM'")).toEqual( - { name: 'nowformat:', params: [{ type: 'macro-parameter', start: 10, value: 'DD MM', end: 17 }] } - ); - expect($tw.utils.parseFilterVariable("now [UTC]YYYY0MM0DD0hh0mm0ssXXX")).toEqual( - { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: '[UTC]YYYY0MM0DD0hh0mm0ssXXX', end: 31 }] } - ); - expect($tw.utils.parseFilterVariable("now '[UTC]YYYY0MM0DD0hh0mm0ssXXX'")).toEqual( - { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: '[UTC]YYYY0MM0DD0hh0mm0ssXXX', end: 33 }] } - ); - expect($tw.utils.parseFilterVariable("now format:'[UTC]YYYY0MM0DD0hh0mm0ssXXX'")).toEqual( - { name: 'now', params: [{ type: 'macro-parameter', start: 3, name:'format', value: '[UTC]YYYY0MM0DD0hh0mm0ssXXX', end: 40 }] } - ); - expect($tw.utils.parseFilterVariable("")).toEqual( - { name: '', params: [] } - ); - }); - - it("should handle the encodeuricomponent and decodeuricomponent operators", function() { - expect(wiki.filterTiddlers("[[<>:\"/\\|?*]encodeuricomponent[]]").join(",")).toBe("%3C%3E%3A%22%2F%5C%7C%3F%2A"); - }); - - } - + // Test filter parsing + it("should parse new-style rich operator suffixes", function() { + expect($tw.wiki.parseFilter("[search:: four, , five,, six [operand]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'search', suffix : ': four, , five,, six ', suffixes : [ [ ], [ 'four', 'five', 'six' ] ], operands: [ { text:'operand' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[search: one, two ,three :[operand]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'search', suffix : ' one, two ,three :', suffixes : [ [ 'one', 'two', 'three' ], [ ] ], operands: [ { text:'operand' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[search: one, two ,three :[operand]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'search', suffix : ' one, two ,three :', suffixes : [ [ 'one', 'two', 'three' ], [ ] ], operands: [ { text:'operand' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[search: one, two ,three : four, , five,, six [operand]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'search', suffix : ' one, two ,three : four, , five,, six ', suffixes : [ [ 'one', 'two', 'three' ], [ 'four', 'five', 'six' ] ], operands: [ { text:'operand' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[search: , : [operand]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'search', suffix : ' , : ', suffixes : [ [ ], [ ] ], operands: [ { text:'operand' } ] } ] } ] + ); }); - })(); + it("should parse multiple operands for operators", function() { + expect($tw.wiki.parseFilter("[search: , : [operand],[operand2]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'search', suffix : ' , : ', suffixes : [ [ ], [ ] ], operands: [ { text:'operand' }, { text:'operand2' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[search: , : [oper,and],[operand2]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'search', suffix : ' , : ', suffixes : [ [ ], [ ] ], operands: [ { text:'oper,and' }, { text:'operand2' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[[GettingStarted]replace:[operand],[operand2]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'title', operands: [ { text:'GettingStarted' } ] }, { operator : 'replace', suffix : '', suffixes : [[]], operands: [ { text:'operand' }, { text:'operand2' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[[GettingStarted]replace[operand],[operand2]split[-]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'title', operands: [{ text:'GettingStarted' }] }, { operator : 'replace', operands: [{ text:'operand' }, { text:'operand2' }] }, { operator : 'split', operands: [ { text:'-' } ] } ] } ] + ); + expect($tw.wiki.parseFilter("[[GettingStarted]replace[operand],[operand2]split[-]split2[a],[b]]")).toEqual( + [ { prefix : '', operators : [ { operator : 'title', operands: [{ text:'GettingStarted' }] }, { operator : 'replace', operands: [ { text:'operand' }, { text:'operand2' } ] }, { operator : 'split', operands: [ {text:'-'} ] }, { operator : 'split2', operands: [ { text:'a' }, { text: 'b' }] } ] } ] + ); + expect($tw.wiki.parseFilter("[[GettingStarted]replace[operand],[operand2]split[-]split2[a],,{c}]")).toEqual( + [ { prefix : '', operators : [ { operator : 'title', operands: [{ text:'GettingStarted' }] }, { operator : 'replace', operands: [ { text:'operand' }, { text:'operand2' } ] }, { operator : 'split', operands: [ {text:'-'} ] }, { operator : 'split2', operands: [ { text:'a' }, { variable: true, text: 'b' }, { indirect: true, text: 'c' }] } ] } ] + ); + }); + + describe("With tiddlers in the store unsorted",function() { + testWithAndWithoutIndexers(); + }); + describe("With tiddlers in the store sorted ascending",function() { + testWithAndWithoutIndexers({sort: "ascending"}); + }); + describe("With tiddlers in the store sorted descending",function() { + testWithAndWithoutIndexers({sort: "descending"}); + }); + +function testWithAndWithoutIndexers(options) { + describe("With no indexers", function() { + var wiki = setupWiki(Object.assign({},options,{enableIndexers: []})); + it("should not create indexes when requested not to",function() { + expect(wiki.getIndexer("FieldIndexer")).toBe(null); + }); + runTests(wiki); + }); + + describe("With all indexers", function() { + var wiki = setupWiki(options); + if(wiki.getIndexer("FieldIndexer")) { + wiki.getIndexer("FieldIndexer").setMaxIndexedValueLength(8); // Note that JoeBloggs is 9, and John is 5 + } + runTests(wiki); + }); +} + +function setupWiki(wikiOptions) { + wikiOptions = wikiOptions || {}; + // Create a wiki + var wiki = new $tw.Wiki(wikiOptions); + // Add a plugin containing some shadow tiddlers + var shadowTiddlers = { + tiddlers: { + "$:/TiddlerFive": { + title: "$:/TiddlerFive", + text: "Everything in federation", + tags: ["two"] + }, + "TiddlerSix": { + title: "TiddlerSix", + text: "Missing inaction from [[TiddlerOne]]", + filter: "[[one]] [[a a]] [subfilter{hasList!!list}]", + tags: [] + }, + "TiddlerSeventh": { + title: "TiddlerSeventh", + text: "", + list: "[[TiddlerOne]] [[Tiddler Three]] [[a fourth tiddler]] [[MissingTiddler]]", + tags: ["one"] + }, + "Tiddler8": { + title: "Tiddler8", + text: "Tidd", + tags: ["one"], + "test-field": "JoeBloggs" + } + } + }; + var tiddlers = [{ + title: "$:/ShadowPlugin", + text: JSON.stringify(shadowTiddlers), + "plugin-type": "plugin", + type: "application/json" + },{ + title: "TiddlerOne", + text: "The quick brown fox in $:/TiddlerTwo", + tags: ["one"], + cost: "123", + value: "120", + slug: "tiddler-one", + authors: "Joe Bloggs", + modifier: "JoeBloggs", + modified: "201304152222" + },{ + title: "$:/TiddlerTwo", + text: "The rain in Spain\nfalls mainly on the plain and [[a fourth tiddler]]", + tags: ["two"], + cost: "42", + value: "190", + slug: "tiddler-two", + authors: "[[John Doe]]", + modifier: "John", + modified: "201304152211" + },{ + title: "Tiddler Three", + text: "The speed of sound in light\n\nThere is no [[TiddlerZero]] but [[TiddlerSix]]", + tags: ["one","two"], + cost: "56", + value: "80", + modifier: "John", + modified: "201304162202" + },{ + title: "a fourth tiddler", + text: "The quality of mercy is not drained by [[Tiddler Three]]", + tags: [], + cost: "82", + value: "72", + empty: "not", + modifier: "John" + },{ + title: "one", + text: "This is the text of tiddler [[one]]", + list: "[[Tiddler Three]] [[TiddlerOne]]", + empty: "", + modifier: "John" + },{ + title: "hasList", + text: "This is the text of tiddler [[hasList]]", + list: "[[Tiddler Three]] [[TiddlerOne]]", + modifier: "PMario" + },{ + title: "has filter", + text: "This is the text of tiddler [[has filter]]", + filter: "[[Tiddler Three]] [[TiddlerOne]] [subfilter{hasList!!list}]", + modifier: "PMario" + },{ + title: "filter regexp test", + text: "Those strings have been used to create the `regexp = /[+|\-|~]?([[](?:[^\]])*\]+)|([+|-|~|\S]\S*)/;`", + filter: "+aaa -bbb ~ccc aaaaaabbbbbbbbaa \"bb'b\" 'cc\"c' [[abc]] [[tiddler with spaces]] [is[test]] [is[te st]] a s df [enlist] +[enlist:raw{test with spaces}] [enlist:raw{test with spaces}] [[a a]] [[ ] [ ]] [[ [hugo]] [subfilter{Story/Tower of Hanoi/A-C Sequence}]", + modifier: "PMario" + }]; + // Load the tiddlers in the required order + var fnCompare; + switch(wikiOptions.sort) { + case "ascending": + fnCompare = function(a,b) { + if(a.title < b.title) { + return -1; + } else if(a.title > b.title) { + return +1; + } else { + return 0; + } + }; + break; + case "descending": + fnCompare = function(a,b) { + if(a.title < b.title) { + return +1; + } else if(a.title > b.title) { + return -1; + } else { + return 0; + } + }; + break; + } + if(fnCompare) { + tiddlers.sort(fnCompare); + } + wiki.addTiddlers(tiddlers); + // Unpack plugin tiddlers + wiki.readPluginInfo(); + wiki.registerPluginTiddlers("plugin"); + wiki.unpackPluginTiddlers(); + wiki.addIndexersToWiki(); + return wiki; +} + +// Our tests +function runTests(wiki) { + + it("should handle the enlist operator", function() { + expect(wiki.filterTiddlers("[enlist[one two three]addsuffix[!]]").join(",")).toBe("one!,two!,three!"); + }); + + it("should handle the enlist-input operator", function() { + expect(wiki.filterTiddlers("[[one two three]enlist-input[]]").join(",")).toBe("one,two,three"); + expect(wiki.filterTiddlers("[[one two two three]enlist-input[]]").join(",")).toBe("one,two,three"); + expect(wiki.filterTiddlers("[[one two two three]enlist-input:dedupe[]]").join(",")).toBe("one,two,three"); + expect(wiki.filterTiddlers("[[one two two three]enlist-input:raw[]]").join(",")).toBe("one,two,two,three"); + expect(wiki.filterTiddlers("[[one two three]] [[four five six]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six"); + expect(wiki.filterTiddlers("[[one two three]] [[four five six]] [[seven eight]] +[enlist-input[]]").join(",")).toBe("one,two,three,four,five,six,seven,eight"); + expect(wiki.filterTiddlers("[[]] +[enlist-input[]]").join(",")).toBe(""); + }); + + it("should handle the then and else operators", function() { + expect(wiki.filterTiddlers("[modifier[JoeBloggs]then[Susi]]").join(",")).toBe("Susi"); + expect(wiki.filterTiddlers("[!modifier[JoeBloggs]then[Susi]]").join(",")).toBe("Susi,Susi,Susi,Susi,Susi,Susi,Susi,Susi"); + expect(wiki.filterTiddlers("[modifier[DaveBloggs]then[Susi]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[modifier[JoeBloggs]else[Susi]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[!modifier[JoeBloggs]else[Susi]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[modifier[DaveBloggs]else[Susi]]").join(",")).toBe("Susi"); + }); + + it("should handle the ~ prefix", function() { + expect(wiki.filterTiddlers("[modifier[JoeBloggs]] ~[[No such tiddler]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[modifier[Susi]] ~[[No such tiddler]]").join(",")).toBe("No such tiddler"); + expect(wiki.filterTiddlers("~[[No such tiddler]]").join(",")).toBe("No such tiddler"); + expect(wiki.filterTiddlers("[my-field[present]] ~[[No such tiddler]]").join(",")).toBe("No such tiddler"); + }); + + it("should handle the lookup operator", function() { + expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],,Tidd"); + expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],8,Tidd"); + expect(wiki.filterTiddlers("Six Seventh 8 +[lookup:8[Tiddler],[text]]").join(",")).toBe("Missing inaction from [[TiddlerOne]],8,Tidd"); + expect(wiki.filterTiddlers("Six Seventh 8 +[lookup[Tiddler],[tags]]").join(",")).toBe(",one,one"); + }); + + it("should retrieve shadow tiddlers", function() { + expect(wiki.getTiddlerText("Tiddler8")).toBe("Tidd"); + }); + + it("should handle the title operator", function() { + expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three"); + expect(wiki.filterTiddlers("[!title[Tiddler Three]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,TiddlerOne"); + expect(wiki.filterTiddlers("TiddlerOne [title[$:/TiddlerTwo]] [[Tiddler Three]] [[A Missing Tiddler]]").join(",")).toBe("TiddlerOne,$:/TiddlerTwo,Tiddler Three,A Missing Tiddler"); + }); + + it("should handle the field operator", function() { + expect(wiki.filterTiddlers("[modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[!modifier[JoeBloggs]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[!is[system]!modifier[JoeBloggs]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[field:modifier[JoeBloggs]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[!field:modifier[JoeBloggs]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[!is[system]!field:modifier[JoeBloggs]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[modifier[John]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three"); + expect(wiki.filterTiddlers("[!modifier[John]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,TiddlerOne"); + expect(wiki.filterTiddlers("[!is[system]!modifier[John]]").join(",")).toBe("filter regexp test,has filter,hasList,TiddlerOne"); + expect(wiki.filterTiddlers("[field:modifier[John]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three"); + expect(wiki.filterTiddlers("[!field:modifier[John]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,TiddlerOne"); + expect(wiki.filterTiddlers("[!is[system]!field:modifier[John]]").join(",")).toBe("filter regexp test,has filter,hasList,TiddlerOne"); + }); + + it("should handle the regexp operator", function() { + expect(wiki.filterTiddlers("[regexp[id]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[!regexp[id]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,one"); + expect(wiki.filterTiddlers("[regexp[Tid]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[regexp[(?i)Tid]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[!regexp[Tid(?i)]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,has filter,hasList,one"); + }); + + // The following 2 tests should write a log -> WARNING: Filter modifier has a deprecated regexp operand XXXX + // The test should pass anyway. + it("should handle the field operator with a regular expression operand", function() { + spyOn(console, 'log'); + expect(wiki.filterTiddlers("[modifier/JoeBloggs/]").join(",")).toBe("TiddlerOne"); + expect(console.log).toHaveBeenCalledWith("WARNING: Filter", "modifier", "has a deprecated regexp operand", /JoeBloggs/); + console.log.calls.reset(); + expect(wiki.filterTiddlers("[modifier/Jo/]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne"); + expect(console.log).toHaveBeenCalledWith("WARNING: Filter", "modifier", "has a deprecated regexp operand", /Jo/); + }); + + it("should handle regular expression operands without crashing", function() { + spyOn(console, 'log'); + // We don't really care about the results. Just don't get RSoD. + expect(() => wiki.filterTiddlers("[all/current/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[prefix/anything/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[title/anything/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[/anything/]")).not.toThrow(); + expect(() => wiki.filterTiddlers("[//]")).not.toThrow(); + }); + + it("should handle the prefix operator", function() { + expect(wiki.filterTiddlers("[prefix[Tiddler]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[prefix:casesensitive[tiddler]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[prefix:caseinsensitive[tiddler]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[prefix[nothing]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]prefix[]]").join(",")).toBe("ABCDE,abcde"); + }); + + it("should handle the suffix operator", function() { + expect(wiki.filterTiddlers("[suffix[One]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[suffix:casesensitive[one]]").join(",")).toBe("one"); + expect(wiki.filterTiddlers("[suffix:caseinsensitive[one]]").join(",")).toBe("one,TiddlerOne"); + expect(wiki.filterTiddlers("[suffix[nothing]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]suffix[]]").join(",")).toBe("ABCDE,abcde"); + }); + + it("should handle the removeprefix operator", function() { + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix[ABC]]").join(",")).toBe("DE"); + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix:casesensitive[ABC]]").join(",")).toBe("DE"); + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix:caseinsensitive[abc]]").join(",")).toBe("DE,de"); + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removeprefix[]]").join(",")).toBe("ABCDE,abcde"); + }); + + it("should handle the removesuffix operator", function() { + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix[DE]]").join(",")).toBe("ABC"); + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix:casesensitive[DE]]").join(",")).toBe("ABC"); + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix:caseinsensitive[de]]").join(",")).toBe("ABC,abc") + expect(wiki.filterTiddlers("[enlist[ABCDE abcde]removesuffix[]]").join(",")).toBe("ABCDE,abcde"); + }); + + it("should handle the sort and sortcs operators", function() { + expect(wiki.filterTiddlers("[sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[!sort[title]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,hasList,has filter,filter regexp test,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin"); + expect(wiki.filterTiddlers("[sort[modified]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one,$:/TiddlerTwo,TiddlerOne,Tiddler Three"); + expect(wiki.filterTiddlers("[!sort[modified]]").join(",")).toBe("Tiddler Three,TiddlerOne,$:/TiddlerTwo,$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); + // Temporarily commenting out the following two lines because of platform differences for localeCompare between the browser and Node.js + // expect(wiki.filterTiddlers("[sortcs[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne,a fourth tiddler,one"); + // expect(wiki.filterTiddlers("[!sortcs[title]]").join(",")).toBe("one,a fourth tiddler,TiddlerOne,Tiddler Three,$:/TiddlerTwo"); + }); + + it("should handle the nsort and nsortcs operators", function() { + expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[nsort[]]").join(",")).toBe("0,1,2,3,5,add,Apple,beatle,Beta"); + expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[!nsort[]]").join(",")).toBe("Beta,beatle,Apple,add,5,3,2,1,0"); + expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[nsortcs[]]").join(",")).toBe("0,1,2,3,5,add,Apple,beatle,Beta"); + expect(wiki.filterTiddlers("3 2 0 1 5 Apple add Beta beatle +[!nsortcs[]]").join(",")).toBe("Beta,beatle,Apple,add,5,3,2,1,0"); + }); + + it("should handle the reverse, first, last, butfirst, butlast, rest and nth operators", function() { + expect(wiki.filterTiddlers("[sort[title]first[]]").join(",")).toBe("$:/ShadowPlugin"); + expect(wiki.filterTiddlers("[sort[title]first[2]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo"); + expect(wiki.filterTiddlers("[sort[title]first[8]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[sort[title]first[x]]").join(",")).toBe("$:/ShadowPlugin"); + expect(wiki.filterTiddlers("[sort[title]last[]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]last[2]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]last[8]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]last[x]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]reverse[]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,hasList,has filter,filter regexp test,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin"); + expect(wiki.filterTiddlers("[sort[title]reverse[x]]").join(",")).toBe("TiddlerOne,Tiddler Three,one,hasList,has filter,filter regexp test,a fourth tiddler,$:/TiddlerTwo,$:/ShadowPlugin"); + expect(wiki.filterTiddlers("[sort[title]butlast[]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[sort[title]butlast[0]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]butlast[2]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one"); + expect(wiki.filterTiddlers("[sort[title]butlast[11]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[sort[title]butlast[x]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[sort[title]rest[]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]rest[2]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]rest[11]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[sort[title]rest[x]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[sort[title]nth[]]").join(",")).toBe("$:/ShadowPlugin"); + expect(wiki.filterTiddlers("[sort[title]nth[2]]").join(",")).toBe("$:/TiddlerTwo"); + expect(wiki.filterTiddlers("[sort[title]nth[11]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[sort[title]nth[x]]").join(",")).toBe("$:/ShadowPlugin"); + }); + + it("should handle the tag operator", function() { + expect(wiki.filterTiddlers("[tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[!tag[one]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one"); + expect(wiki.filterTiddlers("[prefix[Tidd]tag[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[!is[shadow]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); + expect(wiki.filterTiddlers("[all[shadows]tag[two]sort[title]]").join(",")).toBe("$:/TiddlerFive"); + }); + + it("should handle the all operator with field, has and tag operators", function() { + expect(wiki.filterTiddlers("[all[shadows]tag[two]]").join(",")).toBe("$:/TiddlerFive"); + expect(wiki.filterTiddlers("[all[shadows+tiddlers]tag[two]]").join(",")).toBe("$:/TiddlerFive,$:/TiddlerTwo,Tiddler Three"); + expect(wiki.filterTiddlers("[all[tiddlers+shadows]tag[two]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,$:/TiddlerFive"); + expect(wiki.filterTiddlers("[all[shadows+tiddlers]]").join(",")).toBe("$:/TiddlerFive,TiddlerSix,TiddlerSeventh,Tiddler8,$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[all[tiddlers+shadows]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne,$:/TiddlerFive,TiddlerSix,TiddlerSeventh,Tiddler8"); + expect(wiki.filterTiddlers("[all[tiddlers]tag[two]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); + expect(wiki.filterTiddlers("[all[orphans+tiddlers+tags]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,Tiddler Three,TiddlerOne,two,one"); + }); + + it("should handle the tags operator", function() { + expect(wiki.filterTiddlers("[tags[]sort[title]]").join(",")).toBe("one,two"); + expect(wiki.filterTiddlers("[[TiddlerOne]tags[]sort[title]]").join(",")).toBe("one"); + }); + + it("should handle the match operator", function() { + expect(wiki.filterTiddlers("[match[TiddlerOne]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("TiddlerOne TiddlerOne =[match[TiddlerOne]]").join(",")).toBe("TiddlerOne,TiddlerOne"); + expect(wiki.filterTiddlers("[!match[TiddlerOne]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[match:casesensitive[tiddlerone]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[!match:casesensitive[tiddlerone]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[match:caseinsensitive[tiddlerone]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[!match:caseinsensitive[tiddlerone]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three"); + }); + + it("should handle the tagging operator", function() { + expect(wiki.filterTiddlers("[[one]tagging[]sort[title]]").join(",")).toBe("Tiddler Three,Tiddler8,TiddlerOne,TiddlerSeventh"); + expect(wiki.filterTiddlers("[[one]tagging[]]").join(",")).toBe("Tiddler Three,TiddlerOne,TiddlerSeventh,Tiddler8"); + expect(wiki.filterTiddlers("[[two]tagging[]sort[title]]").join(",")).toBe("$:/TiddlerFive,$:/TiddlerTwo,Tiddler Three"); + var fakeWidget = {wiki: wiki, getVariable: function(name) {return name === "currentTiddler" ? "one": undefined;}}; + expect(wiki.filterTiddlers("[all[current]tagging[]]",fakeWidget).join(",")).toBe("Tiddler Three,TiddlerOne,TiddlerSeventh,Tiddler8"); + }); + + it("should handle the untagged operator", function() { + expect(wiki.filterTiddlers("[untagged[]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); + expect(wiki.filterTiddlers("[!untagged[]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); + // Should consider non-existent tiddlers untagged. + expect(wiki.filterTiddlers("[enlist[a b c]untagged[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("[enlist[a b c]!untagged[]]").join(",")).toBe(""); + }); + + it("should handle the links operator", function() { + expect(wiki.filterTiddlers("[!is[shadow]links[]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,has filter,hasList,one,Tiddler Three,TiddlerSix,TiddlerZero"); + expect(wiki.filterTiddlers("[all[shadows]links[]sort[title]]").join(",")).toBe("TiddlerOne"); + }); + + it("should handle the backlinks operator", function() { + expect(wiki.filterTiddlers("[!is[shadow]backlinks[]sort[title]]").join(",")).toBe("a fourth tiddler,has filter,hasList,one,TiddlerOne"); + expect(wiki.filterTiddlers("[all[shadows]backlinks[]sort[title]]").join(",")).toBe("Tiddler Three"); + }); + + it("should handle the has operator", function() { + expect(wiki.filterTiddlers("[has[modified]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[!has[modified]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); + expect(wiki.filterTiddlers("[has[tags]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[!has[tags]sort[title]]").join(",")).toBe("$:/ShadowPlugin,a fourth tiddler,filter regexp test,has filter,hasList,one"); + }); + + it("should handle the has:field operator", function() { + expect(wiki.filterTiddlers("[has:field[empty]sort[title]]").join(",")).toBe("a fourth tiddler,one"); + expect(wiki.filterTiddlers("[!has:field[empty]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,filter regexp test,has filter,hasList,Tiddler Three,TiddlerOne"); + }); + + + it("should handle the limit operator", function() { + expect(wiki.filterTiddlers("[!is[system]sort[title]limit[2]]").join(",")).toBe("a fourth tiddler,filter regexp test"); + expect(wiki.filterTiddlers("[prefix[Tid]sort[title]limit[1]]").join(",")).toBe("Tiddler Three"); + expect(wiki.filterTiddlers("[prefix[Tid]sort[title]!limit[1]]").join(",")).toBe("TiddlerOne"); + }); + + it("should handle the list operator", function() { + expect(wiki.filterTiddlers("[list[TiddlerSeventh]sort[title]]").join(",")).toBe("a fourth tiddler,MissingTiddler,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[tag[one]list[TiddlerSeventh]sort[title]]").join(",")).toBe("a fourth tiddler,MissingTiddler,Tiddler Three,TiddlerOne"); + }); + + it("should handle the listed operator", function() { + expect(wiki.filterTiddlers("TiddlerOne MissingTiddler +[listed[]]").join(",")).toBe('hasList,one'); + expect(wiki.filterTiddlers("one two +[listed[tags]]").join(",")).toBe('TiddlerOne,$:/TiddlerTwo,Tiddler Three'); + }); + + it("should handle the next operator", function() { + expect(wiki.filterTiddlers("[[Tiddler Three]next[TiddlerSeventh]]").join(",")).toBe("a fourth tiddler"); + expect(wiki.filterTiddlers("[[MissingTiddler]next[TiddlerSeventh]]").join(",")).toBe(""); + }); + + it("should handle the previous operator", function() { + expect(wiki.filterTiddlers("[[Tiddler Three]previous[TiddlerSeventh]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[[TiddlerOne]previous[TiddlerSeventh]]").join(",")).toBe(""); + }); + + it("should handle the search operator", function() { + expect(wiki.filterTiddlers("[search[the]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search{Tiddler8}sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:modifier[og]sort[title]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[Do]sort[title]]").join(",")).toBe("$:/TiddlerTwo"); + expect(wiki.filterTiddlers("[search:modifier,authors:casesensitive[do]sort[title]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[search:authors:casesensitive,whitespace[John Doe]sort[title]]").join(",")).toBe("$:/TiddlerTwo"); + expect(wiki.filterTiddlers("[search:modifier:regexp[(d|bl)o(ggs|e)]sort[title]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[search:-modifier,authors:[g]sort[title]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,Tiddler Three"); + expect(wiki.filterTiddlers("[search:*:[g]sort[title]]").join(",")).toBe("$:/ShadowPlugin,filter regexp test,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:text:anchored[the]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); + }); + + it("should yield search results where 'default' search finds at least 1 token", function() { + expect(wiki.filterTiddlers("[search::some[one two]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,one,Tiddler Three,TiddlerOne"); + }); + + it("should yield search results where 'title' finds at least one token", function() { + expect(wiki.filterTiddlers("[search:title:some[tiddler]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:title:some[tiddler one]sort[title]]").join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three,TiddlerOne"); + }); + + it("should yield search results where 'tags' finds at least one token", function() { + expect(wiki.filterTiddlers("[search:tags:some[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:tags:some[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); + expect(wiki.filterTiddlers("[search:tags:some[two one]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); + }); + + it("should yield search results where 'tags' finds at least one token / casesensitive", function() { + expect(wiki.filterTiddlers("[search:tags:some[ONE]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:tags:some,casesensitive[two ONE]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); + }); + + it("should yield search results where 'tags' finds at least one token / anchored", function() { + expect(wiki.filterTiddlers("[search:tags:some,anchored[one]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:tags:some,anchored[two]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); + // search:title + expect(wiki.filterTiddlers("[search:title:some,anchored[tiddler]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:title:some,anchored[tiddler one]sort[title]]").join(",")).toBe("one,Tiddler Three,TiddlerOne"); + }); + + it("should yield search results where 'tags' finds at least one token / anchored & casesensitive", function() { + expect(wiki.filterTiddlers("[search:title:some,anchored,casesensitive[Tiddler one]sort[title]]").join(",")).toBe("one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[search:title:some,anchored,casesensitive[Tiddler ONE]sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + }); + + it("should yield search results that have search tokens spread across different fields", function() { + expect(wiki.filterTiddlers("[search[fox one]sort[title]]").join(",")).toBe("TiddlerOne"); + }); + + it("should handle the each operator", function() { + expect(wiki.filterTiddlers("[each[modifier]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,filter regexp test,TiddlerOne"); + expect(wiki.filterTiddlers("[each:list-item[tags]sort[title]]").join(",")).toBe("one,two"); + expect(wiki.filterTiddlers("[each:list-item[authors]sort[title]]").join(",")).toBe("Bloggs,Joe,John Doe"); + }); + + it("should handle the eachday operator", function() { + expect(wiki.filterTiddlers("[eachday[modified]sort[title]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three"); + }); + + it("should handle the sameday operator", function() { + expect(wiki.filterTiddlers("[sameday[201304152200]sort[title]]").join(",")).toBe("$:/TiddlerTwo,TiddlerOne"); + }); + + describe("testing the is operator",function() { + + it("should handle the '[is[current]]' operator", function() { + var fakeWidget = {getVariable: function() {return "Tiddler Three";}}; + expect(wiki.filterTiddlers("[is[current]]",fakeWidget).join(",")).toBe("Tiddler Three"); + expect(wiki.filterTiddlers("[[Tiddler Three]is[current]]",fakeWidget).join(",")).toBe("Tiddler Three"); + expect(wiki.filterTiddlers("[[$:/TiddlerTwo]is[current]]",fakeWidget).join(",")).toBe(""); + expect(wiki.filterTiddlers("[!is[current]sort[title]]",fakeWidget).join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,TiddlerOne"); + }); + + it("should handle the '[is[system]]' operator", function() { + expect(wiki.filterTiddlers("[is[system]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo"); + expect(wiki.filterTiddlers("[!is[system]sort[title]]").join(",")).toBe("a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + }); + + it("should handle the '[is[shadow]]' operator", function() { + expect(wiki.filterTiddlers("[all[shadows]sort[title]]").join(",")).toBe("$:/TiddlerFive,Tiddler8,TiddlerSeventh,TiddlerSix"); + expect(wiki.filterTiddlers("[!is[shadow]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + }); + + it("should handle the '[is[missing]]' operator", function() { + expect(wiki.filterTiddlers("[all[]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[all[missing]]").join(",")).toBe("TiddlerZero"); + expect(wiki.filterTiddlers("[!is[missing]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[[TiddlerOne]is[missing]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[[TiddlerZero]is[missing]]").join(",")).toBe("TiddlerZero"); + expect(wiki.filterTiddlers("[!title[Tiddler Three]is[missing]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[missing]sort[title]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,a fourth tiddler,filter regexp test,has filter,hasList,one,TiddlerOne"); + }); + + it("should handle the '[is[orphan]]' operator", function() { + expect(wiki.filterTiddlers("[is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,filter regexp test,TiddlerOne"); + expect(wiki.filterTiddlers("[!is[orphan]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,has filter,hasList,one,Tiddler Three"); + expect(wiki.filterTiddlers("[[TiddlerOne]is[orphan]]").join(",")).toBe("TiddlerOne"); + expect(wiki.filterTiddlers("[[TiddlerOne]!is[orphan]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[!title[Tiddler Three]is[orphan]sort[title]]").join(",")).toBe("a fourth tiddler,filter regexp test,TiddlerOne"); + expect(wiki.filterTiddlers("[!title[Tiddler Three]!is[orphan]]").join(",")).toBe("$:/ShadowPlugin,$:/TiddlerTwo,has filter,hasList,one"); + }); + + it("should handle the '[is[draft]]' operator", function() { + var wiki = new $tw.Wiki(); + wiki.addTiddlers([ + {title: "A"}, + {title: "Draft of 'A'", "draft.of": "A", "draft.title": "A"}, + {title: "B"}, + {title: "Draft of 'B'", "draft.of": "B"}, + {title: "C"}, + // Not a true draft. Doesn't have draft.of + {title: "Draft of 'C'", "draft.title": "C"}, + {title: "E"}, + // Broken. Has draft.of, but it's empty. Still a draft + {title: "Draft of 'E'", "draft.of": "", "draft.title": ""} + // Not a draft. It doesn't exist. + //{title: "F"} // This one is deliberately missing + ]); + // is analagous to [has[draft.of]], + // except they handle empty draft.of differently + expect(wiki.filterTiddlers("[all[]] F +[is[draft]]").join(",")).toEqual("Draft of 'A',Draft of 'B',Draft of 'E'"); + expect(wiki.filterTiddlers("[all[]] F +[!is[draft]]").join(",")).toEqual("A,B,C,Draft of 'C',E,F"); + // [is[draft]] and [!is[draft]] are proper complements + var included = wiki.filterTiddlers("[all[]] F +[is[draft]]") + var excluded = wiki.filterTiddlers("[all[]] F +[!is[draft]]") + var all = [].concat(included, excluded).sort(); + // combined, they should have exactly one of everything. + expect(wiki.filterTiddlers("[all[]] F +[sort[]]")).toEqual(all); + }); + + }); + + it("should handle the operand prefixes", function() { + expect(wiki.filterTiddlers("[prefix[Tiddler]] +[sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + }); + + it("should handle indirect operands", function() { + expect(wiki.filterTiddlers("[{!!missing}]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[{!!title}]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[prefix{Tiddler8}] +[sort[title]]").join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[modifier{Tiddler8!!test-field}] +[sort[title]]").join(",")).toBe("TiddlerOne"); + var fakeWidget = {wiki: wiki, getVariable: function(name) {return name === "currentTiddler" ? "Tiddler Three": undefined;}}; + expect(wiki.filterTiddlers("[modifier{!!modifier}] +[sort[title]]",fakeWidget).join(",")).toBe("$:/TiddlerTwo,a fourth tiddler,one,Tiddler Three"); + }); + + it("should handle variable operands", function() { + + var widget = require("$:/core/modules/widgets/widget.js"); + // Create a root widget for attaching event handlers. By using it as the parentWidget for another widget tree, one can reuse the event handlers + var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, + { wiki:wiki, document:$tw.document}); + rootWidget.makeChildWidgets(); + var anchorWidget = rootWidget.children[0]; + rootWidget.setVariable("myVar","Tidd"); + rootWidget.setVariable("myVar2","JoeBloggs"); + expect(wiki.filterTiddlers("[prefix] +[sort[title]]",anchorWidget).join(",")).toBe("Tiddler Three,TiddlerOne"); + expect(wiki.filterTiddlers("[modifier] +[sort[title]]",anchorWidget).join(",")).toBe("TiddlerOne"); + }); + + it("should handle the before and after operators", function() { + expect(wiki.filterTiddlers("[list[TiddlerSeventh]after[TiddlerOne]]").join(",")).toBe("Tiddler Three"); + expect(wiki.filterTiddlers("[list[TiddlerSeventh]after[a fourth tiddler]]").join(",")).toBe("MissingTiddler"); + expect(wiki.filterTiddlers("[list[TiddlerSeventh]after[MissingTiddler]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[list[TiddlerSeventh]before[TiddlerOne]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("[list[TiddlerSeventh]before[a fourth tiddler]]").join(",")).toBe("Tiddler Three"); + expect(wiki.filterTiddlers("[list[TiddlerSeventh]before[MissingTiddler]]").join(",")).toBe("a fourth tiddler"); + }); + + it("should handle the range operator", function() { + expect(wiki.filterTiddlers("[range[10:0:2]]").join(",")).toBe("10,8,6,4,2,0"); + expect(wiki.filterTiddlers("[range[10;0;2]]").join(",")).toBe("10,8,6,4,2,0"); + expect(wiki.filterTiddlers("[range[1.001,5,1]]").join(",")).toBe("1.001,2.001,3.001,4.001"); + expect(wiki.filterTiddlers("[range[0,10]]").join(",")).toBe("0,1,2,3,4,5,6,7,8,9,10"); + expect(wiki.filterTiddlers("[range[0],[10]]").join(",")).toBe("0,1,2,3,4,5,6,7,8,9,10"); + expect(wiki.filterTiddlers("[range[10,0]]").join(",")).toBe("10,9,8,7,6,5,4,3,2,1,0"); + expect(wiki.filterTiddlers("[range[10],[0]]").join(",")).toBe("10,9,8,7,6,5,4,3,2,1,0"); + expect(wiki.filterTiddlers("[range[0,10,2]]").join(",")).toBe("0,2,4,6,8,10"); + expect(wiki.filterTiddlers("[range[0],[10],[2]]").join(",")).toBe("0,2,4,6,8,10"); + expect(wiki.filterTiddlers("[range[10,0,2]]").join(",")).toBe("10,8,6,4,2,0"); + expect(wiki.filterTiddlers("[range[10],[0],[2]]").join(",")).toBe("10,8,6,4,2,0"); + }); + + it("should handle the string operators", function() { + expect(wiki.filterTiddlers("John Paul George Ringo +[length[]]").join(",")).toBe("4,4,6,5"); + expect(wiki.filterTiddlers("John Paul George Ringo +[uppercase[]]").join(",")).toBe("JOHN,PAUL,GEORGE,RINGO"); + expect(wiki.filterTiddlers("John Paul George Ringo +[lowercase[]]").join(",")).toBe("john,paul,george,ringo"); + expect(wiki.filterTiddlers("John Paul George Ringo +[split[]]").join(",")).toBe("J,o,h,n,P,a,u,l,G,e,o,r,g,e,R,i,n,g,o"); + expect(wiki.filterTiddlers("[[John. Paul. George. Ringo.]] +[split[.]trim[]]").join(",")).toBe("John,Paul,George,Ringo,"); + expect(wiki.filterTiddlers("John Paul George Ringo +[split[e]]").join(",")).toBe("John,Paul,G,org,,Ringo"); + expect(wiki.filterTiddlers("John Paul George Ringo +[join[ ]split[e]join[ee]split[ ]]").join(",")).toBe("John,Paul,Geeorgee,Ringo"); + // Ensure that join doesn't return null if passed empty list + expect(wiki.filterTiddlers("Test +[butlast[]join[ ]]")).toEqual([]); + // Ensure that join correctly handles empty strings in source + expect(wiki.filterTiddlers("[[]] Paul +[join[-]]").join(",")).toBe("-Paul"); + expect(wiki.filterTiddlers("[[ John ]] [[Paul ]] [[ George]] Ringo +[trim[]join[-]]").join(",")).toBe("John-Paul-George-Ringo"); + expect(wiki.filterTiddlers("[[ abc ]] [[def ]] [[ ghi]] +[trim[]]").join(",")).toBe("abc,def,ghi"); + expect(wiki.filterTiddlers("[[ abc ]] [[def ]] [[ ghi]] +[trim:prefix[]]").join(",")).toBe("abc ,def ,ghi"); + expect(wiki.filterTiddlers("[[ abc ]] [[def ]] [[ ghi]] +[trim:suffix[]]").join(",")).toBe(" abc,def, ghi"); + expect(wiki.filterTiddlers("[[ abacus ]] [[ baobab ]] +[trim[ab]]").join(",")).toBe(" abacus , baobab "); + expect(wiki.filterTiddlers("[[ abacus ]] [[ baobab ]] +[trim[a]]").join(",")).toBe(" abacus , baobab "); + expect(wiki.filterTiddlers("abacus baobab +[trim[a]]").join(",")).toBe("bacus,baobab"); + expect(wiki.filterTiddlers("abacus baobab +[trim[ab]]").join(",")).toBe("acus,baob"); + expect(wiki.filterTiddlers("abacus baobab +[trim:prefix[ab]]").join(",")).toBe("acus,baobab"); + expect(wiki.filterTiddlers("abacus baobab +[trim:suffix[ab]]").join(",")).toBe("abacus,baob"); + // Trim doesn't hiccup on regexp special characters + expect(wiki.filterTiddlers("[[.*abacus.*]] [[.+baobab.+]] +[trim[.*]]").join(",")).toBe("abacus,.+baobab.+"); + expect(wiki.filterTiddlers("[[.*abacus.*]] [[.+baobab.+]] +[trim[.+]]").join(",")).toBe(".*abacus.*,baobab"); + }); + + it("should handle the mathematics operators", function() { + expect(wiki.filterTiddlers("[[2]add[2]]").join(",")).toBe("4"); + expect(wiki.filterTiddlers("[[4]subtract[2]]").join(",")).toBe("2"); + expect(wiki.filterTiddlers("[[24]divide[8]]").join(",")).toBe("3"); + expect(wiki.filterTiddlers("[[355]divide[113]sign[]multiply[4]]").join(",")).toBe("4"); + expect(wiki.filterTiddlers("[[355]divide[113]add[0.5]round[]multiply[4]]").join(",")).toBe("16"); + expect(wiki.filterTiddlers("1 2 3 4 +[sum[]]").join(",")).toBe("10"); + expect(wiki.filterTiddlers("1 2 3 4 +[product[]]").join(",")).toBe("24"); + expect(wiki.filterTiddlers("1 2 3 4 +[maxall[]]").join(",")).toBe("4"); + expect(wiki.filterTiddlers("1 2 3 4 +[minall[]]").join(",")).toBe("1"); + expect(wiki.filterTiddlers("1 2 3 4 +[max[2]]").join(",")).toBe("2,2,3,4"); + expect(wiki.filterTiddlers("1 2 3 4 +[min[2]]").join(",")).toBe("1,2,2,2"); + }); + +/* listops filters */ + + it("should handle the allafter operator", function() { + expect(wiki.filterTiddlers("1 2 3 4 +[allafter[]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter[1]]").join(",")).toBe("2,3,4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[1]]").join(",")).toBe("1,2,3,4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter[2]]").join(",")).toBe("3,4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[2]]").join(",")).toBe("2,3,4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter[3]]").join(",")).toBe("4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[3]]").join(",")).toBe("3,4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter[4]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[4]]").join(",")).toBe("4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter[5]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allafter:include[5]]").join(",")).toBe(""); + }); + + it("should handle the allbefore operator", function() { + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[1]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[1]]").join(",")).toBe("1"); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[2]]").join(",")).toBe("1"); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[2]]").join(",")).toBe("1,2"); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[3]]").join(",")).toBe("1,2"); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[3]]").join(",")).toBe("1,2,3"); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[4]]").join(",")).toBe("1,2,3"); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[4]]").join(",")).toBe("1,2,3,4"); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore[5]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1 2 3 4 +[allbefore:include[5]]").join(",")).toBe(""); + }); + + it("should handle the append operator", function() { + expect(wiki.filterTiddlers("a b c +[append[d e]]").join(",")).toBe("a,b,c,d,e"); + expect(wiki.filterTiddlers("a b c +[append:1[d e]]").join(",")).toBe("a,b,c,d"); + expect(wiki.filterTiddlers("a b c +[append{TiddlerSeventh!!list}]").join(",")).toBe("a,b,c,TiddlerOne,Tiddler Three,a fourth tiddler,MissingTiddler"); + expect(wiki.filterTiddlers("a b c +[append:2{TiddlerSeventh!!list}]").join(",")).toBe("a,b,c,TiddlerOne,Tiddler Three"); + + expect(wiki.filterTiddlers("a [[b c]] +[append{TiddlerSix!!filter}]").join(",")).toBe("a,b c,one,a a,[subfilter{hasList!!list}]"); + }); + + it("should handle the insertafter operator", function() { + var widget = require("$:/core/modules/widgets/widget.js"); + var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, + { wiki:wiki, document:$tw.document}); + rootWidget.makeChildWidgets(); + var anchorWidget = rootWidget.children[0]; + rootWidget.setVariable("myVar","c"); + rootWidget.setVariable("tidTitle","e"); + rootWidget.setVariable("tidList","one tid with spaces"); + + // Position title specified as suffix. + expect(wiki.filterTiddlers("a b c d e f +[insertafter:myVar[f]]",anchorWidget).join(",")).toBe("a,b,c,f,d,e"); + expect(wiki.filterTiddlers("a b c d e f +[insertafter:myVar]",anchorWidget).join(",")).toBe("a,b,c,e,d,f"); + expect(wiki.filterTiddlers("a b c d e f +[insertafter:myVar[gg gg]]",anchorWidget).join(",")).toBe("a,b,c,gg gg,d,e,f"); + expect(wiki.filterTiddlers("a b c d e +[insertafter:myVar]",anchorWidget).join(",")).toBe("a,b,c,one tid with spaces,d,e"); + expect(wiki.filterTiddlers("a b c d e f +[insertafter:tidTitle{TiddlerOne!!tags}]",anchorWidget).join(",")).toBe("a,b,c,d,e,one,f"); + + // Position title specified as parameter. + expect(wiki.filterTiddlers("a b c d e +[insertafter[f],[a]]",anchorWidget).join(",")).toBe("a,f,b,c,d,e"); + expect(wiki.filterTiddlers("a b c d e +[insertafter[f],]",anchorWidget).join(",")).toBe("a,b,c,f,d,e"); + + // Parameter takes precedence over suffix. + expect(wiki.filterTiddlers("a b c d e +[insertafter:myVar[f],[a]]",anchorWidget).join(",")).toBe("a,f,b,c,d,e"); + + // No position title. + expect(wiki.filterTiddlers("a b c [[with space]] +[insertafter[b]]").join(",")).toBe("a,c,with space,b"); + + // Position title does not exist, and no suffix given. + expect(wiki.filterTiddlers("a b c d e +[insertafter:foo[b]]").join(",")).toBe("a,c,d,e,b"); + expect(wiki.filterTiddlers("a b c d e +[insertafter[b],[foo]]").join(",")).toBe("a,c,d,e,b"); + expect(wiki.filterTiddlers("a b c d e +[insertafter[b],]").join(",")).toBe("a,c,d,e,b"); + + // Position title does not exist, but "start" or "end" given as suffix + expect(wiki.filterTiddlers("a b c d e +[insertafter:start[b],[foo]]").join(",")).toBe("b,a,c,d,e"); + expect(wiki.filterTiddlers("a b c d e +[insertafter:start[b],]").join(",")).toBe("b,a,c,d,e"); + expect(wiki.filterTiddlers("a b c d e +[insertafter:end[b],[foo]]").join(",")).toBe("a,c,d,e,b"); + expect(wiki.filterTiddlers("a b c d e +[insertafter:end[b],]").join(",")).toBe("a,c,d,e,b"); + }); + + it("should handle the insertbefore operator", function() { + var widget = require("$:/core/modules/widgets/widget.js"); + var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, + { wiki:wiki, document:$tw.document}); + rootWidget.makeChildWidgets(); + var anchorWidget = rootWidget.children[0]; + rootWidget.setVariable("myVar","c"); + rootWidget.setVariable("tidTitle","e"); + rootWidget.setVariable("tidList","one tid with spaces"); + + // Position title specified as suffix. + expect(wiki.filterTiddlers("a b c d e f +[insertbefore:myVar[f]]",anchorWidget).join(",")).toBe("a,b,f,c,d,e"); + expect(wiki.filterTiddlers("a b c d e f +[insertbefore:myVar]",anchorWidget).join(",")).toBe("a,b,e,c,d,f"); + expect(wiki.filterTiddlers("a b c d e f +[insertbefore:myVar[gg gg]]",anchorWidget).join(",")).toBe("a,b,gg gg,c,d,e,f"); + expect(wiki.filterTiddlers("a b c d e +[insertbefore:myVar]",anchorWidget).join(",")).toBe("a,b,one tid with spaces,c,d,e"); + expect(wiki.filterTiddlers("a b c d e f +[insertbefore:tidTitle{TiddlerOne!!tags}]",anchorWidget).join(",")).toBe("a,b,c,d,one,e,f"); + + // Position title specified as parameter. + expect(wiki.filterTiddlers("a b c d e +[insertbefore[f],[a]]",anchorWidget).join(",")).toBe("f,a,b,c,d,e"); + expect(wiki.filterTiddlers("a b c d e +[insertbefore[f],]",anchorWidget).join(",")).toBe("a,b,f,c,d,e"); + + // Parameter takes precedence over suffix. + expect(wiki.filterTiddlers("a b c d e +[insertbefore:myVar[f],[a]]",anchorWidget).join(",")).toBe("f,a,b,c,d,e"); + + // No position title. + expect(wiki.filterTiddlers("a b c [[with space]] +[insertbefore[b]]").join(",")).toBe("a,c,with space,b"); + + // Position title does not exist, and no suffix given. + expect(wiki.filterTiddlers("a b c d e +[insertbefore:foo[b]]").join(",")).toBe("a,c,d,e,b"); + expect(wiki.filterTiddlers("a b c d e +[insertbefore[b],[foo]]").join(",")).toBe("a,c,d,e,b"); + expect(wiki.filterTiddlers("a b c d e +[insertbefore[b],]").join(",")).toBe("a,c,d,e,b"); + + // Position title does not exist, but "start" or "end" given as suffix + expect(wiki.filterTiddlers("a b c d e +[insertbefore:start[b],[foo]]").join(",")).toBe("b,a,c,d,e"); + expect(wiki.filterTiddlers("a b c d e +[insertbefore:start[b],]").join(",")).toBe("b,a,c,d,e"); + expect(wiki.filterTiddlers("a b c d e +[insertbefore:end[b],[foo]]").join(",")).toBe("a,c,d,e,b"); + expect(wiki.filterTiddlers("a b c d e +[insertbefore:end[b],]").join(",")).toBe("a,c,d,e,b"); + }); + + it("should handle the move operator", function() { + expect(wiki.filterTiddlers("a b c d e +[move[c]]").join(",")).toBe("a,b,d,c,e"); + expect(wiki.filterTiddlers("a b c d e +[move:2[c]]").join(",")).toBe("a,b,d,e,c"); + expect(wiki.filterTiddlers("a b c d e +[move:10[c]]").join(",")).toBe("a,b,d,e,c"); + expect(wiki.filterTiddlers("a b c d e +[move:-1[c]]").join(",")).toBe("a,c,b,d,e"); + expect(wiki.filterTiddlers("a b c d e +[move:-5[c]]").join(",")).toBe("c,a,b,d,e"); + }); + + it("should handle the prepend operator", function() { + expect(wiki.filterTiddlers("a b c +[prepend[dd ee]]").join(",")).toBe("dd,ee,a,b,c"); + expect(wiki.filterTiddlers("a b c +[prepend:3[ff gg]]").join(",")).toBe("ff,gg,a,b,c"); + expect(wiki.filterTiddlers("a b c +[prepend:1[hh ii]]").join(",")).toBe("hh,a,b,c"); + expect(wiki.filterTiddlers("a b c +[prepend:0[jj kk]]").join(",")).toBe("a,b,c"); + + expect(wiki.filterTiddlers("a b c +[prepend:-0[ll mm]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[prepend:-1[nn oo pp qq]]").join(",")).toBe("nn,oo,pp,a,b,c"); + expect(wiki.filterTiddlers("a b c +[prepend:-2[rr ss tt uu]]").join(",")).toBe("rr,ss,a,b,c"); + expect(wiki.filterTiddlers("a b c +[prepend:-4[rr ss tt uu]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[prepend:-5[vv ww xx yy]]").join(",")).toBe("a,b,c"); + }); + + it("should handle the putafter operator", function() { + expect(wiki.filterTiddlers("a b c dd ee +[putafter[b]]").join(",")).toBe("a,b,ee,c,dd"); + expect(wiki.filterTiddlers("a b c dd ee +[putafter:1[b]]").join(",")).toBe("a,b,ee,c,dd"); + expect(wiki.filterTiddlers("a b c dd ee +[putafter:2[b]]").join(",")).toBe("a,b,dd,ee,c"); + expect(wiki.filterTiddlers("a b c dd ee +[putafter:3[b]]").join(",")).toBe("a,b,c,dd,ee"); + // It starts to duplicate elements + expect(wiki.filterTiddlers("a b c dd ee +[putafter:4[b]]").join(",")).toBe("a,b,b,c,dd,ee"); + expect(wiki.filterTiddlers("a b c dd ee +[putafter:5[b]]").join(",")).toBe("a,b,a,b,c,dd,ee"); + // There are only 5 elements in the input + expect(wiki.filterTiddlers("a b c ff gg +[putafter:6[b]]").join(",")).toBe("a,b,a,b,c,ff,gg"); + + // -1 starts to "eat" elements for the left and duplicates b + expect(wiki.filterTiddlers("a b c hh ii +[putafter:-1[b]]").join(",")).toBe("a,b,b,c,hh,ii"); + // -2 moves c, hh, ii behind b, which is not visible + expect(wiki.filterTiddlers("a b c hh ii +[putafter:-2[b]]").join(",")).toBe("a,b,c,hh,ii"); + // only ii is used from input and it's moved behind b + expect(wiki.filterTiddlers("a b c hh ii +[putafter:-4[b]]").join(",")).toBe("a,b,ii,c,hh"); + // wasting time, because there are only 5 elements + expect(wiki.filterTiddlers("a b c hh ii +[putafter:-5[b]]").join(",")).toBe("a,b,c,hh,ii"); + // there are only 5 elements + expect(wiki.filterTiddlers("a b c hh ii +[putafter:-10[b]]").join(",")).toBe("a,b,c,hh,ii"); + + // use NAN uses default = 1 + expect(wiki.filterTiddlers("a b c jj kk +[putafter:NAN[b]]").join(",")).toBe("a,b,kk,c,jj"); + }); + + it("should handle the putbefore operator", function() { + expect(wiki.filterTiddlers("a b c dd +[putbefore[b]]").join(",")).toBe("a,dd,b,c"); + expect(wiki.filterTiddlers("a b c ff +[putbefore:1[b]]").join(",")).toBe("a,ff,b,c"); + expect(wiki.filterTiddlers("a b c gg +[putbefore:2[b]]").join(",")).toBe("a,c,gg,b"); + + expect(wiki.filterTiddlers("a b c [[g g]] +[putbefore:2[b]]").join(",")).toBe("a,c,g g,b"); + + // this one is strange + expect(wiki.filterTiddlers("a b c ee +[putbefore:0[b]]").join(",")).toBe("a,a,b,c,ee"); + + // b is not part of the list anymore, so it will be appended at the end ??? + expect(wiki.filterTiddlers("a b c hh +[putbefore:3[b]]").join(",")).toBe("a,b,c,hh"); + expect(wiki.filterTiddlers("a b c ii +[putbefore:4[b]]").join(",")).toBe("a,a,b,c,ii"); + + // ???? + expect(wiki.filterTiddlers("a b c ii +[putbefore:10[b]]").join(",")).toBe("a,a,b,c,ii"); + + expect(wiki.filterTiddlers("a b c kk +[putbefore:-1[b]]").join(",")).toBe("a,b,c,kk"); + expect(wiki.filterTiddlers("a b c ll +[putbefore:-2[b]]").join(",")).toBe("a,c,ll,b"); + + expect(wiki.filterTiddlers("a b c mm +[putbefore:-3[b]]").join(",")).toBe("a,mm,b,c"); + + expect(wiki.filterTiddlers("a b c nn +[putbefore:-10[b]]").join(",")).toBe("a,b,c,nn"); + }); + + it("should handle the putfirst operator", function() { + expect(wiki.filterTiddlers("a b c +[putfirst[a b]]").join(",")).toBe("c,a,b"); + expect(wiki.filterTiddlers("a b c +[putfirst[]]").join(",")).toBe("c,a,b"); + expect(wiki.filterTiddlers("a b c +[putfirst:2[]]").join(",")).toBe("b,c,a"); + expect(wiki.filterTiddlers("a b c +[putfirst:3[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[putfirst:4[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[putfirst:-0[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[putfirst:-1[]]").join(",")).toBe("b,c,a"); + expect(wiki.filterTiddlers("a b c +[putfirst:-2[]]").join(",")).toBe("c,a,b"); + expect(wiki.filterTiddlers("a b c +[putfirst:-4[]]").join(",")).toBe("a,b,c"); + }); + + it("should handle the putlast operator", function() { + expect(wiki.filterTiddlers("a b c +[putlast[d e]]").join(",")).toBe("b,c,a"); + expect(wiki.filterTiddlers("a b c +[putlast[]]").join(",")).toBe("b,c,a"); + expect(wiki.filterTiddlers("a b c +[putlast:1[]]").join(",")).toBe("b,c,a"); + expect(wiki.filterTiddlers("a b c +[putlast:2[]]").join(",")).toBe("c,a,b"); + expect(wiki.filterTiddlers("a b c +[putlast:3[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[putlast:4[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[putlast:-0[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[putlast:0[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[putlast:-1[]]").join(",")).toBe("c,a,b"); + expect(wiki.filterTiddlers("a b c +[putlast:-2[]]").join(",")).toBe("b,c,a"); + expect(wiki.filterTiddlers("a b c +[putlast:-4[]]").join(",")).toBe("a,b,c"); + }); + + it("should handle the remove operator", function() { + expect(wiki.filterTiddlers("a b c +[remove[d e]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[remove[a]]").join(",")).toBe("b,c"); + expect(wiki.filterTiddlers("a b c +[remove[c b a]]").join(",")).toBe(""); + }); + + it("should handle the replace operator", function() { + expect(wiki.filterTiddlers("a b c dd +[replace[a]]").join(",")).toBe("dd,b,c"); + expect(wiki.filterTiddlers("a b c dd ee +[replace:2[a]]").join(",")).toBe("dd,ee,b,c"); + expect(wiki.filterTiddlers("a b c dd ee +[replace:5[c]]").join(",")).toBe("a,b,a,b,c,dd,ee"); + + // strange things happen. + expect(wiki.filterTiddlers("a b c dd ee +[replace:-1[c]]").join(",")).toBe("a,b,b,c,dd,ee"); + expect(wiki.filterTiddlers("a b c dd ee +[replace:-2[c]]").join(",")).toBe("a,b,c,dd,ee"); + expect(wiki.filterTiddlers("a b c dd ee +[replace:-2[ee]]").join(",")).toBe("a,b,c,dd,c,dd,ee"); + }); + + it("should handle the sortby operator", function() { + expect(wiki.filterTiddlers("a b c +[sortby[d e]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("a b c +[sortby[b c a]]").join(",")).toBe("b,c,a"); + expect(wiki.filterTiddlers("aa a b c +[sortby[b c a cc]]").join(",")).toBe("aa,b,c,a"); + expect(wiki.filterTiddlers("a bb b c +[sortby[b c a cc]]").join(",")).toBe("bb,b,c,a"); + expect(wiki.filterTiddlers("a bb cc b c +[sortby[b c a cc]]").join(",")).toBe("bb,b,c,a,cc"); + + expect(wiki.filterTiddlers("b a b c +[sortby[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("b a b c +[sortby[a b b c]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("b a b c +[sortby[b a c b]]").join(",")).toBe("b,a,c"); + }); + + it("should handle the sortan operator", function() { + expect(wiki.filterTiddlers("b a c +[sortan[]]").join(",")).toBe("a,b,c"); + expect(wiki.filterTiddlers("b2 a3 a1 b1 c2 a2 c3 b3 c1 +[sortan[]]").join(",")).toBe("a1,a2,a3,b1,b2,b3,c1,c2,c3"); + expect(wiki.filterTiddlers("b2 a10 c10 a1 b1 c2 a2 b10 c1 +[sortan[]]").join(",")).toBe("a1,a2,a10,b1,b2,b10,c1,c2,c10"); + expect(wiki.filterTiddlers("TiddlerOne $:/TiddlerTwo [[Tiddler Three]] +[sortan[]]").join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne"); + }); + + it("should handle the sortan operator sorting on date fields", function() { + expect(wiki.filterTiddlers("TiddlerOne $:/TiddlerTwo [[Tiddler Three]] +[sortan[modified]]").join(",")).toBe("$:/TiddlerTwo,TiddlerOne,Tiddler Three"); + expect(wiki.filterTiddlers("hasList TiddlerOne $:/TiddlerTwo [[Tiddler Three]] +[sortan[modified]]").join(",")).toBe("hasList,$:/TiddlerTwo,TiddlerOne,Tiddler Three"); + }); + + it("should handle the slugify operator", function() { + expect(wiki.filterTiddlers("[[Joe Bloggs]slugify[]]").join(",")).toBe("joe-bloggs"); + expect(wiki.filterTiddlers("[[Joe Bloggs2]slugify[]]").join(",")).toBe("joe-bloggs2"); + expect(wiki.filterTiddlers("[[@£$%^&*((]slugify[]]").join(",")).toBe("64-163-36-37-94-38-42-40-40"); + expect(wiki.filterTiddlers("One one ONE O!N!E +[slugify[]]").join(",")).toBe("one,one,one,one"); + expect(wiki.filterTiddlers("TiddlerOne $:/TiddlerTwo +[slugify[]]").join(",")).toBe("tiddler-one,tiddler-two"); + }); + + it("should handle the sortsub operator", function() { + var widget = require("$:/core/modules/widgets/widget.js"); + var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, + { wiki:wiki, document:$tw.document}); + rootWidget.makeChildWidgets(); + var anchorWidget = rootWidget.children[0]; + rootWidget.setVariable("sort1","[length[]]"); + rootWidget.setVariable("sort2","[get[text]else[]length[]]"); + rootWidget.setVariable("sort3","[{!!value}divide{!!cost}]"); + rootWidget.setVariable("sort4","[{!!title}]"); + rootWidget.setVariable("undefined-variable","[]"); + rootWidget.setVariable("echo","$text$",[{name:"text"}],true); + rootWidget.setVariable("sort4-macro-param","[subfilter]"); + expect(wiki.filterTiddlers("[sortsub:number]",anchorWidget).join(",")).toBe("one,hasList,has filter,TiddlerOne,$:/TiddlerTwo,Tiddler Three,$:/ShadowPlugin,a fourth tiddler,filter regexp test"); + expect(wiki.filterTiddlers("[!sortsub:number]",anchorWidget).join(",")).toBe("filter regexp test,a fourth tiddler,$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,has filter,TiddlerOne,hasList,one"); + expect(wiki.filterTiddlers("[sortsub:string]",anchorWidget).join(",")).toBe("has filter,TiddlerOne,$:/TiddlerTwo,Tiddler Three,$:/ShadowPlugin,a fourth tiddler,filter regexp test,one,hasList"); + expect(wiki.filterTiddlers("[!sortsub:string]",anchorWidget).join(",")).toBe("hasList,one,filter regexp test,a fourth tiddler,$:/ShadowPlugin,$:/TiddlerTwo,Tiddler Three,has filter,TiddlerOne"); + expect(wiki.filterTiddlers("[sortsub:number]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,a fourth tiddler,$:/TiddlerTwo,Tiddler Three,filter regexp test,$:/ShadowPlugin"); + expect(wiki.filterTiddlers("[!sortsub:number]",anchorWidget).join(",")).toBe("$:/ShadowPlugin,filter regexp test,Tiddler Three,$:/TiddlerTwo,a fourth tiddler,has filter,hasList,TiddlerOne,one"); + expect(wiki.filterTiddlers("[sortsub:string]",anchorWidget).join(",")).toBe("one,TiddlerOne,hasList,has filter,$:/ShadowPlugin,a fourth tiddler,$:/TiddlerTwo,Tiddler Three,filter regexp test"); + expect(wiki.filterTiddlers("[!sortsub:string]",anchorWidget).join(",")).toBe("filter regexp test,Tiddler Three,$:/TiddlerTwo,a fourth tiddler,$:/ShadowPlugin,has filter,hasList,TiddlerOne,one"); + expect(wiki.filterTiddlers("[[TiddlerOne]] [[$:/TiddlerTwo]] [[Tiddler Three]] [[a fourth tiddler]] +[!sortsub:number]",anchorWidget).join(",")).toBe("$:/TiddlerTwo,Tiddler Three,TiddlerOne,a fourth tiddler"); + expect(wiki.filterTiddlers("a1 a10 a2 a3 b10 b3 b1 c9 c11 c1 +[sortsub:alphanumeric]",anchorWidget).join(",")).toBe("a1,a2,a3,a10,b1,b3,b10,c1,c9,c11"); + // #7155. The order of the output is the same as the input when an undefined variable is used in the subfitler + expect(wiki.filterTiddlers("a2 a10 a1 +[sortsub:alphanumeric]",anchorWidget).join(",")).toBe("a2,a10,a1"); + expect(wiki.filterTiddlers("a1 a10 a2 a3 b10 b3 b1 c9 c11 c1 +[sortsub:alphanumeric]",anchorWidget).join(",")).toBe("a1,a2,a3,a10,b1,b3,b10,c1,c9,c11"); + }); + + it("should handle the toggle operator", function() { + expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] +[toggle[one]]").join(",")).toBe("two"); + expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] -[[one]] +[toggle[one]]").join(",")).toBe("two,one"); + expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] +[toggle[three],[four]]").join(",")).toBe("one,two,three"); + expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] [[three]] +[toggle[three],[four]]").join(",")).toBe("one,two,four"); + expect(wiki.filterTiddlers("[[Tiddler Three]tags[]] [[three]] [[four]] +[toggle[three],[five]]").join(",")).toBe("one,two,five,four"); + }); + + it("should handle multiple operands for search-replace", function() { + var widget = require("$:/core/modules/widgets/widget.js"); + var rootWidget = new widget.widget({ type:"widget", children:[ {type:"widget", children:[]} ] }, + { wiki:wiki, document:$tw.document}); + rootWidget.makeChildWidgets(); + var anchorWidget = rootWidget.children[0]; + rootWidget.setVariable("var1","different"); + rootWidget.setVariable("myregexp1","e|o"); + rootWidget.setVariable("myregexp2","^Unlike "); + rootWidget.setVariable("myregexp3","^(?!Unlike).*$"); + rootWidget.setVariable("name","(\w+)\s(\w+)"); + expect(wiki.filterTiddlers("[[Welcome to TiddlyWiki, a unique non-linear webpage.]search-replace[webpage],[notebook]]").join(",")).toBe("Welcome to TiddlyWiki, a unique non-linear notebook."); + expect(wiki.filterTiddlers("[[Welcome to TiddlyWiki, a unique non-linear notebook.]search-replace[unique],]",anchorWidget).join(",")).toBe("Welcome to TiddlyWiki, a different non-linear notebook."); + expect(wiki.filterTiddlers("[[Welcome to TiddlyWiki, a unique non-linear notebook.]search-replace[TiddlyWiki],{one}]",anchorWidget).join(",")).toBe("Welcome to This is the text of tiddler [[one]], a unique non-linear notebook."); + expect(wiki.filterTiddlers("[[Hello There]search-replace:g:regexp,[]]",anchorWidget).join(",")).toBe("Hll Thr"); + expect(wiki.filterTiddlers("[[Hello There]search-replace::regexp,[]]",anchorWidget).join(",")).toBe("Hllo There"); + expect(wiki.filterTiddlers("[[Hello There]search-replace:gi[H],[]]",anchorWidget).join(",")).toBe("ello Tere"); + expect(wiki.filterTiddlers("[[Unlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data]search-replace:g:regexp,[]]",anchorWidget).join(",")).toBe("conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data"); + expect(wiki.filterTiddlers("[[Unlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data]search-replace:gm:regexp,[]]",anchorWidget).join(",")).toBe("conventional online services, TiddlyWiki lets you choose where to keep your data\nconventional online services, TiddlyWiki lets you choose where to keep your data\nconventional online services, TiddlyWiki lets you choose where to keep your data\nconventional online services, TiddlyWiki lets you choose where to keep your data"); + expect(wiki.filterTiddlers("[[Hello There\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\nguaranteeing that in the decades to come you will still be able to use the notes you take today.]search-replace:gm:regexp,[]]",anchorWidget).join(",")).toBe("\nUnlike conventional online services, TiddlyWiki lets you choose where to keep your data\n"); + expect(wiki.filterTiddlers("[[This is equation $$x$$ end.]search-replace[equation $$x$$ end.],[relation $$x$$ finish.]]").join(",")).toBe("This is relation $$x$$ finish."); + expect(wiki.filterTiddlers("[[This is an amazing TiddlyWiki]] [[How old is TiddlyWiki?. TiddlyWiki is great]] [[My TiddlyWiki is so fast.]] +[search-replace:g:regexp[TiddlyWiki],[TW]]").join(",")).toBe("This is an amazing TW,How old is TW?. TW is great,My TW is so fast."); + expect(wiki.filterTiddlers("[[This is an amazing TiddlyWiki]] [[How old is TiddlyWiki?. TiddlyWiki is great]] [[My TiddlyWiki is so fast.]] +[search-replace::regexp[TiddlyWiki],[TW]]").join(",")).toBe("This is an amazing TW,How old is TW?. TiddlyWiki is great,My TW is so fast."); + expect(wiki.filterTiddlers("[[This is an amazing TiddlyWiki]] [[How old is TiddlyWiki?. TiddlyWiki is great]] [[My TiddlyWiki is so fast.]] +[search-replace:g[TiddlyWiki],[TW]]").join(",")).toBe("This is an amazing TW,How old is TW?. TW is great,My TW is so fast."); + }); + + it("should handle the pad operator", function() { + expect(wiki.filterTiddlers("[[2]pad[]]").join(",")).toBe("2"); + expect(wiki.filterTiddlers("[[2]pad[0]]").join(",")).toBe("2"); + expect(wiki.filterTiddlers("[[2]pad[1]]").join(",")).toBe("2"); + expect(wiki.filterTiddlers("2 20 +[pad[3]]").join(",")).toBe("002,020"); + expect(wiki.filterTiddlers("[[2]pad[9]]").join(",")).toBe("000000002"); + expect(wiki.filterTiddlers("[[2]pad[9],[a]]").join(",")).toBe("aaaaaaaa2"); + expect(wiki.filterTiddlers("[[12]pad[9],[abc]]").join(",")).toBe("abcabca12"); + expect(wiki.filterTiddlers("[[12]pad:suffix[9],[abc]]").join(",")).toBe("12abcabca"); + }); + + it("should handle the escapecss operator", function() { + expect(wiki.filterTiddlers("[[Hello There]escapecss[]]").join(",")).toBe("Hello\\ There"); + expect(wiki.filterTiddlers('\'"Reveal.js" by Devin Weaver[1]\' +[escapecss[]]').join(",")).toBe('\\"Reveal\\.js\\"\\ by\\ Devin\\ Weaver\\[1\\]'); + expect(wiki.filterTiddlers(".foo#bar (){} '--a' 0 \0 +[escapecss[]]").join(",")).toBe("\\.foo\\#bar,\\(\\)\\{\\},--a,\\30 ,\ufffd"); + expect(wiki.filterTiddlers("'' +[escapecss[]]").join(",")).toBe(""); + expect(wiki.filterTiddlers("1234 +[escapecss[]]").join(",")).toBe("\\31 234"); + expect(wiki.filterTiddlers("'-25' +[escapecss[]]").join(",")).toBe("-\\32 5"); + expect(wiki.filterTiddlers("'-' +[escapecss[]]").join(",")).toBe("\\-"); + }); + + it("should handle the format operator", function() { + expect(wiki.filterTiddlers("[[Hello There]] [[GettingStarted]] +[format:titlelist[]]").join(" ")).toBe("[[Hello There]] GettingStarted"); + expect(wiki.filterTiddlers("[title[Hello There]] +[format:titlelist[]]").join(" ")).toBe("[[Hello There]]"); + expect(wiki.filterTiddlers("[title[HelloThere]] +[format:titlelist[]]").join(" ")).toBe("HelloThere"); + expect(wiki.filterTiddlers("0 +[format:timestamp[]]").join(",")).toBe("19700101000000000"); + expect(wiki.filterTiddlers("1603188514443 +[format:timestamp[]]").join(",")).toBe("20201020100834443"); + expect(wiki.filterTiddlers("void +[format:timestamp[]]").join(",")).toBe(""); + }); + + it("should handle the deserializers operator", function() { + var expectedDeserializers = ["application/javascript","application/json","application/x-tiddler","application/x-tiddler-html-div","application/x-tiddlers","text/css","text/html","text/plain"]; + if($tw.browser) { + expectedDeserializers.unshift("(DOM)"); + } + expect(wiki.filterTiddlers("[deserializers[]]").join(",")).toBe(expectedDeserializers.join(",")); + }); + + it("should handle the charcode operator", function() { + expect(wiki.filterTiddlers("[charcode[9]]").join(" ")).toBe(String.fromCharCode(9)); + expect(wiki.filterTiddlers("[charcode[9],[10]]").join(" ")).toBe(String.fromCharCode(9) + String.fromCharCode(10)); + expect(wiki.filterTiddlers("[charcode[]]").join(" ")).toBe(""); + }); + + it("should handle the levenshtein operator", function() { + expect(wiki.filterTiddlers("[[apple]levenshtein[apple]]").join(" ")).toBe("0"); + expect(wiki.filterTiddlers("[[apple]levenshtein[banana]]").join(" ")).toBe("9"); + expect(wiki.filterTiddlers("[[representation]levenshtein[misreprehensionisation]]").join(" ")).toBe("10"); + expect(wiki.filterTiddlers("[[the cat sat on the mat]levenshtein[the hat saw in every category]]").join(" ")).toBe("13"); + }); + + it("should handle the makepatches operator", function() { + expect(wiki.filterTiddlers("[[apple]makepatches[apple]]").join(" ")).toBe(""); + expect(wiki.filterTiddlers("[[apple]makepatches[banana]]").join(" ")).toBe("@@ -1,5 +1,6 @@\n-apple\n+banana\n"); + expect(wiki.filterTiddlers("[[representation]makepatches[misreprehensionisation]]").join(" ")).toBe("@@ -1,13 +1,21 @@\n+mis\n repre\n-sent\n+hensionis\n atio\n"); + expect(wiki.filterTiddlers("[[the cat sat on the mat]makepatches[the hat saw in every category]]").join(" ")).toBe("@@ -1,22 +1,29 @@\n the \n-c\n+h\n at sa\n-t on the mat\n+w in every category\n"); + }); + + it("should parse filter variable parameters", function(){ + expect($tw.utils.parseFilterVariable("currentTiddler")).toEqual( + { name: 'currentTiddler', params: [ ] } + ); + expect($tw.utils.parseFilterVariable("now DDMM")).toEqual( + { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: 'DDMM', end: 8 }] } + ); + expect($tw.utils.parseFilterVariable("now DDMM UTC")).toEqual( + { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: 'DDMM', end: 8 }, { type: 'macro-parameter', start: 8, value: 'UTC', end: 12 }] } + ); + expect($tw.utils.parseFilterVariable("now format:DDMM")).toEqual( + { name: 'now', params: [{ type: 'macro-parameter', name:'format', start: 3, value: 'DDMM', end: 15 }] } + ); + expect($tw.utils.parseFilterVariable("now format:'DDMM'")).toEqual( + { name: 'now', params: [{ type: 'macro-parameter', name:'format', start: 3, value: 'DDMM', end: 17 }] } + ); + expect($tw.utils.parseFilterVariable("nowformat:'DDMM'")).toEqual( + { name: 'nowformat:\'DDMM\'', params: [] } + ); + expect($tw.utils.parseFilterVariable("nowformat:'DD MM'")).toEqual( + { name: 'nowformat:', params: [{ type: 'macro-parameter', start: 10, value: 'DD MM', end: 17 }] } + ); + expect($tw.utils.parseFilterVariable("now [UTC]YYYY0MM0DD0hh0mm0ssXXX")).toEqual( + { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: '[UTC]YYYY0MM0DD0hh0mm0ssXXX', end: 31 }] } + ); + expect($tw.utils.parseFilterVariable("now '[UTC]YYYY0MM0DD0hh0mm0ssXXX'")).toEqual( + { name: 'now', params: [{ type: 'macro-parameter', start: 3, value: '[UTC]YYYY0MM0DD0hh0mm0ssXXX', end: 33 }] } + ); + expect($tw.utils.parseFilterVariable("now format:'[UTC]YYYY0MM0DD0hh0mm0ssXXX'")).toEqual( + { name: 'now', params: [{ type: 'macro-parameter', start: 3, name:'format', value: '[UTC]YYYY0MM0DD0hh0mm0ssXXX', end: 40 }] } + ); + expect($tw.utils.parseFilterVariable("")).toEqual( + { name: '', params: [] } + ); + }); + + it("should handle the encodeuricomponent and decodeuricomponent operators", function() { + expect(wiki.filterTiddlers("[[<>:\"/\\|?*]encodeuricomponent[]]").join(",")).toBe("%3C%3E%3A%22%2F%5C%7C%3F%2A"); + }); + +} + +}); + diff --git a/editions/test/tiddlers/tests/test-html-parser.js b/editions/test/tiddlers/tests/test-html-parser.js index d2266ca5e..17bdec493 100644 --- a/editions/test/tiddlers/tests/test-html-parser.js +++ b/editions/test/tiddlers/tests/test-html-parser.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests for the internal components of the HTML tag parser \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -232,4 +232,3 @@ describe("HTML tag new parser tests", function() { }); -})(); diff --git a/editions/test/tiddlers/tests/test-json-filters.js b/editions/test/tiddlers/tests/test-json-filters.js index 68a82e774..c90574b9a 100644 --- a/editions/test/tiddlers/tests/test-json-filters.js +++ b/editions/test/tiddlers/tests/test-json-filters.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests the JSON filters and the format:json operator \*/ -(function(){ + /* jslint node: true, browser: true */ /* eslint-env node, browser, jasmine */ @@ -111,4 +111,3 @@ describe("json filter tests", function() { }); -})(); diff --git a/editions/test/tiddlers/tests/test-linked-list.js b/editions/test/tiddlers/tests/test-linked-list.js index de477257d..e369aa613 100644 --- a/editions/test/tiddlers/tests/test-linked-list.js +++ b/editions/test/tiddlers/tests/test-linked-list.js @@ -21,7 +21,7 @@ NOTE TO FURTHER LINKED LIST DEVELOPERS: the end. I think you'll probably be better off preventing 'prev' from ever adding undefined. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -307,4 +307,3 @@ describe("LinkedList class tests", function() { }); }); -})(); diff --git a/editions/test/tiddlers/tests/test-parsetextreference.js b/editions/test/tiddlers/tests/test-parsetextreference.js index 59f885232..c9b2966bf 100644 --- a/editions/test/tiddlers/tests/test-parsetextreference.js +++ b/editions/test/tiddlers/tests/test-parsetextreference.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests for source attribute in parser returned from wiki.parseTextReference \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -129,4 +129,3 @@ describe("Wiki.parseTextReference tests", function() { }); -})(); diff --git a/editions/test/tiddlers/tests/test-popup.js b/editions/test/tiddlers/tests/test-popup.js index 455da2b9b..b6e725373 100644 --- a/editions/test/tiddlers/tests/test-popup.js +++ b/editions/test/tiddlers/tests/test-popup.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests some utility function of the Popup prototype. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -60,4 +60,3 @@ describe("Popup tests", function() { }); }); -})(); diff --git a/editions/test/tiddlers/tests/test-prefixes-filter.js b/editions/test/tiddlers/tests/test-prefixes-filter.js index a8d109d73..c71d32585 100644 --- a/editions/test/tiddlers/tests/test-prefixes-filter.js +++ b/editions/test/tiddlers/tests/test-prefixes-filter.js @@ -4,7 +4,7 @@ type: application/javascript tags: [[$:/tags/test-spec]] Tests the reduce prefix and filter. \*/ -(function(){ + /* jslint node: true, browser: true */ /* eslint-env node, browser, jasmine */ @@ -459,5 +459,3 @@ describe("'reduce' and 'intersection' filter prefix tests", function() { expect(wiki.filterTiddlers('[tag[shopping]] :reduce[]',anchorWidget).join(",")).toBe(" 0 Brownies, 1 Chick Peas, 2 Milk, 3 Rice Pudding,"); }); }); - -})(); \ No newline at end of file diff --git a/editions/test/tiddlers/tests/test-tags.js b/editions/test/tiddlers/tests/test-tags.js index 563c39fe5..5a02e238a 100644 --- a/editions/test/tiddlers/tests/test-tags.js +++ b/editions/test/tiddlers/tests/test-tags.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests the tagging mechanism. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -179,4 +179,3 @@ function runTests(wiki,wikiOptions) { }); -})(); diff --git a/editions/test/tiddlers/tests/test-tiddler.js b/editions/test/tiddlers/tests/test-tiddler.js index f85ee9c6a..90c19b319 100644 --- a/editions/test/tiddlers/tests/test-tiddler.js +++ b/editions/test/tiddlers/tests/test-tiddler.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests the tiddler object \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -134,4 +134,3 @@ describe("Tiddler tests", function() { }); -})(); diff --git a/editions/test/tiddlers/tests/test-utils.js b/editions/test/tiddlers/tests/test-utils.js index d41d5047a..d1a060177 100644 --- a/editions/test/tiddlers/tests/test-utils.js +++ b/editions/test/tiddlers/tests/test-utils.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests various utility functions. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -187,5 +187,3 @@ describe("Utility tests", function() { }); }); - -})(); \ No newline at end of file diff --git a/editions/test/tiddlers/tests/test-widget.js b/editions/test/tiddlers/tests/test-widget.js index 544ed928f..1f37d9209 100755 --- a/editions/test/tiddlers/tests/test-widget.js +++ b/editions/test/tiddlers/tests/test-widget.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests the wikitext rendering pipeline end-to-end. We also need tests that individually test parsers, rendertreenodes etc., but this gets us started. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -737,7 +737,7 @@ describe("Widget module", function() { // Render the widget node to the DOM renderWidgetNode(widgetNode); var childNode = widgetNode; - while (childNode.children.length > 0) { + while(childNode.children.length > 0) { childNode = childNode.children[0]; } // First make sure A and B imported @@ -751,7 +751,7 @@ describe("Widget module", function() { wiki.addTiddler({title: "DE", text: "\\define D() D2"}); widgetNode.refresh({"ABC": {modified: true}, "DE": {modified: true}}); var childNode = widgetNode; - while (childNode.children.length > 0) { + while(childNode.children.length > 0) { childNode = childNode.children[0]; } // Make sure \import recognized changes and deletions @@ -822,4 +822,3 @@ describe("Widget module", function() { }); }); -})(); diff --git a/editions/test/tiddlers/tests/test-wikitext-parser.js b/editions/test/tiddlers/tests/test-wikitext-parser.js index bc3d9acd8..1b26b3ed5 100644 --- a/editions/test/tiddlers/tests/test-wikitext-parser.js +++ b/editions/test/tiddlers/tests/test-wikitext-parser.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests for wikitext parser \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -327,4 +327,3 @@ describe("WikiText parser tests", function() { }); -})(); diff --git a/editions/test/tiddlers/tests/test-wikitext-tabs-macro.js b/editions/test/tiddlers/tests/test-wikitext-tabs-macro.js index 39f061d11..837786a97 100644 --- a/editions/test/tiddlers/tests/test-wikitext-tabs-macro.js +++ b/editions/test/tiddlers/tests/test-wikitext-tabs-macro.js @@ -9,7 +9,7 @@ Intended to permit future readability improvements. Adding new functionality will probably change the "expected" html structure. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -84,4 +84,3 @@ describe("Tabs-macro HTML tests", function() { }); }); -})(); diff --git a/editions/test/tiddlers/tests/test-wikitext.js b/editions/test/tiddlers/tests/test-wikitext.js index eddef73f7..be07ed8d4 100644 --- a/editions/test/tiddlers/tests/test-wikitext.js +++ b/editions/test/tiddlers/tests/test-wikitext.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests the wikitext rendering pipeline end-to-end. We also need tests that individually test parsers, rendertreenodes etc., but this gets us started. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -71,4 +71,3 @@ describe("WikiText tests", function() { }); }); -})(); diff --git a/editions/tw5.com/tiddlers/system/dropbox-url-macro.js b/editions/tw5.com/tiddlers/system/dropbox-url-macro.js index ac7a306ca..b13c55262 100644 --- a/editions/tw5.com/tiddlers/system/dropbox-url-macro.js +++ b/editions/tw5.com/tiddlers/system/dropbox-url-macro.js @@ -12,7 +12,7 @@ Implements the Dropbox URL converter macro. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -29,4 +29,3 @@ exports.run = function(url) { return "`" + url + "` ([[open|" + url + "]])"; }; -})(); diff --git a/editions/tw5.com/tiddlers/system/if-macro.js b/editions/tw5.com/tiddlers/system/if-macro.js index 6c902ed65..1d2d0fc67 100644 --- a/editions/tw5.com/tiddlers/system/if-macro.js +++ b/editions/tw5.com/tiddlers/system/if-macro.js @@ -3,7 +3,7 @@ title: $:/editions/tw5.com/if-macro.js type: application/javascript module-type: macro \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -23,4 +23,3 @@ exports.run = function(cond, then, elze) { return cond ? then : elze; }; -})(); diff --git a/editions/tw5.com/tiddlers/system/theme.tid b/editions/tw5.com/tiddlers/system/theme.tid index 58690c397..6931f70b9 100644 --- a/editions/tw5.com/tiddlers/system/theme.tid +++ b/editions/tw5.com/tiddlers/system/theme.tid @@ -1,3 +1,6 @@ +created: 20230707105616070 +modified: 20230707105617245 title: $:/theme +type: text/vnd.tiddlywiki $:/themes/tiddlywiki/snowwhite \ No newline at end of file diff --git a/plugins/tiddlywiki/aws/modules/command.js b/plugins/tiddlywiki/aws/modules/command.js index 880eea924..193d1f718 100644 --- a/plugins/tiddlywiki/aws/modules/command.js +++ b/plugins/tiddlywiki/aws/modules/command.js @@ -6,7 +6,7 @@ module-type: command --aws command \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -239,5 +239,4 @@ Command.prototype.subCommands["s3-savetiddlers"] = function() { exports.Command = Command; -})(); diff --git a/plugins/tiddlywiki/aws/modules/encodings.js b/plugins/tiddlywiki/aws/modules/encodings.js index f67fded27..c635dd543 100644 --- a/plugins/tiddlywiki/aws/modules/encodings.js +++ b/plugins/tiddlywiki/aws/modules/encodings.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator for applying encodeuricomponent() to each item, with the addition of converting single quotes to %27, as required by AWS \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,4 +24,3 @@ exports["aws-encodeuricomponent"] = function(source,operator,options) { return results; }; -})(); diff --git a/plugins/tiddlywiki/aws/modules/init.js b/plugins/tiddlywiki/aws/modules/init.js index b0b7d3c71..504f82baf 100644 --- a/plugins/tiddlywiki/aws/modules/init.js +++ b/plugins/tiddlywiki/aws/modules/init.js @@ -6,7 +6,7 @@ module-type: startup AWS initialisation \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -34,4 +34,3 @@ exports.startup = function() { } }; -})(); diff --git a/plugins/tiddlywiki/aws/modules/utils.js b/plugins/tiddlywiki/aws/modules/utils.js index d57546aeb..8a8aa30a4 100644 --- a/plugins/tiddlywiki/aws/modules/utils.js +++ b/plugins/tiddlywiki/aws/modules/utils.js @@ -6,7 +6,7 @@ module-type: library AWS utility functions \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -73,4 +73,3 @@ function putFile(region,bucketName,title,text,type,callback) { exports.putFile = putFile; exports.getFile = getFile; -})(); diff --git a/plugins/tiddlywiki/bibtex/deserializer.js b/plugins/tiddlywiki/bibtex/deserializer.js index 9a87e82fb..2ead04d45 100644 --- a/plugins/tiddlywiki/bibtex/deserializer.js +++ b/plugins/tiddlywiki/bibtex/deserializer.js @@ -6,7 +6,7 @@ module-type: tiddlerdeserializer BibTeX file deserializer \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -47,4 +47,3 @@ exports["application/x-bibtex"] = function(text,fields) { return results; }; -})(); diff --git a/plugins/tiddlywiki/browser-sniff/browser.js b/plugins/tiddlywiki/browser-sniff/browser.js index 26989623a..92ae9438f 100644 --- a/plugins/tiddlywiki/browser-sniff/browser.js +++ b/plugins/tiddlywiki/browser-sniff/browser.js @@ -6,7 +6,7 @@ module-type: info Initialise $:/info/browser tiddlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -79,4 +79,3 @@ exports.getInfoTiddlerFields = function() { return infoTiddlerFields; }; -})(); diff --git a/plugins/tiddlywiki/browser-storage/rawmarkup.js b/plugins/tiddlywiki/browser-storage/rawmarkup.js index bf7c41e0a..dd5c1cb57 100644 --- a/plugins/tiddlywiki/browser-storage/rawmarkup.js +++ b/plugins/tiddlywiki/browser-storage/rawmarkup.js @@ -90,4 +90,3 @@ function hookBootTiddlersLoaded() { }); } -})(); diff --git a/plugins/tiddlywiki/browser-storage/startup.js b/plugins/tiddlywiki/browser-storage/startup.js index 552de93d2..dff27f3e6 100644 --- a/plugins/tiddlywiki/browser-storage/startup.js +++ b/plugins/tiddlywiki/browser-storage/startup.js @@ -6,7 +6,7 @@ module-type: startup Startup initialisation \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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 { @@ -129,4 +129,3 @@ exports.startup = function() { }); }; -})(); diff --git a/plugins/tiddlywiki/browser-storage/util.js b/plugins/tiddlywiki/browser-storage/util.js index 7474a367c..31a4a9a83 100644 --- a/plugins/tiddlywiki/browser-storage/util.js +++ b/plugins/tiddlywiki/browser-storage/util.js @@ -7,7 +7,7 @@ Utility methods for browser-storage plugin \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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 @@ -110,4 +110,3 @@ BrowserStorageUtil.prototype.clearLocalStorage = function() { exports.BrowserStorageUtil = BrowserStorageUtil; -})(); diff --git a/plugins/tiddlywiki/cecily/cecily.js b/plugins/tiddlywiki/cecily/cecily.js index 9eec05fd4..5dcc48573 100644 --- a/plugins/tiddlywiki/cecily/cecily.js +++ b/plugins/tiddlywiki/cecily/cecily.js @@ -6,7 +6,7 @@ module-type: storyview Positions tiddlers on a 2D map \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -142,4 +142,3 @@ CecilyStoryView.prototype.lookupTiddlerInMap = function(title,domNode) { exports.cecily = CecilyStoryView; -})(); diff --git a/plugins/tiddlywiki/classictools/modules/recipe.js b/plugins/tiddlywiki/classictools/modules/recipe.js index 5b3a0b019..533cafe57 100644 --- a/plugins/tiddlywiki/classictools/modules/recipe.js +++ b/plugins/tiddlywiki/classictools/modules/recipe.js @@ -8,7 +8,7 @@ Module to deserialize tiddlers from an old school TiddlyWiki recipe file. The idea is to process the recipe file recursively, loading tiddlers into the main store using synchronous file operations. The tiddlers have their titles prefixed with the associated marker in curly brackets ("{shadow}", "{tiddler}" etc). \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -72,4 +72,3 @@ exports["text/vnd.tiddlywiki2-recipe"] = function(text,fields) { return tiddlers; }; -})(); diff --git a/plugins/tiddlywiki/codemirror/edit-codemirror.js b/plugins/tiddlywiki/codemirror/edit-codemirror.js index a8e79928d..c1c2d9428 100755 --- a/plugins/tiddlywiki/codemirror/edit-codemirror.js +++ b/plugins/tiddlywiki/codemirror/edit-codemirror.js @@ -6,7 +6,7 @@ module-type: widget Edit-codemirror widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -17,4 +17,3 @@ var editTextWidgetFactory = require("$:/core/modules/editor/factory.js").editTex exports["edit-codemirror"] = editTextWidgetFactory(CodeMirrorEngine,CodeMirrorEngine); -})(); diff --git a/plugins/tiddlywiki/codemirror/engine.js b/plugins/tiddlywiki/codemirror/engine.js index d994344fc..63f6a3a68 100755 --- a/plugins/tiddlywiki/codemirror/engine.js +++ b/plugins/tiddlywiki/codemirror/engine.js @@ -6,7 +6,7 @@ module-type: library Text editor engine based on a CodeMirror instance \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -317,4 +317,3 @@ CodeMirrorEngine.prototype.executeTextOperation = function(operation) { exports.CodeMirrorEngine = $tw.browser ? CodeMirrorEngine : require("$:/core/modules/editor/engines/simple.js").SimpleEngine; -})(); diff --git a/plugins/tiddlywiki/consent-banner/raw-widget.js b/plugins/tiddlywiki/consent-banner/raw-widget.js index a38deee39..3d8e09974 100644 --- a/plugins/tiddlywiki/consent-banner/raw-widget.js +++ b/plugins/tiddlywiki/consent-banner/raw-widget.js @@ -6,7 +6,7 @@ module-type: widget An override of the raw widget that blocks raw content until the user has consented to accept cookies \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -66,4 +66,3 @@ RawWidget.prototype.refresh = function(changedTiddlers) { exports.raw = RawWidget; -})(); diff --git a/plugins/tiddlywiki/consent-banner/startup.js b/plugins/tiddlywiki/consent-banner/startup.js index 861a03a91..c56f6f30d 100644 --- a/plugins/tiddlywiki/consent-banner/startup.js +++ b/plugins/tiddlywiki/consent-banner/startup.js @@ -6,7 +6,7 @@ module-type: startup Startup initialisation \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -104,4 +104,3 @@ exports.startup = function() { } }; -})(); diff --git a/plugins/tiddlywiki/d3/barwidget.js b/plugins/tiddlywiki/d3/barwidget.js index 18ada16c9..6b7042dbb 100644 --- a/plugins/tiddlywiki/d3/barwidget.js +++ b/plugins/tiddlywiki/d3/barwidget.js @@ -6,7 +6,7 @@ module-type: widget A widget for displaying stacked or grouped bar charts. Derived from http://bl.ocks.org/mbostock/3943967 \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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)}; }); } }; @@ -201,4 +201,3 @@ BarWidget.prototype.refresh = function(changedTiddlers) { exports.d3bar = BarWidget; -})(); diff --git a/plugins/tiddlywiki/d3/cloudwidget.js b/plugins/tiddlywiki/d3/cloudwidget.js index 149747d3e..501f4eee2 100644 --- a/plugins/tiddlywiki/d3/cloudwidget.js +++ b/plugins/tiddlywiki/d3/cloudwidget.js @@ -6,7 +6,7 @@ module-type: widget A widget for displaying word clouds. Derived from https://github.com/jasondavies/d3-cloud \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -130,4 +130,3 @@ CloudWidget.prototype.refresh = function(changedTiddlers) { exports.d3cloud = CloudWidget; -})(); diff --git a/plugins/tiddlywiki/dynannotate/modules/dynannotate.js b/plugins/tiddlywiki/dynannotate/modules/dynannotate.js index 12d8f7155..3681e393c 100644 --- a/plugins/tiddlywiki/dynannotate/modules/dynannotate.js +++ b/plugins/tiddlywiki/dynannotate/modules/dynannotate.js @@ -6,7 +6,7 @@ module-type: widget Dynannotate widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -433,4 +433,3 @@ DynannotateWidget.prototype.refresh = function(changedTiddlers) { exports.dynannotate = DynannotateWidget; -})(); diff --git a/plugins/tiddlywiki/dynannotate/modules/legacy-selection-tracker.js b/plugins/tiddlywiki/dynannotate/modules/legacy-selection-tracker.js index f282601f8..86bdfa157 100644 --- a/plugins/tiddlywiki/dynannotate/modules/legacy-selection-tracker.js +++ b/plugins/tiddlywiki/dynannotate/modules/legacy-selection-tracker.js @@ -6,7 +6,7 @@ module-type: library Legacy version of the dyannotate background daemon to track the selection \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -101,4 +101,3 @@ LegacySelectionTracker.prototype.findSelectionContainer = function findSelection exports.LegacySelectionTracker = LegacySelectionTracker; -})(); diff --git a/plugins/tiddlywiki/dynannotate/modules/selection-tracker.js b/plugins/tiddlywiki/dynannotate/modules/selection-tracker.js index 6b74d0c4b..3653353e1 100644 --- a/plugins/tiddlywiki/dynannotate/modules/selection-tracker.js +++ b/plugins/tiddlywiki/dynannotate/modules/selection-tracker.js @@ -6,7 +6,7 @@ module-type: library Background daemon to track the selection \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -168,4 +168,3 @@ SelectionTracker.prototype.performSelectionActions = function(chunks,variables,a exports.SelectionTracker = SelectionTracker; -})(); diff --git a/plugins/tiddlywiki/dynannotate/modules/startup.js b/plugins/tiddlywiki/dynannotate/modules/startup.js index a2fe6a7f6..fe3f68af7 100644 --- a/plugins/tiddlywiki/dynannotate/modules/startup.js +++ b/plugins/tiddlywiki/dynannotate/modules/startup.js @@ -6,7 +6,7 @@ module-type: startup Startup the dyannotate background daemon to track the selection \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -36,5 +36,4 @@ exports.startup = function() { } }; -})(); \ No newline at end of file diff --git a/plugins/tiddlywiki/dynannotate/modules/textmap.js b/plugins/tiddlywiki/dynannotate/modules/textmap.js index 934ceb0ff..700527eb3 100644 --- a/plugins/tiddlywiki/dynannotate/modules/textmap.js +++ b/plugins/tiddlywiki/dynannotate/modules/textmap.js @@ -6,7 +6,7 @@ module-type: library Structure for modelling mapping between a string and its representation in the DOM \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -179,4 +179,3 @@ exports.TextMap.prototype.extractContext = function(startContainer,startOffset,t }; }; -})(); diff --git a/plugins/tiddlywiki/dynaview/dynaview.js b/plugins/tiddlywiki/dynaview/dynaview.js index 271a41985..f7f2cdbd8 100644 --- a/plugins/tiddlywiki/dynaview/dynaview.js +++ b/plugins/tiddlywiki/dynaview/dynaview.js @@ -6,7 +6,7 @@ module-type: startup Zoom everything \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -264,4 +264,3 @@ function saveViewportDimensions() { } } -})(); diff --git a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js index 72e0e9201..84a932cfb 100644 --- a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js +++ b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js @@ -8,7 +8,7 @@ ENEX file deserializer For details see: https://blog.evernote.com/tech/2013/08/08/evernote-export-format-enex/ \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -77,4 +77,3 @@ function convertDate(isoDate) { return (isoDate || "").replace("T","").replace("Z","") + "000" } -})(); diff --git a/plugins/tiddlywiki/external-attachments/startup.js b/plugins/tiddlywiki/external-attachments/startup.js index 9478c6e2a..c04358d48 100644 --- a/plugins/tiddlywiki/external-attachments/startup.js +++ b/plugins/tiddlywiki/external-attachments/startup.js @@ -6,7 +6,7 @@ module-type: startup Startup initialisation \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -125,4 +125,3 @@ function test_makePathRelative() { } -})(); diff --git a/plugins/tiddlywiki/filesystem/filesystemadaptor.js b/plugins/tiddlywiki/filesystem/filesystemadaptor.js index 1779855df..dc87afa7f 100644 --- a/plugins/tiddlywiki/filesystem/filesystemadaptor.js +++ b/plugins/tiddlywiki/filesystem/filesystemadaptor.js @@ -6,7 +6,7 @@ module-type: syncadaptor A sync adaptor module for synchronising with the local filesystem via node.js APIs \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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); @@ -162,4 +162,3 @@ if(fs) { exports.adaptorClass = FileSystemAdaptor; } -})(); diff --git a/plugins/tiddlywiki/freelinks/plain-text.js b/plugins/tiddlywiki/freelinks/plain-text.js index 2e7e0d707..4cf879671 100644 --- a/plugins/tiddlywiki/freelinks/plain-text.js +++ b/plugins/tiddlywiki/freelinks/plain-text.js @@ -6,7 +6,7 @@ module-type: widget A copy of the core text widget under a different name \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -59,4 +59,3 @@ PlainTextNodeWidget.prototype.refresh = function(changedTiddlers) { exports["plain-text"] = PlainTextNodeWidget; -})(); diff --git a/plugins/tiddlywiki/freelinks/text.js b/plugins/tiddlywiki/freelinks/text.js index 2b3370ebd..884681e56 100755 --- a/plugins/tiddlywiki/freelinks/text.js +++ b/plugins/tiddlywiki/freelinks/text.js @@ -6,7 +6,7 @@ module-type: widget An override of the core text widget that automatically linkifies the text \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -165,4 +165,3 @@ TextNodeWidget.prototype.refresh = function(changedTiddlers) { exports.text = TextNodeWidget; -})(); diff --git a/plugins/tiddlywiki/googleanalytics/googleanalytics.js b/plugins/tiddlywiki/googleanalytics/googleanalytics.js index 617a7a17a..a039a1645 100644 --- a/plugins/tiddlywiki/googleanalytics/googleanalytics.js +++ b/plugins/tiddlywiki/googleanalytics/googleanalytics.js @@ -6,7 +6,7 @@ module-type: startup Runs Google Analytics with the account number in the tiddler `$:/GoogleAnalyticsAccount` and the domain name in `$:/GoogleAnalyticsDomain` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -58,4 +58,3 @@ exports.startup = function() { -})(); diff --git a/plugins/tiddlywiki/highlight-legacy/highlightblock.js b/plugins/tiddlywiki/highlight-legacy/highlightblock.js index 9c1187a91..3cd0e4760 100644 --- a/plugins/tiddlywiki/highlight-legacy/highlightblock.js +++ b/plugins/tiddlywiki/highlight-legacy/highlightblock.js @@ -41,4 +41,3 @@ CodeBlockWidget.prototype.postRender = function() { } }; -})(); diff --git a/plugins/tiddlywiki/highlight/highlightblock.js b/plugins/tiddlywiki/highlight/highlightblock.js index 1d8034631..e879fe233 100644 --- a/plugins/tiddlywiki/highlight/highlightblock.js +++ b/plugins/tiddlywiki/highlight/highlightblock.js @@ -6,16 +6,13 @@ module-type: widget Wraps up the fenced code blocks parser for highlight and use in TiddlyWiki5 \*/ -(function() { /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; var TYPE_MAPPINGS_BASE = "$:/config/HighlightPlugin/TypeMappings/"; - var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock; - var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js"); if(hljs.getLanguage !== undefined) { @@ -23,7 +20,6 @@ if(hljs.getLanguage !== undefined) { $tw.utils.each($tw.modules.types["highlight"],function(moduleInfo,moduleName) { $tw.utils.evalSandboxed(moduleInfo.definition,{hljs:hljs, exports:{}},moduleName); }); - CodeBlockWidget.prototype.postRender = function() { var domNode = this.domNodes[0], language = this.language, @@ -46,6 +42,4 @@ if(hljs.getLanguage !== undefined) { } } }; -} - -})(); +} diff --git a/plugins/tiddlywiki/innerwiki/data.js b/plugins/tiddlywiki/innerwiki/data.js index c325a3cf8..e8423fbe0 100644 --- a/plugins/tiddlywiki/innerwiki/data.js +++ b/plugins/tiddlywiki/innerwiki/data.js @@ -6,7 +6,7 @@ module-type: widget Widget to represent a single item of data \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -55,4 +55,3 @@ DataWidget.prototype.refresh = function(changedTiddlers) { exports.data = DataWidget; exports.anchor = DataWidget; -})(); diff --git a/plugins/tiddlywiki/innerwiki/innerwiki.js b/plugins/tiddlywiki/innerwiki/innerwiki.js index 983128a26..05a1aba62 100644 --- a/plugins/tiddlywiki/innerwiki/innerwiki.js +++ b/plugins/tiddlywiki/innerwiki/innerwiki.js @@ -6,7 +6,7 @@ module-type: widget Widget to display an innerwiki in an iframe \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -408,4 +408,3 @@ InnerWikiWidget.prototype.saveScreenshot = function(options,callback) { exports.innerwiki = InnerWikiWidget; -})(); diff --git a/plugins/tiddlywiki/innerwiki/screenshot.js b/plugins/tiddlywiki/innerwiki/screenshot.js index 428dfb59e..67a91f900 100644 --- a/plugins/tiddlywiki/innerwiki/screenshot.js +++ b/plugins/tiddlywiki/innerwiki/screenshot.js @@ -6,7 +6,7 @@ module-type: command Commands to render tiddlers identified by a filter and save any screenshots identified by <$innerwiki> widgets \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -80,4 +80,3 @@ Command.prototype.findInnerWikiWidgets = function(widgetNode) { exports.Command = Command; -})(); diff --git a/plugins/tiddlywiki/jasmine/jasmine-plugin.js b/plugins/tiddlywiki/jasmine/jasmine-plugin.js index 8dbf6568e..5660dcd40 100644 --- a/plugins/tiddlywiki/jasmine/jasmine-plugin.js +++ b/plugins/tiddlywiki/jasmine/jasmine-plugin.js @@ -6,7 +6,7 @@ module-type: library The main module of the Jasmine test plugin for TiddlyWiki5 \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: true */ @@ -71,7 +71,7 @@ exports.runTests = function(callback,specFilter) { context.require = function(moduleTitle) { // mock out the 'glob' module required in // "$:/plugins/tiddlywiki/jasmine/jasmine/jasmine.js" - if (moduleTitle === "glob") { + if(moduleTitle === "glob") { return {}; } return $tw.modules.execute(moduleTitle,title); @@ -158,4 +158,3 @@ exports.runTests = function(callback,specFilter) { } }; -})(); diff --git a/plugins/tiddlywiki/jasmine/run-wiki-based-tests.js b/plugins/tiddlywiki/jasmine/run-wiki-based-tests.js index 5f28db061..7eedd24cb 100644 --- a/plugins/tiddlywiki/jasmine/run-wiki-based-tests.js +++ b/plugins/tiddlywiki/jasmine/run-wiki-based-tests.js @@ -6,7 +6,7 @@ tags: [[$:/tags/test-spec]] Tests the wiki based tests \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -90,4 +90,3 @@ describe("Wiki-based tests", function() { }); -})(); diff --git a/plugins/tiddlywiki/jasmine/startup.js b/plugins/tiddlywiki/jasmine/startup.js index 47aec342d..f0f79e6f3 100644 --- a/plugins/tiddlywiki/jasmine/startup.js +++ b/plugins/tiddlywiki/jasmine/startup.js @@ -6,7 +6,7 @@ module-type: startup The main module of the Jasmine test plugin for TiddlyWiki5 \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: true */ @@ -35,4 +35,3 @@ if($tw.browser) { exports.after = ["commands"]; } -})(); diff --git a/plugins/tiddlywiki/jszip/startup.js b/plugins/tiddlywiki/jszip/startup.js index 26466d74e..85767182d 100644 --- a/plugins/tiddlywiki/jszip/startup.js +++ b/plugins/tiddlywiki/jszip/startup.js @@ -6,7 +6,7 @@ module-type: startup Setup the root widget event handlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -101,4 +101,3 @@ function downloadZipFile(title,filename) { } } -})(); diff --git a/plugins/tiddlywiki/katex/latex-parser.js b/plugins/tiddlywiki/katex/latex-parser.js index 6b72c7f51..f5256ea96 100644 --- a/plugins/tiddlywiki/katex/latex-parser.js +++ b/plugins/tiddlywiki/katex/latex-parser.js @@ -17,7 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -66,4 +66,3 @@ exports.parse = function() { }]; }; -})(); diff --git a/plugins/tiddlywiki/katex/wrapper.js b/plugins/tiddlywiki/katex/wrapper.js index ceda68c84..5d4f31244 100644 --- a/plugins/tiddlywiki/katex/wrapper.js +++ b/plugins/tiddlywiki/katex/wrapper.js @@ -6,7 +6,7 @@ module-type: widget Wrapper for `katex.min.js` that provides a `<$latex>` widget. It is also available under the alias `<$katex>` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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"]; @@ -95,5 +95,4 @@ KaTeXWidget.prototype.refresh = function(changedTiddlers) { exports.latex = KaTeXWidget; exports.katex = KaTeXWidget; -})(); diff --git a/plugins/tiddlywiki/markdown-legacy/editor-operations/make-markdown-link.js b/plugins/tiddlywiki/markdown-legacy/editor-operations/make-markdown-link.js index 13f5026a7..71e0635b2 100644 --- a/plugins/tiddlywiki/markdown-legacy/editor-operations/make-markdown-link.js +++ b/plugins/tiddlywiki/markdown-legacy/editor-operations/make-markdown-link.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to make a markdown link \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -34,4 +34,3 @@ exports["make-markdown-link"] = function(event,operation) { operation.newSelEnd = operation.newSelStart; }; -})(); diff --git a/plugins/tiddlywiki/markdown-legacy/wrapper.js b/plugins/tiddlywiki/markdown-legacy/wrapper.js index 6fa56232a..9c408bbf0 100755 --- a/plugins/tiddlywiki/markdown-legacy/wrapper.js +++ b/plugins/tiddlywiki/markdown-legacy/wrapper.js @@ -6,7 +6,7 @@ module-type: parser Wraps up the remarkable parser for use as a Parser in TiddlyWiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -338,4 +338,3 @@ var MarkdownParser = function(type, text, options) { exports["text/x-markdown"] = MarkdownParser; exports["text/markdown"] = MarkdownParser; -})(); diff --git a/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js b/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js index b124325c8..67006cd6d 100644 --- a/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js +++ b/plugins/tiddlywiki/markdown/editor-operations/make-markdown-link.js @@ -6,7 +6,7 @@ module-type: texteditoroperation Text editor operation to make a markdown link \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -40,4 +40,3 @@ exports["make-markdown-link"] = function(event,operation) { operation.newSelEnd = operation.newSelStart; }; -})(); diff --git a/plugins/tiddlywiki/markdown/markdown-it-katex.js b/plugins/tiddlywiki/markdown/markdown-it-katex.js index 4bbd5c655..ac8b6d2ab 100644 --- a/plugins/tiddlywiki/markdown/markdown-it-katex.js +++ b/plugins/tiddlywiki/markdown/markdown-it-katex.js @@ -5,7 +5,7 @@ module-type: library Based on markdown-it-katex v2.0.0 by @waylonflinn https://github.com/waylonflinn/markdown-it-katex | MIT License \*/ -(function(){ + /* Process inline math */ /* Like markdown-it-simplemath, this is a stripped down, simplified version of: @@ -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 = "$$"; @@ -166,5 +166,4 @@ function math_inline_block(state, silent) { module.exports = function math_plugin(md, options) { md.inline.ruler.after('escape', 'math_inline', math_inline); md.inline.ruler.after('escape', 'math_inline_block', math_inline_block); -}; -})(); \ No newline at end of file +}; \ No newline at end of file diff --git a/plugins/tiddlywiki/markdown/markdown-it-tiddlywiki.js b/plugins/tiddlywiki/markdown/markdown-it-tiddlywiki.js index 64189ba8b..06394f3c9 100644 --- a/plugins/tiddlywiki/markdown/markdown-it-tiddlywiki.js +++ b/plugins/tiddlywiki/markdown/markdown-it-tiddlywiki.js @@ -6,7 +6,7 @@ module-type: library Wraps up the markdown-it parser for use as a Parser in TiddlyWiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -536,4 +536,3 @@ module.exports = function tiddlyWikiPlugin(markdown,options) { md.core.ruler.push('wikify',wikify); }; -})(); diff --git a/plugins/tiddlywiki/markdown/wrapper.js b/plugins/tiddlywiki/markdown/wrapper.js index 98c5c2ae3..c7c46ae45 100755 --- a/plugins/tiddlywiki/markdown/wrapper.js +++ b/plugins/tiddlywiki/markdown/wrapper.js @@ -6,7 +6,7 @@ module-type: parser Wraps up the markdown-it parser for use as a Parser in TiddlyWiki \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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) { @@ -261,4 +261,3 @@ function MarkdownParser(type,text,options) { exports["text/markdown"] = MarkdownParser; exports["text/x-markdown"] = MarkdownParser; -})(); diff --git a/plugins/tiddlywiki/mobiledragdrop/startup.js b/plugins/tiddlywiki/mobiledragdrop/startup.js index 6abbbd16d..ac9207d56 100644 --- a/plugins/tiddlywiki/mobiledragdrop/startup.js +++ b/plugins/tiddlywiki/mobiledragdrop/startup.js @@ -6,7 +6,7 @@ module-type: startup Startup initialisation \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -22,4 +22,3 @@ exports.startup = function() { window.addEventListener("touchmove", function() {}); }; -})(); diff --git a/plugins/tiddlywiki/nodewebkitsaver/nodewebkit.js b/plugins/tiddlywiki/nodewebkitsaver/nodewebkit.js index 73cbd2f10..fa8f4dbd6 100644 --- a/plugins/tiddlywiki/nodewebkitsaver/nodewebkit.js +++ b/plugins/tiddlywiki/nodewebkitsaver/nodewebkit.js @@ -6,7 +6,7 @@ module-type: saver Handles saving changes in the NW.js environment. Not required by TiddlyDesktop, which re-uses the TiddlyFox saver, but useful if you're embedding a single TiddlyWiki document into a NW.js app. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false, netscape: false, Components: false */ @@ -58,4 +58,3 @@ exports.create = function(wiki) { return new NodeWebKitSaver(wiki); }; -})(); diff --git a/plugins/tiddlywiki/pluginlibrary/libraryserver.js b/plugins/tiddlywiki/pluginlibrary/libraryserver.js index 4f5f3e2ec..3143c0857 100644 --- a/plugins/tiddlywiki/pluginlibrary/libraryserver.js +++ b/plugins/tiddlywiki/pluginlibrary/libraryserver.js @@ -6,7 +6,7 @@ module-type: library A simple HTTP-over-window.postMessage implementation of a standard TiddlyWeb-compatible server. It uses real HTTP to load the individual tiddler JSON files. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -87,4 +87,3 @@ function httpGet(url,callback) { http.send(); } -})(); diff --git a/plugins/tiddlywiki/qrcode/makeqr.js b/plugins/tiddlywiki/qrcode/makeqr.js index 561dfb4a5..041add722 100644 --- a/plugins/tiddlywiki/qrcode/makeqr.js +++ b/plugins/tiddlywiki/qrcode/makeqr.js @@ -6,7 +6,7 @@ module-type: macro Macro to convert a string into a QR Code \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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 { @@ -71,4 +71,3 @@ function generateQrCode(text,options) { } -})(); diff --git a/plugins/tiddlywiki/railroad/components.js b/plugins/tiddlywiki/railroad/components.js index 85d0d16e2..98c55c056 100644 --- a/plugins/tiddlywiki/railroad/components.js +++ b/plugins/tiddlywiki/railroad/components.js @@ -6,7 +6,7 @@ module-type: library Components of a railroad diagram. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -287,5 +287,3 @@ exports.components = { Terminal: Terminal, Transclusion: Transclusion }; - -})(); \ No newline at end of file diff --git a/plugins/tiddlywiki/railroad/parser.js b/plugins/tiddlywiki/railroad/parser.js index 013d898d7..77d4cfd21 100644 --- a/plugins/tiddlywiki/railroad/parser.js +++ b/plugins/tiddlywiki/railroad/parser.js @@ -33,7 +33,7 @@ pragmas: \end single|double|none \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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 @@ -448,5 +448,3 @@ Parser.prototype.readPragma = function(source,pos) { /////////////////////////// Exports exports.parser = Parser; - -})(); \ No newline at end of file diff --git a/plugins/tiddlywiki/railroad/typed-parser.js b/plugins/tiddlywiki/railroad/typed-parser.js index c956ff09b..61c7bbacc 100644 --- a/plugins/tiddlywiki/railroad/typed-parser.js +++ b/plugins/tiddlywiki/railroad/typed-parser.js @@ -6,7 +6,7 @@ module-type: parser This parser wraps unadorned railroad syntax into a railroad widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -24,5 +24,4 @@ console.log(text); exports["text/vnd.tiddlywiki.railroad"] = RailroadParser; -})(); diff --git a/plugins/tiddlywiki/railroad/wrapper.js b/plugins/tiddlywiki/railroad/wrapper.js index 311d2f420..cc7560879 100644 --- a/plugins/tiddlywiki/railroad/wrapper.js +++ b/plugins/tiddlywiki/railroad/wrapper.js @@ -6,7 +6,7 @@ module-type: widget Wrapper for `railroad-diagrams.js` that provides a `<$railroad>` widget. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -143,5 +143,3 @@ RailroadWidget.prototype.dispatchLink = function(to,event) { }; exports.railroad = RailroadWidget; - -})(); \ No newline at end of file diff --git a/plugins/tiddlywiki/savetrail/savetrail.js b/plugins/tiddlywiki/savetrail/savetrail.js index ec6fe7c01..ab7fab4a4 100644 --- a/plugins/tiddlywiki/savetrail/savetrail.js +++ b/plugins/tiddlywiki/savetrail/savetrail.js @@ -6,7 +6,7 @@ module-type: startup A startup module to download every changed tiddler as a JSON file \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -150,4 +150,3 @@ function saveTiddlerFile(tiddler,options) { document.body.removeChild(link); } -})(); diff --git a/plugins/tiddlywiki/share/rawmarkup.js b/plugins/tiddlywiki/share/rawmarkup.js index 264f7fc73..9f4ce48ea 100644 --- a/plugins/tiddlywiki/share/rawmarkup.js +++ b/plugins/tiddlywiki/share/rawmarkup.js @@ -6,7 +6,7 @@ module-type: library Read tiddlers from the browser location hash \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -109,4 +109,3 @@ function removeWarningBanner() { stylesWrapper.parentNode.removeChild(stylesWrapper); } -})(); diff --git a/plugins/tiddlywiki/stacked-view/stacked.js b/plugins/tiddlywiki/stacked-view/stacked.js index 32d30d6d5..e0448794e 100644 --- a/plugins/tiddlywiki/stacked-view/stacked.js +++ b/plugins/tiddlywiki/stacked-view/stacked.js @@ -6,7 +6,7 @@ module-type: storyview Keeps tiddlers in a stack \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -84,5 +84,3 @@ StackedListView.prototype.remove = function(widget) { }; exports.stacked = StackedListView; - -})(); \ No newline at end of file diff --git a/plugins/tiddlywiki/tahoelafs/saver.js b/plugins/tiddlywiki/tahoelafs/saver.js index 2e508352e..223db8dfb 100644 --- a/plugins/tiddlywiki/tahoelafs/saver.js +++ b/plugins/tiddlywiki/tahoelafs/saver.js @@ -6,7 +6,7 @@ module-type: saver A bare bones saver for Tahoe-LAFS. It just PUTs the new HTML file back to the server at the same URL. \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -54,4 +54,3 @@ exports.create = function(wiki) { return new TahoeSaver(wiki); }; -})(); diff --git a/plugins/tiddlywiki/text-slicer/modules/commands/slice.js b/plugins/tiddlywiki/text-slicer/modules/commands/slice.js index 67f2b02f1..79f675e88 100644 --- a/plugins/tiddlywiki/text-slicer/modules/commands/slice.js +++ b/plugins/tiddlywiki/text-slicer/modules/commands/slice.js @@ -6,7 +6,7 @@ module-type: command Command to slice a specified tiddler \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -55,4 +55,3 @@ Command.prototype.execute = function() { exports.Command = Command; -})(); diff --git a/plugins/tiddlywiki/text-slicer/modules/filters/list-children.js b/plugins/tiddlywiki/text-slicer/modules/filters/list-children.js index 443f80a0b..1b9462232 100644 --- a/plugins/tiddlywiki/text-slicer/modules/filters/list-children.js +++ b/plugins/tiddlywiki/text-slicer/modules/filters/list-children.js @@ -6,7 +6,7 @@ module-type: filteroperator Filter operator returning all the descendents of a tiddler listed in the "list" field \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -35,4 +35,3 @@ exports["list-children"] = function(source,operator,options) { return Object.keys(children); }; -})(); diff --git a/plugins/tiddlywiki/text-slicer/modules/slicer.js b/plugins/tiddlywiki/text-slicer/modules/slicer.js index c3e3328e4..a89f17b91 100644 --- a/plugins/tiddlywiki/text-slicer/modules/slicer.js +++ b/plugins/tiddlywiki/text-slicer/modules/slicer.js @@ -16,7 +16,7 @@ var slicer = new textSlicer.Slicer(doc,{ }); \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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); @@ -475,4 +475,3 @@ Slicer.prototype.makeTitle = function(prefix) { exports.Slicer = Slicer; -})(); diff --git a/plugins/tiddlywiki/text-slicer/modules/startup/slicer-startup.js b/plugins/tiddlywiki/text-slicer/modules/startup/slicer-startup.js index 19eeac5be..20e0c0007 100644 --- a/plugins/tiddlywiki/text-slicer/modules/startup/slicer-startup.js +++ b/plugins/tiddlywiki/text-slicer/modules/startup/slicer-startup.js @@ -6,7 +6,7 @@ module-type: startup Setup the root widget event handlers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -48,4 +48,3 @@ exports.startup = function() { }); }; -})(); diff --git a/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js b/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js index 15fbaa4fd..54cac7f2e 100644 --- a/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js +++ b/plugins/tiddlywiki/tiddlyweb/tiddlywebadaptor.js @@ -6,7 +6,7 @@ module-type: syncadaptor A sync adaptor module for synchronising with TiddlyWeb compatible servers \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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; @@ -376,4 +376,3 @@ if($tw.browser && document.location.protocol.substr(0,4) === "http" ) { exports.adaptorClass = TiddlyWebAdaptor; } -})(); diff --git a/plugins/tiddlywiki/tw2parser/classictransclude.js b/plugins/tiddlywiki/tw2parser/classictransclude.js index 8afbed60c..1551ec599 100644 --- a/plugins/tiddlywiki/tw2parser/classictransclude.js +++ b/plugins/tiddlywiki/tw2parser/classictransclude.js @@ -6,7 +6,7 @@ module-type: widget Transclude widget \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -97,7 +97,7 @@ TranscludeWidget.prototype.execute = function() { this.setVariable("transclusion",recursionMarker); // Parse var text = this.wiki.getTiddlerText(this.transcludeTitle); - if (!!this.section||!!this.slice) { + if(!!this.section||!!this.slice) { text =this.refineTiddlerText(text, this.section, this.slice); } @@ -155,7 +155,7 @@ TranscludeWidget.prototype.getTextSlice = function(text,sliceName) TranscludeWidget.prototype.refineTiddlerText = function(text,section,slice) { var textsection = null; - if (slice) { + if(slice) { var textslice = this.getTextSlice(text,slice); if(textslice) return textslice; @@ -192,4 +192,3 @@ TranscludeWidget.prototype.refresh = function(changedTiddlers) { exports.classictransclude = TranscludeWidget; -})(); diff --git a/plugins/tiddlywiki/tw2parser/entry.js b/plugins/tiddlywiki/tw2parser/entry.js index f97cf4cdc..d0760fb28 100644 --- a/plugins/tiddlywiki/tw2parser/entry.js +++ b/plugins/tiddlywiki/tw2parser/entry.js @@ -3,7 +3,7 @@ title: $:/macros/tiddlywiki/entry.js type: application/javascript module-type: macro \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; @@ -21,10 +21,9 @@ 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/parameteradapter.js b/plugins/tiddlywiki/tw2parser/parameteradapter.js index 7dc8e751d..280602edb 100644 --- a/plugins/tiddlywiki/tw2parser/parameteradapter.js +++ b/plugins/tiddlywiki/tw2parser/parameteradapter.js @@ -3,7 +3,7 @@ title: $:/macros/classic/macroadapter.js type: application/javascript module-type: module \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -94,4 +94,3 @@ var paramadapter = { exports.name = 'macroadapter'; exports.namedapter = namedapter; exports.paramadapter = paramadapter; -})(); diff --git a/plugins/tiddlywiki/tw2parser/wikitextparser.js b/plugins/tiddlywiki/tw2parser/wikitextparser.js index 947519bb9..63d50469a 100644 --- a/plugins/tiddlywiki/tw2parser/wikitextparser.js +++ b/plugins/tiddlywiki/tw2parser/wikitextparser.js @@ -28,7 +28,7 @@ HTML nodes look like this: ` \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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]; @@ -197,4 +197,3 @@ WikiTextParser.prototype.subWikifyTerm = function(output,terminatorRegExp) { exports["text/x-tiddlywiki"] = WikiTextParser; -})(); diff --git a/plugins/tiddlywiki/tw2parser/wikitextrules.js b/plugins/tiddlywiki/tw2parser/wikitextrules.js index d7f809723..dd3366e10 100755 --- a/plugins/tiddlywiki/tw2parser/wikitextrules.js +++ b/plugins/tiddlywiki/tw2parser/wikitextrules.js @@ -6,7 +6,7 @@ module-type: module Rule modules for the wikitext parser \*/ -(function(){ + /*jslint node: true, browser: true */ /*global $tw: false */ @@ -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