diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 9e586b92e..000000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -# Ignore "third party" code whose style we will not change. -/boot/sjcl.js -/core/modules/utils/base64-utf8/base64-utf8.module.js -/core/modules/utils/base64-utf8/base64-utf8.module.min.js -/core/modules/utils/diff-match-patch/diff_match_patch.js -/core/modules/utils/diff-match-patch/diff_match_patch_uncompressed.js -/core/modules/utils/dom/csscolorparser.js -/plugins/tiddlywiki/*/files/ diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 0316b8385..000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,286 +0,0 @@ -env: - browser: true - commonjs: true - es2021: true - node: true -extends: 'eslint:recommended' -globals: - "$tw": "writable" # temporary -parserOptions: - ecmaVersion: 5 -rules: - array-bracket-newline: 'off' - array-bracket-spacing: 'off' - array-callback-return: 'off' - array-element-newline: 'off' - arrow-body-style: error - arrow-parens: - - error - - as-needed - arrow-spacing: - - error - - after: true - before: true - block-scoped-var: 'off' - block-spacing: 'off' - brace-style: 'off' - callback-return: 'off' - camelcase: 'off' - capitalized-comments: 'off' - class-methods-use-this: error - comma-dangle: 'off' - comma-spacing: 'off' - comma-style: 'off' - complexity: 'off' - computed-property-spacing: 'off' - consistent-return: 'off' - consistent-this: 'off' - curly: 'off' - default-case: 'off' - default-case-last: error - default-param-last: error - dot-location: 'off' - dot-notation: 'off' - eol-last: 'off' - eqeqeq: 'off' - func-call-spacing: 'off' - func-name-matching: 'off' - func-names: 'off' - func-style: 'off' - function-call-argument-newline: 'off' - function-paren-newline: 'off' - generator-star-spacing: error - global-require: 'off' - grouped-accessor-pairs: error - guard-for-in: 'off' - handle-callback-err: 'off' - id-blacklist: error - id-denylist: error - id-length: 'off' - id-match: error - implicit-arrow-linebreak: error - indent: 'off' - indent-legacy: 'off' - init-declarations: 'off' - jsx-quotes: error - key-spacing: 'off' - keyword-spacing: - - error - - before: true - after: false - overrides: - 'case': - after: true - 'do': - 'after': true - 'else': - after: true - 'return': - after: true - 'throw': - after: true - 'try': - after: true - line-comment-position: 'off' - linebreak-style: 'off' - lines-around-comment: 'off' - lines-around-directive: 'off' - lines-between-class-members: error - max-classes-per-file: error - max-depth: 'off' - max-len: 'off' - max-lines: 'off' - max-lines-per-function: 'off' - max-nested-callbacks: error - max-params: 'off' - max-statements: 'off' - max-statements-per-line: 'off' - multiline-comment-style: 'off' - multiline-ternary: 'off' - new-parens: 'off' - newline-after-var: 'off' - newline-before-return: 'off' - newline-per-chained-call: 'off' - no-alert: 'off' - no-array-constructor: 'off' - no-await-in-loop: error - no-bitwise: 'off' - no-buffer-constructor: 'off' - no-caller: error - no-catch-shadow: 'off' - no-confusing-arrow: error - no-console: 'off' - no-constant-condition: - - error - - checkLoops: false - no-constructor-return: error - no-continue: 'off' - no-div-regex: 'off' - no-duplicate-imports: error - no-else-return: 'off' - no-empty-function: 'off' - no-eq-null: 'off' - no-eval: 'off' - no-extend-native: 'off' - no-extra-bind: 'off' - no-extra-label: 'off' - no-extra-parens: 'off' - no-floating-decimal: 'off' - no-implicit-coercion: - - error - - boolean: false - number: false - string: false - no-implicit-globals: 'off' - no-implied-eval: error - no-inline-comments: 'off' - no-invalid-this: 'off' - no-iterator: error - no-label-var: 'off' - no-labels: 'off' - no-lone-blocks: 'off' - no-lonely-if: 'off' - no-loop-func: 'off' - no-loss-of-precision: error - no-magic-numbers: 'off' - no-mixed-operators: 'off' - no-mixed-requires: 'off' - no-multi-assign: 'off' - no-multi-spaces: 'off' - no-multi-str: error - no-multiple-empty-lines: 'off' - no-native-reassign: 'off' - no-negated-condition: 'off' - no-negated-in-lhs: error - no-nested-ternary: 'off' - no-new: 'off' - no-new-func: 'off' - no-new-object: 'off' - no-new-require: error - no-new-wrappers: error - no-octal-escape: error - no-param-reassign: 'off' - no-path-concat: error - no-plusplus: 'off' - no-process-env: 'off' - no-process-exit: 'off' - no-promise-executor-return: error - no-proto: 'off' - no-restricted-exports: error - no-restricted-globals: error - no-restricted-imports: error - no-restricted-modules: error - no-restricted-properties: error - no-restricted-syntax: error - no-return-assign: 'off' - no-return-await: error - no-script-url: 'off' - no-self-compare: 'off' - no-sequences: 'off' - no-shadow: 'off' - no-spaced-func: 'off' - no-sync: 'off' - no-tabs: 'off' - no-template-curly-in-string: error - no-ternary: 'off' - no-throw-literal: 'off' - no-trailing-spaces: 'off' - no-undef-init: 'off' - no-undefined: 'off' - no-underscore-dangle: 'off' - no-unmodified-loop-condition: 'off' - no-unneeded-ternary: 'off' - no-unreachable-loop: error - no-unused-expressions: 'off' - no-use-before-define: 'off' - no-useless-backreference: error - no-useless-call: 'off' - no-useless-computed-key: error - no-useless-concat: 'off' - no-useless-constructor: error - no-useless-rename: error - no-useless-return: 'off' - no-var: 'off' - no-void: 'off' - no-warning-comments: 'off' - no-whitespace-before-property: error - nonblock-statement-body-position: - - error - - any - object-curly-newline: 'off' - object-curly-spacing: 'off' - object-property-newline: 'off' - object-shorthand: 'off' - one-var: 'off' - one-var-declaration-per-line: 'off' - operator-assignment: 'off' - operator-linebreak: 'off' - padded-blocks: 'off' - padding-line-between-statements: error - prefer-arrow-callback: 'off' - prefer-const: 'off' - prefer-destructuring: 'off' - prefer-exponentiation-operator: 'off' - prefer-named-capture-group: 'off' - prefer-numeric-literals: error - prefer-object-spread: 'off' - prefer-promise-reject-errors: error - prefer-reflect: 'off' - prefer-regex-literals: 'off' - prefer-rest-params: 'off' - prefer-spread: 'off' - prefer-template: 'off' - quote-props: 'off' - quotes: - - error - - double - - avoidEscape: true - radix: 'off' - require-atomic-updates: error - require-await: error - require-jsdoc: 'off' - require-unicode-regexp: 'off' - rest-spread-spacing: error - semi: 'off' - semi-spacing: 'off' - semi-style: 'off' - sort-imports: error - sort-keys: 'off' - sort-vars: 'off' - space-before-blocks: 'off' - space-before-function-paren: 'off' - space-in-parens: 'off' - space-infix-ops: 'off' - space-unary-ops: 'off' - spaced-comment: 'off' - strict: 'off' - switch-colon-spacing: 'off' - symbol-description: error - template-curly-spacing: error - template-tag-spacing: error - unicode-bom: - - error - - never - valid-jsdoc: 'off' - valid-typeof: - - error - - requireStringLiterals: false - vars-on-top: 'off' - wrap-iife: 'off' - wrap-regex: 'off' - yield-star-spacing: error - yoda: 'off' - - # temporary rules - no-useless-escape: 'off' - no-unused-vars: 'off' - no-empty: 'off' - no-extra-semi: 'off' - no-redeclare: 'off' - no-control-regex: "off" - no-mixed-spaces-and-tabs: "off" - no-extra-boolean-cast: "off" - no-prototype-builtins: "off" - no-undef: "off" - no-unreachable: "off" - no-self-assign: "off" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 737d523ef..ed16d707d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,17 +5,17 @@ on: - master - tiddlywiki-com env: - NODE_VERSION: "18" + NODE_VERSION: "22" jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "${{ env.NODE_VERSION }}" - run: "./bin/ci-test.sh" - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: name: playwright-report @@ -30,8 +30,8 @@ jobs: TW5_BUILD_MAIN_EDITION: "./editions/prerelease" TW5_BUILD_OUTPUT: "./output/prerelease" steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "${{ env.NODE_VERSION }}" - run: "./bin/ci-pre-build.sh" @@ -62,8 +62,8 @@ jobs: TW5_BUILD_OUTPUT: "./output" TW5_BUILD_ARCHIVE: "./output" steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: "${{ env.NODE_VERSION }}" - run: "./bin/ci-pre-build.sh" diff --git a/.github/workflows/cla-check.yml b/.github/workflows/cla-check.yml index 72bba1c54..331727b71 100644 --- a/.github/workflows/cla-check.yml +++ b/.github/workflows/cla-check.yml @@ -14,7 +14,7 @@ jobs: if: ${{ (github.event.pull_request.user.login != github.repository_owner) }} steps: - run: | - if ! curl -s https://raw.githubusercontent.com/Jermolene/TiddlyWiki5/tiddlywiki-com/licenses/cla-individual.md | grep -o "@$USER,"; then + if ! curl -s https://raw.githubusercontent.com/Jermolene/TiddlyWiki5/tiddlywiki-com/licenses/cla-individual.md | grep -io "@$USER,"; then echo "CLA not signed" gh pr comment "$NUMBER" -b "@$USER It appears that this is your first contribution to the project, welcome. diff --git a/.github/workflows/cla-signed.yml b/.github/workflows/cla-signed.yml index 6783219d1..01d57d014 100644 --- a/.github/workflows/cla-signed.yml +++ b/.github/workflows/cla-signed.yml @@ -23,8 +23,8 @@ jobs: pull-requests: write steps: - run: | - if ! $BRANCH == "tiddlywiki-com"; then - echo "This CLA signature targets the wrong branch" + if [[ "$BRANCH" != "tiddlywiki-com" ]]; then + echo "This CLA signature targets the wrong branch: $BRANCH" gh pr comment "$NUMBER" -b "@$AUTHOR Signatures to the CLA must target the 'tiddlywiki-com' branch." fi env: diff --git a/bin/build-site.sh b/bin/build-site.sh index fbb34cc98..799cfbed3 100755 --- a/bin/build-site.sh +++ b/bin/build-site.sh @@ -5,7 +5,7 @@ # Default to the current version number for building the plugin library if [ -z "$TW5_BUILD_VERSION" ]; then - TW5_BUILD_VERSION=v5.3.6 + TW5_BUILD_VERSION=v5.3.7 fi echo "Using TW5_BUILD_VERSION as [$TW5_BUILD_VERSION]" @@ -97,7 +97,6 @@ if [ -n "$TW5_BUILD_ARCHIVE" ]; then node $TW5_BUILD_TIDDLYWIKI \ $TW5_BUILD_MAIN_EDITION \ - --verbose \ --version \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_ARCHIVE \ @@ -115,7 +114,6 @@ fi node $TW5_BUILD_TIDDLYWIKI \ $TW5_BUILD_MAIN_EDITION \ - --verbose \ --version \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ @@ -128,7 +126,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /tiddlywikicore-.js Core plugin javascript node $TW5_BUILD_TIDDLYWIKI \ ./editions/empty \ - --verbose \ --output $TW5_BUILD_OUTPUT \ --build empty emptyexternalcore \ || exit 1 @@ -137,7 +134,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /test.html Test edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/test \ - --verbose \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all test.html text/plain \ || exit 1 @@ -150,7 +146,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /dev/static/static.css Static stylesheet node $TW5_BUILD_TIDDLYWIKI \ ./editions/dev \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/dev \ --build index favicon static \ @@ -159,29 +154,13 @@ node $TW5_BUILD_TIDDLYWIKI \ # /tour.html tour edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/tour \ - --verbose \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all tour.html text/plain \ || exit 1 -# /dev/index.html Developer docs -# /dev/favicon.ico Favicon for dev site -# /dev/static.html Static rendering of default tiddlers -# /dev/alltiddlers.html Static rendering of all tiddlers -# /dev/static/* Static single tiddlers -# /dev/static/static.css Static stylesheet -node $TW5_BUILD_TIDDLYWIKI \ - ./editions/dev \ - --verbose \ - --load $TW5_BUILD_OUTPUT/build.tid \ - --output $TW5_BUILD_OUTPUT/dev \ - --build index favicon static \ - || exit 1 - # /share.html Custom edition for sharing via the URL node $TW5_BUILD_TIDDLYWIKI \ ./editions/share \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --build share \ @@ -190,7 +169,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /upgrade.html Custom edition for performing upgrades node $TW5_BUILD_TIDDLYWIKI \ ./editions/upgrade \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --build upgrade \ @@ -199,7 +177,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /encrypted.html Copy of the main file encrypted with the password "password" node $TW5_BUILD_TIDDLYWIKI \ $TW5_BUILD_MAIN_EDITION \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --build encrypted \ @@ -215,7 +192,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/xlsx-utils/index.html xlsx-utils edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/xlsx-utils \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/xlsx-utils/ \ --build index \ @@ -224,7 +200,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/resumebuilder/index.html Resume builder edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/resumebuilder \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/resumebuilder/ \ --build index \ @@ -233,7 +208,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/text-slicer/index.html Text slicer edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/text-slicer \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/text-slicer/ \ --build index \ @@ -242,7 +216,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/translators/index.html Translators edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/translators \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/translators/ \ --build index \ @@ -251,7 +224,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/introduction/index.html Introduction edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/introduction \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/introduction/ \ --build index \ @@ -260,7 +232,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/full/index.html Full edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/full \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/full/ \ --build index \ @@ -269,7 +240,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/tw5.com-docs/index.html tiddlywiki.com docs edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/tw5.com-docs \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/tw5.com-docs/ \ --build index \ @@ -278,7 +248,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /editions/twitter-archivist/index.html Twitter Archivist edition node $TW5_BUILD_TIDDLYWIKI \ ./editions/twitter-archivist \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/editions/twitter-archivist/ \ --build index \ @@ -294,7 +263,6 @@ node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \ ./editions/innerwikidemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/innerwiki/index.html text/plain \ @@ -305,7 +273,6 @@ node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \ ./editions/dynaviewdemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/dynaview/index.html text/plain \ @@ -320,7 +287,6 @@ node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \ ./editions/katexdemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/katex/index.html text/plain \ @@ -331,7 +297,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /plugins/tiddlywiki/tahoelafs/empty.html Empty wiki with Tahoe-LAFS plugin node $TW5_BUILD_TIDDLYWIKI \ ./editions/tahoelafs \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/tahoelafs/index.html text/plain \ @@ -342,7 +307,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /plugins/tiddlywiki/d3/empty.html Empty wiki with D3 plugin node $TW5_BUILD_TIDDLYWIKI \ ./editions/d3demo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/d3/index.html text/plain \ @@ -353,7 +317,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /plugins/tiddlywiki/codemirror/empty.html Empty wiki with codemirror plugin node $TW5_BUILD_TIDDLYWIKI \ ./editions/codemirrordemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/codemirror/index.html text/plain \ @@ -364,7 +327,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /plugins/tiddlywiki/markdown/empty.html Empty wiki with Markdown plugin node $TW5_BUILD_TIDDLYWIKI \ ./editions/markdowndemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/markdown/index.html text/plain \ @@ -375,7 +337,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /plugins/tiddlywiki/tw2parser/empty.html Empty wiki with tw2parser plugin node $TW5_BUILD_TIDDLYWIKI \ ./editions/classicparserdemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/tw2parser/index.html text/plain \ @@ -386,7 +347,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /plugins/tiddlywiki/highlight/empty.html Empty wiki with highlight plugin node $TW5_BUILD_TIDDLYWIKI \ ./editions/highlightdemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/highlight/index.html text/plain \ @@ -397,7 +357,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /plugins/tiddlywiki/geospatial/empty.html Empty wiki with geospatial plugin node $TW5_BUILD_TIDDLYWIKI \ ./editions/geospatialdemo \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT \ --rendertiddler $:/core/save/all plugins/tiddlywiki/geospatial/index.html text/plain \ @@ -425,7 +384,6 @@ rm -rf $TW5_BUILD_OUTPUT/languages/zh-Hant/static/* # /languages/de-AT/empty.html Empty wiki with de-AT language node $TW5_BUILD_TIDDLYWIKI \ ./editions/de-AT \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/de-AT \ --build favicon empty static index \ @@ -435,7 +393,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /languages/de-DE/empty.html Empty wiki with de-DE language node $TW5_BUILD_TIDDLYWIKI \ ./editions/de-DE \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/de-DE \ --build favicon empty static index \ @@ -445,7 +402,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /languages/es-ES/empty.html Empty wiki with es-ES language node $TW5_BUILD_TIDDLYWIKI \ ./editions/es-ES \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/es-ES \ --build favicon empty static index \ @@ -455,7 +411,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /languages/fr-FR/empty.html Empty wiki with fr-FR language node $TW5_BUILD_TIDDLYWIKI \ ./editions/fr-FR \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/fr-FR \ --build favicon empty static index \ @@ -465,7 +420,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /languages/ja-JP/empty.html Empty wiki with ja-JP language node $TW5_BUILD_TIDDLYWIKI \ ./editions/ja-JP \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/ja-JP \ --build empty index \ @@ -475,7 +429,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /languages/ko-KR/empty.html Empty wiki with ko-KR language node $TW5_BUILD_TIDDLYWIKI \ ./editions/ko-KR \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/ko-KR \ --build favicon empty static index \ @@ -485,7 +438,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /languages/zh-Hans/empty.html Empty wiki with zh-Hans language node $TW5_BUILD_TIDDLYWIKI \ ./editions/zh-Hans \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/zh-Hans \ --build empty index \ @@ -495,7 +447,6 @@ node $TW5_BUILD_TIDDLYWIKI \ # /languages/zh-Hant/empty.html Empty wiki with zh-Hant language node $TW5_BUILD_TIDDLYWIKI \ ./editions/zh-Hant \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/languages/zh-Hant \ --build empty index \ @@ -509,7 +460,6 @@ node $TW5_BUILD_TIDDLYWIKI \ node $TW5_BUILD_TIDDLYWIKI \ ./editions/pluginlibrary \ - --verbose \ --load $TW5_BUILD_OUTPUT/build.tid \ --output $TW5_BUILD_OUTPUT/library/$TW5_BUILD_VERSION \ --build library\ diff --git a/boot/boot.js b/boot/boot.js index ea20c83fd..11286678d 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -232,10 +232,10 @@ $tw.utils.error = function(err) { var link = dm("a"), text = JSON.stringify(tiddlers); if(Blob !== undefined) { - var blob = new Blob([text], {type: "text/html"}); + var blob = new Blob([text], {type: "application/json"}); link.setAttribute("href", URL.createObjectURL(blob)); } else { - link.setAttribute("href","data:text/html," + encodeURIComponent(text)); + link.setAttribute("href","data:application/json," + encodeURIComponent(text)); } link.setAttribute("download","emergency-tiddlers-" + (new Date()) + ".json"); document.body.appendChild(link); @@ -386,8 +386,8 @@ $tw.utils.parseDate = function(value) { parseInt(value.substr(10,2)||"00",10), parseInt(value.substr(12,2)||"00",10), parseInt(value.substr(14,3)||"000",10))); - d.setUTCFullYear(year); // See https://stackoverflow.com/a/5870822 - return d; + d.setUTCFullYear(year); // See https://stackoverflow.com/a/5870822 + return d; } else if($tw.utils.isDate(value)) { return value; } else { @@ -1470,17 +1470,15 @@ $tw.Wiki = function(options) { // Unpack the currently registered plugins, creating shadow tiddlers for their constituent tiddlers this.unpackPluginTiddlers = function() { var self = this; - // Sort the plugin titles by the `plugin-priority` field - pluginTiddlers.sort(function(a,b) { - if("plugin-priority" in a.fields && "plugin-priority" in b.fields) { - return a.fields["plugin-priority"] - b.fields["plugin-priority"]; - } else if("plugin-priority" in a.fields) { + // Sort the plugin titles by the `plugin-priority` field, if this field is missing, default to 1 + pluginTiddlers.sort(function(a, b) { + var priorityA = "plugin-priority" in a.fields ? a.fields["plugin-priority"] : 1; + var priorityB = "plugin-priority" in b.fields ? b.fields["plugin-priority"] : 1; + if (priorityA !== priorityB) { + return priorityA - priorityB; + } else if (a.fields.title < b.fields.title) { return -1; - } else if("plugin-priority" in b.fields) { - return +1; - } else if(a.fields.title < b.fields.title) { - return -1; - } else if(a.fields.title === b.fields.title) { + } else if (a.fields.title === b.fields.title) { return 0; } else { return +1; @@ -1904,8 +1902,16 @@ $tw.loadTiddlersFromFile = function(filepath,fields) { extensionInfo = $tw.utils.getFileExtensionInfo(ext), type = extensionInfo ? extensionInfo.type : null, typeInfo = type ? $tw.config.contentTypeInfo[type] : null, - data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8"), - tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields), + fileSize = fs.statSync(filepath).size, + data; + if(fileSize > $tw.config.maxEditFileSize) { + data = "File " + filepath + "not loaded because it is too large"; + console.log("Warning: " + data); + ext = ".txt"; + } else { + data = fs.readFileSync(filepath,typeInfo ? typeInfo.encoding : "utf8"); + } + var tiddlers = $tw.wiki.deserializeTiddlers(ext,data,fields), metadata = $tw.loadMetadataForFile(filepath); if(metadata) { if(type === "application/json") { @@ -2465,13 +2471,15 @@ $tw.boot.initStartup = function(options) { $tw.utils.registerFileType("image/webp","base64",".webp",{flags:["image"]}); $tw.utils.registerFileType("image/heic","base64",".heic",{flags:["image"]}); $tw.utils.registerFileType("image/heif","base64",".heif",{flags:["image"]}); + $tw.utils.registerFileType("image/avif","base64",".avif",{flags:["image"]}); $tw.utils.registerFileType("image/svg+xml","utf8",".svg",{flags:["image"]}); $tw.utils.registerFileType("image/vnd.microsoft.icon","base64",".ico",{flags:["image"]}); $tw.utils.registerFileType("image/x-icon","base64",".ico",{flags:["image"]}); $tw.utils.registerFileType("application/wasm","base64",".wasm"); - $tw.utils.registerFileType("application/font-woff","base64",".woff"); - $tw.utils.registerFileType("application/x-font-ttf","base64",".woff"); - $tw.utils.registerFileType("application/font-woff2","base64",".woff2"); + $tw.utils.registerFileType("font/woff","base64",".woff"); + $tw.utils.registerFileType("font/woff2","base64",".woff2"); + $tw.utils.registerFileType("font/ttf","base64",".ttf"); + $tw.utils.registerFileType("font/otf","base64",".otf"); $tw.utils.registerFileType("audio/ogg","base64",".ogg"); $tw.utils.registerFileType("audio/mp4","base64",[".mp4",".m4a"]); $tw.utils.registerFileType("video/ogg","base64",[".ogm",".ogv",".ogg"]); diff --git a/boot/bootprefix.js b/boot/bootprefix.js index 4dae1b28f..92785d823 100644 --- a/boot/bootprefix.js +++ b/boot/bootprefix.js @@ -19,6 +19,10 @@ var _bootprefix = (function($tw) { $tw = $tw || Object.create(null); $tw.boot = $tw.boot || Object.create(null); +// Config +$tw.config = $tw.config || Object.create(null); +$tw.config.maxEditFileSize = 100 * 1024 * 1024; // 100MB + // Detect platforms if(!("browser" in $tw)) { $tw.browser = typeof(window) !== "undefined" && typeof(document) !== "undefined" ? {} : null; diff --git a/core/acknowledgements.tid b/core/acknowledgements.tid index cb54e3d23..e1015e2c9 100644 --- a/core/acknowledgements.tid +++ b/core/acknowledgements.tid @@ -5,7 +5,3 @@ TiddlyWiki incorporates code from these fine OpenSource projects: * [[The Stanford Javascript Crypto Library|http://bitwiseshiftleft.github.io/sjcl/]] * [[The Jasmine JavaScript Test Framework|https://jasmine.github.io/]] * [[Normalize.css by Nicolas Gallagher|http://necolas.github.io/normalize.css/]] - -And media from these projects: - -* World flag icons from [[Wikipedia|http://commons.wikimedia.org/wiki/Category:SVG_flags_by_country]] diff --git a/core/copyright.tid b/core/copyright.tid index 3f52380cc..233295ce2 100644 --- a/core/copyright.tid +++ b/core/copyright.tid @@ -4,7 +4,7 @@ type: text/plain TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com) Copyright (c) 2004-2007, Jeremy Ruston -Copyright (c) 2007-2024, UnaMesa Association +Copyright (c) 2007-2025, UnaMesa Association All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/core/images/language.tid b/core/images/language.tid new file mode 100644 index 000000000..bb4061495 --- /dev/null +++ b/core/images/language.tid @@ -0,0 +1,5 @@ +title: $:/core/images/language +tags: $:/tags/Image + +\parameters (size:"22pt") +> height=<> class="tc-image-language tc-image-button" viewBox="0 0 92 92"> \ No newline at end of file diff --git a/core/language/en-GB/Buttons.multids b/core/language/en-GB/Buttons.multids index 30f89eec7..2fa732fd9 100644 --- a/core/language/en-GB/Buttons.multids +++ b/core/language/en-GB/Buttons.multids @@ -133,6 +133,7 @@ Excise/Caption/Replace/Link: link Excise/Caption/Replace/Transclusion: transclusion Excise/Caption/Tag: Tag new tiddler with the title of this tiddler Excise/Caption/TiddlerExists: Warning: tiddler already exists +Excise/DefaultTitle: New Excision Excise/Hint: Excise the selected text into a new tiddler Heading1/Caption: heading 1 Heading1/Hint: Apply heading level 1 formatting to lines containing selection diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index a1b164c5c..129dab0b4 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -96,6 +96,10 @@ Plugins/PluginWillRequireReload: (requires reload) Plugins/Plugins/Caption: Plugins Plugins/Plugins/Hint: Plugins Plugins/Reinstall/Caption: reinstall +Plugins/Stability/Deprecated: DEPRECATED +Plugins/Stability/Experimental: EXPERIMENTAL +Plugins/Stability/Legacy: LEGACY +Plugins/Stability/Stable: STABLE Plugins/Themes/Caption: Themes Plugins/Themes/Hint: Theme plugins Plugins/Update/Caption: update @@ -171,6 +175,8 @@ Settings/NavigationPermalinkviewMode/UpdateAddressBar/Description: Update addres Settings/PerformanceInstrumentation/Caption: Performance Instrumentation Settings/PerformanceInstrumentation/Hint: Displays performance statistics in the browser developer console. Requires reload to take effect Settings/PerformanceInstrumentation/Description: Enable performance instrumentation +Settings/RecentLimit/Caption: Recent Tab Limit +Settings/RecentLimit/Hint: Maximum number of tiddlers to be displayed under the sidebar "Recent" tab Settings/ToolbarButtonStyle/Caption: Toolbar Button Style Settings/ToolbarButtonStyle/Hint: Choose the style for toolbar buttons: Settings/ToolbarButtonStyle/Styles/Borderless: Borderless @@ -200,10 +206,10 @@ Settings/MissingLinks/Hint: Choose whether to link to tiddlers that do not exist Settings/MissingLinks/Description: Enable links to missing tiddlers SocialCard/Caption: Social Media Card SocialCard/Domain/Prompt: Domain name to display for the link (for example, ''tiddlywiki.com'') -SocialCard/Hint: This information is used by social and messaging services to display a preview card for links to this TiddlyWiki when hosted online -SocialCard/PreviewUrl/Prompt: Full URL to preview image for this TiddlyWiki +SocialCard/Hint: This information is used by social and messaging services to display a preview card for links to this ~TiddlyWiki when hosted online +SocialCard/PreviewUrl/Prompt: Full URL to preview image for this ~TiddlyWiki SocialCard/PreviewUrl/Preview: Preview image: -SocialCard/Url/Prompt: Full URL of this TiddlyWiki +SocialCard/Url/Prompt: Full URL of this ~TiddlyWiki StoryTiddler/Caption: Story Tiddler StoryTiddler/Hint: This rule cascade is used to dynamically choose the template for displaying a tiddler in the story river. StoryView/Caption: Story View diff --git a/core/language/en-GB/EditTemplate.multids b/core/language/en-GB/EditTemplate.multids index c4bfa5e56..8b2e6e17a 100644 --- a/core/language/en-GB/EditTemplate.multids +++ b/core/language/en-GB/EditTemplate.multids @@ -26,6 +26,8 @@ Tags/ClearInput/Caption: clear input Tags/ClearInput/Hint: Clear tag input Tags/Dropdown/Caption: tag list Tags/Dropdown/Hint: Show tag list +Tags/EmptyMessage: No tags found +Tags/EmptyMessage/System: No system tags found Title/BadCharacterWarning: Warning: avoid using any of the characters <> in tiddler titles Title/Exists/Prompt: Target tiddler already exists Title/Relink/Prompt: Update ''<$text text=<>/>'' to ''<$text text=<>/>'' in the //tags// and //list// fields of other tiddlers diff --git a/core/language/en-GB/Search.multids b/core/language/en-GB/Search.multids index 2a57a6416..f5aa478bf 100644 --- a/core/language/en-GB/Search.multids +++ b/core/language/en-GB/Search.multids @@ -6,6 +6,8 @@ Filter/Hint: Search via a [[filter expression|https://tiddlywiki.com/static/Filt Filter/Matches: //<> matches// Matches: //<> matches// Matches/All: All matches: +Matches/NoMatch: //No match// +Matches/NoResult: //No search result// Matches/Title: Title matches: Search: Search Search/TooShort: Search text too short diff --git a/core/language/en-GB/icon.tid b/core/language/en-GB/icon.tid deleted file mode 100644 index 1967b895f..000000000 --- a/core/language/en-GB/icon.tid +++ /dev/null @@ -1,13 +0,0 @@ -title: $:/languages/en-GB/icon -type: image/svg+xml - - - - - - - - - - - diff --git a/core/modules/commander.js b/core/modules/commander.js index b55679a2e..b73e39b0f 100644 --- a/core/modules/commander.js +++ b/core/modules/commander.js @@ -6,10 +6,7 @@ module-type: global The $tw.Commander class is a command interpreter \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -173,5 +170,3 @@ Commander.initCommands = function(moduleType) { }; exports.Commander = Commander; - -})(); diff --git a/core/modules/commands/build.js b/core/modules/commands/build.js index 8471119d7..cbb7663f1 100644 --- a/core/modules/commands/build.js +++ b/core/modules/commands/build.js @@ -6,10 +6,7 @@ module-type: command Command to build a build target \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -24,7 +21,7 @@ var Command = function(params,commander) { Command.prototype.execute = function() { // Get the build targets defined in the wiki - var buildTargets = $tw.boot.wikiInfo.build; + var buildTargets = $tw.boot.wikiInfo && $tw.boot.wikiInfo.build; if(!buildTargets) { return "No build targets defined"; } @@ -48,5 +45,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/clearpassword.js b/core/modules/commands/clearpassword.js index 9f714a3ef..915c60d23 100644 --- a/core/modules/commands/clearpassword.js +++ b/core/modules/commands/clearpassword.js @@ -6,10 +6,7 @@ module-type: command Clear password for crypto operations \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -29,5 +26,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/commands.js b/core/modules/commands/commands.js index 813f19064..ddaa387db 100644 --- a/core/modules/commands/commands.js +++ b/core/modules/commands/commands.js @@ -7,10 +7,6 @@ Runs the commands returned from a filter \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -38,5 +34,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/deletetiddlers.js b/core/modules/commands/deletetiddlers.js index 3d8b855d9..797a6428a 100644 --- a/core/modules/commands/deletetiddlers.js +++ b/core/modules/commands/deletetiddlers.js @@ -6,10 +6,7 @@ module-type: command Command to delete tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -38,5 +35,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/editions.js b/core/modules/commands/editions.js index cc802b9f5..c46489d09 100644 --- a/core/modules/commands/editions.js +++ b/core/modules/commands/editions.js @@ -6,10 +6,7 @@ module-type: command Command to list the available editions \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -35,5 +32,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/fetch.js b/core/modules/commands/fetch.js index 07cda691c..be076eb3c 100644 --- a/core/modules/commands/fetch.js +++ b/core/modules/commands/fetch.js @@ -6,10 +6,7 @@ module-type: command Commands to fetch external tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -171,5 +168,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..861c8f6d8 100644 --- a/core/modules/commands/help.js +++ b/core/modules/commands/help.js @@ -6,10 +6,7 @@ module-type: command Help command \*/ -(function(){ -/*jshint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -37,5 +34,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/import.js b/core/modules/commands/import.js index 9465c3da1..7c7b6740d 100644 --- a/core/modules/commands/import.js +++ b/core/modules/commands/import.js @@ -6,10 +6,7 @@ module-type: command Command to import tiddlers from a file \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -44,5 +41,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/init.js b/core/modules/commands/init.js index 2d053ae3c..ed48a5494 100644 --- a/core/modules/commands/init.js +++ b/core/modules/commands/init.js @@ -6,10 +6,7 @@ module-type: command Command to initialise an empty wiki folder \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -55,5 +52,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/listen.js b/core/modules/commands/listen.js index ca6e6e076..80cb18293 100644 --- a/core/modules/commands/listen.js +++ b/core/modules/commands/listen.js @@ -6,10 +6,7 @@ module-type: command Listen for HTTP requests and serve tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var Server = require("$:/core/modules/server/server.js").Server; @@ -44,5 +41,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/load.js b/core/modules/commands/load.js index 8fd9cba10..e19ecd59a 100644 --- a/core/modules/commands/load.js +++ b/core/modules/commands/load.js @@ -6,10 +6,7 @@ module-type: command Command to load tiddlers from a file or directory \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -47,5 +44,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/makelibrary.js b/core/modules/commands/makelibrary.js index 3af2e4943..b8ad2e5b6 100644 --- a/core/modules/commands/makelibrary.js +++ b/core/modules/commands/makelibrary.js @@ -6,10 +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 */ "use strict"; exports.info = { @@ -41,5 +38,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/output.js b/core/modules/commands/output.js index 0532f58d7..d43eb2596 100644 --- a/core/modules/commands/output.js +++ b/core/modules/commands/output.js @@ -6,10 +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 */ "use strict"; exports.info = { @@ -34,5 +31,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/password.js b/core/modules/commands/password.js index 85d53fa33..27139a9ed 100644 --- a/core/modules/commands/password.js +++ b/core/modules/commands/password.js @@ -6,10 +6,7 @@ module-type: command Save password for crypto operations \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -32,5 +29,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/render.js b/core/modules/commands/render.js index bd8b23171..c85feda92 100644 --- a/core/modules/commands/render.js +++ b/core/modules/commands/render.js @@ -6,10 +6,7 @@ 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"); @@ -66,6 +63,3 @@ Render individual tiddlers and save the results to the specified files }; exports.Command = Command; - - })(); - \ No newline at end of file diff --git a/core/modules/commands/rendertiddler.js b/core/modules/commands/rendertiddler.js index 41812aea1..2a996c8c1 100755 --- a/core/modules/commands/rendertiddler.js +++ b/core/modules/commands/rendertiddler.js @@ -6,10 +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 */ "use strict"; exports.info = { @@ -53,5 +50,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/rendertiddlers.js b/core/modules/commands/rendertiddlers.js index 78272cc33..f392ba704 100644 --- a/core/modules/commands/rendertiddlers.js +++ b/core/modules/commands/rendertiddlers.js @@ -6,10 +6,7 @@ module-type: command Command to render several tiddlers to a folder of files \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var widget = require("$:/core/modules/widgets/widget.js"); @@ -65,5 +62,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/save.js b/core/modules/commands/save.js index 3cb7ef08c..1d9155623 100644 --- a/core/modules/commands/save.js +++ b/core/modules/commands/save.js @@ -6,10 +6,7 @@ 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 = { @@ -64,6 +61,3 @@ Saves individual tiddlers in their raw text or binary format to the specified fi }; exports.Command = Command; - - })(); - \ No newline at end of file diff --git a/core/modules/commands/savelibrarytiddlers.js b/core/modules/commands/savelibrarytiddlers.js index af42d7c8a..431960edd 100644 --- a/core/modules/commands/savelibrarytiddlers.js +++ b/core/modules/commands/savelibrarytiddlers.js @@ -16,10 +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 */ "use strict"; exports.info = { @@ -94,5 +91,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/savetiddler.js b/core/modules/commands/savetiddler.js index efc484ec7..492fe9f12 100644 --- a/core/modules/commands/savetiddler.js +++ b/core/modules/commands/savetiddler.js @@ -6,10 +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 */ "use strict"; exports.info = { @@ -47,5 +44,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/savetiddlers.js b/core/modules/commands/savetiddlers.js index 9c750e204..0e15d5edc 100644 --- a/core/modules/commands/savetiddlers.js +++ b/core/modules/commands/savetiddlers.js @@ -6,10 +6,7 @@ module-type: command Command to save several tiddlers to a folder of files \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var widget = require("$:/core/modules/widgets/widget.js"); @@ -52,5 +49,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/savewikifolder.js b/core/modules/commands/savewikifolder.js index 461ff6f04..751e0e54e 100644 --- a/core/modules/commands/savewikifolder.js +++ b/core/modules/commands/savewikifolder.js @@ -15,10 +15,7 @@ The following options are supported: Supports backward compatibility with --savewikifolder [] [ [=] ]* \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -221,5 +218,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..d1ee487a2 100644 --- a/core/modules/commands/server.js +++ b/core/modules/commands/server.js @@ -6,10 +6,7 @@ module-type: command Deprecated legacy command for serving tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var Server = require("$:/core/modules/server/server.js").Server; @@ -51,5 +48,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/setfield.js b/core/modules/commands/setfield.js index 3f8ec1d14..7be8cbdca 100644 --- a/core/modules/commands/setfield.js +++ b/core/modules/commands/setfield.js @@ -6,10 +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 */ "use strict"; var widget = require("$:/core/modules/widgets/widget.js"); @@ -54,5 +51,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/unpackplugin.js b/core/modules/commands/unpackplugin.js index 6f85c066f..5e2bd33c0 100644 --- a/core/modules/commands/unpackplugin.js +++ b/core/modules/commands/unpackplugin.js @@ -6,10 +6,7 @@ module-type: command Command to extract the shadow tiddlers from within a plugin \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -40,5 +37,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/verbose.js b/core/modules/commands/verbose.js index 6b0117829..23b5303c7 100644 --- a/core/modules/commands/verbose.js +++ b/core/modules/commands/verbose.js @@ -6,10 +6,7 @@ module-type: command Verbose command \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -30,5 +27,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/commands/version.js b/core/modules/commands/version.js index 24edc97f7..e14c635de 100644 --- a/core/modules/commands/version.js +++ b/core/modules/commands/version.js @@ -6,10 +6,7 @@ module-type: command Version command \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.info = { @@ -28,5 +25,3 @@ Command.prototype.execute = function() { }; exports.Command = Command; - -})(); diff --git a/core/modules/config.js b/core/modules/config.js index fdcf94d0f..3546a21bc 100644 --- a/core/modules/config.js +++ b/core/modules/config.js @@ -6,10 +6,7 @@ module-type: config Core configuration constants \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.preferences = {}; @@ -37,5 +34,3 @@ exports.htmlVoidElements = "area,base,br,col,command,embed,hr,img,input,keygen,l exports.htmlBlockElements = "address,article,aside,audio,blockquote,canvas,dd,details,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,nav,ol,p,pre,section,summary,table,tfoot,ul,video".split(","); exports.htmlUnsafeElements = "script".split(","); - -})(); diff --git a/core/modules/deserializers.js b/core/modules/deserializers.js index bff4aaea1..972a41bb0 100644 --- a/core/modules/deserializers.js +++ b/core/modules/deserializers.js @@ -6,10 +6,7 @@ module-type: tiddlerdeserializer Functions to deserialise tiddlers from a block of text \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports["application/x-tiddler-html-div"] = function(text,fields) { @@ -181,5 +178,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 34d11dec7..9b1c8cd81 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -6,10 +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 */ "use strict"; var HEIGHT_VALUE_TITLE = "$:/config/TextEditor/EditorHeight/Height"; @@ -273,5 +270,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 809dc58ea..93f021522 100644 --- a/core/modules/editor/engines/simple.js +++ b/core/modules/editor/engines/simple.js @@ -6,10 +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 */ "use strict"; var HEIGHT_VALUE_TITLE = "$:/config/TextEditor/EditorHeight/Height"; @@ -172,5 +169,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..984cc76ba 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -6,10 +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 */ "use strict"; var DEFAULT_MIN_TEXT_AREA_HEIGHT = "100px"; // Minimum height of textareas in pixels @@ -386,5 +383,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..48d5772d5 100644 --- a/core/modules/editor/operations/bitmap/clear.js +++ b/core/modules/editor/operations/bitmap/clear.js @@ -6,10 +6,7 @@ module-type: bitmapeditoroperation Bitmap editor operation to clear the image \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports["clear"] = function(event) { @@ -20,5 +17,3 @@ exports["clear"] = function(event) { // Save changes this.strokeEnd(); }; - -})(); diff --git a/core/modules/editor/operations/bitmap/resize.js b/core/modules/editor/operations/bitmap/resize.js index 12059a5cb..683cfa11a 100644 --- a/core/modules/editor/operations/bitmap/resize.js +++ b/core/modules/editor/operations/bitmap/resize.js @@ -6,10 +6,7 @@ module-type: bitmapeditoroperation Bitmap editor operation to resize the image \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports["resize"] = function(event) { @@ -25,5 +22,3 @@ exports["resize"] = function(event) { // Save the image into the tiddler this.saveChanges(); }; - -})(); diff --git a/core/modules/editor/operations/bitmap/rotate-left.js b/core/modules/editor/operations/bitmap/rotate-left.js index 6e1b15d3e..25aa77300 100644 --- a/core/modules/editor/operations/bitmap/rotate-left.js +++ b/core/modules/editor/operations/bitmap/rotate-left.js @@ -6,10 +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 */ "use strict"; exports["rotate-left"] = function(event) { @@ -20,5 +17,3 @@ exports["rotate-left"] = function(event) { // Save the image into the tiddler this.saveChanges(); }; - -})(); diff --git a/core/modules/editor/operations/text/excise.js b/core/modules/editor/operations/text/excise.js index ced771719..c0920cf09 100644 --- a/core/modules/editor/operations/text/excise.js +++ b/core/modules/editor/operations/text/excise.js @@ -6,26 +6,30 @@ module-type: texteditoroperation Text editor operation to excise the selection to a new tiddler \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; +function isMarkdown(mediaType) { + return mediaType === 'text/markdown' || mediaType === 'text/x-markdown'; +} + exports["excise"] = function(event,operation) { var editTiddler = this.wiki.getTiddler(this.editTitle), - editTiddlerTitle = this.editTitle; + editTiddlerTitle = this.editTitle, + wikiLinks = !isMarkdown(editTiddler.fields.type), + excisionBaseTitle = $tw.language.getString("Buttons/Excise/DefaultTitle"); if(editTiddler && editTiddler.fields["draft.of"]) { editTiddlerTitle = editTiddler.fields["draft.of"]; } - var excisionTitle = event.paramObject.title || this.wiki.generateNewTitle("New Excision"); + var excisionTitle = event.paramObject.title || this.wiki.generateNewTitle(excisionBaseTitle); this.wiki.addTiddler(new $tw.Tiddler( this.wiki.getCreationFields(), this.wiki.getModificationFields(), { title: excisionTitle, text: operation.selection, - tags: event.paramObject.tagnew === "yes" ? [editTiddlerTitle] : [] + tags: event.paramObject.tagnew === "yes" ? [editTiddlerTitle] : [], + type: editTiddler.fields.type } )); operation.replacement = excisionTitle; @@ -34,7 +38,8 @@ exports["excise"] = function(event,operation) { operation.replacement = "{{" + operation.replacement+ "}}"; break; case "link": - operation.replacement = "[[" + operation.replacement+ "]]"; + operation.replacement = wikiLinks ? "[[" + operation.replacement+ "]]" + : ("[" + operation.replacement + "](<#" + operation.replacement + ">)"); break; case "macro": operation.replacement = "<<" + (event.paramObject.macro || "translink") + " \"\"\"" + operation.replacement + "\"\"\">>"; @@ -45,5 +50,3 @@ exports["excise"] = function(event,operation) { operation.newSelStart = operation.selStart; 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..19e4a8997 100644 --- a/core/modules/editor/operations/text/focus-editor.js +++ b/core/modules/editor/operations/text/focus-editor.js @@ -4,14 +4,9 @@ type: application/javascript module-type: texteditoroperation Simply focus the Text editor \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; 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..0e24d7413 100644 --- a/core/modules/editor/operations/text/insert-text.js +++ b/core/modules/editor/operations/text/insert-text.js @@ -6,10 +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 */ "use strict"; exports["insert-text"] = function(event,operation) { @@ -19,5 +16,3 @@ exports["insert-text"] = function(event,operation) { operation.newSelStart = operation.selStart + operation.replacement.length; 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..ca11f34c6 100644 --- a/core/modules/editor/operations/text/make-link.js +++ b/core/modules/editor/operations/text/make-link.js @@ -6,10 +6,7 @@ module-type: texteditoroperation Text editor operation to make a link \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports["make-link"] = function(event,operation) { @@ -25,5 +22,3 @@ exports["make-link"] = function(event,operation) { operation.newSelStart = operation.selStart + operation.replacement.length; 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..0f3412b67 100644 --- a/core/modules/editor/operations/text/prefix-lines.js +++ b/core/modules/editor/operations/text/prefix-lines.js @@ -6,10 +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 */ "use strict"; exports["prefix-lines"] = function(event,operation) { @@ -51,5 +48,3 @@ exports["prefix-lines"] = function(event,operation) { operation.newSelEnd = operation.newSelStart + operation.replacement.length; } }; - -})(); diff --git a/core/modules/editor/operations/text/replace-all.js b/core/modules/editor/operations/text/replace-all.js index fc1541935..f6fe0b24c 100644 --- a/core/modules/editor/operations/text/replace-all.js +++ b/core/modules/editor/operations/text/replace-all.js @@ -6,10 +6,7 @@ module-type: texteditoroperation Text editor operation to replace the entire text \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports["replace-all"] = function(event,operation) { @@ -19,5 +16,3 @@ exports["replace-all"] = function(event,operation) { operation.newSelStart = 0; 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..24ef9c70f 100644 --- a/core/modules/editor/operations/text/replace-selection.js +++ b/core/modules/editor/operations/text/replace-selection.js @@ -6,10 +6,7 @@ module-type: texteditoroperation Text editor operation to replace the selection \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports["replace-selection"] = function(event,operation) { @@ -19,5 +16,3 @@ exports["replace-selection"] = function(event,operation) { operation.newSelStart = operation.selStart; 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..00b7174b6 100644 --- a/core/modules/editor/operations/text/save-selection.js +++ b/core/modules/editor/operations/text/save-selection.js @@ -6,10 +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 */ "use strict"; exports["save-selection"] = function(event,operation) { @@ -19,5 +16,3 @@ exports["save-selection"] = function(event,operation) { this.wiki.setText(tiddler,field,null,operation.text.substring(operation.selStart,operation.selEnd)); } }; - -})(); diff --git a/core/modules/editor/operations/text/wrap-lines.js b/core/modules/editor/operations/text/wrap-lines.js index 2e4f22943..9e85d50ca 100644 --- a/core/modules/editor/operations/text/wrap-lines.js +++ b/core/modules/editor/operations/text/wrap-lines.js @@ -6,10 +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 */ "use strict"; exports["wrap-lines"] = function(event,operation) { @@ -43,5 +40,3 @@ exports["wrap-lines"] = function(event,operation) { operation.newSelEnd = operation.newSelStart + (operation.cutEnd - operation.cutStart); } }; - -})(); diff --git a/core/modules/editor/operations/text/wrap-selection.js b/core/modules/editor/operations/text/wrap-selection.js index 6800cbe5b..4fb463b74 100644 --- a/core/modules/editor/operations/text/wrap-selection.js +++ b/core/modules/editor/operations/text/wrap-selection.js @@ -6,45 +6,128 @@ 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 */ "use strict"; exports["wrap-selection"] = function(event,operation) { - if(operation.selStart === operation.selEnd) { - // No selection; check if we're within the prefix/suffix - if(operation.text.substring(operation.selStart - event.paramObject.prefix.length,operation.selStart + event.paramObject.suffix.length) === event.paramObject.prefix + event.paramObject.suffix) { + var o = operation, + prefix = event.paramObject.prefix, + suffix = event.paramObject.suffix, + trimSelection = event.paramObject.trimSelection || "no", + selLength = o.selEnd - o.selStart; + + // This function detects, if trailing spaces are part of the selection __and__ if the user wants to handle them + // Returns "yes", "start", "end", "no" (default) + // yes .. there are trailing spaces at both ends + // start .. there are trailing spaces at the start + // end .. there are trailing spaces at the end + // no .. no trailing spaces are taken into account + var trailingSpaceAt = function(sel) { + var _start, + _end, + result; + // trimSelection is a user parameter, which this evaluations takes into account + switch(trimSelection) { + case "end": + result = (sel.trimEnd().length !== selLength) ? "end" : "no"; + break; + case "yes": + _start = sel.trimStart().length !== selLength; + _end = sel.trimEnd().length !== selLength; + result = (_start && _end) ? "yes" : (_start) ? "start" : (_end) ? "end" : "no"; + break; + case "start": + result = (sel.trimStart().length !== selLength) ? "start" : "no"; + break; + default: + result = "no"; + break; + } + return result; + } + + function togglePrefixSuffix() { + if(o.text.substring(o.selStart - prefix.length, o.selStart + suffix.length) === prefix + suffix) { // Remove the prefix and suffix - operation.cutStart = operation.selStart - event.paramObject.prefix.length; - operation.cutEnd = operation.selEnd + event.paramObject.suffix.length; - operation.replacement = ""; - operation.newSelStart = operation.cutStart; - operation.newSelEnd = operation.newSelStart; + o.cutStart = o.selStart - prefix.length; + o.cutEnd = o.selEnd + suffix.length; + o.replacement = ""; + o.newSelStart = o.cutStart; + o.newSelEnd = o.newSelStart; } else { // Wrap the cursor instead - operation.cutStart = operation.selStart; - operation.cutEnd = operation.selEnd; - operation.replacement = event.paramObject.prefix + event.paramObject.suffix; - operation.newSelStart = operation.selStart + event.paramObject.prefix.length; - operation.newSelEnd = operation.newSelStart; + o.cutStart = o.selStart; + o.cutEnd = o.selEnd; + o.replacement = prefix + suffix; + o.newSelStart = o.selStart + prefix.length; + o.newSelEnd = o.newSelStart; } - } else if(operation.text.substring(operation.selStart,operation.selStart + event.paramObject.prefix.length) === event.paramObject.prefix && operation.text.substring(operation.selEnd - event.paramObject.suffix.length,operation.selEnd) === event.paramObject.suffix) { + } + + // options: lenPrefix, lenSuffix + function removePrefixSuffix(options) { + options = options || {}; + var _lenPrefix = options.lenPrefix || 0; + var _lenSuffix = options.lenSuffix || 0; + + o.cutStart = o.selStart - _lenPrefix; + o.cutEnd = o.selEnd + _lenSuffix; + o.replacement = (_lenPrefix || _lenSuffix) ? o.selection : o.selection.substring(prefix.length, o.selection.length - suffix.length); + o.newSelStart = o.cutStart; + o.newSelEnd = o.cutStart + o.replacement.length; + } + + function addPrefixSuffix() { + // remove trailing space if requested + switch(trailingSpaceAt(o.selection)) { + case "no": + // has no trailing spaces + o.cutStart = o.selStart; + o.cutEnd = o.selEnd; + o.replacement = prefix + o.selection + suffix; + o.newSelStart = o.selStart; + o.newSelEnd = o.selStart + o.replacement.length; + break; + case "yes": + // handle both ends + o.cutStart = o.selEnd - (o.selection.trimStart().length); + o.cutEnd = o.selection.trimEnd().length + o.selStart; + o.replacement = prefix + o.selection.trim() + suffix; + o.newSelStart = o.cutStart; + o.newSelEnd = o.cutStart + o.replacement.length; + break; + case "start": + // handle leading + o.cutStart = o.selEnd - (o.selection.trimStart().length); + o.cutEnd = o.selEnd; + o.replacement = prefix + o.selection.trimStart() + suffix; + o.newSelStart = o.cutStart; + o.newSelEnd = o.cutStart + o.replacement.length; + break; + case "end": + // handle trailing + o.cutStart = o.selStart; + o.cutEnd = o.selection.trimEnd().length + o.selStart; + o.replacement = prefix + o.selection.trimEnd() + suffix; + o.newSelStart = o.selStart; + o.newSelEnd = o.selStart + o.replacement.length; + break; + } + } + + if(o.selStart === o.selEnd) { + // No selection; Create prefix and suffix. Set cursor in between them: ""|"" + togglePrefixSuffix(); + } else if(o.text.substring(o.selStart, o.selStart + prefix.length) === prefix && + o.text.substring(o.selEnd - suffix.length,o.selEnd) === suffix) { // Prefix and suffix are already present, so remove them - operation.cutStart = operation.selStart; - operation.cutEnd = operation.selEnd; - operation.replacement = operation.selection.substring(event.paramObject.prefix.length,operation.selection.length - event.paramObject.suffix.length); - operation.newSelStart = operation.selStart; - operation.newSelEnd = operation.selStart + operation.replacement.length; + removePrefixSuffix(); + } else if(o.text.substring(o.selStart - prefix.length, o.selStart) === prefix && + o.text.substring(o.selEnd, o.selEnd + suffix.length) === suffix) { + // Prefix and suffix are present BUT not selected -> remove them + removePrefixSuffix({"lenPrefix": prefix.length, "lenSuffix": suffix.length}); } else { // Add the prefix and suffix - operation.cutStart = operation.selStart; - operation.cutEnd = operation.selEnd; - operation.replacement = event.paramObject.prefix + operation.selection + event.paramObject.suffix; - operation.newSelStart = operation.selStart; - operation.newSelEnd = operation.selStart + operation.replacement.length; + addPrefixSuffix(); } }; - -})(); diff --git a/core/modules/filterrunprefixes/all.js b/core/modules/filterrunprefixes/all.js index 652936de0..7d57ce408 100644 --- a/core/modules/filterrunprefixes/all.js +++ b/core/modules/filterrunprefixes/all.js @@ -7,10 +7,7 @@ Union of sets without de-duplication. Equivalent to = filter run prefix. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -21,5 +18,3 @@ exports.all = function(operationSubFunction) { results.push.apply(results, operationSubFunction(source,widget)); }; }; - -})(); diff --git a/core/modules/filterrunprefixes/and.js b/core/modules/filterrunprefixes/and.js index 309c228e6..c394b243e 100644 --- a/core/modules/filterrunprefixes/and.js +++ b/core/modules/filterrunprefixes/and.js @@ -7,10 +7,7 @@ Intersection of sets. Equivalent to + filter run prefix. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -24,5 +21,3 @@ exports.and = function(operationSubFunction,options) { results.pushTop(operationSubFunction(source,widget)); }; }; - -})(); diff --git a/core/modules/filterrunprefixes/cascade.js b/core/modules/filterrunprefixes/cascade.js index 486e75f45..98044579c 100644 --- a/core/modules/filterrunprefixes/cascade.js +++ b/core/modules/filterrunprefixes/cascade.js @@ -3,10 +3,7 @@ title: $:/core/modules/filterrunprefixes/cascade.js type: application/javascript module-type: filterrunprefix \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -39,5 +36,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..89635069c 100644 --- a/core/modules/filterrunprefixes/else.js +++ b/core/modules/filterrunprefixes/else.js @@ -6,10 +6,7 @@ module-type: filterrunprefix Equivalent to ~ filter run prefix. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -23,5 +20,3 @@ exports.else = function(operationSubFunction) { } }; }; - -})(); diff --git a/core/modules/filterrunprefixes/except.js b/core/modules/filterrunprefixes/except.js index 659f14228..5ebed7fea 100644 --- a/core/modules/filterrunprefixes/except.js +++ b/core/modules/filterrunprefixes/except.js @@ -7,10 +7,7 @@ Difference of sets. Equivalent to - filter run prefix. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -21,5 +18,3 @@ exports.except = function(operationSubFunction) { results.remove(operationSubFunction(source,widget)); }; }; - -})(); diff --git a/core/modules/filterrunprefixes/filter.js b/core/modules/filterrunprefixes/filter.js index 4ab057109..0c6ed150f 100644 --- a/core/modules/filterrunprefixes/filter.js +++ b/core/modules/filterrunprefixes/filter.js @@ -4,10 +4,7 @@ type: application/javascript module-type: filterrunprefix \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -35,5 +32,3 @@ exports.filter = function(operationSubFunction,options) { } } }; - -})(); diff --git a/core/modules/filterrunprefixes/intersection.js b/core/modules/filterrunprefixes/intersection.js index 34d36066f..ce9ea4546 100644 --- a/core/modules/filterrunprefixes/intersection.js +++ b/core/modules/filterrunprefixes/intersection.js @@ -4,10 +4,7 @@ type: application/javascript module-type: filterrunprefix \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -27,5 +24,3 @@ exports.intersection = function(operationSubFunction) { } }; }; - -})(); diff --git a/core/modules/filterrunprefixes/map.js b/core/modules/filterrunprefixes/map.js index b756d6699..c7f1ae5eb 100644 --- a/core/modules/filterrunprefixes/map.js +++ b/core/modules/filterrunprefixes/map.js @@ -3,10 +3,7 @@ title: $:/core/modules/filterrunprefixes/map.js type: application/javascript module-type: filterrunprefix \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -40,5 +37,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..c4ffb2014 100644 --- a/core/modules/filterrunprefixes/or.js +++ b/core/modules/filterrunprefixes/or.js @@ -6,10 +6,7 @@ module-type: filterrunprefix Equivalent to a filter run with no prefix. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -20,5 +17,3 @@ exports.or = function(operationSubFunction) { results.pushTop(operationSubFunction(source,widget)); }; }; - -})(); diff --git a/core/modules/filterrunprefixes/reduce.js b/core/modules/filterrunprefixes/reduce.js index ee2998837..351d976bd 100644 --- a/core/modules/filterrunprefixes/reduce.js +++ b/core/modules/filterrunprefixes/reduce.js @@ -3,10 +3,7 @@ title: $:/core/modules/filterrunprefixes/reduce.js type: application/javascript module-type: filterrunprefix \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -36,5 +33,3 @@ exports.reduce = function(operationSubFunction,options) { } } }; - -})(); diff --git a/core/modules/filterrunprefixes/sort.js b/core/modules/filterrunprefixes/sort.js index d8d376126..126376887 100644 --- a/core/modules/filterrunprefixes/sort.js +++ b/core/modules/filterrunprefixes/sort.js @@ -4,10 +4,7 @@ type: application/javascript module-type: filterrunprefix \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -48,5 +45,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..0f37fb37f 100644 --- a/core/modules/filterrunprefixes/then.js +++ b/core/modules/filterrunprefixes/then.js @@ -6,10 +6,7 @@ module-type: filterrunprefix Replace results of previous runs unless empty \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -28,5 +25,3 @@ exports.then = function(operationSubFunction) { } }; }; - -})(); diff --git a/core/modules/filters.js b/core/modules/filters.js index aa82a352a..321f5a211 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -6,10 +6,7 @@ module-type: wikimethod Adds tiddler filtering methods to the $tw.Wiki object. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var widgetClass = require("$:/core/modules/widgets/widget.js").widget; @@ -367,5 +364,3 @@ exports.compileFilter = function(filterString) { this.filterCacheCount++; return fnMeasured; }; - -})(); diff --git a/core/modules/filters/addprefix.js b/core/modules/filters/addprefix.js index d1f0a822b..497af1f3b 100644 --- a/core/modules/filters/addprefix.js +++ b/core/modules/filters/addprefix.js @@ -8,10 +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 */ "use strict"; /* @@ -24,5 +21,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..27ca659e9 100644 --- a/core/modules/filters/addsuffix.js +++ b/core/modules/filters/addsuffix.js @@ -8,10 +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 */ "use strict"; /* @@ -24,5 +21,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..9840a73fa 100644 --- a/core/modules/filters/after.js +++ b/core/modules/filters/after.js @@ -6,10 +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 */ "use strict"; /* @@ -27,5 +24,3 @@ exports.after = function(source,operator,options) { return [results[index + 1]]; } }; - -})(); diff --git a/core/modules/filters/all.js b/core/modules/filters/all.js index 3554a74b3..790afeca5 100644 --- a/core/modules/filters/all.js +++ b/core/modules/filters/all.js @@ -8,10 +8,7 @@ Filter operator for selecting tiddlers [all[shadows+tiddlers]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var allFilterOperators; @@ -54,5 +51,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..098fa85f0 100644 --- a/core/modules/filters/all/current.js +++ b/core/modules/filters/all/current.js @@ -6,10 +6,7 @@ module-type: allfilteroperator Filter function for [all[current]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -23,5 +20,3 @@ exports.current = function(source,prefix,options) { return []; } }; - -})(); diff --git a/core/modules/filters/all/missing.js b/core/modules/filters/all/missing.js index 4ba932089..c87e43c98 100644 --- a/core/modules/filters/all/missing.js +++ b/core/modules/filters/all/missing.js @@ -6,10 +6,7 @@ module-type: allfilteroperator Filter function for [all[missing]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -18,5 +15,3 @@ Export our filter function 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..a2e29ba97 100644 --- a/core/modules/filters/all/orphans.js +++ b/core/modules/filters/all/orphans.js @@ -6,10 +6,7 @@ module-type: allfilteroperator Filter function for [all[orphans]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -18,5 +15,3 @@ Export our filter function 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..7946afa73 100644 --- a/core/modules/filters/all/shadows.js +++ b/core/modules/filters/all/shadows.js @@ -6,10 +6,7 @@ module-type: allfilteroperator Filter function for [all[shadows]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -18,5 +15,3 @@ Export our filter function 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..de243453f 100644 --- a/core/modules/filters/all/tags.js +++ b/core/modules/filters/all/tags.js @@ -6,10 +6,7 @@ module-type: allfilteroperator Filter function for [all[tags]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -18,5 +15,3 @@ Export our filter function 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..4e480bf4d 100644 --- a/core/modules/filters/all/tiddlers.js +++ b/core/modules/filters/all/tiddlers.js @@ -6,10 +6,7 @@ module-type: allfilteroperator Filter function for [all[tiddlers]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -18,5 +15,3 @@ Export our filter function 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..f8bd4903a 100644 --- a/core/modules/filters/backlinks.js +++ b/core/modules/filters/backlinks.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for returning all the backlinks from a tiddler \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -22,5 +19,3 @@ exports.backlinks = function(source,operator,options) { }); return results.makeTiddlerIterator(options.wiki); }; - -})(); diff --git a/core/modules/filters/backtranscludes.js b/core/modules/filters/backtranscludes.js index 253b9dd7b..2451ab941 100644 --- a/core/modules/filters/backtranscludes.js +++ b/core/modules/filters/backtranscludes.js @@ -7,9 +7,6 @@ Filter operator for returning all the backtranscludes from a tiddler \*/ (function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* diff --git a/core/modules/filters/before.js b/core/modules/filters/before.js index 292cc619d..1d3473b69 100644 --- a/core/modules/filters/before.js +++ b/core/modules/filters/before.js @@ -6,10 +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 */ "use strict"; /* @@ -27,5 +24,3 @@ exports.before = function(source,operator,options) { return [results[index - 1]]; } }; - -})(); diff --git a/core/modules/filters/commands.js b/core/modules/filters/commands.js index 5ab575a78..753c8b8db 100644 --- a/core/modules/filters/commands.js +++ b/core/modules/filters/commands.js @@ -6,10 +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 */ "use strict"; /* @@ -23,5 +20,3 @@ exports.commands = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/compare.js b/core/modules/filters/compare.js index fd509a28e..ac84f8da2 100644 --- a/core/modules/filters/compare.js +++ b/core/modules/filters/compare.js @@ -6,10 +6,7 @@ module-type: filteroperator General purpose comparison operator \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.compare = function(source,operator,options) { @@ -36,5 +33,3 @@ var modes = { "lteq": function(value) {return value <= 0;}, "lt": function(value) {return value < 0;} } - -})(); diff --git a/core/modules/filters/contains.js b/core/modules/filters/contains.js index 918f415cd..910b43a4a 100644 --- a/core/modules/filters/contains.js +++ b/core/modules/filters/contains.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for finding values in array fields \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -41,5 +38,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..3a7be70ad 100644 --- a/core/modules/filters/count.js +++ b/core/modules/filters/count.js @@ -6,10 +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 */ "use strict"; /* @@ -22,5 +19,3 @@ exports.count = function(source,operator,options) { }); return [count + ""]; }; - -})(); diff --git a/core/modules/filters/crypto.js b/core/modules/filters/crypto.js index cfb524d06..8b05220b2 100644 --- a/core/modules/filters/crypto.js +++ b/core/modules/filters/crypto.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operators for cryptography, using the Stanford JavaScript library \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.sha256 = function(source,operator,options) { @@ -20,5 +17,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..663416d64 100644 --- a/core/modules/filters/days.js +++ b/core/modules/filters/days.js @@ -6,10 +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 */ "use strict"; /* @@ -46,5 +43,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..cebab43d3 100644 --- a/core/modules/filters/deserialize.js +++ b/core/modules/filters/deserialize.js @@ -4,10 +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 */ "use strict"; exports["deserialize"] = function(source,operator,options) { @@ -35,5 +32,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..7ab96fbae 100644 --- a/core/modules/filters/deserializers.js +++ b/core/modules/filters/deserializers.js @@ -6,10 +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 */ "use strict"; /* @@ -23,5 +20,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..30b6da0a7 100644 --- a/core/modules/filters/duplicateslugs.js +++ b/core/modules/filters/duplicateslugs.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter function for [duplicateslugs[]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..0a389b5c3 100644 --- a/core/modules/filters/each.js +++ b/core/modules/filters/each.js @@ -7,10 +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 */ "use strict"; /* @@ -63,5 +60,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..86f343e25 100644 --- a/core/modules/filters/eachday.js +++ b/core/modules/filters/eachday.js @@ -6,10 +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 */ "use strict"; /* @@ -35,5 +32,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..ce526a9a9 100644 --- a/core/modules/filters/editiondescription.js +++ b/core/modules/filters/editiondescription.js @@ -6,10 +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 */ "use strict"; /* @@ -29,5 +26,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..919dacfe9 100644 --- a/core/modules/filters/editions.js +++ b/core/modules/filters/editions.js @@ -6,10 +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 */ "use strict"; /* @@ -28,5 +25,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..cffcf33ef 100644 --- a/core/modules/filters/else.js +++ b/core/modules/filters/else.js @@ -6,10 +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 */ "use strict"; /* @@ -26,5 +23,3 @@ exports.else = function(source,operator,options) { return results; } }; - -})(); diff --git a/core/modules/filters/encodings.js b/core/modules/filters/encodings.js index a43a15f76..ecb0d7289 100644 --- a/core/modules/filters/encodings.js +++ b/core/modules/filters/encodings.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for applying decodeURIComponent() to each item. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -18,8 +15,8 @@ Export our filter functions exports.decodebase64 = function(source,operator,options) { var results = []; - var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1; - var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1; + var binary = operator.suffixes && operator.suffixes[0].indexOf("binary") !== -1; + var urlsafe = operator.suffixes && operator.suffixes[0].indexOf("urlsafe") !== -1; source(function(tiddler,title) { results.push($tw.utils.base64Decode(title,binary,urlsafe)); }); @@ -28,8 +25,8 @@ exports.decodebase64 = function(source,operator,options) { exports.encodebase64 = function(source,operator,options) { var results = []; - var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1; - var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1; + var binary = operator.suffixes && operator.suffixes[0].indexOf("binary") !== -1; + var urlsafe = operator.suffixes && operator.suffixes[0].indexOf("urlsafe") !== -1; source(function(tiddler,title) { results.push($tw.utils.base64Encode(title,binary,urlsafe)); }); @@ -116,5 +113,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..69aa9e9e0 100644 --- a/core/modules/filters/enlist.js +++ b/core/modules/filters/enlist.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator returning its operand parsed as a list \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -38,5 +35,3 @@ exports.enlist = function(source,operator,options) { return list; } }; - -})(); diff --git a/core/modules/filters/field.js b/core/modules/filters/field.js index 3a07c0c27..8dd608d45 100644 --- a/core/modules/filters/field.js +++ b/core/modules/filters/field.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for comparing fields for equality \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -71,5 +68,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..e569f0e5e 100644 --- a/core/modules/filters/fields.js +++ b/core/modules/filters/fields.js @@ -6,10 +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 */ "use strict"; /* @@ -41,5 +38,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..466d43f8b 100644 --- a/core/modules/filters/filter.js +++ b/core/modules/filters/filter.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator returning those input titles that pass a subfilter \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -30,5 +27,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..944007797 100644 --- a/core/modules/filters/format.js +++ b/core/modules/filters/format.js @@ -4,10 +4,7 @@ type: application/javascript module-type: filteroperator Filter operator for formatting strings \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var formatFilterOperators; @@ -42,5 +39,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..c74df3444 100644 --- a/core/modules/filters/format/date.js +++ b/core/modules/filters/format/date.js @@ -3,10 +3,7 @@ title: $:/core/modules/filters/format/date.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -22,5 +19,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..5db3658e7 100644 --- a/core/modules/filters/format/json.js +++ b/core/modules/filters/format/json.js @@ -3,10 +3,7 @@ title: $:/core/modules/filters/format/json.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -31,5 +28,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..ab9c02d72 100644 --- a/core/modules/filters/format/relativedate.js +++ b/core/modules/filters/format/relativedate.js @@ -3,10 +3,7 @@ title: $:/core/modules/filters/format/relativedate.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -22,5 +19,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..9be351c33 100644 --- a/core/modules/filters/format/timestamp.js +++ b/core/modules/filters/format/timestamp.js @@ -3,10 +3,7 @@ title: $:/core/modules/filters/format/timestamp.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -22,4 +19,3 @@ exports.timestamp = function(source,operand,options) { }); return results; }; -})(); \ No newline at end of file diff --git a/core/modules/filters/format/titlelist.js b/core/modules/filters/format/titlelist.js index 47608323d..9e9c827ef 100644 --- a/core/modules/filters/format/titlelist.js +++ b/core/modules/filters/format/titlelist.js @@ -3,10 +3,7 @@ title: $:/core/modules/filters/format/titlelist.js type: application/javascript module-type: formatfilteroperator \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -21,5 +18,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..b6f2fa636 100644 --- a/core/modules/filters/function.js +++ b/core/modules/filters/function.js @@ -6,10 +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 */ "use strict"; /* @@ -17,20 +14,23 @@ Export our filter function */ exports.function = function(source,operator,options) { var functionName = operator.operands[0], - params = []; + params = [], + results; $tw.utils.each(operator.operands.slice(1),function(param) { params.push({value: param}); }); + // console.log(`Calling ${functionName} with params ${JSON.stringify(params)}`); var variableInfo = options.widget && options.widget.getVariableInfo && options.widget.getVariableInfo(functionName,{params: params, source: source}); if(variableInfo && variableInfo.srcVariable && variableInfo.srcVariable.isFunctionDefinition) { - return variableInfo.resultList ? variableInfo.resultList : [variableInfo.text]; + results = variableInfo.resultList ? variableInfo.resultList : [variableInfo.text]; } // Return the input list if the function wasn't found - var results = []; - source(function(tiddler,title) { - results.push(title); - }); + if(!results) { + results = []; + source(function(tiddler,title) { + results.push(title); + }); + } + // console.log(`function ${functionName} with params ${JSON.stringify(params)} results: ${JSON.stringify(results)}`); return results; }; - -})(); diff --git a/core/modules/filters/get.js b/core/modules/filters/get.js index feae6684e..8c078ec85 100644 --- a/core/modules/filters/get.js +++ b/core/modules/filters/get.js @@ -6,10 +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 */ "use strict"; /* @@ -27,5 +24,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..ce34b3356 100644 --- a/core/modules/filters/getindex.js +++ b/core/modules/filters/getindex.js @@ -6,10 +6,7 @@ module-type: filteroperator returns the value at a given index of datatiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -28,5 +25,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..eab697194 100644 --- a/core/modules/filters/getvariable.js +++ b/core/modules/filters/getvariable.js @@ -6,10 +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 */ "use strict"; /* @@ -22,5 +19,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..ceb117f9c 100644 --- a/core/modules/filters/has.js +++ b/core/modules/filters/has.js @@ -6,10 +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 */ "use strict"; /* @@ -66,5 +63,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..43d660cb9 100644 --- a/core/modules/filters/haschanged.js +++ b/core/modules/filters/haschanged.js @@ -6,10 +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 */ "use strict"; /* @@ -32,5 +29,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..1de730217 100644 --- a/core/modules/filters/indexes.js +++ b/core/modules/filters/indexes.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for returning the indexes of a data tiddler \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -26,5 +23,3 @@ exports.indexes = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/insertafter.js b/core/modules/filters/insertafter.js index 79c84cb95..a8f1edf12 100644 --- a/core/modules/filters/insertafter.js +++ b/core/modules/filters/insertafter.js @@ -6,10 +6,7 @@ module-type: filteroperator Insert an item after another item in a list \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -42,5 +39,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..33e41887f 100644 --- a/core/modules/filters/insertbefore.js +++ b/core/modules/filters/insertbefore.js @@ -6,10 +6,7 @@ module-type: filteroperator Insert an item before another item in a list \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -42,5 +39,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..87861a6e9 100644 --- a/core/modules/filters/is.js +++ b/core/modules/filters/is.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for checking tiddler properties \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var isFilterOperators; @@ -44,5 +41,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..7fb02772e 100644 --- a/core/modules/filters/is/binary.js +++ b/core/modules/filters/is/binary.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[binary]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..274d3eba1 100644 --- a/core/modules/filters/is/blank.js +++ b/core/modules/filters/is/blank.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[blank]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..1853c5e28 100644 --- a/core/modules/filters/is/current.js +++ b/core/modules/filters/is/current.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[current]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -33,5 +30,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..caba7849f 100644 --- a/core/modules/filters/is/draft.js +++ b/core/modules/filters/is/draft.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[draft]] analagous to [has[draft.of]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..be276c834 100644 --- a/core/modules/filters/is/image.js +++ b/core/modules/filters/is/image.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[image]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..7720ac472 100644 --- a/core/modules/filters/is/missing.js +++ b/core/modules/filters/is/missing.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[missing]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..8827da4c9 100644 --- a/core/modules/filters/is/orphan.js +++ b/core/modules/filters/is/orphan.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[orphan]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -33,5 +30,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..4f1335c69 100644 --- a/core/modules/filters/is/shadow.js +++ b/core/modules/filters/is/shadow.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[shadow]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..b27feb392 100644 --- a/core/modules/filters/is/system.js +++ b/core/modules/filters/is/system.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[system]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..69d1713be 100644 --- a/core/modules/filters/is/tag.js +++ b/core/modules/filters/is/tag.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[tag]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -33,5 +30,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..24ca5cee2 100644 --- a/core/modules/filters/is/tiddler.js +++ b/core/modules/filters/is/tiddler.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[tiddler]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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..624a179d7 100644 --- a/core/modules/filters/is/variable.js +++ b/core/modules/filters/is/variable.js @@ -6,10 +6,7 @@ module-type: isfilteroperator Filter function for [is[variable]] \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,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 0c58964eb..8f16ad417 100644 --- a/core/modules/filters/json-ops.js +++ b/core/modules/filters/json-ops.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operators for JSON operations \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports["jsonget"] = function(source,operator,options) { @@ -279,6 +276,3 @@ function setDataItem(data,indexes,value) { } return data; } - -})(); - \ No newline at end of file diff --git a/core/modules/filters/limit.js b/core/modules/filters/limit.js index c878c1ac7..9b440155e 100644 --- a/core/modules/filters/limit.js +++ b/core/modules/filters/limit.js @@ -6,10 +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 */ "use strict"; /* @@ -30,5 +27,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..0b56a8871 100644 --- a/core/modules/filters/links.js +++ b/core/modules/filters/links.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for returning all the links from a tiddler \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -22,5 +19,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..2a5e7b8bb 100644 --- a/core/modules/filters/list.js +++ b/core/modules/filters/list.js @@ -6,10 +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 */ "use strict"; /* @@ -31,5 +28,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..610305245 100644 --- a/core/modules/filters/listed.js +++ b/core/modules/filters/listed.js @@ -6,10 +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 */ "use strict"; /* @@ -23,5 +20,3 @@ exports.listed = function(source,operator,options) { }); return results; }; - -})(); diff --git a/core/modules/filters/listops.js b/core/modules/filters/listops.js index 89bd8eeb7..ccd81b9fe 100644 --- a/core/modules/filters/listops.js +++ b/core/modules/filters/listops.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operators for manipulating the current selection list \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -116,5 +113,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..f500b87dd 100644 --- a/core/modules/filters/lookup.js +++ b/core/modules/filters/lookup.js @@ -12,10 +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 */ "use strict"; /* @@ -49,5 +46,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..ce0b2b9d4 100644 --- a/core/modules/filters/match.js +++ b/core/modules/filters/match.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for checking if a title matches a string \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -49,5 +46,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..4c2a9168a 100644 --- a/core/modules/filters/math.js +++ b/core/modules/filters/math.js @@ -13,10 +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 */ "use strict"; exports.negate = makeNumericBinaryOperator( @@ -128,7 +125,7 @@ exports.minall = makeNumericReducingOperator( exports.median = makeNumericArrayOperator( function(values) { var len = values.length, median; - values.sort(); + values.sort(function(a,b) {return a-b}); if(len % 2) { // Odd, return the middle number median = values[(len - 1) / 2]; @@ -243,5 +240,3 @@ function makeNumericArrayOperator(fnCalc) { return results; }; }; - -})(); diff --git a/core/modules/filters/minlength.js b/core/modules/filters/minlength.js index d4e679bef..4428049f8 100644 --- a/core/modules/filters/minlength.js +++ b/core/modules/filters/minlength.js @@ -6,10 +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 */ "use strict"; /* @@ -25,5 +22,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..67b994d52 100644 --- a/core/modules/filters/moduleproperty.js +++ b/core/modules/filters/moduleproperty.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter [[module-name]moduleproperty[name]] retrieve a module property \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -18,13 +15,18 @@ Export our filter function exports.moduleproperty = function(source,operator,options) { var results = []; source(function(tiddler,title) { - var value = require(title)[operator.operand || ""]; - if(value !== undefined) { - results.push(value); + try { + var value = require(title)[operator.operand || ""]; + if(value !== undefined) { + if(typeof value !== "string") { + value = JSON.stringify(value); + } + results.push(value); + } + } catch(e) { + // Do nothing. It probably wasn't a module. } }); results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/modules.js b/core/modules/filters/modules.js index a9e185018..b09d8d825 100644 --- a/core/modules/filters/modules.js +++ b/core/modules/filters/modules.js @@ -6,10 +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 */ "use strict"; /* @@ -37,5 +34,3 @@ exports.modules = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/moduletypes.js b/core/modules/filters/moduletypes.js index 67321caea..752c383ac 100644 --- a/core/modules/filters/moduletypes.js +++ b/core/modules/filters/moduletypes.js @@ -6,10 +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 */ "use strict"; /* @@ -23,5 +20,3 @@ exports.moduletypes = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/next.js b/core/modules/filters/next.js index c12295bf5..01c7e1f90 100644 --- a/core/modules/filters/next.js +++ b/core/modules/filters/next.js @@ -6,10 +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 */ "use strict"; /* @@ -28,5 +25,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..c56f88a91 100644 --- a/core/modules/filters/plugintiddlers.js +++ b/core/modules/filters/plugintiddlers.js @@ -6,10 +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 */ "use strict"; /* @@ -28,5 +25,3 @@ exports.plugintiddlers = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/prefix.js b/core/modules/filters/prefix.js index 97dd56f4e..9b53cd78e 100644 --- a/core/modules/filters/prefix.js +++ b/core/modules/filters/prefix.js @@ -6,10 +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 */ "use strict"; /* @@ -50,5 +47,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..2d76aa59f 100644 --- a/core/modules/filters/previous.js +++ b/core/modules/filters/previous.js @@ -6,10 +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 */ "use strict"; /* @@ -28,5 +25,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..7932e8548 100644 --- a/core/modules/filters/range.js +++ b/core/modules/filters/range.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for generating a numeric range. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -99,5 +96,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..112a927bc 100644 --- a/core/modules/filters/reduce.js +++ b/core/modules/filters/reduce.js @@ -6,10 +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 */ "use strict"; /* @@ -44,5 +41,3 @@ exports.reduce = function(source,operator,options) { return []; } }; - -})(); diff --git a/core/modules/filters/regexp.js b/core/modules/filters/regexp.js index 837e77575..b9d3e2377 100644 --- a/core/modules/filters/regexp.js +++ b/core/modules/filters/regexp.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for regexp matching \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -68,5 +65,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..5e9e4919e 100644 --- a/core/modules/filters/removeprefix.js +++ b/core/modules/filters/removeprefix.js @@ -6,10 +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 */ "use strict"; /* @@ -34,5 +31,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..98f4f9ba5 100644 --- a/core/modules/filters/removesuffix.js +++ b/core/modules/filters/removesuffix.js @@ -6,10 +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 */ "use strict"; /* @@ -38,5 +35,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..91e3e55e3 100644 --- a/core/modules/filters/sameday.js +++ b/core/modules/filters/sameday.js @@ -6,10 +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 */ "use strict"; /* @@ -29,5 +26,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..532cdc839 100644 --- a/core/modules/filters/search.js +++ b/core/modules/filters/search.js @@ -6,10 +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 */ "use strict"; /* @@ -55,5 +52,3 @@ exports.search = function(source,operator,options) { }); } }; - -})(); diff --git a/core/modules/filters/shadowsource.js b/core/modules/filters/shadowsource.js index f16e2bcc7..279759991 100644 --- a/core/modules/filters/shadowsource.js +++ b/core/modules/filters/shadowsource.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for returning the source plugins for shadow tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -26,5 +23,3 @@ exports.shadowsource = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/slugify.js b/core/modules/filters/slugify.js index afc12423e..694426d2a 100644 --- a/core/modules/filters/slugify.js +++ b/core/modules/filters/slugify.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for slugifying a tiddler title \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.slugify = function(source,operator,options) { @@ -19,5 +16,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..cdfe79728 100644 --- a/core/modules/filters/sort.js +++ b/core/modules/filters/sort.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for sorting \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -52,5 +49,3 @@ var prepare_results = function (source) { }); return results; }; - -})(); diff --git a/core/modules/filters/sortsub.js b/core/modules/filters/sortsub.js index d328be09c..291829992 100644 --- a/core/modules/filters/sortsub.js +++ b/core/modules/filters/sortsub.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for sorting by a subfilter \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -48,5 +45,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..c38b5480d 100644 --- a/core/modules/filters/splitbefore.js +++ b/core/modules/filters/splitbefore.js @@ -6,10 +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 */ "use strict"; /* @@ -27,5 +24,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..df097582a 100644 --- a/core/modules/filters/storyviews.js +++ b/core/modules/filters/storyviews.js @@ -6,10 +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 */ "use strict"; /* @@ -25,5 +22,3 @@ exports.storyviews = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/strings.js b/core/modules/filters/strings.js index 11f7634b7..4183bac7f 100644 --- a/core/modules/filters/strings.js +++ b/core/modules/filters/strings.js @@ -8,10 +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 */ "use strict"; exports.length = makeStringBinaryOperator( @@ -293,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..5e35f7cd1 100644 --- a/core/modules/filters/subfilter.js +++ b/core/modules/filters/subfilter.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator returning its operand evaluated as a filter \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -29,5 +26,3 @@ exports.subfilter = function(source,operator,options) { return list; } }; - -})(); diff --git a/core/modules/filters/substitute.js b/core/modules/filters/substitute.js index 655ef7321..925e59286 100644 --- a/core/modules/filters/substitute.js +++ b/core/modules/filters/substitute.js @@ -6,10 +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 */ "use strict"; /* @@ -32,5 +29,3 @@ 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..d16150706 100644 --- a/core/modules/filters/subtiddlerfields.js +++ b/core/modules/filters/subtiddlerfields.js @@ -6,10 +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 */ "use strict"; /* @@ -27,5 +24,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..e31d40568 100644 --- a/core/modules/filters/suffix.js +++ b/core/modules/filters/suffix.js @@ -6,10 +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 */ "use strict"; /* @@ -54,5 +51,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..fdb67af79 100644 --- a/core/modules/filters/tag.js +++ b/core/modules/filters/tag.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for checking for the presence of a tag \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -54,5 +51,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..0efff01ef 100644 --- a/core/modules/filters/tagging.js +++ b/core/modules/filters/tagging.js @@ -6,10 +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 */ "use strict"; /* @@ -22,5 +19,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..c4ce719c8 100644 --- a/core/modules/filters/tags.js +++ b/core/modules/filters/tags.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator returning all the tags of the selected tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -27,5 +24,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..5d9c75a08 100644 --- a/core/modules/filters/then.js +++ b/core/modules/filters/then.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for replacing any titles with a constant \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -22,5 +19,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..a1dff909b 100644 --- a/core/modules/filters/title.js +++ b/core/modules/filters/title.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for comparing title fields for equality \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -28,5 +25,3 @@ exports.title = function(source,operator,options) { } return results; }; - -})(); diff --git a/core/modules/filters/transcludes.js b/core/modules/filters/transcludes.js index 8f42b3bae..0245dcaa4 100644 --- a/core/modules/filters/transcludes.js +++ b/core/modules/filters/transcludes.js @@ -7,9 +7,6 @@ Filter operator for returning all the transcludes from a tiddler \*/ (function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* diff --git a/core/modules/filters/unknown.js b/core/modules/filters/unknown.js index 6ae5baaf0..8fe2a6889 100644 --- a/core/modules/filters/unknown.js +++ b/core/modules/filters/unknown.js @@ -8,10 +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 */ "use strict"; var fieldFilterOperatorFn = require("$:/core/modules/filters/field.js").field; @@ -45,5 +42,3 @@ exports["[unknown]"] = function(source,operator,options) { // Otherwise, use the "field" operator return fieldFilterOperatorFn(source,operator,options); }; - -})(); diff --git a/core/modules/filters/untagged.js b/core/modules/filters/untagged.js index d16de87f8..22f3f6d0c 100644 --- a/core/modules/filters/untagged.js +++ b/core/modules/filters/untagged.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator returning all the selected tiddlers that are untagged \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -25,5 +22,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..f35885cb0 100644 --- a/core/modules/filters/variables.js +++ b/core/modules/filters/variables.js @@ -6,10 +6,7 @@ module-type: filteroperator Filter operator for returning the names of the active variables \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -28,5 +25,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..5bdbcdfdf 100644 --- a/core/modules/filters/wikiparserrules.js +++ b/core/modules/filters/wikiparserrules.js @@ -6,10 +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 */ "use strict"; /* @@ -27,5 +24,3 @@ exports.wikiparserrules = function(source,operator,options) { results.sort(); return results; }; - -})(); diff --git a/core/modules/filters/x-listops.js b/core/modules/filters/x-listops.js index ae17297a5..2f305d0ca 100644 --- a/core/modules/filters/x-listops.js +++ b/core/modules/filters/x-listops.js @@ -6,10 +6,7 @@ module-type: filteroperator Extended filter operators to manipulate the current list. \*/ -(function () { - /*jslint node: true, browser: true */ - /*global $tw: false */ "use strict"; /* @@ -231,5 +228,3 @@ Extended filter operators to manipulate the current list. } return cycleValueInArray(results,operands,step); } - -})(); diff --git a/core/modules/indexers/field-indexer.js b/core/modules/indexers/field-indexer.js index 3aefc99ac..47e89de34 100644 --- a/core/modules/indexers/field-indexer.js +++ b/core/modules/indexers/field-indexer.js @@ -6,10 +6,7 @@ module-type: indexer Indexes the tiddlers with each field value \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global modules: false */ "use strict"; var DEFAULT_MAXIMUM_INDEXED_VALUE_LENGTH = 128; @@ -139,5 +136,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..7844173c6 100644 --- a/core/modules/indexers/tag-indexer.js +++ b/core/modules/indexers/tag-indexer.js @@ -6,10 +6,7 @@ module-type: indexer Indexes the tiddlers with each tag \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global modules: false */ "use strict"; function TagIndexer(wiki) { @@ -94,5 +91,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..9775b2d6b 100644 --- a/core/modules/info/platform.js +++ b/core/modules/info/platform.js @@ -6,10 +6,7 @@ module-type: info Initialise basic platform $:/info/ tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.getInfoTiddlerFields = function(updateInfoTiddlersCallback) { @@ -48,5 +45,3 @@ exports.getInfoTiddlerFields = function(updateInfoTiddlersCallback) { } return infoTiddlerFields; }; - -})(); diff --git a/core/modules/keyboard.js b/core/modules/keyboard.js index 1740ba35b..8adab9e81 100644 --- a/core/modules/keyboard.js +++ b/core/modules/keyboard.js @@ -6,10 +6,7 @@ module-type: global Keyboard handling utilities \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var namedKeys = { @@ -383,5 +380,3 @@ KeyboardManager.prototype.handleShortcutChanges = function(changedTiddlers) { }; exports.KeyboardManager = KeyboardManager; - -})(); diff --git a/core/modules/language.js b/core/modules/language.js index 5e44d6696..b0409ee4d 100644 --- a/core/modules/language.js +++ b/core/modules/language.js @@ -6,10 +6,7 @@ module-type: global The $tw.Language() manages translateable strings \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -41,5 +38,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..871ce630d 100644 --- a/core/modules/macros/changecount.js +++ b/core/modules/macros/changecount.js @@ -6,10 +6,7 @@ module-type: macro Macro to return the changecount for the current tiddler \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -26,5 +23,3 @@ Run the macro 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..8134bdeff 100644 --- a/core/modules/macros/contrastcolour.js +++ b/core/modules/macros/contrastcolour.js @@ -6,10 +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 */ "use strict"; /* @@ -51,5 +48,3 @@ exports.run = function(target,fallbackTarget,colourA,colourB) { brightnessB = rgbColourB[0] * 0.299 + rgbColourB[1] * 0.587 + rgbColourB[2] * 0.114; 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 a492fd81c..e5d2f9137 100644 --- a/core/modules/macros/csvtiddlers.js +++ b/core/modules/macros/csvtiddlers.js @@ -6,10 +6,7 @@ module-type: macro Macro to output tiddlers matching a filter to CSV \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -75,5 +72,3 @@ exports.run = function(filter,format) { function quoteAndEscape(value) { return "\"" + value.replace(/"/mg,"\"\"") + "\""; } - -})(); diff --git a/core/modules/macros/displayshortcuts.js b/core/modules/macros/displayshortcuts.js index b18297238..10f6c7221 100644 --- a/core/modules/macros/displayshortcuts.js +++ b/core/modules/macros/displayshortcuts.js @@ -6,10 +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 */ "use strict"; /* @@ -41,5 +38,3 @@ exports.run = function(shortcuts,prefix,separator,suffix) { return ""; } }; - -})(); diff --git a/core/modules/macros/jsontiddler.js b/core/modules/macros/jsontiddler.js index 509fd5559..ff5ae3c9b 100644 --- a/core/modules/macros/jsontiddler.js +++ b/core/modules/macros/jsontiddler.js @@ -6,10 +6,7 @@ module-type: macro Macro to output a single tiddler to JSON \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -37,4 +34,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..25e08f6b9 100644 --- a/core/modules/macros/jsontiddlers.js +++ b/core/modules/macros/jsontiddlers.js @@ -6,10 +6,7 @@ module-type: macro Macro to output tiddlers matching a filter to JSON \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -29,5 +26,3 @@ Run the macro 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..db67495e5 100644 --- a/core/modules/macros/makedatauri.js +++ b/core/modules/macros/makedatauri.js @@ -8,10 +8,7 @@ Macro to convert a string of text to a data URI <> \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -32,5 +29,3 @@ Run the macro 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..86513f1b9 100644 --- a/core/modules/macros/now.js +++ b/core/modules/macros/now.js @@ -6,10 +6,7 @@ module-type: macro Macro to return a formatted version of the current time \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -28,5 +25,3 @@ Run the macro 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..ff6716dd4 100644 --- a/core/modules/macros/qualify.js +++ b/core/modules/macros/qualify.js @@ -6,10 +6,7 @@ module-type: macro Macro to qualify a state tiddler title according \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -28,5 +25,3 @@ Run the macro exports.run = function(title) { return title + "-" + this.getStateQualifier(); }; - -})(); diff --git a/core/modules/macros/resolvepath.js b/core/modules/macros/resolvepath.js index d84d87563..68c2e4d04 100644 --- a/core/modules/macros/resolvepath.js +++ b/core/modules/macros/resolvepath.js @@ -6,10 +6,7 @@ module-type: macro Resolves a relative path for an absolute rootpath. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "resolvepath"; @@ -25,5 +22,3 @@ Run the macro 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..056c713df 100644 --- a/core/modules/macros/unusedtitle.js +++ b/core/modules/macros/unusedtitle.js @@ -5,10 +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 */ "use strict"; exports.name = "unusedtitle"; @@ -16,20 +13,20 @@ exports.name = "unusedtitle"; exports.params = [ {name: "baseName"}, {name: "separator"}, - {name: "template"} + {name: "template"}, + {name: "startCount"} ]; /* Run the macro */ -exports.run = function(baseName,separator,template) { +exports.run = function(baseName,separator,template,startCount) { separator = separator || " "; + startCount = startCount || 0; if(!baseName) { baseName = $tw.language.getString("DefaultNewTiddlerTitle"); } // $tw.wiki.generateNewTitle = function(baseTitle,options) - // options.prefix must be a string! - return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template}); + // options.prefix must be a string! + return this.wiki.generateNewTitle(baseName, {"prefix": separator, "template": template, "startCount": startCount}).trim(); }; - -})(); diff --git a/core/modules/macros/version.js b/core/modules/macros/version.js index b0dd0b0d5..0a5315b81 100644 --- a/core/modules/macros/version.js +++ b/core/modules/macros/version.js @@ -6,10 +6,7 @@ module-type: macro Macro to return the TiddlyWiki core version number \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -26,5 +23,3 @@ Run the macro exports.run = function() { return $tw.version; }; - -})(); diff --git a/core/modules/parsers/audioparser.js b/core/modules/parsers/audioparser.js index 5eb2ff985..601de058e 100644 --- a/core/modules/parsers/audioparser.js +++ b/core/modules/parsers/audioparser.js @@ -6,10 +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 */ "use strict"; var AudioParser = function(type,text,options) { @@ -36,6 +33,3 @@ exports["audio/ogg"] = AudioParser; 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..947d9befa 100644 --- a/core/modules/parsers/binaryparser.js +++ b/core/modules/parsers/binaryparser.js @@ -6,10 +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 */ "use strict"; var BINARY_WARNING_MESSAGE = "$:/core/ui/BinaryWarning"; @@ -69,6 +66,3 @@ 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..2d32b3a06 100644 --- a/core/modules/parsers/csvparser.js +++ b/core/modules/parsers/csvparser.js @@ -6,10 +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 */ "use strict"; var CsvParser = function(type,text,options) { @@ -58,6 +55,3 @@ 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..fee869868 100644 --- a/core/modules/parsers/htmlparser.js +++ b/core/modules/parsers/htmlparser.js @@ -6,10 +6,7 @@ module-type: parser The HTML parser displays text as raw HTML \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var HtmlParser = function(type,text,options) { @@ -34,6 +31,3 @@ 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..c7201445f 100644 --- a/core/modules/parsers/imageparser.js +++ b/core/modules/parsers/imageparser.js @@ -6,10 +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 */ "use strict"; var ImageParser = function(type,text,options) { @@ -40,8 +37,6 @@ exports["image/gif"] = ImageParser; exports["image/webp"] = ImageParser; exports["image/heic"] = ImageParser; exports["image/heif"] = ImageParser; +exports["image/avif"] = 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 8d143c5e9..99ccbb40a 100644 --- a/core/modules/parsers/parseutils.js +++ b/core/modules/parsers/parseutils.js @@ -22,10 +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 */ "use strict"; /* @@ -425,5 +422,3 @@ exports.serializeAttribute = function(node,options) { } return attributeString; }; - -})(); diff --git a/core/modules/parsers/pdfparser.js b/core/modules/parsers/pdfparser.js index c7830bf69..0551e93fa 100644 --- a/core/modules/parsers/pdfparser.js +++ b/core/modules/parsers/pdfparser.js @@ -6,10 +6,7 @@ module-type: parser The PDF parser embeds a PDF viewer \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var ImageParser = function(type,text,options) { @@ -30,6 +27,3 @@ 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 17f9bde10..ca97404ac 100644 --- a/core/modules/parsers/textparser.js +++ b/core/modules/parsers/textparser.js @@ -6,10 +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 */ "use strict"; var TextParser = function(type,text,options) { @@ -32,5 +29,3 @@ exports["application/javascript"] = TextParser; 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..e4406e56a 100644 --- a/core/modules/parsers/videoparser.js +++ b/core/modules/parsers/videoparser.js @@ -6,10 +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 */ "use strict"; var VideoParser = function(type,text,options) { @@ -36,5 +33,3 @@ exports["video/ogg"] = VideoParser; 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 aae047316..ca84e24aa 100644 --- a/core/modules/parsers/wikiparser/rules/codeblock.js +++ b/core/modules/parsers/wikiparser/rules/codeblock.js @@ -12,10 +12,7 @@ Wiki text rule for code blocks. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "codeblock"; @@ -60,5 +57,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "```" + tree.attributes.language.value + "\n" + tree.attributes.code.value + "\n```\n\n"; } - -})(); diff --git a/core/modules/parsers/wikiparser/rules/codeinline.js b/core/modules/parsers/wikiparser/rules/codeinline.js index 4d32089ab..a9dadad27 100644 --- a/core/modules/parsers/wikiparser/rules/codeinline.js +++ b/core/modules/parsers/wikiparser/rules/codeinline.js @@ -11,10 +11,7 @@ Wiki text inline rule for code runs. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "codeinline"; @@ -58,5 +55,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "`" + serialize(tree.children) + "`"; } - -})(); diff --git a/core/modules/parsers/wikiparser/rules/commentblock.js b/core/modules/parsers/wikiparser/rules/commentblock.js index 5f87020ca..9a953be08 100644 --- a/core/modules/parsers/wikiparser/rules/commentblock.js +++ b/core/modules/parsers/wikiparser/rules/commentblock.js @@ -18,10 +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 */ "use strict"; exports.name = "commentblock"; @@ -65,5 +62,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return tree.text + "\n\n" + serialize(tree.children); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/commentinline.js b/core/modules/parsers/wikiparser/rules/commentinline.js index b96f5d78b..6eb49e839 100644 --- a/core/modules/parsers/wikiparser/rules/commentinline.js +++ b/core/modules/parsers/wikiparser/rules/commentinline.js @@ -12,10 +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 */ "use strict"; exports.name = "commentinline"; @@ -57,5 +54,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return tree.text; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/conditional.js b/core/modules/parsers/wikiparser/rules/conditional.js index 6ec8a6ab5..57db3891e 100644 --- a/core/modules/parsers/wikiparser/rules/conditional.js +++ b/core/modules/parsers/wikiparser/rules/conditional.js @@ -11,9 +11,6 @@ This is a <%if [{something}] %>Elephant<%elseif [{else}] %>Pelican<%else%>Crocod \*/ (function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "conditional"; diff --git a/core/modules/parsers/wikiparser/rules/dash.js b/core/modules/parsers/wikiparser/rules/dash.js index 84f996cf6..93a69b946 100644 --- a/core/modules/parsers/wikiparser/rules/dash.js +++ b/core/modules/parsers/wikiparser/rules/dash.js @@ -12,10 +12,7 @@ This is an em-dash: --- ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "dash"; @@ -40,5 +37,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return tree.entity === "–" ? "--" : "---"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/bold.js b/core/modules/parsers/wikiparser/rules/emphasis/bold.js index c6758819f..12e9ea7a2 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/bold.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/bold.js @@ -17,10 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "bold"; @@ -50,5 +47,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "''" + serialize(tree.children) + "''"; }; - -})(); \ 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 12b9a34c9..446fdedb4 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/italic.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/italic.js @@ -17,10 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "italic"; @@ -50,5 +47,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "//" + serialize(tree.children) + "//"; }; - -})(); \ 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 44e180a84..038aaceba 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/strikethrough.js @@ -17,10 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "strikethrough"; @@ -50,5 +47,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "~~" + serialize(tree.children) + "~~"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/subscript.js b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js index e2d9f766b..0b24ad14b 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/subscript.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/subscript.js @@ -17,10 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "subscript"; @@ -50,5 +47,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return ",," + serialize(tree.children) + ",,"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/emphasis/superscript.js b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js index df6d0217c..96e3c7769 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/superscript.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/superscript.js @@ -17,10 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "superscript"; @@ -50,5 +47,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "^^" + serialize(tree.children) + "^^"; }; - -})(); \ 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 2bf57f1bd..8395a0038 100644 --- a/core/modules/parsers/wikiparser/rules/emphasis/underscore.js +++ b/core/modules/parsers/wikiparser/rules/emphasis/underscore.js @@ -17,10 +17,7 @@ This wikiparser can be modified using the rules eg: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "underscore"; @@ -50,5 +47,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "__" + serialize(tree.children) + "__"; }; - -})(); \ 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 d5d0405f2..ff1030b2c 100644 --- a/core/modules/parsers/wikiparser/rules/entity.js +++ b/core/modules/parsers/wikiparser/rules/entity.js @@ -10,10 +10,7 @@ Wiki text inline rule for HTML entities. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "entity"; @@ -40,5 +37,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return tree.entity; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/extlink.js b/core/modules/parsers/wikiparser/rules/extlink.js index 88dfd3e0a..c284dac4b 100644 --- a/core/modules/parsers/wikiparser/rules/extlink.js +++ b/core/modules/parsers/wikiparser/rules/extlink.js @@ -14,10 +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 */ "use strict"; exports.name = "extlink"; @@ -60,5 +57,3 @@ exports.serialize = function(tree,serialize) { return tree.attributes.href.value; } }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js b/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js index f3a342ee0..802371ec0 100644 --- a/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js +++ b/core/modules/parsers/wikiparser/rules/filteredtranscludeblock.js @@ -14,10 +14,7 @@ Wiki text rule for block-level filtered transclusion. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "filteredtranscludeblock"; @@ -85,5 +82,3 @@ exports.serialize = function(tree,serialize) { if(tree.attributes.itemClass) serialized += "." + tree.attributes.itemClass.value.split(" ").join("."); return serialized + "\n\n"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js b/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js index efc596bba..8db822049 100644 --- a/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js +++ b/core/modules/parsers/wikiparser/rules/filteredtranscludeinline.js @@ -14,10 +14,7 @@ Wiki text rule for inline filtered transclusion. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "filteredtranscludeinline"; @@ -75,5 +72,3 @@ exports.serialize = function(tree,serialize) { var result = filteredtranscludeblock.serialize(tree,serialize); return result.trimEnd(); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/fnprocdef.js b/core/modules/parsers/wikiparser/rules/fnprocdef.js index 8343e0cca..953f1687f 100644 --- a/core/modules/parsers/wikiparser/rules/fnprocdef.js +++ b/core/modules/parsers/wikiparser/rules/fnprocdef.js @@ -20,10 +20,7 @@ definition text ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "fnprocdef"; @@ -107,6 +104,3 @@ exports.serialize = function(tree,serialize) { // Construct the serialized string, concat the children because pragma rule wrap everything below it as children return "\\" + type + " " + name + "(" + params + ")\n" + definition + "\n\\end\n\n" + serialize(tree.children) + "\n"; }; - -})(); - \ 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 ae290ef29..ab53a4a89 100644 --- a/core/modules/parsers/wikiparser/rules/hardlinebreaks.js +++ b/core/modules/parsers/wikiparser/rules/hardlinebreaks.js @@ -17,10 +17,7 @@ Not ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "hardlinebreaks"; @@ -69,5 +66,3 @@ exports.serialize = function(tree,serialize) { } return text + serialize(tree.children); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/heading.js b/core/modules/parsers/wikiparser/rules/heading.js index 3c762fd83..32571ea96 100644 --- a/core/modules/parsers/wikiparser/rules/heading.js +++ b/core/modules/parsers/wikiparser/rules/heading.js @@ -6,10 +6,7 @@ module-type: wikirule Wiki text block rule for headings \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "heading"; @@ -53,5 +50,3 @@ exports.serialize = function(tree,serialize) { var headingText = serialize(tree.children); return Array(headingLevel + 1).join("!") + (classes ? "." + classes : "") + " " + headingText + "\n\n"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/horizrule.js b/core/modules/parsers/wikiparser/rules/horizrule.js index 386a0aaef..01657e854 100644 --- a/core/modules/parsers/wikiparser/rules/horizrule.js +++ b/core/modules/parsers/wikiparser/rules/horizrule.js @@ -10,10 +10,7 @@ Wiki text block rule for rules. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "horizrule"; @@ -34,5 +31,3 @@ exports.parse = function() { exports.serialize = function(tree,serialize) { return "---\n\n"; } - -})(); diff --git a/core/modules/parsers/wikiparser/rules/html.js b/core/modules/parsers/wikiparser/rules/html.js index 5c128529e..7529340e5 100644 --- a/core/modules/parsers/wikiparser/rules/html.js +++ b/core/modules/parsers/wikiparser/rules/html.js @@ -17,10 +17,7 @@ This is a widget invocation }}} \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "html"; @@ -215,5 +212,3 @@ exports.serialize = function(tree,serialize) { } return result; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/image.js b/core/modules/parsers/wikiparser/rules/image.js index 7b612a9c7..2c6218fbd 100644 --- a/core/modules/parsers/wikiparser/rules/image.js +++ b/core/modules/parsers/wikiparser/rules/image.js @@ -17,10 +17,7 @@ Wiki text inline rule for embedding images. For example: Generates the `<$image>` widget. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "image"; @@ -138,5 +135,3 @@ exports.serialize = function(tree,serialize) { var source = tree.attributes.source.value; return "[img" + width + height + padSpace + "[" + tooltip + source + "]]"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/import.js b/core/modules/parsers/wikiparser/rules/import.js index 3cfcad5d7..c80cb7e77 100644 --- a/core/modules/parsers/wikiparser/rules/import.js +++ b/core/modules/parsers/wikiparser/rules/import.js @@ -10,10 +10,7 @@ Wiki pragma rule for importing variable definitions ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "import"; @@ -56,5 +53,3 @@ exports.serialize = function(tree,serialize) { // Sibling below the pragma become children, so we append the serialized children to the end.. return "\\import " + filter + "\n" + serialize(tree.children); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/list.js b/core/modules/parsers/wikiparser/rules/list.js index d0a5e2f65..f84d5c54f 100644 --- a/core/modules/parsers/wikiparser/rules/list.js +++ b/core/modules/parsers/wikiparser/rules/list.js @@ -40,10 +40,7 @@ A CSS class can be applied to a list item as follows: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "list"; @@ -218,5 +215,3 @@ exports.serialize = function (tree,serialize) { // Begin serialization from the root node, with an empty string as the initial marker prefix return serializeList(tree, "") + "\n\n"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/macrocallblock.js b/core/modules/parsers/wikiparser/rules/macrocallblock.js index a684a2d28..c23558413 100644 --- a/core/modules/parsers/wikiparser/rules/macrocallblock.js +++ b/core/modules/parsers/wikiparser/rules/macrocallblock.js @@ -10,10 +10,7 @@ Wiki rule for block macro calls ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "macrocallblock"; @@ -73,5 +70,3 @@ exports.serialize = function (node) { result += ">>\n\n"; return result; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/macrocallinline.js b/core/modules/parsers/wikiparser/rules/macrocallinline.js index ff91b7a91..de700ce2b 100644 --- a/core/modules/parsers/wikiparser/rules/macrocallinline.js +++ b/core/modules/parsers/wikiparser/rules/macrocallinline.js @@ -10,10 +10,7 @@ Wiki rule for macro calls ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "macrocallinline"; @@ -54,5 +51,3 @@ exports.serialize = function (tree,serialize) { var result = macrocallblock.serialize(tree,serialize); return result.trimEnd(); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/macrodef.js b/core/modules/parsers/wikiparser/rules/macrodef.js index 5c20a0302..b01872bdd 100644 --- a/core/modules/parsers/wikiparser/rules/macrodef.js +++ b/core/modules/parsers/wikiparser/rules/macrodef.js @@ -12,10 +12,7 @@ definition text, including $param$ markers ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "macrodef"; @@ -102,5 +99,3 @@ exports.serialize = function(tree,serialize) { } return "\\define " + name + "(" + params + ")\n" + definition + "\n\\end\n\n" + serialize(tree.children); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/parameters.js b/core/modules/parsers/wikiparser/rules/parameters.js index a214164ca..90c0c8537 100644 --- a/core/modules/parsers/wikiparser/rules/parameters.js +++ b/core/modules/parsers/wikiparser/rules/parameters.js @@ -11,10 +11,7 @@ definition text ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "parameters"; @@ -63,5 +60,3 @@ exports.serialize = function(tree,serialize) { }).join(","); return "\\parameters(" + params + ")\n\n" + serialize(tree.children); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/parsermode.js b/core/modules/parsers/wikiparser/rules/parsermode.js index b57bdae4d..4692a15e0 100644 --- a/core/modules/parsers/wikiparser/rules/parsermode.js +++ b/core/modules/parsers/wikiparser/rules/parsermode.js @@ -11,10 +11,7 @@ Wiki pragma rule for parser mode specifications ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "parsermode"; @@ -75,5 +72,3 @@ exports.serialize = function(tree,serialize) { var mode = tree.parseAsInline ? "inline" : "block"; return "\\parsermode " + mode + "\n\n" + serialize(tree.children); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/prettyextlink.js b/core/modules/parsers/wikiparser/rules/prettyextlink.js index 088a981b8..2491c59a6 100644 --- a/core/modules/parsers/wikiparser/rules/prettyextlink.js +++ b/core/modules/parsers/wikiparser/rules/prettyextlink.js @@ -11,10 +11,7 @@ Wiki text inline rule for external links. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "prettyextlink"; @@ -122,5 +119,3 @@ exports.serialize = function(tree,serialize) { var url = tree.attributes.href.value; return "[ext[" + (tooltip !== url ? tooltip + "|" : "") + url + "]]"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/prettylink.js b/core/modules/parsers/wikiparser/rules/prettylink.js index 7a516a801..49f3875e6 100644 --- a/core/modules/parsers/wikiparser/rules/prettylink.js +++ b/core/modules/parsers/wikiparser/rules/prettylink.js @@ -12,10 +12,7 @@ Wiki text inline rule for pretty links. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "prettylink"; @@ -72,5 +69,3 @@ exports.serialize = function(tree,serialize) { var target = tree.attributes.to ? tree.attributes.to.value : tree.attributes.href.value; return "[[" + text + (text !== target ? "|" + target : "") + "]]"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/quoteblock.js b/core/modules/parsers/wikiparser/rules/quoteblock.js index 05a42f517..cb510af88 100644 --- a/core/modules/parsers/wikiparser/rules/quoteblock.js +++ b/core/modules/parsers/wikiparser/rules/quoteblock.js @@ -6,10 +6,7 @@ module-type: wikirule Wiki text rule for quote blocks. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "quoteblock"; @@ -87,5 +84,3 @@ exports.serialize = function (tree,serialize) { } return result.join("\n") + "\n\n"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/rules.js b/core/modules/parsers/wikiparser/rules/rules.js index 8aca74e16..ba99bc405 100644 --- a/core/modules/parsers/wikiparser/rules/rules.js +++ b/core/modules/parsers/wikiparser/rules/rules.js @@ -11,10 +11,7 @@ Wiki pragma rule for rules specifications ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "rules"; @@ -84,5 +81,3 @@ exports.serialize = function (tree,serialize) { } return result.join("\n"); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/styleblock.js b/core/modules/parsers/wikiparser/rules/styleblock.js index 091ce7f53..e8b72a22e 100644 --- a/core/modules/parsers/wikiparser/rules/styleblock.js +++ b/core/modules/parsers/wikiparser/rules/styleblock.js @@ -26,10 +26,7 @@ This is a paragraph ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "styleblock"; @@ -121,5 +118,3 @@ exports.serialize = function(tree,serialize) { result += "\n@@\n\n" return result; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/styleinline.js b/core/modules/parsers/wikiparser/rules/styleinline.js index 77857b006..ef32e1140 100644 --- a/core/modules/parsers/wikiparser/rules/styleinline.js +++ b/core/modules/parsers/wikiparser/rules/styleinline.js @@ -13,10 +13,7 @@ Wiki text inline rule for assigning styles and classes to inline runs. For examp \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "styleinline"; @@ -69,5 +66,3 @@ exports.serialize = function(tree,serialize) { result += " " + serialize(tree.children) + "@@"; return result; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/syslink.js b/core/modules/parsers/wikiparser/rules/syslink.js index a9a04cc7b..ded606ab7 100644 --- a/core/modules/parsers/wikiparser/rules/syslink.js +++ b/core/modules/parsers/wikiparser/rules/syslink.js @@ -6,10 +6,7 @@ module-type: wikirule Wiki text inline rule for system tiddler links. Can be suppressed preceding them with `~`. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "syslink"; @@ -58,5 +55,3 @@ exports.serialize = function(tree,serialize) { serialized += tree.attributes ? tree.attributes.to.value : tree.text; return serialized; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/table.js b/core/modules/parsers/wikiparser/rules/table.js index 992c05b4e..9d3e6c77c 100644 --- a/core/modules/parsers/wikiparser/rules/table.js +++ b/core/modules/parsers/wikiparser/rules/table.js @@ -6,10 +6,7 @@ module-type: wikirule Wiki text block rule for tables. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "table"; @@ -217,5 +214,3 @@ exports.serialize = function(tree,serialize) { // Return the completed block return serialized + "\n"; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/transcludeblock.js b/core/modules/parsers/wikiparser/rules/transcludeblock.js index 8aac3ee65..03da4113e 100644 --- a/core/modules/parsers/wikiparser/rules/transcludeblock.js +++ b/core/modules/parsers/wikiparser/rules/transcludeblock.js @@ -11,10 +11,7 @@ Wiki text rule for block-level transclusion. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "transcludeblock"; @@ -133,5 +130,3 @@ exports.serialize = function(tree,serialize) { result += "}}\n\n"; return result; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/transcludeinline.js b/core/modules/parsers/wikiparser/rules/transcludeinline.js index 17271bcd5..281021643 100644 --- a/core/modules/parsers/wikiparser/rules/transcludeinline.js +++ b/core/modules/parsers/wikiparser/rules/transcludeinline.js @@ -11,10 +11,7 @@ Wiki text rule for inline-level transclusion. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "transcludeinline"; @@ -89,5 +86,3 @@ exports.serialize = function(tree,serialize) { var result = transcludeblock.serialize(tree,serialize); return result.trimEnd(); }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/typedblock.js b/core/modules/parsers/wikiparser/rules/typedblock.js index c0adb1c0c..6f1552934 100644 --- a/core/modules/parsers/wikiparser/rules/typedblock.js +++ b/core/modules/parsers/wikiparser/rules/typedblock.js @@ -22,10 +22,7 @@ $$$ ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var widget = require("$:/core/modules/widgets/widget.js"); @@ -104,5 +101,3 @@ exports.serialize = function (tree,serialize) { } return ""; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/whitespace.js b/core/modules/parsers/wikiparser/rules/whitespace.js index 5fd9d4b83..3be34ee88 100644 --- a/core/modules/parsers/wikiparser/rules/whitespace.js +++ b/core/modules/parsers/wikiparser/rules/whitespace.js @@ -11,10 +11,7 @@ Wiki pragma rule for whitespace specifications ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "whitespace"; @@ -68,5 +65,3 @@ exports.parse = function() { // No parse tree nodes to return return []; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/wikilink.js b/core/modules/parsers/wikiparser/rules/wikilink.js index 8628a4f6c..2c176763c 100644 --- a/core/modules/parsers/wikiparser/rules/wikilink.js +++ b/core/modules/parsers/wikiparser/rules/wikilink.js @@ -14,10 +14,7 @@ AnotherLink Precede a camel case word with `~` to prevent it from being recognised as a link. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "wikilink"; @@ -72,5 +69,3 @@ exports.serialize = function(tree,serialize) { serialized += tree.attributes ? tree.attributes.to.value : tree.text; return serialized; }; - -})(); diff --git a/core/modules/parsers/wikiparser/rules/wikilinkprefix.js b/core/modules/parsers/wikiparser/rules/wikilinkprefix.js index a51544e58..30a216e01 100644 --- a/core/modules/parsers/wikiparser/rules/wikilinkprefix.js +++ b/core/modules/parsers/wikiparser/rules/wikilinkprefix.js @@ -10,10 +10,7 @@ Wiki text inline rule for suppressed wiki links. For example: ``` \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.name = "wikilinkprefix"; @@ -42,5 +39,3 @@ exports.serialize = function(tree,serialize) { serialized += tree.text; return serialized; }; - -})(); diff --git a/core/modules/parsers/wikiparser/wikiparser.js b/core/modules/parsers/wikiparser/wikiparser.js index 68977c9d8..ab4bab11e 100644 --- a/core/modules/parsers/wikiparser/wikiparser.js +++ b/core/modules/parsers/wikiparser/wikiparser.js @@ -19,10 +19,7 @@ Attributes are stored as hashmaps of the following objects: {type: "macro", macro: } - indirect through a macro invocation \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -495,5 +492,3 @@ 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..a9d6c748f 100644 --- a/core/modules/parsers/wikiparser/wikirulebase.js +++ b/core/modules/parsers/wikiparser/wikirulebase.js @@ -6,10 +6,7 @@ module-type: global Base class for wiki parser rules \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -35,5 +32,3 @@ WikiRuleBase.prototype.findNextMatch = function(startPos) { }; exports.WikiRuleBase = WikiRuleBase; - -})(); diff --git a/core/modules/pluginswitcher.js b/core/modules/pluginswitcher.js index 2915de95a..d89d261d7 100644 --- a/core/modules/pluginswitcher.js +++ b/core/modules/pluginswitcher.js @@ -6,10 +6,7 @@ module-type: global Manages switching plugins for themes and languages. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -75,5 +72,3 @@ PluginSwitcher.prototype.switchPlugins = function() { }; exports.PluginSwitcher = PluginSwitcher; - -})(); diff --git a/core/modules/saver-handler.js b/core/modules/saver-handler.js index 23056bcc2..7f4e834a0 100644 --- a/core/modules/saver-handler.js +++ b/core/modules/saver-handler.js @@ -6,10 +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 */ "use strict"; /* @@ -46,8 +43,10 @@ function SaverHandler(options) { // Filter the changes so that we only count changes to tiddlers that we care about var filteredChanges = self.filterFn.call(self.wiki,function(iterator) { $tw.utils.each(changes,function(change,title) { - var tiddler = self.wiki.getTiddler(title); - iterator(tiddler,title); + if(change.normal) { + var tiddler = self.wiki.getTiddler(title); + iterator(tiddler,title); + } }); }); // Adjust the number of changes @@ -183,7 +182,7 @@ SaverHandler.prototype.saveWiki = function(options) { // Call the highest priority saver that supports this method for(var t=this.savers.length-1; t>=0; t--) { var saver = this.savers[t]; - if(saver.info.capabilities.indexOf(method) !== -1 && saver.save(text,method,callback,{variables: {filename: variables.filename}})) { + if(saver.info.capabilities.indexOf(method) !== -1 && saver.save(text,method,callback,{variables: {filename: variables.filename, type: variables.type}})) { this.logger.log("Saving wiki with method",method,"through saver",saver.info.name); return true; } @@ -212,5 +211,3 @@ SaverHandler.prototype.updateDirtyStatus = function() { }; exports.SaverHandler = SaverHandler; - -})(); diff --git a/core/modules/savers/andtidwiki.js b/core/modules/savers/andtidwiki.js index 9ab405e37..5ce4dbe0e 100644 --- a/core/modules/savers/andtidwiki.js +++ b/core/modules/savers/andtidwiki.js @@ -6,10 +6,8 @@ module-type: saver Handles saving changes via the AndTidWiki Android app \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false, netscape: false, Components: false */ + "use strict"; var AndTidWiki = function(wiki) { @@ -86,5 +84,3 @@ Create an instance of this saver exports.create = function(wiki) { return new AndTidWiki(wiki); }; - -})(); diff --git a/core/modules/savers/custom.js b/core/modules/savers/custom.js index 836691204..dc5f91703 100644 --- a/core/modules/savers/custom.js +++ b/core/modules/savers/custom.js @@ -9,10 +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 */ "use strict"; var findSaver = function(window) { @@ -57,4 +54,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..9d046d24a 100644 --- a/core/modules/savers/download.js +++ b/core/modules/savers/download.js @@ -6,10 +6,7 @@ module-type: saver Handles saving changes via HTML5's download APIs \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -22,6 +19,7 @@ DownloadSaver.prototype.save = function(text,method,callback,options) { options = options || {}; // Get the current filename var filename = options.variables.filename; + var type = options.variables.type; if(!filename) { var p = document.location.pathname.lastIndexOf("/"); if(p !== -1) { @@ -32,13 +30,16 @@ DownloadSaver.prototype.save = function(text,method,callback,options) { if(!filename) { filename = "tiddlywiki.html"; } + if(!type) { + type = "text/html"; + } // Set up the link var link = document.createElement("a"); if(Blob !== undefined) { - var blob = new Blob([text], {type: "text/html"}); + var blob = new Blob([text], {type: type}); link.setAttribute("href", URL.createObjectURL(blob)); } else { - link.setAttribute("href","data:text/html," + encodeURIComponent(text)); + link.setAttribute("href","data:" + type + "," + encodeURIComponent(text)); } link.setAttribute("download",filename); document.body.appendChild(link); @@ -80,5 +81,3 @@ Create an instance of this saver exports.create = function(wiki) { return new DownloadSaver(wiki); }; - -})(); diff --git a/core/modules/savers/fsosaver.js b/core/modules/savers/fsosaver.js index 37224e42a..85b56e956 100644 --- a/core/modules/savers/fsosaver.js +++ b/core/modules/savers/fsosaver.js @@ -9,10 +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 */ "use strict"; /* @@ -70,5 +67,3 @@ Create an instance of this saver exports.create = function(wiki) { return new FSOSaver(wiki); }; - -})(); diff --git a/core/modules/savers/gitea.js b/core/modules/savers/gitea.js index 826719ee9..ef23214c1 100644 --- a/core/modules/savers/gitea.js +++ b/core/modules/savers/gitea.js @@ -6,10 +6,7 @@ module-type: saver Saves wiki by pushing a commit to the gitea \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -132,5 +129,3 @@ Create an instance of this saver exports.create = function(wiki) { return new GiteaSaver(wiki); }; - -})(); diff --git a/core/modules/savers/github.js b/core/modules/savers/github.js index c0a34f2d6..f0dca48fc 100644 --- a/core/modules/savers/github.js +++ b/core/modules/savers/github.js @@ -6,10 +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 */ "use strict"; /* @@ -115,5 +112,3 @@ Create an instance of this saver exports.create = function(wiki) { return new GitHubSaver(wiki); }; - -})(); diff --git a/core/modules/savers/gitlab.js b/core/modules/savers/gitlab.js index 243aab8a5..43305b578 100644 --- a/core/modules/savers/gitlab.js +++ b/core/modules/savers/gitlab.js @@ -6,10 +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 */ "use strict"; /* @@ -113,5 +110,3 @@ Create an instance of this saver exports.create = function(wiki) { return new GitLabSaver(wiki); }; - -})(); diff --git a/core/modules/savers/manualdownload.js b/core/modules/savers/manualdownload.js index af9bcd743..bb3c3c142 100644 --- a/core/modules/savers/manualdownload.js +++ b/core/modules/savers/manualdownload.js @@ -6,10 +6,7 @@ module-type: saver Handles saving changes via HTML5's download APIs \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Title of the tiddler containing the download message @@ -52,5 +49,3 @@ Create an instance of this saver exports.create = function(wiki) { return new ManualDownloadSaver(wiki); }; - -})(); diff --git a/core/modules/savers/msdownload.js b/core/modules/savers/msdownload.js index 6cb55c334..233fd3571 100644 --- a/core/modules/savers/msdownload.js +++ b/core/modules/savers/msdownload.js @@ -6,10 +6,7 @@ module-type: saver Handles saving changes via window.navigator.msSaveBlob() \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -55,5 +52,3 @@ Create an instance of this saver exports.create = function(wiki) { return new MsDownloadSaver(wiki); }; - -})(); diff --git a/core/modules/savers/put.js b/core/modules/savers/put.js index a1ebef4bb..b77cfdfc8 100644 --- a/core/modules/savers/put.js +++ b/core/modules/savers/put.js @@ -9,10 +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 */ "use strict"; /* @@ -20,7 +17,7 @@ Retrieve ETag if available */ var retrieveETag = function(self) { var headers = { - Accept: "*/*;charset=UTF-8" + Accept: "*/*" }; $tw.utils.httpRequest({ url: self.uri(), @@ -55,7 +52,7 @@ var PutSaver = function(wiki) { callback: function(err,data,xhr) { // Check DAV header http://www.webdav.org/specs/rfc2518.html#rfc.section.9.1 if(!err) { - self.serverAcceptsPuts = xhr.status === 200 && !!xhr.getResponseHeader("dav"); + self.serverAcceptsPuts = xhr.status >= 200 && xhr.status < 300 && !!xhr.getResponseHeader("dav"); } } }); @@ -136,5 +133,3 @@ Create an instance of this saver exports.create = function(wiki) { return new PutSaver(wiki); }; - -})(); diff --git a/core/modules/savers/tiddlyfox.js b/core/modules/savers/tiddlyfox.js index 81b373d42..2356e287e 100644 --- a/core/modules/savers/tiddlyfox.js +++ b/core/modules/savers/tiddlyfox.js @@ -6,10 +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 */ "use strict"; var TiddlyFoxSaver = function(wiki) { @@ -82,5 +79,3 @@ Create an instance of this saver exports.create = function(wiki) { return new TiddlyFoxSaver(wiki); }; - -})(); diff --git a/core/modules/savers/tiddlyie.js b/core/modules/savers/tiddlyie.js index d6d49db45..3b380592d 100644 --- a/core/modules/savers/tiddlyie.js +++ b/core/modules/savers/tiddlyie.js @@ -6,10 +6,7 @@ module-type: saver Handles saving changes via Internet Explorer BHO extenion (TiddlyIE) \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -67,5 +64,3 @@ Create an instance of this saver exports.create = function(wiki) { return new TiddlyIESaver(wiki); }; - -})(); diff --git a/core/modules/savers/twedit.js b/core/modules/savers/twedit.js index ec125bf94..8aae0c54e 100644 --- a/core/modules/savers/twedit.js +++ b/core/modules/savers/twedit.js @@ -6,10 +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 */ "use strict"; var TWEditSaver = function(wiki) { @@ -87,5 +84,3 @@ exports.create = function(wiki) { if($tw.browser) { window.version = {title: "TiddlyWiki"}; } - -})(); diff --git a/core/modules/savers/upload.js b/core/modules/savers/upload.js index ade545000..7f17d77bd 100644 --- a/core/modules/savers/upload.js +++ b/core/modules/savers/upload.js @@ -8,10 +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 */ "use strict"; /* @@ -107,5 +104,3 @@ Create an instance of this saver 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..e67e701f5 100644 --- a/core/modules/server/authenticators/basic.js +++ b/core/modules/server/authenticators/basic.js @@ -6,10 +6,7 @@ module-type: authenticator Authenticator for WWW basic authentication \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; if($tw.node) { @@ -90,5 +87,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 cc1d6bdaf..bbcf9a1d4 100644 --- a/core/modules/server/authenticators/header.js +++ b/core/modules/server/authenticators/header.js @@ -6,10 +6,7 @@ module-type: authenticator Authenticator for trusted header authentication \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; function HeaderAuthenticator(server) { @@ -46,4 +43,3 @@ HeaderAuthenticator.prototype.authenticateRequest = function(request,response,st exports.AuthenticatorClass = HeaderAuthenticator; -})(); diff --git a/core/modules/server/routes/delete-tiddler.js b/core/modules/server/routes/delete-tiddler.js index 85b552599..33cb40d55 100644 --- a/core/modules/server/routes/delete-tiddler.js +++ b/core/modules/server/routes/delete-tiddler.js @@ -6,10 +6,6 @@ module-type: route DELETE /recipes/default/tiddlers/:title \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "DELETE"; @@ -24,5 +20,3 @@ exports.handler = function(request,response,state) { }); response.end(); }; - -}()); diff --git a/core/modules/server/routes/get-favicon.js b/core/modules/server/routes/get-favicon.js index 39a391127..8b757b2f7 100644 --- a/core/modules/server/routes/get-favicon.js +++ b/core/modules/server/routes/get-favicon.js @@ -6,10 +6,6 @@ module-type: route GET /favicon.ico \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "GET"; @@ -20,5 +16,3 @@ exports.handler = function(request,response,state) { var buffer = state.wiki.getTiddlerText("$:/favicon.ico",""); state.sendResponse(200,{"Content-Type": "image/x-icon"},buffer,"base64"); }; - -}()); diff --git a/core/modules/server/routes/get-file.js b/core/modules/server/routes/get-file.js index 45aa51d34..39681de4c 100644 --- a/core/modules/server/routes/get-file.js +++ b/core/modules/server/routes/get-file.js @@ -6,10 +6,6 @@ module-type: route GET /files/:filepath \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "GET"; @@ -44,5 +40,3 @@ exports.handler = function(request,response,state) { state.sendResponse(404,{"Content-Type": "text/plain"},"File '" + suppliedFilename + "' not found"); } }; - -}()); diff --git a/core/modules/server/routes/get-index.js b/core/modules/server/routes/get-index.js index f2d01f793..7ba52faf6 100644 --- a/core/modules/server/routes/get-index.js +++ b/core/modules/server/routes/get-index.js @@ -6,10 +6,6 @@ module-type: route GET / \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "GET"; @@ -23,5 +19,3 @@ exports.handler = function(request,response,state) { }; state.sendResponse(200,responseHeaders,text); }; - -}()); diff --git a/core/modules/server/routes/get-login-basic.js b/core/modules/server/routes/get-login-basic.js index d573a0b5d..bca3bd18d 100644 --- a/core/modules/server/routes/get-login-basic.js +++ b/core/modules/server/routes/get-login-basic.js @@ -6,10 +6,6 @@ module-type: route GET /login-basic -- force a Basic Authentication challenge \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "GET"; @@ -25,12 +21,10 @@ exports.handler = function(request,response,state) { response.end(); } else { // Redirect to the root wiki if login worked - var location = ($tw.syncadaptor && $tw.syncadaptor.host)? $tw.syncadaptor.host: "/"; + var location = ($tw.syncadaptor && $tw.syncadaptor.host)? $tw.syncadaptor.host: `${state.pathPrefix}/`; response.writeHead(302,{ Location: location }); response.end(); } }; - -}()); diff --git a/core/modules/server/routes/get-status.js b/core/modules/server/routes/get-status.js index ac35ee874..d93c64037 100644 --- a/core/modules/server/routes/get-status.js +++ b/core/modules/server/routes/get-status.js @@ -6,10 +6,6 @@ module-type: route GET /status \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "GET"; @@ -29,5 +25,3 @@ exports.handler = function(request,response,state) { }); state.sendResponse(200,{"Content-Type": "application/json"},text,"utf8"); }; - -}()); diff --git a/core/modules/server/routes/get-tiddler-html.js b/core/modules/server/routes/get-tiddler-html.js index ab1570e30..a891ea6e7 100644 --- a/core/modules/server/routes/get-tiddler-html.js +++ b/core/modules/server/routes/get-tiddler-html.js @@ -6,10 +6,6 @@ module-type: route GET /:title \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "GET"; @@ -40,5 +36,3 @@ exports.handler = function(request,response,state) { response.end(); } }; - -}()); diff --git a/core/modules/server/routes/get-tiddler.js b/core/modules/server/routes/get-tiddler.js index ae6cfeadc..58ecb8a43 100644 --- a/core/modules/server/routes/get-tiddler.js +++ b/core/modules/server/routes/get-tiddler.js @@ -6,10 +6,6 @@ module-type: route GET /recipes/default/tiddlers/:title \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "GET"; @@ -42,5 +38,3 @@ exports.handler = function(request,response,state) { response.end(); } }; - -}()); diff --git a/core/modules/server/routes/get-tiddlers-json.js b/core/modules/server/routes/get-tiddlers-json.js index 6f3f07f6a..89f91032e 100644 --- a/core/modules/server/routes/get-tiddlers-json.js +++ b/core/modules/server/routes/get-tiddlers-json.js @@ -6,10 +6,6 @@ module-type: route GET /recipes/default/tiddlers.json?filter= \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var DEFAULT_FILTER = "[all[tiddlers]!is[system]sort[title]]"; @@ -46,5 +42,3 @@ exports.handler = function(request,response,state) { var text = JSON.stringify(tiddlers); state.sendResponse(200,{"Content-Type": "application/json"},text,"utf8"); }; - -}()); diff --git a/core/modules/server/routes/put-tiddler.js b/core/modules/server/routes/put-tiddler.js index ff1bd2737..74327bd50 100644 --- a/core/modules/server/routes/put-tiddler.js +++ b/core/modules/server/routes/put-tiddler.js @@ -6,10 +6,6 @@ module-type: route PUT /recipes/default/tiddlers/:title \*/ -(function() { - -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.method = "PUT"; @@ -48,5 +44,3 @@ exports.handler = function(request,response,state) { }); response.end(); }; - -}()); diff --git a/core/modules/server/server.js b/core/modules/server/server.js index d3c98f8fc..2118e9b50 100644 --- a/core/modules/server/server.js +++ b/core/modules/server/server.js @@ -6,10 +6,7 @@ module-type: library Serve tiddlers over http \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; if($tw.node) { @@ -374,5 +371,3 @@ Server.prototype.listen = function(port,host,prefix) { }; exports.Server = Server; - -})(); diff --git a/core/modules/startup/browser-messaging.js b/core/modules/startup/browser-messaging.js index 733041e45..27ddb19d5 100644 --- a/core/modules/startup/browser-messaging.js +++ b/core/modules/startup/browser-messaging.js @@ -6,10 +6,7 @@ module-type: startup Browser message handling \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -181,5 +178,3 @@ exports.startup = function() { } },false); }; - -})(); diff --git a/core/modules/startup/commands.js b/core/modules/startup/commands.js index bd8b4afb3..3e4e40f45 100644 --- a/core/modules/startup/commands.js +++ b/core/modules/startup/commands.js @@ -6,10 +6,7 @@ module-type: startup Command processing \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -33,5 +30,3 @@ exports.startup = function(callback) { ); commander.execute(); }; - -})(); diff --git a/core/modules/startup/favicon.js b/core/modules/startup/favicon.js index 55e7891e2..d1a7c5677 100644 --- a/core/modules/startup/favicon.js +++ b/core/modules/startup/favicon.js @@ -6,10 +6,7 @@ module-type: startup Favicon handling \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -39,5 +36,3 @@ function setFavicon() { faviconLink.setAttribute("href",$tw.utils.makeDataUri(tiddler.fields.text,tiddler.fields.type,tiddler.fields._canonical_uri)); } } - -})(); diff --git a/core/modules/startup/info.js b/core/modules/startup/info.js index ed2305930..a5767ed34 100644 --- a/core/modules/startup/info.js +++ b/core/modules/startup/info.js @@ -6,10 +6,7 @@ module-type: startup Initialise $:/info tiddlers via $:/temp/info-plugin pseudo-plugin \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -54,5 +51,3 @@ exports.startup = function() { $tw.wiki.registerPluginTiddlers("info",[TITLE_INFO_PLUGIN]); $tw.wiki.unpackPluginTiddlers(); }; - -})(); diff --git a/core/modules/startup/load-modules.js b/core/modules/startup/load-modules.js index 1dc71f7ac..cf0a8232d 100644 --- a/core/modules/startup/load-modules.js +++ b/core/modules/startup/load-modules.js @@ -6,10 +6,7 @@ module-type: startup Load core modules \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -36,5 +33,3 @@ exports.startup = function() { $tw.wiki.initParsers(); $tw.Commander.initCommands(); }; - -})(); diff --git a/core/modules/startup/password.js b/core/modules/startup/password.js index 5e8bd5352..5ea36ee19 100644 --- a/core/modules/startup/password.js +++ b/core/modules/startup/password.js @@ -6,10 +6,7 @@ module-type: startup Password handling \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -49,5 +46,3 @@ exports.startup = function() { } }); }; - -})(); diff --git a/core/modules/startup/plugins.js b/core/modules/startup/plugins.js index fc8ba9589..3ceda8669 100644 --- a/core/modules/startup/plugins.js +++ b/core/modules/startup/plugins.js @@ -6,10 +6,7 @@ module-type: startup Startup logic concerned with managing plugins \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -75,11 +72,10 @@ exports.startup = function() { $tw.wiki.unpackPluginTiddlers(); // Queue change events for the changed shadow tiddlers $tw.utils.each(Object.keys(changedShadowTiddlers),function(title) { - $tw.wiki.enqueueTiddlerEvent(title,changedShadowTiddlers[title]); + $tw.wiki.enqueueTiddlerEvent(title,changedShadowTiddlers[title], true); }); } } }); }; -})(); diff --git a/core/modules/startup/render.js b/core/modules/startup/render.js index 7206a51d0..13cbb0356 100644 --- a/core/modules/startup/render.js +++ b/core/modules/startup/render.js @@ -6,10 +6,7 @@ module-type: startup Title, stylesheet and page rendering \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -120,5 +117,3 @@ exports.startup = function() { // Run any post-render startup actions $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction/PostRender"); }; - -})(); diff --git a/core/modules/startup/rootwidget.js b/core/modules/startup/rootwidget.js index d81e07aee..b30e03e7b 100644 --- a/core/modules/startup/rootwidget.js +++ b/core/modules/startup/rootwidget.js @@ -6,10 +6,7 @@ module-type: startup Setup the root widget and the core root widget handlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -52,7 +49,9 @@ exports.startup = function() { basicAuthUsername: params["basic-auth-username"], basicAuthUsernameFromStore: params["basic-auth-username-from-store"], basicAuthPassword: params["basic-auth-password"], - basicAuthPasswordFromStore: params["basic-auth-password-from-store"] + basicAuthPasswordFromStore: params["basic-auth-password-from-store"], + bearerAuthToken: params["bearer-auth-token"], + bearerAuthTokenFromStore: params["bearer-auth-token-from-store"] }); }); $tw.rootWidget.addEventListener("tm-http-cancel-all-requests",function(event) { @@ -75,8 +74,9 @@ exports.startup = function() { $tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) { $tw.utils.copyToClipboard(event.param,{ successNotification: event.paramObject && event.paramObject.successNotification, - failureNotification: event.paramObject && event.paramObject.failureNotification - }); + failureNotification: event.paramObject && event.paramObject.failureNotification, + plainText: event.paramObject && event.paramObject.plainText + },event.paramObject && event.paramObject.type); }); // Install the tm-focus-selector message $tw.rootWidget.addEventListener("tm-focus-selector",function(event) { @@ -125,5 +125,3 @@ exports.startup = function() { }); } }; - -})(); diff --git a/core/modules/startup/startup.js b/core/modules/startup/startup.js index e09f6393f..6f78c71b5 100755 --- a/core/modules/startup/startup.js +++ b/core/modules/startup/startup.js @@ -6,10 +6,7 @@ module-type: startup Miscellaneous startup logic for both the client and server. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -67,14 +64,6 @@ exports.startup = function() { wiki: $tw.wiki, document: $tw.browser ? document : $tw.fakeDocument }); - // Execute any startup actions - $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction"); - if($tw.browser) { - $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction/Browser"); - } - if($tw.node) { - $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction/Node"); - } // Kick off the language manager and switcher $tw.language = new $tw.Language(); $tw.languageSwitcher = new $tw.PluginSwitcher({ @@ -88,8 +77,10 @@ exports.startup = function() { if($tw.browser) { var pluginTiddler = $tw.wiki.getTiddler(plugins[0]); if(pluginTiddler) { + document.documentElement.setAttribute("lang",pluginTiddler.getFieldString("name")); document.documentElement.setAttribute("dir",pluginTiddler.getFieldString("text-direction") || "auto"); } else { + document.documentElement.setAttribute("lang","en-GB"); document.documentElement.removeAttribute("dir"); } } @@ -115,6 +106,14 @@ exports.startup = function() { handlerMethod: "handleKeydownEvent" }]); } + // Execute any startup actions + $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction"); + if($tw.browser) { + $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction/Browser"); + } + if($tw.node) { + $tw.rootWidget.invokeActionsByTag("$:/tags/StartupAction/Node"); + } // Clear outstanding tiddler store change events to avoid an unnecessary refresh cycle at startup $tw.wiki.clearTiddlerEventQueue(); // Find a working syncadaptor @@ -146,5 +145,3 @@ exports.startup = function() { $tw.anim = new $tw.utils.Animator(); } }; - -})(); diff --git a/core/modules/startup/story.js b/core/modules/startup/story.js index c58c759c3..a0c878024 100644 --- a/core/modules/startup/story.js +++ b/core/modules/startup/story.js @@ -6,10 +6,7 @@ module-type: startup Load core modules \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -234,5 +231,3 @@ function updateLocationHash(options) { } } } - -})(); diff --git a/core/modules/startup/windows.js b/core/modules/startup/windows.js index 34f45d7a5..8506a9866 100644 --- a/core/modules/startup/windows.js +++ b/core/modules/startup/windows.js @@ -6,10 +6,7 @@ module-type: startup Setup root widget handlers for the messages concerned with opening external browser windows \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; // Export name and synchronous status @@ -110,5 +107,3 @@ exports.startup = function() { // Close open windows when unloading main window $tw.addUnloadTask(closeAllWindows); }; - -})(); diff --git a/core/modules/story.js b/core/modules/story.js index 16ff5a74a..4e624bb26 100644 --- a/core/modules/story.js +++ b/core/modules/story.js @@ -6,10 +6,7 @@ module-type: global Lightweight object for managing interactions with the story and history lists. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -133,6 +130,3 @@ Story.prototype.storyNewTiddler = function(targetTitle) { }; exports.Story = Story; - - -})(); diff --git a/core/modules/storyviews/classic.js b/core/modules/storyviews/classic.js index a85e458c5..c1f1c0e0f 100644 --- a/core/modules/storyviews/classic.js +++ b/core/modules/storyviews/classic.js @@ -6,10 +6,7 @@ module-type: storyview Views the story as a linear sequence \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var easing = "cubic-bezier(0.645, 0.045, 0.355, 1)"; // From http://easings.net/#easeInOutCubic @@ -117,5 +114,3 @@ ClassicStoryView.prototype.remove = function(widget) { }; exports.classic = ClassicStoryView; - -})(); diff --git a/core/modules/storyviews/pop.js b/core/modules/storyviews/pop.js index e2634e3d5..cbf649b18 100644 --- a/core/modules/storyviews/pop.js +++ b/core/modules/storyviews/pop.js @@ -6,10 +6,7 @@ module-type: storyview Animates list insertions and removals \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var PopStoryView = function(listWidget) { @@ -99,5 +96,3 @@ PopStoryView.prototype.remove = function(widget) { }; exports.pop = PopStoryView; - -})(); diff --git a/core/modules/storyviews/zoomin.js b/core/modules/storyviews/zoomin.js index d02f705e7..e5c5b88a8 100644 --- a/core/modules/storyviews/zoomin.js +++ b/core/modules/storyviews/zoomin.js @@ -6,10 +6,7 @@ module-type: storyview Zooms between individual tiddlers \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var easing = "cubic-bezier(0.645, 0.045, 0.355, 1)"; // From http://easings.net/#easeInOutCubic @@ -226,5 +223,3 @@ ZoominListView.prototype.logTextNodeRoot = function(node) { }; exports.zoomin = ZoominListView; - -})(); diff --git a/core/modules/syncer.js b/core/modules/syncer.js index f7627e1ac..f565d0b9f 100644 --- a/core/modules/syncer.js +++ b/core/modules/syncer.js @@ -6,10 +6,7 @@ module-type: global The syncer tracks changes to the store and synchronises them to a remote data store represented as a "sync adaptor" \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -703,5 +700,3 @@ SyncFromServerTask.prototype.run = function(callback) { }; exports.Syncer = Syncer; - -})(); diff --git a/core/modules/tiddler.js b/core/modules/tiddler.js index b0b6e6942..d28f90945 100644 --- a/core/modules/tiddler.js +++ b/core/modules/tiddler.js @@ -6,10 +6,7 @@ module-type: tiddlermethod Extension methods for the $tw.Tiddler object (constructor and methods required at boot time are in boot/boot.js) \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; exports.hasTag = function(tag) { @@ -40,10 +37,10 @@ exports.getFieldString = function(field,defaultValue) { }; /* -Get the value of a field as a list +Get the value of a field as an array / list */ exports.getFieldList = function(field) { - var value = this.fields[field]; + var value = this.getFieldString(field,null); // Check for a missing field if(value === undefined || value === null) { return []; @@ -99,5 +96,3 @@ exports.getFieldDay = function(field) { this.cache.day[field] = day; return day; }; - -})(); diff --git a/core/modules/upgraders/plugins.js b/core/modules/upgraders/plugins.js index 83487aabf..8f35d5090 100644 --- a/core/modules/upgraders/plugins.js +++ b/core/modules/upgraders/plugins.js @@ -6,10 +6,7 @@ module-type: upgrader Upgrader module that checks that plugins are newer than any already installed version \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var UPGRADE_LIBRARY_TITLE = "$:/UpgradeLibrary"; @@ -75,5 +72,3 @@ exports.upgrade = function(wiki,titles,tiddlers) { }); return messages; }; - -})(); diff --git a/core/modules/upgraders/system.js b/core/modules/upgraders/system.js index a653a75b1..ae3f76b3c 100644 --- a/core/modules/upgraders/system.js +++ b/core/modules/upgraders/system.js @@ -6,10 +6,7 @@ module-type: upgrader Upgrader module that suppresses certain system tiddlers that shouldn't be imported \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var DONT_IMPORT_LIST = ["$:/Import", "$:/build"], @@ -47,5 +44,3 @@ exports.upgrade = function(wiki,titles,tiddlers) { } return messages; }; - -})(); diff --git a/core/modules/upgraders/themetweaks.js b/core/modules/upgraders/themetweaks.js index e411b285a..616f9008d 100644 --- a/core/modules/upgraders/themetweaks.js +++ b/core/modules/upgraders/themetweaks.js @@ -15,10 +15,7 @@ Now, each tweak is stored in its own separate tiddler. This upgrader copies any values from the old format to the new. The old data tiddlers are not deleted in case they have been used to store additional indexes. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var MAPPINGS = { @@ -61,5 +58,3 @@ exports.upgrade = function(wiki,titles,tiddlers) { }); return messages; }; - -})(); diff --git a/core/modules/utils/crypto.js b/core/modules/utils/crypto.js index 8ad0923a4..dc239fbcc 100644 --- a/core/modules/utils/crypto.js +++ b/core/modules/utils/crypto.js @@ -6,10 +6,7 @@ module-type: utils Utility functions related to crypto. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -90,5 +87,3 @@ exports.decryptStoreAreaInteractive = function(encryptedStoreArea,callback,optio }); } }; - -})(); diff --git a/core/modules/utils/csv.js b/core/modules/utils/csv.js index 68b647127..177f0c0ac 100644 --- a/core/modules/utils/csv.js +++ b/core/modules/utils/csv.js @@ -6,10 +6,7 @@ module-type: utils A barebones CSV parser \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var QUOTE = '"'; @@ -120,5 +117,3 @@ exports.parseCsvStringWithHeader = function(text,options) { } return csv; } - -})(); diff --git a/core/modules/utils/dom/animations/slide.js b/core/modules/utils/dom/animations/slide.js index face94960..2057c4460 100644 --- a/core/modules/utils/dom/animations/slide.js +++ b/core/modules/utils/dom/animations/slide.js @@ -6,10 +6,7 @@ module-type: animation A simple slide animation that varies the height of the element \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; function slideOpen(domNode,options) { @@ -111,5 +108,3 @@ exports.slide = { open: slideOpen, close: slideClosed }; - -})(); diff --git a/core/modules/utils/dom/animator.js b/core/modules/utils/dom/animator.js index f994d9b58..013900975 100644 --- a/core/modules/utils/dom/animator.js +++ b/core/modules/utils/dom/animator.js @@ -6,10 +6,7 @@ module-type: utils Orchestrates animations and transitions \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; function Animator() { @@ -39,5 +36,3 @@ Animator.prototype.perform = function(type,domNode,options) { }; exports.Animator = Animator; - -})(); diff --git a/core/modules/utils/dom/browser.js b/core/modules/utils/dom/browser.js index fcc292bed..7501d4154 100644 --- a/core/modules/utils/dom/browser.js +++ b/core/modules/utils/dom/browser.js @@ -6,10 +6,7 @@ module-type: utils Browser feature detection \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -160,5 +157,3 @@ exports.getFullScreenApis = function() { return result; } }; - -})(); diff --git a/core/modules/utils/dom/dom.js b/core/modules/utils/dom/dom.js index 0b71e128c..a5b14ff78 100644 --- a/core/modules/utils/dom/dom.js +++ b/core/modules/utils/dom/dom.js @@ -6,10 +6,7 @@ module-type: utils Various static DOM-related utility functions. \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var Popup = require("$:/core/modules/utils/dom/popup.js"); @@ -268,9 +265,10 @@ exports.copyStyles = function(srcDomNode,dstDomNode) { /* Copy plain text to the clipboard on browsers that support it */ -exports.copyToClipboard = function(text,options) { - options = options || {}; - text = text || ""; +exports.copyToClipboard = function(text,options,type) { + var text = text || ""; + var options = options || {}; + var type = type || "text/plain"; var textArea = document.createElement("textarea"); textArea.style.position = "fixed"; textArea.style.top = 0; @@ -283,10 +281,16 @@ exports.copyToClipboard = function(text,options) { textArea.style.outline = "none"; textArea.style.boxShadow = "none"; textArea.style.background = "transparent"; - textArea.value = text; document.body.appendChild(textArea); textArea.select(); textArea.setSelectionRange(0,text.length); + textArea.addEventListener("copy",function(event) { + event.preventDefault(); + if (options.plainText) { + event.clipboardData.setData("text/plain",options.plainText); + } + event.clipboardData.setData(type,text); + }); var succeeded = false; try { succeeded = document.execCommand("copy"); @@ -388,5 +392,3 @@ exports.querySelectorAllSafe = function(selector,baseElement) { console.log("Invalid selector: ",selector); } }; - -})(); diff --git a/core/modules/utils/dom/dragndrop.js b/core/modules/utils/dom/dragndrop.js index c7c32cbaf..25a13537c 100644 --- a/core/modules/utils/dom/dragndrop.js +++ b/core/modules/utils/dom/dragndrop.js @@ -6,10 +6,7 @@ module-type: utils Browser data transfer utilities, used with the clipboard and drag and drop \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -275,5 +272,3 @@ exports.dragEventContainsFiles = function(event) { }; exports.dragEventContainsType = dragEventContainsType; - -})(); diff --git a/core/modules/utils/dom/http.js b/core/modules/utils/dom/http.js index 65bdfd1e5..75b82cd77 100644 --- a/core/modules/utils/dom/http.js +++ b/core/modules/utils/dom/http.js @@ -6,10 +6,7 @@ module-type: utils HTTP support \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -104,6 +101,8 @@ basicAuthUsername: plain username for basic authentication basicAuthUsernameFromStore: name of password store entry containing username basicAuthPassword: plain password for basic authentication basicAuthPasswordFromStore: name of password store entry containing password +bearerAuthToken: plain text token for bearer authentication +bearerAuthTokenFromStore: name of password store entry contain bear authorization token */ function HttpClientRequest(options) { var self = this; @@ -135,8 +134,11 @@ function HttpClientRequest(options) { }); this.basicAuthUsername = options.basicAuthUsername || (options.basicAuthUsernameFromStore && $tw.utils.getPassword(options.basicAuthUsernameFromStore)) || ""; this.basicAuthPassword = options.basicAuthPassword || (options.basicAuthPasswordFromStore && $tw.utils.getPassword(options.basicAuthPasswordFromStore)) || ""; + this.bearerAuthToken = options.bearerAuthToken || (options.bearerAuthTokenFromStore && $tw.utils.getPassword(options.bearerAuthTokenFromStore)) || ""; if(this.basicAuthUsername && this.basicAuthPassword) { this.requestHeaders.Authorization = "Basic " + $tw.utils.base64Encode(this.basicAuthUsername + ":" + this.basicAuthPassword); + } else if(this.bearerAuthToken) { + this.requestHeaders.Authorization = "Bearer " + this.bearerAuthToken; } } @@ -211,11 +213,11 @@ HttpClientRequest.prototype.send = function(callback) { if(lengthComputable) { setBinding(self.bindProgress,"" + Math.floor((loaded/total) * 100)) } - self.wiki.invokeActionString(self.progressActions,undefined,{ + self.wiki.invokeActionString(self.progressActions,undefined,$tw.utils.extend({},self.variables,{ lengthComputable: lengthComputable ? "yes" : "no", loaded: loaded, total: total - },{parentWidget: $tw.rootWidget}); + }),{parentWidget: $tw.rootWidget}); } }); } @@ -348,5 +350,3 @@ exports.setQueryStringParameter = function(url,paramName,paramValue) { return url; } }; - -})(); diff --git a/core/modules/utils/dom/keyboard.js b/core/modules/utils/dom/keyboard.js index 0ba1af5a0..926753a65 100644 --- a/core/modules/utils/dom/keyboard.js +++ b/core/modules/utils/dom/keyboard.js @@ -6,10 +6,7 @@ module-type: utils Keyboard utilities; now deprecated. Instead, use $tw.keyboardManager \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; ["parseKeyDescriptor","checkKeyDescriptor"].forEach(function(method) { @@ -21,5 +18,3 @@ Keyboard utilities; now deprecated. Instead, use $tw.keyboardManager } }; }); - -})(); diff --git a/core/modules/utils/dom/modal.js b/core/modules/utils/dom/modal.js index 1e620aa9a..cd827c3be 100644 --- a/core/modules/utils/dom/modal.js +++ b/core/modules/utils/dom/modal.js @@ -6,10 +6,7 @@ module-type: utils Modal message mechanism \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var widget = require("$:/core/modules/widgets/widget.js"); @@ -253,5 +250,3 @@ Modal.prototype.adjustPageClass = function() { }; exports.Modal = Modal; - -})(); diff --git a/core/modules/utils/dom/notifier.js b/core/modules/utils/dom/notifier.js index bf93d451c..8743b83be 100644 --- a/core/modules/utils/dom/notifier.js +++ b/core/modules/utils/dom/notifier.js @@ -6,10 +6,7 @@ module-type: utils Notifier mechanism \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var widget = require("$:/core/modules/widgets/widget.js"); @@ -88,5 +85,3 @@ Notifier.prototype.display = function(title,options) { }; exports.Notifier = Notifier; - -})(); diff --git a/core/modules/utils/dom/popup.js b/core/modules/utils/dom/popup.js index 017e7da8f..6ed7c4bca 100644 --- a/core/modules/utils/dom/popup.js +++ b/core/modules/utils/dom/popup.js @@ -6,10 +6,7 @@ module-type: utils Module that creates a $tw.utils.Popup object prototype that manages popups in the browser \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -243,5 +240,3 @@ exports.buildCoordinates = function(prefix,position) { } exports.Popup = Popup; - -})(); diff --git a/core/modules/utils/dom/scroller.js b/core/modules/utils/dom/scroller.js index 905bb2750..84be12c50 100644 --- a/core/modules/utils/dom/scroller.js +++ b/core/modules/utils/dom/scroller.js @@ -6,10 +6,7 @@ module-type: utils Module that creates a $tw.utils.Scroller object prototype that manages scrolling in the browser \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; /* @@ -135,5 +132,3 @@ PageScroller.prototype.scrollSelectorIntoView = function(baseElement,selector,ca }; exports.PageScroller = PageScroller; - -})(); diff --git a/core/modules/utils/edition-info.js b/core/modules/utils/edition-info.js index f8a5cab06..2c525e3cc 100644 --- a/core/modules/utils/edition-info.js +++ b/core/modules/utils/edition-info.js @@ -6,10 +6,7 @@ module-type: utils-node Information about the available editions \*/ -(function(){ -/*jslint node: true, browser: true */ -/*global $tw: false */ "use strict"; var fs = require("fs"), @@ -29,10 +26,14 @@ exports.getEditionInfo = function() { for(var entryIndex=0; entryIndex