Ntv.js Framework (chapter fourth)-1common.js and 2core.js

Source: Internet
Author: User

1common.js Source code:

The global $ object, similar to the naming of the jquery framework, is used to shorten the function name and refine the code. This file contains only common objects that provide global scope.

var $ = function (selector) {}; function encapsulation of the ID selector. Call $ ("#Id"), $ ("TagName")

$.ajax = function (o) {}; function encapsulation of AJAX functions. Call $.ajax ({type:post, url: "...", Data: {...}});

2core.js Source code:

The global NTV object contains 2 parts, a log Debug class, and a browser platform information detection class.

var NTV = NTV | |   {}; each NTV module file header uses this method to extend the object. This means that if the context already exists, the NTV object returns an existing NTV object and creates an empty object if it does not exist. This approach also does not depend on writing an object to multiple files in the order in which they are referenced in the page.


Ntv.log class, Debug mode of the log output implementation and debug mode open and close.

Ntv.log.debug = Boolean; Whether to turn on debug mode.

Ntv.log.console = function (str) {}; Output logs. Call Ntv.log.console ("$PAGE, log Information");

Ntv.log.filter = function (str) {}; Log information filtering class.

You can use ntv.log.console ("Log information") anywhere after the reference to this article to output debugging information on the page. However, it is important to note that because the framework source code has built up a lot of log output (for development debugging), so if only using ntv.log.console ("Log Information"), the way to output our own debugging information on the page, will result in the frame with hundreds of log information output mixed in a piece , this is not conducive to our attention to the log information we want, it is the existence of filter, you can set the filter key to filter output to the page information, such as when you debug the set-top box key value code, you can open "Ntv.key" The object function log output begins (the framework defines different key headers for the log information of different pairs of images). The developer's debugging information on the page suggests using ntv.log.console ("$PAGE, log Information"); The log information beginning with "$PAGE" is turned on by default.


Ntv.profile class



Debug mode effects:


Ntv.js Framework (chapter fourth)-1common.js and 2core.js

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.