u2ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.htaccess +7 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/attr/behavior/README.md +25 -0
- package/attr/behavior/behavior.js +261 -0
- package/attr/behavior/manifest.json +43 -0
- package/attr/behavior/tests/minimal.html +19 -0
- package/attr/behavior/tests/test.html +98 -0
- package/attr/confirm/README.md +36 -0
- package/attr/confirm/confirm.js +90 -0
- package/attr/confirm/manifest.json +43 -0
- package/attr/confirm/tests/minimal.html +23 -0
- package/attr/confirm/tests/test.html +79 -0
- package/attr/draghandle/README.md +41 -0
- package/attr/draghandle/draghandle.js +42 -0
- package/attr/draghandle/tests/minimal.html +44 -0
- package/attr/focusgroup/README.md +49 -0
- package/attr/focusgroup/focusgroup.js +100 -0
- package/attr/focusgroup/manifest.json +38 -0
- package/attr/focusgroup/tests/minimal.html +27 -0
- package/attr/focusgroup/tests/test.html +154 -0
- package/attr/href/README.md +38 -0
- package/attr/href/href.js +42 -0
- package/attr/href/manifest.json +43 -0
- package/attr/href/tests/minimal.html +17 -0
- package/attr/href/tests/test.html +70 -0
- package/attr/intersect/README.md +42 -0
- package/attr/intersect/intersect.js +99 -0
- package/attr/intersect/manifest.json +57 -0
- package/attr/intersect/tests/minimal.html +30 -0
- package/attr/intersect/tests/test.html +64 -0
- package/attr/navigable/README.md +31 -0
- package/attr/navigable/TargetObserver.js +91 -0
- package/attr/navigable/U2TargetObserver.js +75 -0
- package/attr/navigable/manifest.json +42 -0
- package/attr/navigable/navigable.js +87 -0
- package/attr/navigable/tests/U1TargetObserver.html +56 -0
- package/attr/navigable/tests/minimal.html +17 -0
- package/attr/navigable/tests/targetObserver.html +106 -0
- package/attr/navigable/tests/test.html +84 -0
- package/attr/parallax/README.md +48 -0
- package/attr/parallax/parallax.js +119 -0
- package/attr/parallax/tests/minimal.html +25 -0
- package/attr/parallax/tests/performance.html +102 -0
- package/attr/parallax/tests/test.html +108 -0
- package/attr/skin/README.md +59 -0
- package/attr/skin/skin.css +51 -0
- package/attr/skin/tests/minimal.html +34 -0
- package/attr/skin/tests/test.html +96 -0
- package/class/badge/README.md +25 -0
- package/class/badge/badge.css +35 -0
- package/class/badge/tests/minimal.html +17 -0
- package/class/badge/tests/test.html +112 -0
- package/class/card1/README.md +45 -0
- package/class/card1/card1.css +30 -0
- package/class/card1/tests/minimal.html +33 -0
- package/class/card1/tests/test.html +78 -0
- package/class/flex/README.md +62 -0
- package/class/flex/flex.css +25 -0
- package/class/flex/tests/minimal.html +31 -0
- package/class/flex/tests/test.html +58 -0
- package/class/grid/README.md +52 -0
- package/class/grid/grid.css +40 -0
- package/class/grid/tests/minimal.html +34 -0
- package/class/grid/tests/test.html +78 -0
- package/class/input/README.md +49 -0
- package/class/input/input.css +33 -0
- package/class/input/tests/minimal.html +39 -0
- package/class/input/tests/test.html +29 -0
- package/class/reset/README.md +47 -0
- package/class/reset/reset.css +8 -0
- package/class/reset/tests/minimal.html +23 -0
- package/class/table/README.md +57 -0
- package/class/table/table.css +126 -0
- package/class/table/tests/minimal.html +40 -0
- package/class/table/tests/test.html +226 -0
- package/class/unstyle/README.md +32 -0
- package/class/unstyle/tests/minimal.html +22 -0
- package/class/unstyle/tests/test.html +32 -0
- package/class/unstyle/unstyle.css +12 -0
- package/class/width/README.md +48 -0
- package/class/width/tests/minimal.html +27 -0
- package/class/width/tests/test.html +101 -0
- package/class/width/width.css +22 -0
- package/css/base/README.md +25 -0
- package/css/base/base.css +127 -0
- package/css/base/beta.css +50 -0
- package/css/base/full.css +5 -0
- package/css/base/nomotion.css +9 -0
- package/css/base/print.css +36 -0
- package/css/base/tests/nomotion.html +89 -0
- package/css/base/tests/test.html +539 -0
- package/css/classes/README.md +17 -0
- package/css/classes/classes.css +78 -0
- package/css/classes/tests/test.html +63 -0
- package/css/classless/README.md +26 -0
- package/css/classless/aria.css +64 -0
- package/css/classless/classless.css +124 -0
- package/css/classless/full.css +11 -0
- package/css/classless/more.css +340 -0
- package/css/classless/simple.css +103 -0
- package/css/classless/snippeds/a/icons.css +12 -0
- package/css/classless/snippeds/experiments/conventions.css +41 -0
- package/css/classless/snippeds/hr/gradient.css +3 -0
- package/css/classless/snippeds/hr/section_sign.css +16 -0
- package/css/classless/snippeds/hr/tests.html +50 -0
- package/css/classless/tests/aria.html +101 -0
- package/css/classless/tests/foreign/classless-almond.css.html +445 -0
- package/css/classless/tests/foreign/classless-classless.css.html +831 -0
- package/css/classless/tests/foreign/classless-mvp.html +415 -0
- package/css/classless/tests/foreign/classless.sakura.html +224 -0
- package/css/classless/tests/foreign/stylestage.dev.html +304 -0
- package/css/classless/tests/foreign/test-homogenizer.html +433 -0
- package/css/classless/tests/foreign/test-html5-elements-tester.html +956 -0
- package/css/classless/tests/foreign/test-opinionated_css.html +148 -0
- package/css/classless/tests/list-bullet.html +110 -0
- package/css/classless/tests/more.html +246 -0
- package/css/classless/tests/oklch.experiments.html +280 -0
- package/css/classless/tests/test.html +106 -0
- package/css/classless/tests/variables.html +109 -0
- package/css/classless/variables.css +99 -0
- package/css/norm/README.md +37 -0
- package/css/norm/beta.css +40 -0
- package/css/norm/norm.css +98 -0
- package/css/norm/oldies.css +60 -0
- package/css/norm/tests/test.html +434 -0
- package/css/norm/tests/test.js +103 -0
- package/el/accordion/README.md +59 -0
- package/el/accordion/accordion.css +7 -0
- package/el/accordion/accordion.js +258 -0
- package/el/accordion/manifest.json +57 -0
- package/el/accordion/tests/minimal.html +44 -0
- package/el/accordion/tests/test.html +168 -0
- package/el/alert/README.md +67 -0
- package/el/alert/alert copy.js +224 -0
- package/el/alert/alert.css +73 -0
- package/el/alert/alert.js +187 -0
- package/el/alert/manifest.json +77 -0
- package/el/alert/tests/minimal.html +36 -0
- package/el/alert/tests/test.html +105 -0
- package/el/buttongroup/README.md +36 -0
- package/el/buttongroup/buttongroup.css +30 -0
- package/el/buttongroup/buttongroup.js +56 -0
- package/el/buttongroup/tests/minimal.html +31 -0
- package/el/buttongroup/tests/test.html +83 -0
- package/el/bytes/README.md +41 -0
- package/el/bytes/bytes.css +6 -0
- package/el/bytes/bytes.js +97 -0
- package/el/bytes/manifest.json +95 -0
- package/el/bytes/tests/minimal.html +19 -0
- package/el/bytes/tests/test.html +117 -0
- package/el/carousel/README.md +52 -0
- package/el/carousel/carousel.css +46 -0
- package/el/carousel/carousel.js +371 -0
- package/el/carousel/manifest.json +58 -0
- package/el/carousel/tests/experiments.html +77 -0
- package/el/carousel/tests/minimal.html +31 -0
- package/el/carousel/tests/nested.html +54 -0
- package/el/carousel/tests/test.html +136 -0
- package/el/carousel-nav/README.md +40 -0
- package/el/carousel-nav/carousel-nav.js +74 -0
- package/el/carousel-nav/tests/minimal.html +32 -0
- package/el/carousel-nav/tests/test.html +59 -0
- package/el/code/README.md +68 -0
- package/el/code/code.css +46 -0
- package/el/code/code.js +289 -0
- package/el/code/manifest.json +66 -0
- package/el/code/tests/minimal.html +35 -0
- package/el/code/tests/test.html +162 -0
- package/el/copy/README.md +35 -0
- package/el/copy/copy.css +3 -0
- package/el/copy/copy.js +118 -0
- package/el/copy/manifest.json +49 -0
- package/el/copy/tests/minimal.html +21 -0
- package/el/copy/tests/test.html +75 -0
- package/el/counter/README.md +47 -0
- package/el/counter/counter.css +8 -0
- package/el/counter/counter.js +95 -0
- package/el/counter/manifest.json +59 -0
- package/el/counter/tests/minimal.html +27 -0
- package/el/counter/tests/test.html +106 -0
- package/el/ico/README.md +162 -0
- package/el/ico/font/Font Awesome.css +22 -0
- package/el/ico/font/LigatureSymbols.css +7 -0
- package/el/ico/font/Material Icons.css +6 -0
- package/el/ico/font/RemixFilled.css +8 -0
- package/el/ico/font/RemixOutlined.css +8 -0
- package/el/ico/font/old/anicons.css +31 -0
- package/el/ico/font/old/devicons.css +210 -0
- package/el/ico/font/old/material.all.css +36 -0
- package/el/ico/font/old/remix.css +15 -0
- package/el/ico/font/old/utf8.css +54 -0
- package/el/ico/ico.css +111 -0
- package/el/ico/ico.js +189 -0
- package/el/ico/manifest.json +86 -0
- package/el/ico/tests/combinations.html +86 -0
- package/el/ico/tests/emojis.html +213 -0
- package/el/ico/tests/fonts.html +110 -0
- package/el/ico/tests/ico-directory.html +254 -0
- package/el/ico/tests/minimal.html +46 -0
- package/el/ico/tests/test.html +210 -0
- package/el/ico/tests/util-multi.svg +6 -0
- package/el/ico/tests/util.css +2 -0
- package/el/ico/tests/util.js +110 -0
- package/el/input/README.md +39 -0
- package/el/input/input.css +35 -0
- package/el/input/input.js +331 -0
- package/el/input/tests/formParticipation.html +113 -0
- package/el/input/tests/minimal.html +33 -0
- package/el/input/tests/test.html +258 -0
- package/el/masonry/README.md +51 -0
- package/el/masonry/manifest.json +60 -0
- package/el/masonry/masonry.css +27 -0
- package/el/masonry/masonry.js +92 -0
- package/el/masonry/tests/minimal.html +39 -0
- package/el/masonry/tests/test.html +42 -0
- package/el/number/README.md +47 -0
- package/el/number/manifest.json +121 -0
- package/el/number/number.css +6 -0
- package/el/number/number.js +67 -0
- package/el/number/tests/minimal.html +25 -0
- package/el/number/tests/test.html +138 -0
- package/el/out/README.md +32 -0
- package/el/out/manifest.json +38 -0
- package/el/out/out.css +2 -0
- package/el/out/out.js +59 -0
- package/el/out/tests/minimal.html +25 -0
- package/el/out/tests/test.html +37 -0
- package/el/parallax-bg/README.md +36 -0
- package/el/parallax-bg/parallax-bg.css +13 -0
- package/el/parallax-bg/parallax-bg.js +186 -0
- package/el/parallax-bg/tests/bg.jpg +0 -0
- package/el/parallax-bg/tests/bg1.jpg +0 -0
- package/el/parallax-bg/tests/bg2.jpg +0 -0
- package/el/parallax-bg/tests/demo.html +88 -0
- package/el/parallax-bg/tests/minimal.html +30 -0
- package/el/parallax-bg/tests/test.html +64 -0
- package/el/parallax-bg/tests/visible.html +90 -0
- package/el/qrcode/README.md +38 -0
- package/el/qrcode/manifest.json +43 -0
- package/el/qrcode/package.json +22 -0
- package/el/qrcode/qrcode.css +13 -0
- package/el/qrcode/qrcode.js +46 -0
- package/el/qrcode/tests/minimal.html +26 -0
- package/el/qrcode/tests/test.html +31 -0
- package/el/rating/README.md +45 -0
- package/el/rating/manifest.json +65 -0
- package/el/rating/rating.css +11 -0
- package/el/rating/rating.js +139 -0
- package/el/rating/tests/minimal.html +26 -0
- package/el/rating/tests/tests.html +77 -0
- package/el/rte/README.md +37 -0
- package/el/rte/rte.css +9 -0
- package/el/rte/rte.js +56 -0
- package/el/rte/tests/minimal.html +25 -0
- package/el/rte/tests/test.html +37 -0
- package/el/skeleton/README.md +30 -0
- package/el/skeleton/manifest.json +51 -0
- package/el/skeleton/skeleton.css +61 -0
- package/el/skeleton/skeleton.js +72 -0
- package/el/skeleton/tests/minimal.html +22 -0
- package/el/skeleton/tests/test.html +22 -0
- package/el/splitbutton/README.md +39 -0
- package/el/splitbutton/splitbutton.css +48 -0
- package/el/splitbutton/splitbutton.js +26 -0
- package/el/splitbutton/tests/minimal.html +30 -0
- package/el/splitbutton/tests/test.html +68 -0
- package/el/splitpanel/README.md +39 -0
- package/el/splitpanel/manifest.json +49 -0
- package/el/splitpanel/splitpanel.css +17 -0
- package/el/splitpanel/splitpanel.js +116 -0
- package/el/splitpanel/tests/minimal.html +31 -0
- package/el/splitpanel/tests/tests.html +121 -0
- package/el/table/README.md +68 -0
- package/el/table/manifest.json +43 -0
- package/el/table/table.css +59 -0
- package/el/table/table.js +194 -0
- package/el/table/tests/minimal.html +38 -0
- package/el/table/tests/test.html +108 -0
- package/el/tabs/README.md +50 -0
- package/el/tabs/manifest.json +59 -0
- package/el/tabs/tabs.css +23 -0
- package/el/tabs/tabs.js +210 -0
- package/el/tabs/tests/minimal.html +35 -0
- package/el/tabs/tests/test.html +180 -0
- package/el/textfit/README.md +34 -0
- package/el/textfit/manifest.json +45 -0
- package/el/textfit/tests/minimal.html +25 -0
- package/el/textfit/tests/test.html +26 -0
- package/el/textfit/textfit.css +6 -0
- package/el/textfit/textfit.js +80 -0
- package/el/time/README.md +72 -0
- package/el/time/manifest.json +118 -0
- package/el/time/tests/minimal.html +19 -0
- package/el/time/tests/test.html +160 -0
- package/el/time/time copy.js +141 -0
- package/el/time/time.js +168 -0
- package/el/time/time.old.uhtml.js +129 -0
- package/el/tooltip/README.md +48 -0
- package/el/tooltip/manifest.json +69 -0
- package/el/tooltip/tests/minimal.html +25 -0
- package/el/tooltip/tests/test.html +178 -0
- package/el/tooltip/tooltip.css +97 -0
- package/el/tooltip/tooltip.js +82 -0
- package/el/tree1/README.md +111 -0
- package/el/tree1/manifest.json +78 -0
- package/el/tree1/tests/animated.html +134 -0
- package/el/tree1/tests/custom.html +51 -0
- package/el/tree1/tests/minimal.html +44 -0
- package/el/tree1/tests/test.html +260 -0
- package/el/tree1/tree1.css +26 -0
- package/el/tree1/tree1.js +265 -0
- package/el/typewriter/README.md +62 -0
- package/el/typewriter/manifest.json +66 -0
- package/el/typewriter/tests/minimal.html +25 -0
- package/el/typewriter/tests/test.html +78 -0
- package/el/typewriter/typewriter.css +6 -0
- package/el/typewriter/typewriter.js +166 -0
- package/el/typewriter/typewriter.mp3 +0 -0
- package/js/Placer/Placer.js +156 -0
- package/js/Placer/README.md +62 -0
- package/js/Placer/tests/minimal.html +34 -0
- package/js/Placer/tests/test.html +49 -0
- package/js/PointerObserver/PointerObserver.js +130 -0
- package/js/PointerObserver/README.md +34 -0
- package/js/PointerObserver/tests/minimal.html +29 -0
- package/js/PointerObserver/tests/test.html +35 -0
- package/js/SelectorObserver/README.md +47 -0
- package/js/SelectorObserver/SelectorObserver.js +201 -0
- package/js/SelectorObserver/tests/minimal.html +21 -0
- package/js/SelectorObserver/tests/test.html +57 -0
- package/js/SelectorObserver/tests/tests.html +161 -0
- package/js/contextmenu/README.md +93 -0
- package/js/contextmenu/contextmenu.js +336 -0
- package/js/contextmenu/tests/minimal.html +44 -0
- package/js/contextmenu/tests/test.html +131 -0
- package/js/dialog/README.md +49 -0
- package/js/dialog/dialog.js +261 -0
- package/js/dialog/notification.mp3 +0 -0
- package/js/dialog/tests/minimal.html +29 -0
- package/js/dialog/tests/notification.mp3 +0 -0
- package/js/dialog/tests/test.html +135 -0
- package/js/rte/README.md +44 -0
- package/js/rte/old/NodeCleaner.js +315 -0
- package/js/rte/old/Rte/Rte.mjs +316 -0
- package/js/rte/old/Rte/Rte.ui.items.mjs +543 -0
- package/js/rte/old/Rte/Rte.ui.mjs +154 -0
- package/js/rte/old/Rte/crossbrowser.mjs +323 -0
- package/js/rte/old/Rte/font/tinymce.svg +98 -0
- package/js/rte/old/Rte/font/tinymce.woff +0 -0
- package/js/rte/old/Rte/helpers.mjs +159 -0
- package/js/rte/old/Rte/htmlparser.mjs +178 -0
- package/js/rte/old/Rte/index.mjs +5 -0
- package/js/rte/old/Rte/main.css +189 -0
- package/js/rte/old/old.rte.js +132 -0
- package/js/rte/old/range-selection.old.js +394 -0
- package/js/rte/rte.js +7 -0
- package/js/rte/src/behavior.js +228 -0
- package/js/rte/src/events.js +73 -0
- package/js/rte/src/fixes.js +251 -0
- package/js/rte/src/range.js +472 -0
- package/js/rte/src/rte.js +72 -0
- package/js/rte/src/ui/items/ai.js +167 -0
- package/js/rte/src/ui/items/code.js +93 -0
- package/js/rte/src/ui/items/undo.js +183 -0
- package/js/rte/src/ui.items.js +571 -0
- package/js/rte/src/ui.js +269 -0
- package/js/rte/src/util/htmlparser.js +178 -0
- package/js/rte/src/util/indentHtml.js +48 -0
- package/js/rte/tests/ai.html +81 -0
- package/js/rte/tests/behavior.html +88 -0
- package/js/rte/tests/events.html +69 -0
- package/js/rte/tests/fixes.html +95 -0
- package/js/rte/tests/minimal.html +34 -0
- package/js/rte/tests/notes.md +6 -0
- package/js/rte/tests/range.html +167 -0
- package/js/rte/tests/selection-explorer.html +222 -0
- package/js/rte/tests/test.html +92 -0
- package/js/shortcut/README.md +33 -0
- package/js/shortcut/shortcut.js +89 -0
- package/js/shortcut/tests/minimal.html +23 -0
- package/js/shortcut/tests/test.html +68 -0
- package/package.json +12 -0
- package/u2/README.md +4 -0
- package/u2/auto.js +161 -0
- package/u2/auto.ui.js +85 -0
- package/u2/experiments/Waiter/test.html +132 -0
- package/u2/experiments/getElementByIdPromise/test.html +76 -0
- package/u2/experiments/patchInputValue.html +124 -0
- package/u2/experiments/radiobutton/test.html +75 -0
- package/u2/experiments/tests/test.html +223 -0
- package/u2/experiments/u1-responsive/responsive.js +62 -0
- package/u2/experiments/u1-responsive/test.html +65 -0
- package/u2/experiments/u2Element.js +139 -0
- package/u2/experiments/u2Element.test.html +47 -0
- package/u2/old-stuff/IterableWeakMap/mod.js +70 -0
- package/u2/old-stuff/css/onStyleSheet/mod.js +114 -0
- package/u2/old-stuff/css/onStyleSheet/monkeypatches.js +28 -0
- package/u2/old-stuff/css/onStyleSheet/test/include.css +19 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-has-include.css +6 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-no-include.css +3 -0
- package/u2/old-stuff/css/onStyleSheet/test/test.html +48 -0
- package/u2/old-stuff/css/parser/mod.js +182 -0
- package/u2/old-stuff/css/parser/parser_old/mod.js +128 -0
- package/u2/old-stuff/css/parser/parser_old/test.html +43 -0
- package/u2/old-stuff/css/parser/parser_old/util.js +22 -0
- package/u2/old-stuff/css/parser/style.html +52 -0
- package/u2/old-stuff/css/parser/test.html +38 -0
- package/u2/old-stuff/el/ai-texter/README.md +23 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.css +12 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.js +153 -0
- package/u2/old-stuff/el/ai-texter/tests/minimal.html +47 -0
- package/u2/old-stuff/el/ai-texter/tests/test.html +71 -0
- package/u2/old-stuff/init.js +38 -0
- package/u2/old-stuff/markHashLinks.js +51 -0
- package/u2/old-stuff/onElement/mod.js +73 -0
- package/u2/old-stuff/test-helpers/mod.js +36 -0
- package/u2/old-stuff/test-helpers/test.html +4 -0
- package/u2/old-stuff/tests/init.js.html +51 -0
- package/u2/old-stuff/viewport.js +64 -0
- package/u2/projects.json +468 -0
- package/u2/tests/boilerplate.html +46 -0
- package/u2/tests/kacheln.html +245 -0
- package/u2/tests/showcase.html +270 -0
- package/u2/tests/showcase2.html +157 -0
- package/u2/tests/test-init.js +35 -0
- package/u2/tests/test.html +355 -0
- package/u2/tools/baseElement.js +95 -0
- package/u2/tools/baseElement.test.html +119 -0
- package/u2/tools/ce-inspector.js +308 -0
- package/u2/tools/ce-inspector.test.html +66 -0
- package/u2/tools/ce-manfest-from-element.js +207 -0
- package/u2/tools/dev-iframe.js +213 -0
- package/u2/tools/dev-iframe.test.html +75 -0
- package/u2/tools/eventsExplorer.js +101 -0
- package/u2/tools/logo/u1.svg +9 -0
- package/u2/tools/logo/u1ui.svg +6 -0
- package/u2/tools/update.repos.json.js +234 -0
- package/u2/u2.js +14 -0
- package/u2/utils.js +59 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function stringGenerator(string) {
|
|
2
|
+
return {
|
|
3
|
+
string: string,
|
|
4
|
+
length: string.length,
|
|
5
|
+
position:0,
|
|
6
|
+
current(){ return string[this.position]; },
|
|
7
|
+
next(){ return string[++this.position]; },
|
|
8
|
+
lookOut(offset) { return string[this.position+offset]; }, // char att offset relative to position
|
|
9
|
+
match(char){ // increments if char matches, resets if not, returns true if end reached
|
|
10
|
+
if (string[this.position]===char) {
|
|
11
|
+
this.position++;
|
|
12
|
+
if (string[this.position] === undefined) {
|
|
13
|
+
this.position = 0; // reset all keywords...!???!?!?
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
this.position = 0;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width">
|
|
6
|
+
<title>parser</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<script type=module>
|
|
12
|
+
|
|
13
|
+
import {dump} from 'https://cdn.jsdelivr.net/gh/nuxodin/dump.js@1.2.1/mod.min.js';
|
|
14
|
+
import {tokenize, startEndConsumer, charsConsumer, fnConsumer,stringIterator} from "./mod.js";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var whitespaces = charsConsumer(" \t\n", 'ws');
|
|
18
|
+
var commentMl = startEndConsumer('/*','*/');
|
|
19
|
+
var string = startEndConsumer('"', '"', '\\', 'string');
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var atStatement = startEndConsumer('@',';','\\','at-rule',{contains:[string]});
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export async function parse(str) {
|
|
28
|
+
return await tokenize( [whitespaces, commentMl, atStatement] , stringIterator(str));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
setTimeout(async function(){
|
|
33
|
+
|
|
34
|
+
let str = styleContent.innerHTML;
|
|
35
|
+
console.log(str)
|
|
36
|
+
var tree = await parse(str, function(item){
|
|
37
|
+
console.log('found', item.parser.name, item.outer);
|
|
38
|
+
});
|
|
39
|
+
dumpOut.innerHTML = dump(tree, {inherit: true});
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
},10);
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
</script>
|
|
46
|
+
<div id=dumpOut></div>
|
|
47
|
+
|
|
48
|
+
<style id=styleContent>
|
|
49
|
+
@import url("import\"te;st");
|
|
50
|
+
|
|
51
|
+
@import "asdf.ch";
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width">
|
|
6
|
+
<title>parser</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<script type=module>
|
|
12
|
+
|
|
13
|
+
import {dump} from 'https://cdn.jsdelivr.net/gh/nuxodin/dump.js@1.2.1/mod.min.js';
|
|
14
|
+
import {tokenize, startEndConsumer, charsConsumer, stringIterator} from "./mod.js";
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var whitespaces = charsConsumer(" \t\n", 'ws');
|
|
18
|
+
var commentMl = startEndConsumer('/*','*/');
|
|
19
|
+
var commentSl = startEndConsumer('//',"\n");
|
|
20
|
+
var string = startEndConsumer('"', '"', '\\', 'string');
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export async function parseCode(str) {
|
|
24
|
+
return await tokenize( [whitespaces, commentMl, commentSl, string] , stringIterator(str));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
let str = `"a\\"" "x" /**/`
|
|
29
|
+
console.log(str)
|
|
30
|
+
|
|
31
|
+
var tree = await parseCode(str, function(item){
|
|
32
|
+
console.log('found', item.parser.name, item.outer);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
dumpOut.innerHTML = dump(tree, {inherit: true});
|
|
36
|
+
|
|
37
|
+
</script>
|
|
38
|
+
<div id=dumpOut></div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Install
|
|
2
|
+
|
|
3
|
+
```html
|
|
4
|
+
<link href="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/ai-texter/ai-texter.min.css" rel=stylesheet>
|
|
5
|
+
<script src="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/ai-texter/ai-texter.min.js" type=module async></script>
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<link href="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/ai-texter/ai-texter.min.css" rel=stylesheet>
|
|
12
|
+
<script src="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/ai-texter/ai-texter.min.js" type=module async></script>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Demos
|
|
16
|
+
|
|
17
|
+
[test.html](http://gcdn.li/u2ui/u2@main/el/ai-texter/tests/test.html)
|
|
18
|
+
|
|
19
|
+
## About
|
|
20
|
+
|
|
21
|
+
- MIT License, Copyright (c) 2022 <u2> (like all repositories in this organization) <br>
|
|
22
|
+
- Suggestions, ideas, finding bugs and making pull requests make us very happy. ♥
|
|
23
|
+
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/* this is a input for ai prompts or a menu for pre-selected prompts, to help write in a textarea, or contenteditable */
|
|
2
|
+
/* usage:
|
|
3
|
+
<label>
|
|
4
|
+
<textarea></textarea>
|
|
5
|
+
<u2-ai-texter endpoint="/api"></u2-ai-texter> <!-- this will create an input where the user can insert ist prompts -->
|
|
6
|
+
</label>
|
|
7
|
+
|
|
8
|
+
// for a specific textarea, save prompts using localStorage
|
|
9
|
+
<textarea id=test></textarea>
|
|
10
|
+
<u2-ai-texter endpoint="/api" for="#test" safe></u2-ai-texter> <!-- this will create an combobox where saved prompts can be selected, they are saved using the id as identifier -->
|
|
11
|
+
|
|
12
|
+
<u2-ai-texter endpoint="/api" for="#test" safe="my-global-prompts"></u2-ai-texter> <!-- this will create an combobox where saved prompts can be selected, they are saved using the save-attribute-value as identifier -->
|
|
13
|
+
|
|
14
|
+
or for every textarea, using predefined prompts
|
|
15
|
+
<u2-ai-texter endpoint="/api" for="textarea">
|
|
16
|
+
<menu>
|
|
17
|
+
<button value="prompt1">prompt 1</button>
|
|
18
|
+
<button value="prompt1">prompt 2</button>
|
|
19
|
+
</menu>
|
|
20
|
+
</u2-ai-texter>
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import {Placer} from '../../../../js/Placer/Placer.js';
|
|
24
|
+
|
|
25
|
+
class Texter extends HTMLElement {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(); // Ruft den Konstruktor der Basisklasse auf
|
|
28
|
+
this.attachShadow({mode: 'open'}); // Erstellt ein Shadow DOM
|
|
29
|
+
this.placer = new Placer(this, { x:'center', y:'after', margin:-5 });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
this.shadowRoot.innerHTML = `
|
|
34
|
+
<style>
|
|
35
|
+
:host {
|
|
36
|
+
border: 1px solid currentColor;
|
|
37
|
+
position: absolute;
|
|
38
|
+
padding:0;
|
|
39
|
+
border-radius: .5em;
|
|
40
|
+
}
|
|
41
|
+
:host(:focus-within) {
|
|
42
|
+
outline: .4em solid blue;
|
|
43
|
+
}
|
|
44
|
+
form {
|
|
45
|
+
display:flex;
|
|
46
|
+
}
|
|
47
|
+
input {
|
|
48
|
+
outline:none;
|
|
49
|
+
flex: 1 1 auto;
|
|
50
|
+
border:0;
|
|
51
|
+
padding: .5em;
|
|
52
|
+
}
|
|
53
|
+
button {
|
|
54
|
+
all: unset;
|
|
55
|
+
display:flex;
|
|
56
|
+
align-items:center;
|
|
57
|
+
padding: .4em;
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
60
|
+
<form>
|
|
61
|
+
<slot>
|
|
62
|
+
<input placeholder="Make the text more unique...">
|
|
63
|
+
</slot>
|
|
64
|
+
<button>
|
|
65
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2zm-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6z"></path></svg>
|
|
66
|
+
</button>
|
|
67
|
+
</form>
|
|
68
|
+
`;
|
|
69
|
+
this.setAttribute('popover', 'manual');
|
|
70
|
+
this.shadowRoot.querySelector('form').addEventListener('submit', (event) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
this.request(this.shadowRoot.querySelector('input').value);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
showFor(element) {
|
|
76
|
+
this.currentTarget = element;
|
|
77
|
+
this.showPopover();
|
|
78
|
+
this.placer.toElement(element);
|
|
79
|
+
this.placer.followElement(element);
|
|
80
|
+
}
|
|
81
|
+
hide() {
|
|
82
|
+
this.hidePopover();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async request(prompt) {
|
|
86
|
+
const target = this.currentTarget;
|
|
87
|
+
|
|
88
|
+
const text = target.value != null ? target.value : target.innerHTML;
|
|
89
|
+
|
|
90
|
+
const body = {
|
|
91
|
+
//model: "llama3-8b-8192",
|
|
92
|
+
model: "llama3-70b-8192",
|
|
93
|
+
stream: false,
|
|
94
|
+
messages: [{
|
|
95
|
+
role: "system",
|
|
96
|
+
content: `You are a text editor. Return only the full(!) edited text without any explanations!
|
|
97
|
+
|
|
98
|
+
Example 1:\n
|
|
99
|
+
Prompt: You're a stupid bloke.\n
|
|
100
|
+
Text: friendlier\n
|
|
101
|
+
Answer: We seem to have different perspectives.\n
|
|
102
|
+
|
|
103
|
+
Example 2:\n
|
|
104
|
+
Prompt: Es war einmal ein\n
|
|
105
|
+
Text: schreib weiter\n
|
|
106
|
+
Answer: Es war einmal ein kleines Mädchen.\n
|
|
107
|
+
`,
|
|
108
|
+
},{
|
|
109
|
+
role: "user",
|
|
110
|
+
content: `Prompt: ${prompt}\nText: ${text}`,
|
|
111
|
+
}],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const endpoint = this.getAttribute('api');
|
|
115
|
+
const apiKey = this.getAttribute('api-key');
|
|
116
|
+
|
|
117
|
+
const result = await fetch(endpoint, {
|
|
118
|
+
method: 'POST',
|
|
119
|
+
headers: {
|
|
120
|
+
'Content-Type': 'application/json',
|
|
121
|
+
'Authorization': `Bearer ${apiKey}`
|
|
122
|
+
},
|
|
123
|
+
body: JSON.stringify(body),
|
|
124
|
+
}).then(response => response.json());
|
|
125
|
+
|
|
126
|
+
console.log(result);
|
|
127
|
+
|
|
128
|
+
const value = result.choices[0].message.content;
|
|
129
|
+
|
|
130
|
+
target[target.value != null ? 'value' : 'innerHTML'] = value;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
customElements.define('u2-ai-texter', Texter);
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
addEventListener('focusin', ({target}) => {
|
|
139
|
+
|
|
140
|
+
if (target.matches('u2-ai-texter')) return;
|
|
141
|
+
|
|
142
|
+
document.querySelectorAll('u2-ai-texter').forEach(texter => {
|
|
143
|
+
if (!target.matches) return;
|
|
144
|
+
if (target.matches(texter.getAttribute('for'))) {
|
|
145
|
+
texter.showFor(target);
|
|
146
|
+
} else {
|
|
147
|
+
const texter = target.parentNode.querySelector(':scope > u2-ai-texter');
|
|
148
|
+
if (texter) {
|
|
149
|
+
texter.showFor(target);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name=viewport content="width=device-width">
|
|
6
|
+
<script src="../../../u2/tests/test-init.js" type=module async></script>
|
|
7
|
+
<!-- <script src="../../u2/auto.js" type=module async></script> -->
|
|
8
|
+
<title>Test</title>
|
|
9
|
+
|
|
10
|
+
<link rel=stylesheet href="../../../css/classless/full.css">
|
|
11
|
+
<link rel=stylesheet href="../../../css/classless/simple.css">
|
|
12
|
+
|
|
13
|
+
<link href="../../../el/code/code.css" rel=stylesheet>
|
|
14
|
+
<script src="../../../el/code/code.js" type=module async></script>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<!--script src="../../../el/tooltip/tooltip.js" type=module async></script>
|
|
19
|
+
<link href="../../../el/tooltip/tooltip.css" rel=stylesheet>
|
|
20
|
+
<script src="../../../el/ico/ico.js" type=module async></script>
|
|
21
|
+
<link href="../../../el/ico/ico.css" rel=stylesheet> -->
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
body {
|
|
25
|
+
place-content: initial;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
28
|
+
|
|
29
|
+
<link href="../ai-texter.css" rel=stylesheet>
|
|
30
|
+
<script src="../ai-texter.js" type=module async></script>
|
|
31
|
+
|
|
32
|
+
<body>
|
|
33
|
+
|
|
34
|
+
<section class="main">
|
|
35
|
+
|
|
36
|
+
<label>
|
|
37
|
+
<textarea></textarea>
|
|
38
|
+
<u2-ai-texter api="https://api.groq.com/openai/v1/chat/completions" api-key="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"></u2-ai-texter>
|
|
39
|
+
</label>
|
|
40
|
+
|
|
41
|
+
</section>
|
|
42
|
+
|
|
43
|
+
<style class="main">
|
|
44
|
+
u2-ai-texter {
|
|
45
|
+
background: #f8f8f8;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name=viewport content="width=device-width">
|
|
6
|
+
<script src="../../../u2/tests/test-init.js" type=module async></script>
|
|
7
|
+
<!-- <script src="../../u2/auto.js" type=module async></script> -->
|
|
8
|
+
<title>Test</title>
|
|
9
|
+
|
|
10
|
+
<link rel=stylesheet href="../../../css/classless/full.css">
|
|
11
|
+
<link rel=stylesheet href="../../../css/classless/simple.css">
|
|
12
|
+
|
|
13
|
+
<link href="../../../el/code/code.css" rel=stylesheet>
|
|
14
|
+
<script src="../../../el/code/code.js" type=module async></script>
|
|
15
|
+
|
|
16
|
+
<!--script src="../../../el/tooltip/tooltip.js" type=module async></script>
|
|
17
|
+
<link href="../../../el/tooltip/tooltip.css" rel=stylesheet>
|
|
18
|
+
<script src="../../../el/ico/ico.js" type=module async></script>
|
|
19
|
+
<link href="../../../el/ico/ico.css" rel=stylesheet> -->
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
body {
|
|
23
|
+
place-content: initial;
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
26
|
+
|
|
27
|
+
<link href="../ai-texter.css" rel=stylesheet>
|
|
28
|
+
<script src="../ai-texter.js" type=module async></script>
|
|
29
|
+
|
|
30
|
+
<body>
|
|
31
|
+
|
|
32
|
+
<section>
|
|
33
|
+
|
|
34
|
+
<h2>u2-ai-texter</h2>
|
|
35
|
+
<label>
|
|
36
|
+
same container
|
|
37
|
+
<textarea></textarea>
|
|
38
|
+
<u2-ai-texter api="https://api.groq.com/openai/v1/chat/completions" api-key="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"></u2-ai-texter>
|
|
39
|
+
</label>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
<h2>Using "for" attribute</h2>
|
|
43
|
+
<label>
|
|
44
|
+
Textarea 1
|
|
45
|
+
<textarea class="forTest"></textarea>
|
|
46
|
+
</label>
|
|
47
|
+
<label>
|
|
48
|
+
Textarea 1
|
|
49
|
+
<textarea class="forTest"></textarea>
|
|
50
|
+
</label>
|
|
51
|
+
<u2-ai-texter for=".forTest" api="https://api.groq.com/openai/v1/chat/completions" api-key="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"></u2-ai-texter>
|
|
52
|
+
|
|
53
|
+
<h2>Using custom buttons</h2>
|
|
54
|
+
|
|
55
|
+
<label>
|
|
56
|
+
Using custom buttons
|
|
57
|
+
<textarea></textarea>
|
|
58
|
+
<u2-ai-texter api="https://api.groq.com/openai/v1/chat/completions" api-key="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">
|
|
59
|
+
<button>korrektur</button>
|
|
60
|
+
<button>ausführlicher</button>
|
|
61
|
+
</u2-ai-texter>
|
|
62
|
+
</label>
|
|
63
|
+
|
|
64
|
+
<h2>Using contenteditable</h2>
|
|
65
|
+
|
|
66
|
+
<div contenteditable>
|
|
67
|
+
<p>Contenteditable</p>
|
|
68
|
+
</div>
|
|
69
|
+
<u2-ai-texter for="[contenteditable]" api="https://api.groq.com/openai/v1/chat/completions" api-key="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"></u2-ai-texter>
|
|
70
|
+
|
|
71
|
+
</section>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
/* prevent double-click selection */
|
|
3
|
+
addEventListener('mousedown', e => {
|
|
4
|
+
if (e.detail < 2) return; // // check event.ctrlKey/event.shiftKey/event.altKey?
|
|
5
|
+
let target = e.composedPath()[0]; // shadow dom
|
|
6
|
+
if (!target.closest('summary,label')) return;
|
|
7
|
+
e.preventDefault();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
|
|
13
|
+
Copy styles to the shadow-dom
|
|
14
|
+
- add functionality to a custom Element Class we can inherit?
|
|
15
|
+
|
|
16
|
+
new SelectorObserver({
|
|
17
|
+
on: el => {
|
|
18
|
+
for (let ss of document.styleSheets) el.shadowRoot.append(ss.ownerNode.cloneNode());
|
|
19
|
+
} ,
|
|
20
|
+
}).observe('[deep-css]');
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
|
|
28
|
+
Add classes on running transitions
|
|
29
|
+
- does this take up too much performance?
|
|
30
|
+
|
|
31
|
+
addEventListener('transitionstart',e=>{
|
|
32
|
+
e.target.classList.add('u2-animating')
|
|
33
|
+
})
|
|
34
|
+
addEventListener('transitionend',e=>{
|
|
35
|
+
e.target.classList.remove('u2-animating')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
console.warn('todo!');
|
|
4
|
+
|
|
5
|
+
/* mark link, todo: loop nav elements, for now it only works with one nav */
|
|
6
|
+
var links = null;
|
|
7
|
+
var getLinks = function(){
|
|
8
|
+
if (links) return links;
|
|
9
|
+
var els = document.querySelectorAll('a[href]');
|
|
10
|
+
links = [];
|
|
11
|
+
for (var i=0,a; a=els[i++];) {
|
|
12
|
+
var matches = a.href.match(/#(.*)/);
|
|
13
|
+
if (!matches) continue;
|
|
14
|
+
var id = matches[1];
|
|
15
|
+
if (!id) continue;
|
|
16
|
+
var target = document.getElementById(id);
|
|
17
|
+
if (!target) continue;
|
|
18
|
+
links.push({a, target, id});
|
|
19
|
+
}
|
|
20
|
+
setTimeout(()=> links = null, 3000);
|
|
21
|
+
return links;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var listen = function(e){
|
|
25
|
+
var links = getLinks(), winner, i=0, link;
|
|
26
|
+
while (link=links[i++]) {
|
|
27
|
+
var pos = link.target.getBoundingClientRect();
|
|
28
|
+
if (pos.top > 140) break; // first target below viewport
|
|
29
|
+
winner = link;
|
|
30
|
+
}
|
|
31
|
+
winner && markLinksActivated(winner.id);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
document.addEventListener('DOMContentLoaded',listen);
|
|
35
|
+
addEventListener('scroll',listen);
|
|
36
|
+
addEventListener('resize',listen);
|
|
37
|
+
|
|
38
|
+
var latestWinner;
|
|
39
|
+
function markLinksActivated(id){
|
|
40
|
+
if (latestWinner === id) return;
|
|
41
|
+
latestWinner = id;
|
|
42
|
+
var actives = document.querySelectorAll('.hashLinkActive');
|
|
43
|
+
for (var i=0,item; item=actives[i++];) item.classList.remove('hashLinkActive');
|
|
44
|
+
var links = getLinks();
|
|
45
|
+
for (i=0; item=links[i++];) {
|
|
46
|
+
item.id === id && item.a.classList.add('hashLinkActive');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
addEventListener('pushstate',e=>markLinksActivated(location.hash));
|
|
51
|
+
//addEventListener('cms.navigator-navigated', e=>markLinksActivated(location.hash)); // todo: make onpopstate-polyfill
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* Copyright (c) 2016 Tobias Buschor https://goo.gl/gl0mbf | MIT License https://goo.gl/HgajeK */
|
|
2
|
+
|
|
3
|
+
console.warn('deprecated!');
|
|
4
|
+
|
|
5
|
+
var listeners = [],
|
|
6
|
+
//root = document.documentElement,
|
|
7
|
+
root = document,
|
|
8
|
+
Observer;
|
|
9
|
+
|
|
10
|
+
export function onElement (selector, options/*, disconnectedCallback*/) {
|
|
11
|
+
if (typeof options === 'function') {
|
|
12
|
+
options = { parsed:options }
|
|
13
|
+
}
|
|
14
|
+
var listener = {
|
|
15
|
+
selector: selector,
|
|
16
|
+
immediate: options.immediate,
|
|
17
|
+
elements: new WeakSet(),
|
|
18
|
+
};
|
|
19
|
+
if (options.parsed) {
|
|
20
|
+
listener.parsed = function(el){
|
|
21
|
+
requestAnimationFrame(()=>options.parsed(el));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
var els = root.querySelectorAll(listener.selector), i=0, el;
|
|
26
|
+
} catch(e) {
|
|
27
|
+
console.error('invalid selector: "'+listener.selector+'"');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
while (el = els[i++]) {
|
|
31
|
+
listener.elements.add(el);
|
|
32
|
+
listener.parsed && listener.parsed.call(el, el);
|
|
33
|
+
listener.immediate && listener.immediate.call(el, el);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
listeners.push(listener);
|
|
37
|
+
if (!Observer) {
|
|
38
|
+
Observer = new MutationObserver(checkMutations);
|
|
39
|
+
Observer.observe(root, {
|
|
40
|
+
childList: true,
|
|
41
|
+
subtree: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
checkListener(listener);
|
|
45
|
+
};
|
|
46
|
+
function checkListener(listener, target) {
|
|
47
|
+
var i=0, el, els = [];
|
|
48
|
+
target && target.matches(listener.selector) && els.push(target);
|
|
49
|
+
if (loaded) { // ok? check inside node on innerHTML - only when loaded
|
|
50
|
+
Array.prototype.push.apply(els, (target||root).querySelectorAll(listener.selector));
|
|
51
|
+
// els.push(...found)?
|
|
52
|
+
}
|
|
53
|
+
while (el = els[i++]) {
|
|
54
|
+
if (listener.elements.has(el)) continue;
|
|
55
|
+
listener.elements.add(el);
|
|
56
|
+
listener.parsed && listener.parsed.call(el, el);
|
|
57
|
+
listener.immediate && listener.immediate.call(el, el);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function checkListeners(inside) {
|
|
61
|
+
var i=0, listener;
|
|
62
|
+
while (listener = listeners[i++]) checkListener(listener, inside);
|
|
63
|
+
}
|
|
64
|
+
function checkMutations(mutations) {
|
|
65
|
+
var j=0, i, mutation, nodes, target;
|
|
66
|
+
while (mutation = mutations[j++]) {
|
|
67
|
+
nodes = mutation.addedNodes, i=0;
|
|
68
|
+
while (target=nodes[i++]) target.nodeType === 1 && checkListeners(target);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let loaded = false;
|
|
73
|
+
document.addEventListener('DOMContentLoaded',()=> loaded = true );
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description create a big test-dom structure
|
|
3
|
+
* @returns HTMLElement, the created root
|
|
4
|
+
* @usage
|
|
5
|
+
* var root = createBigDom({ depth=40, num=5000, maxChildren=100,
|
|
6
|
+
* createElement:()=>{
|
|
7
|
+
* var el = document.createElement('article');
|
|
8
|
+
* el.innerHTML = 'test';
|
|
9
|
+
* return el;
|
|
10
|
+
* }
|
|
11
|
+
* });
|
|
12
|
+
*/
|
|
13
|
+
export function createBigDom({ createElement, root, depth = 40, num = 5000, maxChildren = 100 } = {}) {
|
|
14
|
+
// https://web.dev/dom-size/#how-the-lighthouse-dom-size-audit-fails
|
|
15
|
+
if (!root) {
|
|
16
|
+
var root = document.createElement('div');
|
|
17
|
+
document.body.append(root);
|
|
18
|
+
}
|
|
19
|
+
root.className = 'bigDom';
|
|
20
|
+
let aDepth = 0;
|
|
21
|
+
let aNum = 0;
|
|
22
|
+
function addChildren(parent) {
|
|
23
|
+
aDepth++;
|
|
24
|
+
for (let i = 0; i < maxChildren; i++) {
|
|
25
|
+
if (aNum >= num) break;
|
|
26
|
+
const el = createElement ? createElement() : document.createElement('span');
|
|
27
|
+
parent.append(el);
|
|
28
|
+
aNum++;
|
|
29
|
+
if (aNum >= num) return;
|
|
30
|
+
if (aDepth < depth) addChildren(el);
|
|
31
|
+
}
|
|
32
|
+
aDepth--;
|
|
33
|
+
}
|
|
34
|
+
addChildren(root);
|
|
35
|
+
return root;
|
|
36
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Level.css TEST</title>
|
|
6
|
+
<meta name="viewport" content="width=device-width">
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<script src="../init.js" type=module async></script>
|
|
10
|
+
<link rel=stylesheet href="../../../css/base/full.css" crossorigin>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
|
|
15
|
+
<section>
|
|
16
|
+
|
|
17
|
+
<h2>Doubleclick on label and on summary should not select the text, but it is still selectable</h2>
|
|
18
|
+
<div id=dblClickTest>
|
|
19
|
+
<label>
|
|
20
|
+
A label for:
|
|
21
|
+
<input>
|
|
22
|
+
</label>
|
|
23
|
+
|
|
24
|
+
<details>
|
|
25
|
+
<summary>Summary</summary>
|
|
26
|
+
<div>
|
|
27
|
+
Details Content
|
|
28
|
+
</div>
|
|
29
|
+
</details>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<div id=dblClickTest_shadow style="border:1px solid">
|
|
34
|
+
The same inside Shadow-Dom<br>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
</div>
|
|
38
|
+
<script>
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
shadowDeepCss = function(shadow){
|
|
42
|
+
for (let ss of document.styleSheets) shadow.append(ss.ownerNode.cloneNode());
|
|
43
|
+
}
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
let shadow = dblClickTest_shadow.attachShadow({mode: 'open'});
|
|
47
|
+
//shadowDeepCss(shadow);
|
|
48
|
+
shadow.innerHTML += '<slot></slot>' + dblClickTest.innerHTML;
|
|
49
|
+
|
|
50
|
+
</script>
|
|
51
|
+
</section>
|