{"id":20186812,"url":"https://github.com/moodrain/muyu-util","last_synced_at":"2026-06-08T17:31:16.919Z","repository":{"id":187764299,"uuid":"138562085","full_name":"moodrain/muyu-util","owner":"moodrain","description":"light util to deal with ordinary work of js","archived":false,"fork":false,"pushed_at":"2018-08-31T21:31:59.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T06:46:26.990Z","etag":null,"topics":["ajax","alert","es6","javascript","javascript-util","no-dependencies","pull-to-refresh"],"latest_commit_sha":null,"homepage":"https://s1.moodrain.cn/lib/muyu/index.js","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moodrain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-06-25T07:59:34.000Z","updated_at":"2020-06-17T03:05:45.000Z","dependencies_parsed_at":"2023-08-12T04:11:05.040Z","dependency_job_id":null,"html_url":"https://github.com/moodrain/muyu-util","commit_stats":null,"previous_names":["moodrain/muyu-util"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/moodrain/muyu-util","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moodrain%2Fmuyu-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moodrain%2Fmuyu-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moodrain%2Fmuyu-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moodrain%2Fmuyu-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moodrain","download_url":"https://codeload.github.com/moodrain/muyu-util/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moodrain%2Fmuyu-util/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34073657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ajax","alert","es6","javascript","javascript-util","no-dependencies","pull-to-refresh"],"created_at":"2024-11-14T03:18:42.812Z","updated_at":"2026-06-08T17:31:16.904Z","avatar_url":"https://github.com/moodrain.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"muyu-util\n=======\n沐雨工具库\n-------\n\n\u003e this lib uses es6 and require no dependency\n\u003e  \n\u003e 该库使用es6语法，无需其他依赖\n\n### demo\n\n* pull to load | 下拉加载\n\n\t\t$pullToLoad('goods-container', status =\u003e {\n\t\t\t$get('goods', {page: status.page}, rs =\u003e {\n\t\t\t\trs.data.forEach(goods =\u003e {\n\t\t\t\t\t$add('goods-container', $tag('img', goods.img, 'goods-item', () =\u003e {\n\t\t\t\t\t\twindow.open('goods/' + goods.id)\n\t\t\t\t\t}))\n\t\t\t\t})\n\t\t\t\tstatus.load = true\n\t\t\t})\t\t\n\t\t})\n \n### util list\n\nutil | function | detail\n---- | --- |---\najax | $ajax(method, url, data, header, success, [error], [withCredentials]) | all ajax function is withCredentials by default\najax-get | $get(url, success, [error]) | status code isn't 200 and 'code' in reponse json isn't 0 or 200 will call error  \najax-get | $get(url, data, success, [error], [withCredentials]) | data are key-values to generate query string after url\najax-post | $post(url, data, success, [error], [type], [withCredentials]) | type can be 'form' (default) or 'json' \ngetElement | $e(elem) | the same with document.getElementById()\nget/setValue | $v(elem, [val]) | get value from attr of value of innerHTML, set value to attr of value,innerHTML,href,src according to tagName\nquery | $q(name, [url]) | get query param in url\nget/setCookie | $ck(name, [value], [second]) | cookie expires in 1 day by default\ngetFormData | $fd(prefix, fields) | get value from each input that id is prefix + '-' + field\nfillForm | $ff(prefix, fields) | set each input that id is prefix + '-' + field.key by field.value\najaxFillForm | $aff(url, prefix) | the same to $get(url, rs =\u003e { $ff(prefix, rs.data) })\nstampToDate | $date(date) |\nstampToDatetime | $time(date) |\ntimeToChinese | $timeCn(date) |\nnotify | $notify(msg, [className]) | require muyu.css and use className to add your custom style\nclick | $click(elem, callback) | will cover the previous bind\nenter | $enter(btn) | will trigger btn.click() when keydown enter, and will cover the previous bind\ncreateElement | $tag(tag, [val], [className], [click]) | the same with document.createElement(tag) and call $v, $click or set className on it \naddChildren | $add(parent, ...children) | the same with parent.appendChild() on each child\nclickToTop | $toTop(btn, [elem]) | the default elem is window\nhideFooter | $hideFooter([elem]) | the default elem is the footer tag, hide footer when screen keyboard appears\npullToLoad | $pullToLoad(elem, callback, [distance]) | the default distance is 50, the callback receive an status object {load: bool, page: number}, set statu.load = true when finish loading\nhideElement | $hide(elem) | the same with elem.style.display = 'none'\nshowElement | $show(elem, [inline]) | the same with elem.style.display = 'block' or 'inline-block'\nchangeElementToShow | $change(elem, elems) | hide all elems and show elem\ngetProperty | $pro(obj, property, [split]) | the default split is '.' \nvalueExpress | $vex(exp, def, justify, modify) | too hard to explain\nvalueDefault | $vdf(...exp) | get the first exp that is true, and the last exp if none is true\nvalueLastTrue | $vlt(obj, ...exp) | get the previous once an exp is false, obj if the first exp is false\ntrim | $trim(str, [mode]) | mode can be 'left', 'right' or 'both' (default)\ntransitionNumber | $tran(elem, increment, [second]) | the default second is 1\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoodrain%2Fmuyu-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoodrain%2Fmuyu-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoodrain%2Fmuyu-util/lists"}