├── assets └── logo.png ├── examples ├── CSS │ ├── pacifico-regular-webfont.woff │ ├── pacifico-regular-webfont.woff2 │ ├── stylesheet.css │ └── main.css ├── JS │ ├── main.js │ └── rotten.js └── index.html ├── .github ├── SECURITY.md ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── CONTRIBUTING.md ├── package.json ├── LICENSE.md ├── README.md ├── rotten.min.js ├── DOCSv1.9.0.md ├── DOCUMENTATION.md ├── rotten.js └── development └── rotten.js /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenphuminh/rottenjs/HEAD/assets/logo.png -------------------------------------------------------------------------------- /examples/CSS/pacifico-regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenphuminh/rottenjs/HEAD/examples/CSS/pacifico-regular-webfont.woff -------------------------------------------------------------------------------- /examples/CSS/pacifico-regular-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nguyenphuminh/rottenjs/HEAD/examples/CSS/pacifico-regular-webfont.woff2 -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 1.x.x | :white_check_mark: | 8 | | 1.2.x | :x: | 9 | | 0.x.x | :x: | 10 | -------------------------------------------------------------------------------- /examples/CSS/stylesheet.css: -------------------------------------------------------------------------------- 1 | /*! Generated by Font Squirrel (https://www.fontsquirrel.com) on September 26, 2020 */ 2 | 3 | 4 | 5 | @font-face { 6 | font-family: 'pacificoregular'; 7 | src: url('pacifico-regular-webfont.woff2') format('woff2'), 8 | url('pacifico-regular-webfont.woff') format('woff'); 9 | font-weight: normal; 10 | font-style: normal; 11 | 12 | } -------------------------------------------------------------------------------- /examples/JS/main.js: -------------------------------------------------------------------------------- 1 | function add() { 2 | name.input('',function(){ 3 | alert('Task is empty!'); 4 | },function(){ 5 | content = content + "
" + name.input() + "
"; 6 | }); 7 | tasklist.html(content); 8 | localStorage.setItem('stuff', content); 9 | } 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to RottenJS! 2 | ====================== 3 | 4 | Thanks for your interests in RottenJS, if you want to contribute to the project, please consider looking at the following notes! 5 | 6 | ## First notes 7 | Please contribute to "development/rotten.js". 8 | 9 | ## Language 10 | We would prefer English as the main language for contributing, but you can use Vietnamese! 11 | 12 | ## Writing a Good Pull Request 13 | 14 | - Make sure to write a rich description showing changes that you made, the upgrades on the project, what it would do, etc. 15 | 16 | - Name your pull request nicely. 17 | 18 | - Don't use any NSFW or weird contents in a pull request. 19 | 20 | 21 | That's all, thanks for your time with RottenJS! 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rottenjs", 3 | "version": "2.6.6", 4 | "description": "A light-weight Javascript library for DOM manipulation", 5 | "main": "rotten.min.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/nguyenphuminh/rottenjs.git" 12 | }, 13 | "keywords": [ 14 | "javascript", 15 | "javascript-library", 16 | "javascript-framework", 17 | "dom-manipulation" 18 | ], 19 | "author": "Nguyen Phu Minh", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/nguyenphuminh/rottenjs/issues" 23 | }, 24 | "homepage": "https://github.com/nguyenphuminh/rottenjs#readme" 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /examples/CSS/main.css: -------------------------------------------------------------------------------- 1 | *{ 2 | font-family: helvetica; 3 | } 4 | 5 | body { 6 | margin:0; 7 | text-shadow: 2px 2px 4px darkgray; 8 | background-color: lightgray; 9 | } 10 | 11 | .taskbox{ 12 | width: 30%; 13 | padding: 1%; 14 | border:2px solid black; 15 | border-radius: 5px; 16 | background-color: white; 17 | margin-top: 1%; 18 | } 19 | .content{ 20 | margin-top: 6%; 21 | } 22 | .header{ 23 | color:#5246ab; 24 | font-family: pacificoregular; 25 | font-size: 130px; 26 | } 27 | .tasktitle{ 28 | font-family: helvetica; 29 | font-size:30px; 30 | } 31 | 32 | input{ 33 | width:30%; 34 | border-radius: 5px; 35 | border:2px solid black; 36 | } 37 | button{ 38 | margin-left: 3px; 39 | border-radius: 5px; 40 | border:2px solid #5246ab; 41 | background-color: #5246ab; 42 | color:white; 43 | cursor: pointer; 44 | transition: 0.3s; 45 | } 46 | button:hover{ 47 | background-color: white; 48 | color:#5246ab; 49 | } 50 | 51 | @media screen and (max-width: 700px) { 52 | .taskbox{ 53 | width: 60%; 54 | } 55 | input{ 56 | width:40%; 57 | } 58 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Nguyen Phu Minh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 |
20 |
21 |
22 |
Tasks:
23 |
24 |
25 |
26 |
27 |
Note: Click on the task to clear it!
28 |
29 |

RJS

30 |
31 | 32 | 59 | 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |

A simple, light-weight Javascript library for DOM manipulation and UI development

5 |
6 | 7 | 8 | Downloads 9 | Version 10 | 11 | language 12 |
13 | 14 | ## What is RottenJS ? 15 | RottenJS is a light-weight(2.6kb), all-in-one Javascript library. It can be used for DOM manipulation, but it also provides many utilites for you to create websites with charm. The library is recommended for personal projects as its very light and scale well with medium-sized websites, but not recommended for big websites that are in production. RottenJS is a perfect fit for you if you want to create projects quick and easy, or if you just want to mess around with open-source libraries. 16 | 17 | ## Comparision with other libraries/frameworks 18 | 19 | | Size | Rotten.js | Cash | Zepto 1.2.0 | jQuery Slim 3.4.1 | 20 | | ------------------ | ----------- | ----------- | ----------- | ----------------- | 21 | | Unminified | **13.9 KB** | 36.5 KB | 58.7 KB | 227 KB | 22 | | Minified | **7.8 KB** | 16 KB | 26 KB | 71 KB | 23 | | Minified & Gzipped | **2.6 KB** | 6 KB | 9.8 KB | 24.4 KB | 24 | 25 | When it comes to size, Rotten.js totally shine, so if you want your website to be fast and light, Rotten.js can be a great option! 26 | 27 | ## Getting started 28 | ### Installation 29 | You can clone RottenJS with git: 30 | 31 | git clone https://github.com/nguyenphuminh/RottenJS.git 32 | 33 | Or you can just pull it from unpkg.com by adding this to your .html file: 34 | 35 | 36 | 37 | Or from npm: 38 | 39 | npm install rottenjs 40 | 41 | If you're using NodeJS, please consider check out this code first: 42 | 43 | // Import rottenjs to "rotten" 44 | const rotten = require("rottenjs"); 45 | // Using rt() 46 | const rt = rotten.rt; 47 | // const rdom = rotten.rdom; 48 | // const rUI = rotten.rUI; 49 | // const rDev = rotten.rDev; 50 | 51 | ### Documentations 52 | * Current 53 | * 1.x versions 54 | 55 | ## Pros and Cons 56 | ### Pros 57 | * Written in pure Javascript, easy to setup and use, no toolings needed. 58 | * Lightweight. 59 | * All-in-one. 60 | 61 | ### Cons 62 | * Not optimized. 63 | * Works not that well with big sites 64 | 65 | ## Who is using RottenJS ? 66 | * Jolio 67 | * FreakC 68 | 69 | ## Social medias 70 | * Facebook 71 | * Website 72 | 73 | ## Copyrights and License 74 | Copyrights © 2020 Nguyen Phu Minh 75 | 76 | This library is licensed under the MIT License 77 | -------------------------------------------------------------------------------- /rotten.min.js: -------------------------------------------------------------------------------- 1 | function rt(e){"use strict";const t={el:document.querySelectorAll(e),attr:(e,l)=>{if(null==e){let e=[];return t.el.forEach(t=>e.push(t.attributes)),e}if(null==l)return t.el[0].getAttribute(e);t.el.forEach(t=>t.setAttribute(e,l))},mulAttr:e=>t.el.forEach(t=>e.forEach(e=>t.setAttribute(e[0],e[1]))),mulProp:e=>e.forEach(e=>t.el[0].setAttribute(e[0],e[1])),prop:(e,l)=>null==e?t.el[0].attributes:null==l?t.el[0].getAttribute(e):void t.el[0].setAttribute(e,l),mount:(e,l)=>{if(null!=e){let r=document.querySelector(e);r.innerHTML="back"===l?t.el[0].outerHTML+r.innerHTML:r.innerHTML+t.el[0].outerHTML}},removeAttr:e=>t.el.forEach(t=>t.removeAttribute(e)),removeProp:e=>t.el[0].removeAttribute(e),css:(e,l)=>{t.el.forEach(t=>{null===t.getAttribute("style")&&t.setAttribute("style","");let r=`;${t.getAttribute("style")};${e}:${l}`;t.setAttribute("style",r)})},mulCSS:e=>{t.el.forEach(t=>e.forEach(e=>{null===t.getAttribute("style")&&t.setAttribute("style","");let l=`;${t.getAttribute("style")};${e[0]}:${e[1]}`;t.setAttribute("style",l)}))},style:e=>{if(null==e)return t.el[0].getAttribute("style");t.el.forEach(t=>t.setAttribute("style",e))},hide:(e,l)=>{e=e||0,setTimeout(()=>{t.el.forEach(e=>e.style.display="none"),"function"==typeof l&&l()},e)},show:(e,l)=>{e=e||0,setTimeout(()=>{t.el.forEach(e=>e.style.display=""),"function"==typeof l&&l()},e)},fadeOut:(e,l)=>{null==e&&(e=0),t.el.forEach(t=>{t.style.opacity="0",t.style.transition=`opacity ${e}ms`}),setTimeout(l,e)},fadeIn:(e,l)=>{null==e&&(e=0),t.el.forEach(t=>{t.style.opacity="1",t.style.transition=`opacity ${e}ms`}),setTimeout(l,e)},text:e=>{if(null==e)return t.el[0].innerText;t.el.forEach(t=>t.innerText=e)},html:e=>{if(null==e)return t.el[0].innerHTML;t.el.forEach(t=>t.innerHTML=e)},body:e=>{if(null==e)return t.el[0].outerHTML;t.el.forEach(t=>t.outerHTML=e)},on:(e,l)=>t.el.forEach(t=>t.addEventListener(e,l)),off:(e,l)=>t.el.forEach(t=>t.removeEventListener(e,l)),append:e=>t.el.forEach(t=>t.innerHTML=`${t.innerHTML}${e}`),prepend:e=>t.el.forEach(t=>t.innerHTML=`${e}${t.innerHTML}`),remove:()=>t.el.forEach(e=>e.remove()),empty:()=>t.el.forEach(e=>e.innerHTML=""),input:(e,l,r)=>{let n=!1;if(null==e&&null==l&&null==r)return t.el[0].value;if("string"==typeof e)e===t.el[0].value?l():r();else if(Array.isArray(e)){for(i=0;i{let r=!1;for(let l=0;l{if(null==e)return t.el[0].value;t.el[0].value=e},check:(e,l)=>{if("function"!=typeof e||"function"!=typeof l)return t.el[0].checked;t.el[0].checked?e():l()},click:e=>"function"==typeof e&&t.el.forEach(t=>t.onclick=(()=>e())),hover:(e,l)=>{null!=e&&void 0!==l&&null!==e&&t.el.forEach(t=>{t.onmouseleave=(()=>e()),t.onmouseenter=(()=>l())})},title:e=>{if("undefined"==typeof title||null===title)return t.el[0].title;t.el.forEach(t=>t.title=e)},scroll:()=>t.el[0].scrollIntoView({behavior:"smooth"}),newEl:(e,l,r,n)=>{if(null==r&&(r="front"),null!=e&&"undefined"!==l&&null!==l){let o=document.createElement(e);o.innerHTML=l,n.forEach(e=>o.setAttribute(e[0],e[1])),"front"===r?t.el.forEach(e=>e.append(o)):"back"===r&&t.el.forEach(e=>e.prepend(o))}},appendEl:(e,l)=>{l&&t.el.forEach(e=>e.innerHTML=""),t.el.forEach(t=>t.append(e))},disableEl:e=>t.el.forEach(t=>t.removeChild(e)),prependEl:e=>t.el.forEach(t=>t.prepend(e)),sameEl:e=>t.el[0].outerHTML===e.outerHTML,addClass:e=>t.el.forEach(t=>t.classList.add(e)),removeClass:e=>t.el.forEach(t=>t.classList.remove(e)),hasClass:e=>t.el[0].classList.contains(e),toggleClass:e=>t.el.forEach(t=>t.classList.toggle(e)),rotate:(e,l)=>{null==e&&(e=1);let r=e,n=0,o=1;l.loop?(void 0!==l.delay&&null!==l.delay||(l.delay=1),t.rot=setInterval(()=>{r>=1?n>=360&&(n=0,o++):n<=-360&&(n=0,o++),t.el[0].style.transform=`rotate(${n}deg)`,n+=r,o===l.count&&l.end&&clearInterval(t.rot)},l.delay)):t.el[0].style.transform=`rotate(${r}deg)`},tclick:e=>!(null==e)&&t.el.forEach(t=>t.ondblclick=e),parent:()=>t.el[0].parentNode,child:()=>t.el[0].children,first:()=>t.el[0],typing:e=>{let l=0,r=e.str,n=e.speed;if(e.clrPrev&&(t.el[0].innerHTML=""),e.loop){void 0!==e.delay&&null!==e.delay||(e.delay=1e3);let o=()=>{l{l=0,t.el[0].innerHTML="",o()},n*r.length+e.delay)}else{let e=()=>{lArray.prototype.filter.call(t.el[0].parentNode.children,e=>e!==t.el[0]),switch:e=>{let l,r;t.el.forEach(t=>{r=document.querySelector(e),l=t.outerHTML,t.outerHTML=r.outerHTML,r.outerHTML=l})},is:e=>t.el[0].outerHTML===e,same:e=>t.el[0].innerHTML===e,next:()=>t.el[0].nextElementSibling,prev:()=>t.el[0].previousElementSibling};return t}const rdom={el:(e,t,l)=>(nel=document.createElement(e),null!=t&&("string"==typeof t?nel.innerHTML=t:Array.isArray(t)&&t.forEach(e=>nel.append(e))),void 0!==typeof l&&null!==l&&l.forEach(e=>nel.setAttribute(e[0],e[1])),nel),render:(e,t,l,r)=>{r&&(t.innerHTML=""),null==l&&(l="front"),"front"===l?t.append(e):"back"===l&&t.prepend(e)},remove:(e,t)=>t.removeChild(e),attr:(e,t)=>t.forEach(t=>e.setAttribute(t[0],t[1])),style:(e,t)=>e.setAttribute("style",t),css:(e,t)=>{t.forEach(t=>{null===e.getAttribute("style")&&e.setAttribute("style","");let l=`${e.getAttribute("style")};${t[0]}:${t[1]}`;e.setAttribute("style",l)})},contains:(e,t)=>e!==t&&e.contains(t),on:(e,t,l)=>e.addEventListener(t,l),off:(e,t,l)=>e.removeEventListener(t,l)},rUI={setBGVideo:e=>{let t=document.querySelector("body");if(t.innerHTML='