Hui 2.x.js Official documentation

Source: Internet
Author: User

Basic method

Determines whether the value is the specified data type        var result = Hui.istargettype ("White sign Software", "string");  =>true        var result = Hui.istargettype (123, "number");   =>true        var result = Hui.istargettype ("false", "Boolean");  =>false

Determine if the data type is undefined type        var result = hui.isundefined (undefined);    =>true        var result = hui.isundefined (null);//=>false

Determine if the value is a valid value, non-undefined and non-null        var result = Hui.isvalid ("Hundred Sign Software");   =>true        var result = Hui.isvalid (null);//=>false

  

Determines whether a numeric type, including the string value        var result = Hui.isnumber ("123");   =>true        var result = Hui.isnumber (456);//=>true        var result = Hui.isnumber ("123a");  False

  

Determines whether the function type        var result = hui.isfunction (function () {});   =>true        function Get () {        };        var result = Hui.isfunction (get);   =>true        var result = Hui.isfunction ("abc");//=>false

  

Determines whether the Boolean type is        var result = Hui.isboolean (false);  =>true        var result = Hui.isboolean (true);   =>true        var result = Hui.isboolean ("true");    =>false

  

Determines whether the string type is        var result = hui.isstring ("");  =>true        var result = hui.isstring ("Hundred Sign Software");  =>true        var result = hui.isstring (123);//=>false        var result = hui.isstring (null);    =>false

  

Determine if the date type is        var result = Hui.isdate ("2016-08-24");  =>true        var result = Hui.isdate ("2016/08/24");  =>true        var result = Hui.isdate ("2016-2-1");    =>true        var result = Hui.isdate ("2016-08-24 18:06");    =>true        var result = Hui.isdate ("2016-08-24 18:06:25");    =>true        var result = Hui.isdate ("2016/08/24 18:06:25");    =>true        var result = Hui.isdate ("16/08/24");    =>false        var result = Hui.isdate ("08-24");   =>false

  

  Determines whether a positive        var result = Hui.isplusdecimal (1);  =>true        var result = Hui.isplusdecimal ( -1);  =>false        var result = Hui.isplusdecimal (+1);  =>true        var result = Hui.isplusdecimal ("ten");  =>true

  

Determines if the JSON type is        var obj = "string";        var result = Hui.isjson (obj);   =>false        var obj1 = new String ("abc");        var result = Hui.isjson (obj1);   =>false        var obj3 = {            name: "Hundred sign Software",            autor: "Hundred Small Monk"        };        var result = Hui.isjson (OBJ3);   =>true        var obj4 = ["Hundred Sign Software", "Hundred small Monk"];        var result = Hui.isjson (OBJ4);   =>false        var obj5 = [{name: "Hundred sign Software", Autor: "Hundred Small Monk"}];        var result = Hui.isjson (obj5);   =>false

  

Determine if the array type is        var arr = ["Hundred Sign Software", "Hundred small Monk"];        var result = Hui.isarray (arr);  =>true        var arr1 = new Array (1, 3, 4);        var result = Hui.isarray (ARR1); =>true        var arr2 = [{name: "Hundred sign Software", Autor: "Hundred Small Monk"}];        var result = Hui.isarray (ARR2); =>true        var arr3 = [];        var result = Hui.isarray (ARR3); =>true

  

Determine if the HTML element        var result = Hui.iselement (document.body);  =>true        var result = Hui.iselement (document.getElementById ("NAV"));  =>false, returns True if the element is found

  

Gets the custom class name        function persion (name, age) {            this.name = name;            This.age = age;        }        var p = new Persion ("Hundred Small Monk", at a);        var result = Hui.getcustomtype (p);  =>persion

  

Get method Name, non-anonymous method, need to pass in method string        var result = Hui.getfunctionname ("function GetName () {}");  =>getname

  

Remove the front and back space        var result = Hui.trim ("Hundred Small Monk"); = = Hundred small Monk        var result = Hui.trim ("Hundred Small Monk");    The Hundred monks

  

