{"id":22960309,"url":"https://github.com/stringmanolo/javascriptshortcuts","last_synced_at":"2025-04-02T02:43:24.892Z","repository":{"id":95119416,"uuid":"334324880","full_name":"StringManolo/JavascriptShortcuts","owner":"StringManolo","description":"Set of functions made to heavily increase development speed. ","archived":false,"fork":false,"pushed_at":"2021-01-30T05:31:41.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-07T17:45:02.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/StringManolo.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-30T04:10:59.000Z","updated_at":"2021-01-30T05:31:43.000Z","dependencies_parsed_at":"2023-05-26T19:15:33.067Z","dependency_job_id":null,"html_url":"https://github.com/StringManolo/JavascriptShortcuts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringManolo%2FJavascriptShortcuts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringManolo%2FJavascriptShortcuts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringManolo%2FJavascriptShortcuts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StringManolo%2FJavascriptShortcuts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StringManolo","download_url":"https://codeload.github.com/StringManolo/JavascriptShortcuts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246746879,"owners_count":20827061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-14T18:32:34.496Z","updated_at":"2025-04-02T02:43:24.871Z","avatar_url":"https://github.com/StringManolo.png","language":"JavaScript","readme":"# JavascriptShortcuts\nSet of functions made to heavily increase development speed. \n\n\n## BASIC:  \n\n### $()  \nSelect an element from the document or other element.  \n```\nlet myButton = $(\"#myButton\");\nlet myScriptSrc = $(\"#myDiv\", \"script\").src;\n```\n\n### $$()\nSelect all elements from the document or other element.\n```\nlet links = $$(\"a\");\nlet myHeaders = $$(\"body\", \"header\");\n```\n\n### \\_() \nSame as alert. \n```\n_(5 + 3);\n```\n\n### \\_\\_()\nSame as console.log().\n```\n__(\"Hello!\");\n```\n\n### make()\nCreate an element and return it. You can also change properties.\n```\nlet myButton = make(\"button\", { innerHTML: \"Click me!\", className: \"myButtons\" });\nlet myDiv = make(\"div\");\n```\n\n### ael()\nAdd event listener to element. Click event used if omited.\n```\nlet myButton = make(\"button\", {innerHTML: \"LOGIN\"});\nael(myButton, e =\u003e alert(\"Welcome to login!\"));\nael(myButton, \"click\", () =\u003e location = \"/login.html\");\n```\n\n### add()\nAppend child element to parent. Using body when omited.\n```\nadd(head, myScript);\nadd(myDiv);\n```\n\n### rand()\nTypical Math.floor(Math.random() * X +1) . \n```\nlet randomBetween0And1000 = rand(1000);\n```\n\n### css()\nAdd the css to head element.\n```\ncss(`\nbody {\n  margin: 0;\n  background-color: snow;\n}\n`);\n```\n\n\n## ADVANCED: \nAll functions are returning the most common element. You can exploit it into method chaining, embeed and recursive functions calls. \nYou can avoid save references to elements you're going to use only few times. Is easy to build big oneliners to simplify code.\n\n### Examples: \nCreate button, set innerText to click me and id to myButton, add click event listener to alert message and append it to div: \nVanilla js: \n```\nlet button = document.createElement(\"button\");\nbutton.innerText = \"Click Me Please!\";\nbutton.id = \"myButton\";\nbutton.addEventListener(\"click\", () =\u003e alert(\"Nice click!\"));\nlet myDiv = document.querySelector(\"#myDiv\");\nmyDiv.appendChild(button);\n```\n\nShortcuted js:\n```\nadd($(\"#myDiv\"), ael(make(\"button\",{ innerText: \"Click Me Please!\", id: \"myButton\"}), () =\u003e _(\"Nice click!\")));\n```\n\n245 characters vs 112 characters.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringmanolo%2Fjavascriptshortcuts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstringmanolo%2Fjavascriptshortcuts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringmanolo%2Fjavascriptshortcuts/lists"}