Catalog npm
Back to packageRELEASE DETAILS

0.1.226

npm

18x

util js for build web site

dialoglightboxmiscpopuputil
Published30 Aug 2024
Direct dependencies0
Transitive dependenciesNot calculated

README

Current package documentation

18X

Util js for build web site

No need add npm package dependencies

Import directly in your js

Before use , you should define import map in HTML

For example importmap

<script type="importmap">{"imports":{"x/":"//jsd.cdn.zzko.cn/npm/18x/"}}</script>

You can replace //jsd.cdn.zzko.cn/npm/18x/ as your own CDN in above code

File

toast

x/toast.js

x/toast.css

A notification message pops up in the lower-left corner of the webpage.

When a request using ./f.js fails, it will call this to display an error message.

Box

x/xBox.js : pop up box with close button x/box.js : pop up box style

screenshot example :

x/Box.js: base pop up box

x/htmBox.js: pop up box with html

x/tagBox.js: create a box , append with the new tag

Event

x/On.js : shortcut bind & unbind event with object

Text

x/utf8d.js decode utf8 from Uint8Array

x/bintxt.js decode string from [utf8] concat by 0

Net

x/f.js

  • fTxt : fetch url and return string
  • fJson : fetch url and return json
  • fBin.js : fetch url and return Uint8Array

x/fBintxt.js fetch url and decode via bintxt

x/fBinPrefix.js return fBin func with binded prefix

I18N

x/lang.js

  • init : detect current language by _LANG_URL & _LANG & localStorage.LANG or navigator.language
  • set : set language
  • onSet : hook when language change

x/langSite.js hook when site lang file fetched

x/langHook.js create your own hook for get different lang file

Tag

x/i-h.js html tag generator from _H ( <i-h>foot</i-h> -> _H.foot() ),will auto refresh when lang change

Channel

initC.js

init channel and generate function

  • send (kind, ...msg) → channel
  • hook (kind, ...msg) → unhook function

wrap Broadcast & SharedWorker by init channel

Broadcast

x/BC.js

SharedWorker

x/share.js

Service Worker

use ./serviceWorker.build.coffee generate service worker S.js from ./serviceWorker

SVG

svg

use svgVar.coffee generate svg.css with inline svg var

CSS

_.css css on in one

@import "//cdn.jsdelivr.net/npm/18x/_.css"

reset.css reset css

Route

x/route.js 路径 - 回调函数 ( func(url, PRE) )

  • setUrl 设置浏览器网址不触发路由事件 ( 比如用于多文件的目录章节导航 )
  • goto.js 设置浏览器网址并触发路由事件

x/Match.js 路由匹配, 用法如:

<template lang="pug">
Topbar
  TopbarR
<svelte:component this="{M}"/>
</template>

<script lang="coffee">
> @8p/nav:
  @8p/h404:H404
  @8p/topbar:Topbar
  @8p/wait:Wait
  svelte > tick
  ./TopbarR.svelte
  x/route.js
  x/Match.js

M = Wait

page = (m)=>
  M = Wait
  await tick()
  M = m
  return

match = Match(
  page
  =>
    M = H404
    return
)

route (url)=>
  match url
  return

onI18n =>
  match location.pathname.slice(1)
  return
</script>

x/selfA.js 判断A标签的href是否为当前网站的, 如果是, 返回url, 以实现不刷新跳转 x/a.js 监听所有的A标签, 当点击时, 如果是当前网站的路径, 则阻止默认事件并触发路由(goto) , 如果是外站路径, 自动添加 target="_blank" x/forceGoto.js 强制刷新(因为当网址不变的时候默认不刷新, 会导致比如支付成功的跳转不成功, 这时候就需要强制刷新, 参见 pay/src/TopUp.svelte

I18N.SITE

global variable

x/_.js

fJson / fMd : use _fp get real url, then fetch, return 0 if can't find the real url

USE / MENU : hook form page or menu

About Us

i18n.site

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 0

Native requirements
0 direct targetsNot calculated transitive count
No declared dependencies in this collected response

Declarations describe requirements; they are not a resolved dependency graph.

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "b3e1ef28a8f8a71a3ca344e6a1abca5be02aa8d7",
  "tarball": "https://registry.npmjs.org/18x/-/18x-0.1.226.tgz",
  "fileCount": 85,
  "integrity": "sha512-G4AyEuk+8CJXsitX0gW8Z+U/lWQZ9qJZcjPSFut0/otopjv5qUwoT4hH+yaM/Sl3UV4yhW3s4/C/A2ecEV5+uQ==",
  "signatures": [
    {
      "sig": "MEYCIQDSZdorIXO7xLvh6/s1A6JGmlV1MTxMMGU1ufIZVoqjOwIhAI+mTteQkZ+b95wd1Mqvbsv5mQ2qoqNyvB3wCwWGWNSx",
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
    }
  ],
  "unpackedSize": 106849
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:21 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:728aca0df79d074897fc091925b31ff8bb0bcca02af985e697e2d1b2a473cf4e

Other collected versions

0.1.3377 Nov0.1.3367 Nov0.1.3357 Nov0.1.3347 Nov0.1.3337 Nov0.1.3327 NovView all collected versions →