Element

- null_translator: This function will change word or list of words to other languages, It can be used as a local translator for a webpage. it can be used as writer from JS directly. It takes two arguments the first one is the selector for the element, and the second is an object contains key => language code and the value => word in certian language.

HTML |
<div class="nullText">Hello</div>
JS |
    null_translator(".nullText",{
        en:"Hello",
        fr:"Bonjour",
    });

- null_add_style: This function allows you to add one or more CSS styles to an element. It takes two arguments the first one is the selector for the element, and the second is an object containing CSS properties and values or a string of CSS rules. If using an object, the keys should be property names and values should be property values. If using a string, it should contain valid CSS rules for the element.

HTML |
<div class="box">How are you?</div>
JS |
null_add_style(".box",{
     'background':"red",
     'color':'var(--null-color-white)',
});

You can add same styles to multi elements:

HTML |
<div class="box1">How are you?</div>
<div class="box2">How are you?</div>
JS |
null_add_style([".box1", ".box2"],{
     'background':"red",
     'color':'var(--null-color-white)',
});

- null_truncate: Truncates any text to the specified number of characters or the end of the last word. It takes two arguments the first one is the selector for the element, and the second is a number of characters to display or last word to display as entire word.

HTML |
    <p class="content">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Excepturi veniam ab pariatur reiciendis vitae dolore nesciunt ut eaque! Aut cumque sapiente voluptatum corrupti. Laboriosam officia repellat quam! Cumque minus et repudiandae aliquam, vitae optio voluptatibus! Laboriosam voluptatem veritatis quisquam inventore commodi assumenda, eveniet vitae explicabo ratione natus. Sint neque numquam qui odit minima suscipit non ea in ipsum, reprehenderit perferendis asperiores, quaerat enim ullam ad. Dicta optio odio iste quasi maiores voluptates omnis. Exercitationem pariatur voluptate expedita id culpa dolores delectus, impedit ipsa veritatis ad nemo possimus doloremque eos odit, debitis repudiandae itaque eaque voluptates provident? Assumenda incidunt corrupti nemo?</p>
    <p class="content">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Excepturi veniam ab pariatur reiciendis vitae dolore nesciunt ut eaque! Aut cumque sapiente voluptatum corrupti. Laboriosam officia repellat quam! Cumque minus et repudiandae aliquam, vitae optio voluptatibus! Laboriosam voluptatem veritatis quisquam inventore commodi assumenda, eveniet vitae explicabo ratione natus. Sint neque numquam qui odit minima suscipit non ea in ipsum, reprehenderit perferendis asperiores, quaerat enim ullam ad. Dicta optio odio iste quasi maiores voluptates omnis. Exercitationem pariatur voluptate expedita id culpa dolores delectus, impedit ipsa veritatis ad nemo possimus doloremque eos odit, debitis repudiandae itaque eaque voluptates provident? Assumenda incidunt corrupti nemo?</p>
    <p class="content">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Excepturi veniam ab pariatur reiciendis vitae dolore nesciunt ut eaque! Aut cumque sapiente voluptatum corrupti. Laboriosam officia repellat quam! Cumque minus et repudiandae aliquam, vitae optio voluptatibus! Laboriosam voluptatem veritatis quisquam inventore commodi assumenda, eveniet vitae explicabo ratione natus. Sint neque numquam qui odit minima suscipit non ea in ipsum, reprehenderit perferendis asperiores, quaerat enim ullam ad. Dicta optio odio iste quasi maiores voluptates omnis. Exercitationem pariatur voluptate expedita id culpa dolores delectus, impedit ipsa veritatis ad nemo possimus doloremque eos odit, debitis repudiandae itaque eaque voluptates provident? Assumenda incidunt corrupti nemo?</p>
JS |
null_truncate(".content",20);

- null_create_element: This function will create an HTML element with customizable options.

This function takes two arguments, the first one is the HTML tag for the element that will be created, the second is an object that has set of keys as shown below: 

Option Value Description
id text | number To create an ID for parent element.
classes array To create array of classes for parent element.
title text | number To create a title for parent element.
attributes object To create html attributes for parent element, such as custom attributes, src for image , audio and video, href for anchor, noting that the attribute will be the key and the value will be the value of attribute.
html html To create html code for parent element where you can create children.
text text | number To create text for parent element, noting that you will be able you use text or html.
callBack function To execute a call back function with the created element.
append object To append a parent element to the DOM, you need to specify the position of the element using the "position" key, which has three possible values: "inside", "before", or "after". also, you need to specify the target element on the HTML page where the newly created element will be appended.

Create a div with children:

HTML |
<div id="null"></div> <!-- div to hold the created element with its children -->
JS |
null_create_element("div",{

     id="nullParent",
     classes:["classOne","classTwo","classThree"],
     title:"Hello From Null",
     attributes:{
          data-null:"data-null"
     },
     html:`<div>Hello From <b>Null</b>`,
     append:{
          position:"inside",
          target:document.getElementById("null"),
     }

});

Create an image:

HTML |
<div id="null"></div> <!-- div to hold the created element with its children -->
JS |
null_create_element("img",{
    classes:["null-image-responsive"],
    attributes:{
        src:"",
        width:625,
        height:460,
        alt:"Null Image",
    },
    append:{
        position:"inside",
        target:document.getElementById("null")
    }
});

Create a link:

HTML |
<div id="null"></div> <!-- div to hold the created element with its children -->
JS |
null_create_element("a",{
    classes:["null-link"],
    text:"Null Link",
    attributes:{
        "href":"",
        "aria-label":"Null Link",
    },
    append:{
        position:"inside",
        target:document.getElementById("null")
    }
});

- null_add_classes: This function will add a class or more to an element. It takes two arguments the first one is the selector for the element, and the second is an array of classes to add to the element.

HTML |
<div id="null">
        <div>Hello From Null</div>
</div>
JS |
null_add_classes("#null",["null-box-shadow","null-padding-20"]);

- null_process: Process element(s) by executing a callback function on each matched element. It takes two arguments the first one is the selector to match elements (ID or class), and the second is a callback function to be executed on each matched element.

HTML |
<div class="box">One</div>
<div class="box">Two</div>
<div class="box">Three</div>
JS |
null_process(".box", function (e) {
    e.addEventListener("click", function () {
        e.classList.toggle("active");
    });
});
HTML |
<div id="null">Hi</div>
JS |
null_process("#null", function (e) {
    e.addEventListener("click", function () {
        console.log(e.innerText);
    });
});