-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
228 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import type { IScriptAddon } from '../../../scriptAddon'; | ||
|
||
const addon: IScriptAddon<void> = { | ||
shouldUpdate: (_state, _changedTiddlers, changedAttributes) => { | ||
return $tw.utils.count(changedAttributes) > 0; | ||
}, | ||
onUpdate: (myChart, _state, addonAttributes) => { | ||
// 参数解析 | ||
const resolution = Math.max( | ||
1, | ||
Math.min(1e5, parseInt(addonAttributes.res, 10) || 200), | ||
); | ||
let minX = Number(addonAttributes.min) || -1; | ||
let maxX = Number(addonAttributes.max) || 1; | ||
if (!Number.isFinite(minX)) { | ||
minX = -1; | ||
} | ||
if (!Number.isFinite(maxX)) { | ||
maxX = 1; | ||
} | ||
if (minX > maxX) { | ||
[maxX, minX] = [minX, maxX]; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func | ||
const func = new Function( | ||
'x', | ||
`return ${addonAttributes.func};` || 'return x;', | ||
); | ||
|
||
// 采样 | ||
const points = []; | ||
const step = (maxX - minX) / Math.min(resolution, 1e5); | ||
let minY = Infinity; | ||
let maxY = -Infinity; | ||
for (let x = minX; x <= maxX; x += step) { | ||
const y = func(x); | ||
points.push([x, y]); | ||
if (!Number.isNaN(y) && Number.isFinite(y)) { | ||
minY = Math.min(minY, y); | ||
maxY = Math.max(maxY, y); | ||
} | ||
} | ||
if (!Number.isFinite(minY)) { | ||
minY = 0; | ||
} | ||
if (!Number.isFinite(maxY)) { | ||
maxY = 0; | ||
} | ||
minY -= Math.max(1e-8, maxY - minY) * 5e-3; | ||
maxY += Math.max(1e-8, maxY - minY) * 5e-3; | ||
minX -= Math.max(1e-8, maxX - minX) * 5e-3; | ||
maxX += Math.max(1e-8, maxX - minX) * 5e-3; | ||
myChart.setOption({ | ||
animation: false, | ||
grid: { | ||
top: 40, | ||
left: 50, | ||
right: 40, | ||
bottom: 50, | ||
}, | ||
tooltip: { trigger: 'axis' }, | ||
xAxis: { | ||
name: 'x', | ||
min: minX, | ||
max: maxX, | ||
minorTick: { show: true }, | ||
minorSplitLine: { show: true }, | ||
}, | ||
yAxis: { | ||
name: addonAttributes.yaxis || 'f(x)', | ||
min: minY, | ||
max: maxY, | ||
minorTick: { show: true }, | ||
minorSplitLine: { show: true }, | ||
}, | ||
dataZoom: [ | ||
{ | ||
show: true, | ||
type: 'inside', | ||
filterMode: 'none', | ||
xAxisIndex: [0], | ||
startValue: -20, | ||
endValue: 20, | ||
}, | ||
{ | ||
show: true, | ||
type: 'inside', | ||
filterMode: 'none', | ||
yAxisIndex: [0], | ||
startValue: -20, | ||
endValue: 20, | ||
}, | ||
], | ||
series: [ | ||
{ | ||
type: 'line', | ||
showSymbol: false, | ||
clip: true, | ||
data: points, | ||
}, | ||
], | ||
} as any); | ||
}, | ||
}; | ||
|
||
export default addon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
title: $:/plugins/Gk0Wk/echarts/addons/Function.ts | ||
type: application/javascript | ||
module-type: echarts-component | ||
caption: Function | ||
echarts.author: Gk0Wk(Sttot) | ||
echarts.readme: {{$:/plugins/Gk0Wk/echarts/addons/Function-readme}} | ||
Modern.TiddlyDev#IncludeSource: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
title: $:/plugins/Gk0Wk/echarts/addons/Function-readme | ||
|
||
```html | ||
<$echarts $tiddler="$:/plugins/Gk0Wk/echarts/addons/Function.js" func="x**2" min="-3" max="3" /> | ||
``` | ||
|
||
<$echarts $tiddler="$:/plugins/Gk0Wk/echarts/addons/Function.js" func="x**2" min="-3" max="3" /> | ||
|
||
Attributes: | ||
|
||
* func: function expression, default: x | ||
* min: min value, default: -1 | ||
* max: max value, default: 1 | ||
* res: resolution, default: 200 | ||
* yaxis: name of y axis, default: f(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
wiki/tiddlers/$__config_PageControlButtons_Visibility_$__core_ui_Buttons_advanced-search.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
created: 20231007043121227 | ||
modified: 20231007043121227 | ||
modified: 20231023051834946 | ||
title: $:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/advanced-search | ||
type: text/vnd.tiddlywiki | ||
|
||
show | ||
hide |
4 changes: 2 additions & 2 deletions
4
wiki/tiddlers/$__config_PageControlButtons_Visibility_$__core_ui_Buttons_control-panel.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
created: 20181203004822817 | ||
creator: | ||
modified: 20231007043118915 | ||
modified: 20231023051832669 | ||
modifier: | ||
title: $:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/control-panel | ||
type: text/vnd.tiddlywiki | ||
|
||
show | ||
hide |
6 changes: 6 additions & 0 deletions
6
..._config_PageControlButtons_Visibility_$__plugins_kookma_commander_buttons_pagecontrol.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
created: 20231023051836140 | ||
modified: 20231023051836140 | ||
title: $:/config/PageControlButtons/Visibility/$:/plugins/kookma/commander/buttons/pagecontrol | ||
type: text/vnd.tiddlywiki | ||
|
||
hide |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
author: Gk0Wk | ||
description: Repos for CPL | ||
description: Essential and powerful plugin manager and library | ||
list: readme | ||
name: CPL Repo | ||
plugin-type: plugin | ||
title: $:/plugins/Gk0Wk/CPL-Repo | ||
type: application/json | ||
version: 2022.12.28 | ||
version: 2023.10.20 |
6 changes: 6 additions & 0 deletions
6
wiki/tiddlers/$__plugins_Gk0Wk_CPL-Repo_config_popup-readme-at-startup.tid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
created: 20231023053148278 | ||
modified: 20231023053148278 | ||
title: $:/plugins/Gk0Wk/CPL-Repo/config/popup-readme-at-startup | ||
type: text/vnd.tiddlywiki | ||
|
||
1 |
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
wiki/tiddlers/$__plugins_Gk0Wk_TW5-CodeMirror-Enhanced.json.meta
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
{"tiddlers":{"$:/plugins/Gk0Wk/focused-tiddler/config":{"title":"$:/plugins/Gk0Wk/focused-tiddler/config","type":"text/vnd.tiddlywiki","text":"<$list filter=\"[[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]]\" variable=\"lang\">\n<$list filter=\"[<lang>search[zh]]\">\n\n; 顶部偏移\n: <$edit-text tiddler=\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\" tag=\"input\" default=\"71\" /> (px)\n: 条目顶部与窗口页面顶部的距离小于偏移量时,该条目会被聚焦。(单位:px)\n\n</$list>\n\n<$list filter=\"[<lang>!search[zh]]\">\n\n; Top Offset\n: <$edit-text tiddler=\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\" tag=\"input\" default=\"71\" /> (px)\n: The entry is focused when the distance between the top of the entry and the top of the window page is less than the offset. (Unit: px)\n\n</$list>\n</$list>\n"},"$:/plugins/Gk0Wk/focused-tiddler/readme":{"title":"$:/plugins/Gk0Wk/focused-tiddler/readme","type":"text/vnd.tiddlywiki","text":"<$list filter=\"[[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]]\" variable=\"lang\">\n<$list filter=\"[<lang>search[zh]]\">\n\n! 聚焦条目\n\n检测你现在正在看的条目,并将其标题存在 `$:/temp/focussedTiddler`。\n\n判定方法:当打开新条目、滚动条目至一定位置(可配置)或者点击条目内容时,及判定为聚焦条目。\n\n> 本插件使用灵活而强大的 <$text text=\"TiddlyWiki\" /> 开发框架 [[Tiddly.ModernDev|https://github.com/tiddly-gittly/Modern.TiddlyDev]]\n\n</$list>\n\n<$list filter=\"[<lang>!search[zh]]\">\n\n! focused-tiddler\n\nDetecting the tiddler you are viewing, and save its title to `$:/temp/focussedTiddler`.\n\nJudgment method: When opening a new tiddler, scrolling the tiddler to a certain position (configurable) or clicking on the content of the tiddler, and judged to be a focused tiddler.\n\n> This plugin uses the flexible and powerful <$text text=\"TiddlyWiki\" /> development framework [[Tiddly.ModernDev|https://github.com/tiddly-gittly/Modern.TiddlyDev]]\n\n</$list>\n</$list>\n"},"$:/plugins/Gk0Wk/focused-tiddler/top-offset":{"title":"$:/plugins/Gk0Wk/focused-tiddler/top-offset","text":"71\n"},"'$:/plugins/Gk0Wk/focused-tiddler/top-offset/hook.js":{"title":"'$:/plugins/Gk0Wk/focused-tiddler/top-offset/hook.js","module-type":"startup","type":"application/javascript","Modern.TiddlyDev#Origin":"hook.ts","text":"\"use strict\";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var o in t)__defProp(e,o,{get:t[o],enumerable:!0})},__copyProps=(t,o,r,s)=>{if(o&&\"object\"==typeof o||\"function\"==typeof o)for(let e of __getOwnPropNames(o))__hasOwnProp.call(t,e)||e===r||__defProp(t,e,{get:()=>o[e],enumerable:!(s=__getOwnPropDesc(o,e))||s.enumerable});return t},__toCommonJS=e=>__copyProps(__defProp({},\"__esModule\",{value:!0}),e),hook_exports={},topOffset=(__export(hook_exports,{after:()=>after,name:()=>name,platforms:()=>platforms,startup:()=>startup,synchronous:()=>synchronous}),module.exports=__toCommonJS(hook_exports),71),updateTopOffset=()=>{topOffset=Number($tw.wiki.getTiddlerText(\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\",\"71\").trim()),Number.isSafeInteger(topOffset)||(topOffset=71)},check=()=>{var t=document.querySelectorAll(\".tc-story-river > .tc-tiddler-frame\");if(0===t.length)update(null);else{for(let e=t.length-1;0<=e;e--)if(!(100<t[e].getBoundingClientRect().top))return void update(t[e]);update(t[0])}},previousFocusedDom=null,update=e=>{var t;e!==previousFocusedDom&&(t=null!==e&&(null!=(t=e.getAttribute(\"data-tiddler-title\"))?t:null==(t=e.querySelector(\".tc-tiddler-title .tc-titlebar .tc-title\"))?void 0:t.textContent)||void 0,$tw.wiki.addTiddler({title:\"$:/temp/focussedTiddler\",text:t||\"\"}),previousFocusedDom&&$tw.utils.removeClass(previousFocusedDom,\"gk0wk-focused-tiddler\"),e&&$tw.utils.addClass(e,\"gk0wk-focused-tiddler\"),previousFocusedDom=e)},name=\"gk0wk-focused-tiddler\",platforms=[\"browser\"],after=[\"story\"],synchronous=!0,startup=()=>{updateTopOffset();let e;window.addEventListener(\"scroll\",()=>{void 0===e&&(e=setTimeout(()=>{e=void 0,check()},250))}),window.addEventListener(\"click\",({target:t})=>{var e,o;if(null!=(o=null==(e=document.querySelector(\".tc-story-river\"))?void 0:e.contains)&&o.call(e,t)){var r=document.querySelectorAll(\".tc-story-river > .tc-tiddler-frame\");for(let e=r.length-1;0<=e;e--)if(r[e].contains(t))return void update(r[e])}}),$tw.wiki.addEventListener(\"change\",e=>{e[\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\"]&&updateTopOffset(),(e[\"$:/HistoryList\"]||e[\"$:/StoryList\"])&&setTimeout(()=>check(),$tw.utils.getAnimationDuration()+100)})};"}}} | ||
[ | ||
{ | ||
"text": "{\"tiddlers\":{\"$:/plugins/Gk0Wk/focused-tiddler/config\":{\"title\":\"$:/plugins/Gk0Wk/focused-tiddler/config\",\"type\":\"text/vnd.tiddlywiki\",\"text\":\"<$list filter=\\\"[[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]]\\\" variable=\\\"lang\\\">\\n<$list filter=\\\"[<lang>search[zh]]\\\">\\n\\n; 顶部偏移\\n: <$edit-text tiddler=\\\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\\\" tag=\\\"input\\\" default=\\\"71\\\" /> (px)\\n: 条目顶部与窗口页面顶部的距离小于偏移量时,该条目会被聚焦。(单位:px)\\n\\n</$list>\\n\\n<$list filter=\\\"[<lang>!search[zh]]\\\">\\n\\n; Top Offset\\n: <$edit-text tiddler=\\\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\\\" tag=\\\"input\\\" default=\\\"71\\\" /> (px)\\n: The entry is focused when the distance between the top of the entry and the top of the window page is less than the offset. (Unit: px)\\n\\n</$list>\\n</$list>\\n\"},\"$:/plugins/Gk0Wk/focused-tiddler/readme\":{\"title\":\"$:/plugins/Gk0Wk/focused-tiddler/readme\",\"type\":\"text/vnd.tiddlywiki\",\"text\":\"<$list filter=\\\"[[$:/language]get[text]removeprefix[$:/languages/]else[en-GB]]\\\" variable=\\\"lang\\\">\\n<$list filter=\\\"[<lang>search[zh]]\\\">\\n\\n! 聚焦条目\\n\\n检测你现在正在看的条目,并将其标题存在 `$:/temp/focussedTiddler`。\\n\\n判定方法:当打开新条目、滚动条目至一定位置(可配置)或者点击条目内容时,及判定为聚焦条目。\\n\\n> 本插件使用灵活而强大的 <$text text=\\\"TiddlyWiki\\\" /> 开发框架 [[Tiddly.ModernDev|https://github.com/tiddly-gittly/Modern.TiddlyDev]]\\n\\n</$list>\\n\\n<$list filter=\\\"[<lang>!search[zh]]\\\">\\n\\n! focused-tiddler\\n\\nDetecting the tiddler you are viewing, and save its title to `$:/temp/focussedTiddler`.\\n\\nJudgment method: When opening a new tiddler, scrolling the tiddler to a certain position (configurable) or clicking on the content of the tiddler, and judged to be a focused tiddler.\\n\\n> This plugin uses the flexible and powerful <$text text=\\\"TiddlyWiki\\\" /> development framework [[Tiddly.ModernDev|https://github.com/tiddly-gittly/Modern.TiddlyDev]]\\n\\n</$list>\\n</$list>\\n\"},\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\":{\"title\":\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\",\"text\":\"71\\n\"},\"$:/plugins/Gk0Wk/focused-tiddler/top-offset/hook.js\":{\"title\":\"$:/plugins/Gk0Wk/focused-tiddler/top-offset/hook.js\",\"module-type\":\"startup\",\"type\":\"application/javascript\",\"Modern.TiddlyDev#Origin\":\"hook.ts\",\"text\":\"\\\"use strict\\\";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var o in t)__defProp(e,o,{get:t[o],enumerable:!0})},__copyProps=(t,o,r,s)=>{if(o&&\\\"object\\\"==typeof o||\\\"function\\\"==typeof o)for(let e of __getOwnPropNames(o))__hasOwnProp.call(t,e)||e===r||__defProp(t,e,{get:()=>o[e],enumerable:!(s=__getOwnPropDesc(o,e))||s.enumerable});return t},__toCommonJS=e=>__copyProps(__defProp({},\\\"__esModule\\\",{value:!0}),e),hook_exports={},topOffset=(__export(hook_exports,{after:()=>after,name:()=>name,platforms:()=>platforms,startup:()=>startup,synchronous:()=>synchronous}),module.exports=__toCommonJS(hook_exports),71),updateTopOffset=()=>{topOffset=Number($tw.wiki.getTiddlerText(\\\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\\\",\\\"71\\\").trim()),Number.isSafeInteger(topOffset)||(topOffset=71)},check=()=>{var t=document.querySelectorAll(\\\".tc-story-river .tc-tiddler-frame\\\");if(0===t.length)update(null);else{for(let e=t.length-1;0<=e;e--)if(!(100<t[e].getBoundingClientRect().top))return void update(t[e]);update(t[0])}},previousFocusedDom=null,update=e=>{var t;e!==previousFocusedDom&&(t=null!==e&&(null!=(t=e.getAttribute(\\\"data-tiddler-title\\\"))?t:null==(t=e.querySelector(\\\".tc-tiddler-title .tc-titlebar .tc-title\\\"))?void 0:t.textContent)||void 0,$tw.wiki.addTiddler({title:\\\"$:/temp/focussedTiddler\\\",text:t||\\\"\\\"}),previousFocusedDom&&$tw.utils.removeClass(previousFocusedDom,\\\"gk0wk-focused-tiddler\\\"),e&&$tw.utils.addClass(e,\\\"gk0wk-focused-tiddler\\\"),previousFocusedDom=e)},name=\\\"gk0wk-focused-tiddler\\\",platforms=[\\\"browser\\\"],after=[\\\"render\\\"],synchronous=!0,startup=()=>{updateTopOffset();let e;window.addEventListener(\\\"scroll\\\",()=>{void 0===e&&(e=setTimeout(()=>{e=void 0,check()},250))}),window.addEventListener(\\\"click\\\",({target:t})=>{var e,o;if(null!=(o=null==(e=document.querySelector(\\\".tc-story-river\\\"))?void 0:e.contains)&&o.call(e,t)){var r=document.querySelectorAll(\\\".tc-story-river .tc-tiddler-frame\\\");for(let e=r.length-1;0<=e;e--)if(r[e].contains(t))return void update(r[e])}}),$tw.wiki.addEventListener(\\\"change\\\",e=>{e[\\\"$:/plugins/Gk0Wk/focused-tiddler/top-offset\\\"]&&updateTopOffset(),(e[\\\"$:/HistoryList\\\"]||e[\\\"$:/StoryList\\\"])&&setTimeout(()=>check(),$tw.utils.getAnimationDuration()+100)})};\"}}}", | ||
"title": "$:/plugins/Gk0Wk/focused-tiddler", | ||
"type": "application/json", | ||
"author": "Gk0Wk", | ||
"dependents": "", | ||
"description": "Detecting the tiddler you are viewing", | ||
"list": "readme config", | ||
"name": "Focused Tiddler", | ||
"plugin-type": "plugin", | ||
"version": "0.0.3", | ||
"Modern.TiddlyDev#SHA256-Hashed": "a824f67b3fa431b7fa496185264a3cd2cdfcbce53df02f19bdad115283c88e3e" | ||
} | ||
] |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.