Gradient effects implemented with Jobj _js object-oriented

Source: Internet
Author: User
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; Charset=utf-8 "/> <title> Cloud Habitat Community www.jb51.net</title> <script language=" javascript "type=" text/ JavaScript > function ($) {$.ispercent = function (p) {return/^ (\d*) (\.?) (\d*)%$/.test (p); var __alert__ = $.alert; $.alert = function () {var arg,s= ""; for (var i=0;arg = arguments[i];i++) {s + = arg + "\ n"} __alert__ (s); }) (window); String.prototype.trim = function () {return this.replace (^\s*) | ( \s*$)/g, ""); var jobj = {}; (function ($) {/*----------------------------------------------------------------------------Config Private----- -----------------------------------------------------------------------*/var Config = {}; (function ($) {$. Const = {}; $.Path = {}; $.loadedmodule = {}; } (Config) $. $getConfigConst = function () {return config.const; $. $getConfigPath = function () {return config.path; $. $getConfigLoaded = function () {return config.loadedmodule; }/*----------------------------------------------------------------------------Error jobj.error------------- ---------------------------------------------------------------*/ $. Error = {}; (function ($) {$.debug = true; var errorlist = {}; $. $pushError = function (msg,e) {}}) ($. ERROR)/*----------------------------------------------------------------------------Dom operater jobj.dom objec T----------------------------------------------------------------------------*/var domobj = function () {var $ = this; var object; $. $setHTMLObject = function (p) {object = P; Alert ($. $setHTMLObject. Caller); $. $getHTMLObject = function () {return object $. $appendTo = function (p) {f = jobj.dom.$ (P,false) | | document.body; F.appendchild (object); return $; } $. $attr = function (k,v) {object.setattribute (k,v); Object[k] = v; return $; $. $attrs = function (rule) {var k; For (k in rule) {$. $attr (K,rule[k]); } return $; } $. $css = function (k,v) {object.style[k] = V; return $; $. $csss = function (rule) {var k; For (k-rule) $. $CSS (K,rule[k]); return $; } } $. Dom = {}; (function ($,$$) {var domobj = new Domobj (); $.$ = function (p,f) {var o = typeof (P) = = "Object"? P:document.getelementbyid (P); if (f!== false) {domobj. $setHTMLObject (o); return domobj; }else return o; $. $tag = function (p) {return o = document.getElementsByTagName (p); } $. $c = function (p,n) {var o; try{if (n) o = document.createelemnet ("<" + p + "Name=" + N +"' >"); else o = document.createelement (p); }catch (e) {o = Document.createelement (p); O.name = name; Domobj. $setHTMLObject (o); return domobj; } })($. dom,$)/*----------------------------------------------------------------------------------Browser Check jobj.br Owser Object----------------------------------------------------------------------------------*/$. Browser = {}; (function ($) {var $FV = function () {var f= "-1", n=navigator; if (n.plugins && n.plugins.length) {for (Var ii=0;ii<n.plugins.length;ii++) {if (N.plugins[ii].nam E.indexof (' Shockwave Flash ')!=-1) {f=n.plugins[ii].description.split (' Shockwave flash ') [1]; Break else if (window. ActiveXObject) {for (Var ii=10;ii>=2;ii--) {try {var fl=eval ("New ActiveXObject" (' shockwaveflash.sh Ockwaveflash. " +ii+ ""); if (fl) {f=ii + '. 0 '; break;} }catch (e) {} } if (f = = "-1") return F; else return f.substring (0,f.indexof (".") +2}//notice:firefox, NS can ' t use Property:name (case sensitive)! Because it ' s a hold field, and it ' s values is anonymous. var n_ = Navigator,s_ = screen; var B = n_.appname; var ua = N_.userAgent.toLowerCase (); $.name = "Unknow"; $.safari = Ua.indexof ("Safari") >-1; Always check for Safari & Opera $.opera = Ua.indexof ("opera") >-1; Before ns or IE $.firefox = ua.indexof (' Firefox ') >-1; Check for Gecko engine $.ns =!$.firefox &&!$.opera &&!$.safari && (b== "Netscape"); $.ie =!$.opera && (b== "Microsoft Internet Explorer"); $.name = ($.ie? "IE": ($.firefox?) "Firefox": ($.ns?) "Netscape": ($.opera?) "Opera": ($.safari?) "Safari": "Unknow"))); Switch ($.name) {case "opera": $.fullversion = Ua.substr (Ua.indexof ("opera") + 6); Break Case "IE": $.fUllversion = Ua.substr (Ua.indexof ("MSIE") + 5). Split (";") [0]; Break Case "Firefox": $.fullversion = Ua.substr (Ua.indexof ("Firefox") + 8); Break Case "Safari": $.fullversion = Ua.substr (Ua.indexof ("version") + 8). Split ("") [0]; Break Case "Netscape": $.fullversion = Ua.substr (Ua.indexof ("Netscape") + 9); Break Default: $.fullversion = "-1"; } $.version = parsefloat ($.fullversion); $.flashversion = $FV (); $.cookieenabled = n_.cookieenabled; $.javaenabled = n_.javaenabled (); })($. Browser); /*----------------------------------------------------------------------------------Cookie Operate Jobj.cookie Object----------------------------------------------------------------------------------*/$. Cookie = {}; (function ($) {$. $get = function () {var cookies = Document.cookie; if (cookies = = "") return; cookies = Cookies.split (';'); for (Var i=0 i < cookies.length i++)/BrEak each pair to an array cookies[i] = cookies[i].split (' = '); for (var i = 0; i < cookies.length i++) {$[(cookies[i][0]). Trim ()] = decodeURIComponent (cookies[i][1)); } $. $get (); $. $save = function (daystolive, path, domain, secure) {var dt = (new Date ()). GetTime () + daystolive * 24 * 60 * 60 * 10 00; For (Var prop in $) {if (typeof $[prop] = = ' function ') continue; var cookie = ""; Cookie = prop + ' = ' + encodeURIComponent (This[prop]); if (daystolive | | daystolive = = 0) cookie + "; expires=" + New Date (DT). toUTCString (); if (path) cookie = = ";p ath=" + path; if (domain) cookie = "; domain= "+ domain; if (secure) cookie = "; secure"; Document.cookie = cookie; } $. $remove = function (path, domain, secure) {$.save (0, path, domain, secure); For (Var prop in this) {if (typeof This[prop]!= ' function ') delete This[prop]; } } })($. Cookies); /*------------------------------------------------------------------------------stylesheets Operate; ------------------------------------------------------------------------------* * * $.stylesheets = {}; /*------------------------------------------------------------------------------Ajax Operate; ------------------------------------------------------------------------------*/ $. Ajax = {}; (function ($,$$) {$. $getXMLHttp = function () {var xmlHttp = null; if ($$. browser.ie && $$. Browser.version < 7) {var v = [' MSXML2. xmlhttp.8.0 ', ' MSXML2. xmlhttp.7.0 ', ' MSXML2. xmlhttp.6.0 ', ' MSXML2. xmlhttp.5.0 ', ' MSXML2. xmlhttp.4.0 ', ' MSXML2. xmlhttp.3.0 ', ' MSXML2. xmlhttp.2.6 ', ' MSXML2. XMLHTTP ', ' microsoft.xmlhttp ']; if (typeof (Config.Const.ACTIVEXOBJECT_XMLHTTP) = = "string") v[0] = Config.Const.ACTIVEXOBJECT_XMLHTTP; for (var i=0;v_ = v[i];i++) {try{xmlHttp = new ActiveXObject (V_); Config.Const.ACTIVEXOBJECT_XMLHTTP = V_; Break }catch (e) {}}}else{xmlHttp = new XMLHttpRequest (); } if (xmlHttp = null) {alert ("Your system does not support Ajax"); return xmlHttp; $. $load = function () {} $. $attr = function (p,k) {return P.attributes.nameditem (k); } })($. ajax,$); var $getBasePath = function () {var scripts,script; Scripts = Document.scripts | | $.dom. $tag ("SCRIPT"); for (var i=0;script = scripts[i];i++) {var matchs = Script.src.match (/(. *) jobj.js$/i) | | []; if (1 in matchs) {basepath = matchs[1]; Config.Path.basePath = matchs[1]; Break }} $getBasePath (); }) (Jobj); </script> </pead> <body> <div id= "AA" ></div> <script language= "javascript" type= "Tex" T/javascript "> for (var i=0;i<20;i++) {h = w = 400-i * +" px "; c = "#" + (parseint ("ffffff")-I *). toString (16); Jobj.dom. $c ("DIV"). $ATTR ("id", "div_" + i). $appendTo ("div_" + (i-1)) . $csss ({position: "relative", Top: "10px", Left: "10px"}). $css ("width", W). $css ("height", h). $CSS ("BackgroundColor", C ); } </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.