Remove all spaces        var result = Hui.trimall ("Hundred Small Monk");    The Hundred monks

  

The judgment is whether the API object exists and is usually used to determine if the Apicloud development environment is        var result = Hui.apiexit ();//=>false        apiready = function () {            var result = Hui.apiexit (); =>true        };        Hui.ready = function () {            var result = Hui.apiexit ();//=>true        };

  

Serializes an object into a string, that is, you can see the internal structure        var obj = {name: "Hundred sign Software", Autor: "Hundred Small Monk"};        var result = Hui.objparse (obj); = "{name:" Hundred sign Software ", Autor:" Hundred Small Monk "}"

  

Generates a unique GUID string, 32-bit unique code        var guid = Hui.guid ();  =>abf9a9a2-8ef9-b291-e557-579f8271f3cf

  

Serialize JSON object to URL format        var obj = {name: "Hundred sign Software", Autor: "Hundred Small Monk"};        var result = Hui.serialize (obj);    =>&name= hundred sign software &autor= hundred small Monk

  

Get the variable value corresponding to the format type, method eval Call        var val = "123";        var reslut = Hui.getvaluetypeformat (val);   = "123"

  

Object copy, inherit, and return new object, support deep copy        var a = {name: "Hundred Sign Software"};        var B = {autor: "Hundred Small Monk"};        var result = Hui.deepassign ({}, A, b);  =>{name: "Hundred sign Software", Autor: "Hundred Small Monk"}        var c = {name: "Hundred sign Software", Autor: "Renaissance Emperor"};        var d = {autor: "Hundred Small Monk", age:23};        var result = Hui.deepassign ({}, C, D);  =>{name: "Hundred sign Software", Autor: "Hundred Small Monk", age:23}

  

Dom Operation Methods

Gets the DOM node based on        the ID name var header = Hui.byid ("header");

  

Gets the DOM node        var footers = hui.byclassname ("Hui-footer") according to the class attribute name;

  

Gets the DOM node        var elements = hui.bytagname ("<div>") according to the tag name;

  

Imitating the jquery $ selector syntax, the difference is that hui.js always returns the array type        var header = hui.$ ("header") [0];        var divs = hui.$ ("div");        var txt = hui.$ ("input[type= ' text ']");

  

Get a single DOM node        var header = Hui.single ("header");

  

Gets the first DOM node of        the var div = Hui.first ("Div.nav");

  

Gets the last Dom node        var li = hui.last ("ul Li");

  

Find the specified DOM element        var header = Hui.find (Document.body, ". Nav");

  

Gets the value of the CSS property        var val = hui.getcss (document.body, "Margin-left");   =>0px

  

Gets the offset of the DOM element        var offsetobj = Hui.offset (Hui.single ("header"));   = = {T:0,l:0,w:320,h:44}

  

Load the template defined by the link import tag

         /* * Load link Import Template         * input parameter:         * templateselectors:link Template content Selector         * targetselectors: Append to specified DOM element after loading template         */        hui. Loadlinktppl (". Tppl", document.body);

  

JavaScript template engine

<!--definition template, <%%> wrapped JavaScript code, <%=%> output variable--<script type= "text/html" id= "TPPL" > <%    for (var i=0; i < list.length;i++) {%> <li> name: <%=list[i].name%></li> <%}%> </script> <script type= "Text/javascript" >//Define data collection, must be JSON type var data = {list:                [{name: "Hundred sign Software", Autor: "Hundred Small Monk", age:23        }            ]        }; Call HUI.TPPL (Tpl,data);        Returns HTML after rendering, cannot render multiple data collections repeatedly var html = HUI.TPPL (document.getElementById ("Tppl"), data);        It is also possible to call var render = Hui.tppl (document.getElementById ("TPPL"));        var html = render (data);                    Can load different data to render the same set of templates var html2 = render ({list: [{name: "Hui 2.x",    Autor: "Hundred Small Monk"}]}); </script>

  

Hui 2.x.js Official documents

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.