Home Web Front-end JS Tutorial JavaScript framework summary personal work experience_javascript skills

JavaScript framework summary personal work experience_javascript skills

May 16, 2016 pm 06:51 PM
js frame

/***************************************************** ************************************ Author: Xiao Feng
QQ:77182997
MSN :xiaofengnet@hotmail.com
Email:xiaofengnet@163.com
Website: http://www.d369.net
Please retain the copyright and thank you for your cooperation
Version: V 1.6.1
/****************************************************** ****************************************
/*
is XiaoFeng .System adds a method Scroll [2009-02-18] V 1.4.1
adds a method Index to Array [2009-04-09] V 1.4.2
adds TrimStart, TrimEnd, Trim, StartsWith to String ,EndsWith function[2009-04-09] V 1.4.3
Add toFixed method to Number to realize the number of decimal places retained [2009-04-17] V 1.4.4
FileType to obtain the name and file of the file The suffix name [2009-04-20] V 1.4.5
XiaoFeng.Dialog opens the selection window and save window [2009-05-28] V 1.4.6
Add the method getType to each object through the Object class Get the parent node of the object getParent[2009-06-04] V 1.4.7
Update method getQuery(s) U defaults to the current address bar address, s is the parameter passed in to be extracted getQuery(U,s) U For the passed in address s and for the passed in parameters to be extracted [2009-06-08] V 1.4.8
Add two methods for String wTh full-width conversion to half-width and hTw half-width conversion to full solution [2009-06-08 ] V 1.4.8
Changed a method ajax.Fun = function(){} in the ajax class when it is being processed, and an attribute ajax.Error that determines whether the server handler has an error [2009- 06-09] V 1.4.9
Rewritten the methods of String, Array, Object, and Element [2009-06-12] V 1.5.0
Added the capture event source getElement XiaoFeng.getElement [2009-06 -12] V 1.5.1
Updated the loading XML function to be compatible with FF IE LoadXml() [2009-06-12] V 1.5.2
Added the function unlimited drop-down list SelectClass [2009-06-13] V 1.6.0
Updated that when the selection of the infinite drop-down list is empty, the selected value is the value of the previous level drop-down list [2009-06-13] V 1.6.1
*/
/*======================================== ================================================== =
Core content of the framework--------[Basic tool class]
============================ ================================================== ===========
*/
if(!window.XiaoFeng || !XiaoFeng || typeof XiaoFeng == "undefined")var XiaoFeng = window.XiaoFeng = new Object() ;
var Prototype = {
Version: "1.4.9",
ScriptFragment: '(?:)((n|r|.)*?)(?:)',
emptyFunction: function(){},
K: function(e){return e}
}
/*================================== ================================================== =====
【Add static method to Object class】
Created on [2008-08-13]
Add static method to Object class: extend
*/
Object.extend = function(destination,source){
for(property in source)destination[property] = source[property];
return destination;
}
//Add for each object through the Object class Method extend
Object.prototype.extend = function(object){return Object.extend.apply(this,[this,object]);}
/*============ ================================================== =============================
[Add attributes to the array]
[Created on 2009-06-12]
Add additional attributes to the array
*/
Object.extend(Array.prototype,{
remove : function(N){//Remove the specified element
if(isNaN(N )||N>this.length)return false;
for(var i=0,n=0;ithis.length -= 1;
},
add : function(v){//Add an array element
for(var i=0;iif(this[i].toString() == v.toString()) break;
this.push(v);
},
index : function(s){// Specify the index of the element in the array
var FlagIndex = -1;
for(var i = 0;i if(this[i].toString() == s. toString()){FlagIndex = i; break;}
return FlagIndex;
},
first : function(){return this[0];},//The first element in the array
last : function(){return this[this.length - 1];},//The last element in the array
clear : function(){this.length = 0; return this;}//Clear the array element
});
/*======================================== ================================================== ====
[Add attributes to string]
[Created on 2009-06-12]
Add additional attributes to string
*/
Object.extend(String.prototype ,{
len : function(){return this.replace(/[^x00-xff]/g,"ya").length;},//The length of the string, one Chinese character is two
Length : function(){
var M = 0;
for(var i=0;iif(this.charCodeAt(i) > 255)
M = M 2;
else
M = M 1;
}
return M;
},
Trim : function(s){return this.TrimStart(s). TrimEnd(s);},//Clear the specified characters at the beginning and end
TrimStart: function(s){//Clear the specified characters at the beginning
if(!s)s = "\s ";
var trimStartStr = new RegExp("^(" s ") ","g");
return this.replace(trimStartStr,"");
},
TrimEnd : function(s){ //Clear the specified characters at the end
if (!s)s = "\s ";
var trimEndStr = new RegExp("(" s ") $","g");
return this .replace(trimEndStr,"");
},
StartsWith : function(s){
if (!s)s = "\s";
var startsWithStr = new RegExp("^(" s ")","g");
return startsWithStr.test(this);
},
EndsWith : function(s){
if (!s)s = "\s";
var endsWithStr = new RegExp("(" s ")$","g");
return endsWithStr.test(this);
},
wTh : function(){//全角转换半角
var s = "";
for(var i = 0;i s = this.charCodeAt(i) >= 65248?String.fromCharCode(this.charCodeAt(i) - 65248):this.charAt(i);
return s;
},
hTw : function(){//半角转换全角
var s = "";
for(var i = 0;i s = this.charCodeAt(i) return s;
},
LeftStr : function(M){//左边指定长度字符
if(this.Length() > M){
var str = "";
for(var i=0;iif(this.charCodeAt(i) > 255)
M -= 2;
else
M -= 1;
str = this.substring(i,i 1);
if(M }
return str "...";
}else
return this;
},
stripTags : function(){return this.replace(/?[^>] >/gi, '');}
});
/*===========================================================================================
【取得数字小数点后几位】
[创建于2009-06-12]
为数字添加附加属性
*/
Object.extend(Number.prototype,{
toFixed : function(N){//格式化数字
if(arguments.length == 0)N = 2;
with(Math){var m = pow(10,Number(N));var s = (round(this*m)/m).toString();}
if(s.indexOf('.') s = ".";
s = "000000000000000000000000000000";
}
return s.substr(0,s.indexOf('.') N 1);
}
});
/*========================================================================================
【获取一个指定ID的结点】
创建于[2005-05-03]
document.getElementById(Id)获取一个指定ID的结点,是这个方法的快捷方式和扩展可以指定多个参
数返回一个对象数组。The parameter does not have to be an ID but can also be a reference to the object itself. For example, $("id") is equivalent to $($("id"))
*/
var $ = XiaoFeng.$ = function( ){
var elements = new Array();
for(var i=0;ivar element = arguments[i];
if (typeof( element) == "string") element = document.getElementById?document.getElementById(element):document.all.element
if (arguments.length==1) return element;
elements.push(element) ;
}
return elements;
}
/*============================== ================================================== ========
[Get a node with a specified ID]
Created on [2005-05-03]
document.getElementsByName(id) gets a name set with a specified ID, yes Shortcuts and extensions of this method can specify multiple parameters and return an object array
*/
var $N = XiaoFeng.$N = function(){
var elements = new Array();
for(var i=0;ivar element=arguments[i];
if (typeof(element) == "string") element = document.getElementsByName?document .getElementsByName(element):document.all.element;
if (arguments.length==1) return element;
elements.push(element);
}
return elements;
}
/*============================================ ============================================
【Get one Node specifying TagName]
Created in [2005-05-03]
document.getElementsByTagName(TagName) gets a name set specifying TagName. It is a shortcut and extension of this method that can specify multiple parameters and return one Object array
*/
var $T = XiaoFeng.$T = function(){
var elements = new Array();
for(var i=0;ivar element = arguments[i];
if (typeof(element) == "string") element = document.getElementsByTagName(element);
if (arguments.length==1) return element;
elements.push(element);
}
return elements;
}
/*================== ================================================== ====================
【Create an element】
Created on [2008-06-18]
*/
var $ C = XiaoFeng.$C = function(){return document.createElement(arguments[0]);}
/*======================== ================================================== ===================
【Convert Array】
Created on [2008-08-13]
*/
var $A = XiaoFeng.$A = function(a){return a?Array.apply(null,a):new Array;}
/*==================== ================================================== ======================
[Catch event source]
Created on [2008-08-13]
*/
var getElement = XiaoFeng.getElement = function(){
if(arguments.length == 0)
return event.srcElement;
else
return document.all?arguments[0].srcElement :arguments[0].target;
}
/*================================== ================================================== =====
[Add events, unloading events and mouse coordinates to the Object class]
Created on [2008-10-09]
Add events, unloading events and mouse coordinates to the Object class:
*/
Object.extend(Object.prototype,{
addEvent : function(a, b, c, d){
//Add function
if(a.attachEvent)a.attachEvent (b[0], c);
else a.addEventListener(b[1] || b[0].replace(/^on/, ""), c, d || false);
return c;
},
delEvent : function(a, b, c, d){
if(a.detachEvent) a.detachEvent(b[0], c);
else a .removeEventListener(b[1] || b[0].replace(/^on/, ""), c, d || false);
return c;
},
Event : function (){//Get Event
return window.event ? window.event : (function (o){
do{
o = o.caller;
} while (o && !/^ [object[ A-Za-z]*Event]$/.test(o.arguments[0]));
return o.arguments[0];
})(this.reEvent);
},
Scroll : function(){
return {
Left : document.body.scrollLeft == 0?document.documentElement.scrollLeft:document.body.scrollLeft,
Top :document. body.scrollTop == 0?document.documentElement.scrollTop:document.body.scrollTop
};
}
});
/*============ ================================================== ==========================
[Judge the browser and its version number]
[Created on 2009-06-12]
*/
XiaoFeng.userAgent = function(){
var ua = navigator.userAgent.toLowerCase();
if(window.ActiveXObject)return {name : "IE",ver : ua .match(/msie ([d.] )/)[1]}
if(document.getBoxObjectFor)return {name : "Firefox",ver : ua.match(/firefox/([d.] )/ )[1]}
if(window.MessageEvent && !document.getBoxObjectFor)return {name : "Chrome",ver : ua.match(/chrome/([d.] )/)[1]}
if(window.opera)return {name : "Opera",ver : ua.match(/opera.([d.] )/)[1]}
if(window.openDatabase)return {name : " Safari",ver : ua.match(/version/([d.] )/)[1]}
return {name : "Other",ver : 0}
}
/*== ================================================== ====================================
[Relative coordinates of the mouse]
[Create on 2008-10-06]
*/
var Event = function(){
var e = Object.Event();
var o = {x : 0,y : 0};
switch(arguments[0]){
case 0:/*relative position of the mouse*/
o.x = e.clientX;
o.y = e.clientY;
break;
case 1:/*Absolute position of mouse*/
o.x = e.clientX Object.Scroll().Left;
o.y = e.clientY Object.Scroll().Top;
break;
default:/*relative position of the mouse*/
o.x = e.clientX;
o.y = e.clientY;
break;
}
return o;
}
/*================================================ ===========================================
【Ajax creation class ]
Created on [2008-05-30]
Updated on [2009-06-09]
var ajax = new AjaxRequest();
ajax.Url = "Test.aspx";
ajax.Content = "";
ajax.Fun = function(){alert("Extracting..");}
ajax.CallBack = function(e){
//Operation code
var XmlDoc=e.responseText;
var XmlDoc=e.responseXML;
var Roots=XmlDoc.documentElement.childNodes;
alert(Roots[0].childNodes[0].text);
}
ajax.Send();
*/
XiaoFeng.Ajax = AjaxRequest;
function AjaxRequest(){
var xmlhttp = false;
var self = this ;
this.Method = "post";
this.Url = "";
this.Content = "";
this.Async = true;
this.Fun = function( ){return;};
this.CallBack = function(obj){return;}
this.Error = null;
this.Create = function(){//Create XMLHttpRequest
if( typeof(window.XMLHttpRequest)!="undefined"){
xmlhttp = new XMLHttpRequest();
if(xmlhttp.overrideMimeType)xmlhttp.overrideMimeType("text/html");
}else if( window.ActiveXObject){
var Versions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
for(var i=0;itry{
var XmlHttp = new ActiveXObject(Versions[i]);
xmlhttp = XmlHttp;
}catch (Error){
if(i == (Versions.length-1))alert("Error: Failed to create server object instance.");//Browser problem//Throws Error.description
}
}
}
return xmlhttp;
}
this.Send = function(){
if(this.Url == ""){alert("The processing address cannot be Empty!");}
xmlhttp = this.Create();
xmlhttp.open(this.Method,this.Url,true);
if(this.Method == "post")xmlhttp .setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
if (xmlhttp.status == 200){
self.CallBack(xmlhttp);
}else{
alert("Error: Error code [" xmlhttp.status "]");
self. Error = "Server error [" xmlhttp.status "].";
clipboardData.setData("text",self.Url "?" self.Content);
self.CallBack(self);
}
}else
self.Fun();
}
if(this.Method.toLowerCase() == "post")
xmlhttp.send(this.Content);
else
xmlhttp.send(null);
}
}
/*======================== ================================================== ==============
[Create XML object class]
[Created on 2008-04-09]
var Http_Request=false;
*/
function CreateAjax(){
var Ajax_Obj;
if(typeof(window.XMLHttpRequest) != "undefined"){
Ajax_Obj = new XMLHttpRequest();
if(Ajax_Obj.overrideMimeType)Ajax_Obj .overrideMimeType("text/html");
}else if(window.ActiveXObject){
var Versions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp. 3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
for(var i=0;itry{
var XmlHttp=new ActiveXObject(Versions [i]);
Ajax_Obj = XmlHttp;
}catch(Error){
if(i == (Versions.length-1))alert("Error: Failed to create server object instance [Browser Problem].");//Browser problem//Throws Error.description
}
}
}
return Ajax_Obj;
}
/*===== ================================================== =================================
[Load XML operation class]
[Created in 2009- 06-12]
*/
function LoadXml(Path){
if(XiaoFeng.userAgent().name == "Firefox"){
var Dom = document.implementation.createDocument(" ", "", null);
Dom.async = false;
Dom.load(Path);
}else{
Dom = new ActiveXObject("Microsoft.XMLDOM");
Dom.async = false;
Dom.load(Path);
}
return Dom;
}
/*============== ================================================== ========================
[Cookies operation class]
[Created on 2008-04-09]
*/
var Cookies = {
GetVal:function(offset){//Get the decoded value of Cookie
var endstr = document.cookie.indexOf(";", offset);
if (endstr = = -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
},
Add:function(name,value,hours ){//Set Cookie value
var expire = "";
if(hours != null){
expire = new Date((new Date()).getTime() hours * 3600000) ;
expire = "; expires=" expire.toGMTString();
}
document.cookie = name "=" escape(value) expire;
},
Del:function( name){//Delete Cookie
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = GetCookie (name);
document. cookie = name "=" cval "; expires=" exp.toGMTString();
},
Get:function(name){//Get the original value of Cookie
var cookieValue = "";
var search = name "=";
if(document.cookie.length > 0 ){
offset = document.cookie.indexOf(search);
if (offset != -1){
offset = search.length;
end = document.cookie.indexOf("; ", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
},
get:function(name){/*Get the original value of Cookie Note here mainly corresponds to the Cookies array in C#*/
var reg = new RegExp( "(^|&)" name "=([^&]*)(&|$)");
var r = Cookies.Get("HTGL").match(reg);
if ( r != null) return unescape(r[2]);
return "";
}
}
/*//============== ================================================== ======================
//[Get the actual coordinates of the object]
[Created on 2008-04-09]
*/
function getDim(e){
var rd = {x:0,y:0};
do{
rd.x = e.offsetLeft;
rd.y = e. offsetTop;
e = e.offsetParent;
}while(e)
return rd;
}
/*//============== ================================================== ======================
//[Get the parent node of the object]
[Created on 2008-06-04]
*/
function getParent(o,N){
var e = new Object();
e = o;
do{
e = e.parentNode;
try{ if(e.tagName.toLowerCase() == N.toLowerCase())break;}catch(e){break;}
}while(e)
return e;
}
/ *//================================================ =======================================
//[Get the actual four-corner coordinates of the object 】
[Created on 2008-10-09]
*/
function getInfo(o){//Get coordinates
var to = new Object();
to.left = to .right=to.top=to.bottom=0;
var twidth = o.offsetWidth;
var theight = o.offsetHeight;
do{
to.left = o.offsetLeft;
to.top = o.offsetTop;
o = o.offsetParent;
}while(o != document.body)
to.right = to.left twidth;

to.bottom = to.top theight;
return to;
}
/*//======================== ================================================== ============
//[Get the object matching the specified character]
[Created on 2008-10-09]
*/
function getObj( o,s){
f = false;
while(o != document.body){
if(o.id.toLowerCase().indexOf(s) != -1){
f = true;
break;
}
o = o.offsetParent;
}
return f;
}
/*======== ================================================== ==============================
[Get parameter value]
[Created on 2008-06-08]
*/
var getQuery = XiaoFeng.getQuery = function(){
if(arguments.length == 0)return null;
if(arguments.length == 1){
var reg = new RegExp("(^|&)" arguments[0] "=([^&]*)(&|$)");
var r = window.location.search.substr(1) .match(reg);
if (r!=null) return unescape(r[2]);
return null;
}else{
var Reg = new RegExp(arguments[1] "=\w ","gi");
try{return arguments[0].match(Reg).toString().split(",")[0].split("=")[1] ;}catch(e){return null;}
}
}
/*============================ ================================================== ============
【Drag function】
Created on [2008-04-09]
*/
var Drag = XiaoFeng.Drag = function(o ){
var x,y;
x = getDim(o).x;
y = getDim(o).y;
var deltaX = event.clientX - x;
var deltaY=event.clientY - y;
var drag = true;
o.style.filter = "Alpha(Opacity=60)";
o.onmousemove = function(){
if( drag){
o.style.left=(event.clientX - deltaX) "px";
o.style.top=(event.clientY - deltaY) "px";
if(event. clientX - deltaX if(event.clientY - deltaY if(event. clientX - deltaX o.offsetWidth >= XiaoFeng.System.Size(0).x)o.style.left = (XiaoFeng.System.Size(0).x - o.offsetWidth) "px";
if( event.clientY - deltaY o.offsetHeight >= XiaoFeng.System.Size(0).y)o.style.top = (XiaoFeng.System.Size(0).y - o.offsetHeight) "px";
o.setCapture();
}
}
o.onmouseup = function(){
o.style.filter = "Alpha(Opacity=100)";
drag = false;
o.releaseCapture();
}
}
/*============================== ================================================== ==========
[Character conversion class]
Created in [2008-04-09]
Updated in [2008-06-02]
*/
var StrToHtml = {
sTh:function(s){
s = s.replace(/,"s = s.replace(/>/gi,">" );
s = s.replace(/"/gi,""");
s = s.replace(/&/gi,"&");
s = s.replace(/ /gi," ");
return s;
},
hTs:function(s){
s = s.replace(/," s = s.replace(/>/gi,">");
s = s.replace(/\/gi,""");
s = s.replace(/&/gi," &");
s = s.replace(/ /gi," ");
return s;
},
bTy:function(s){
s = s.replace (/[/gi,"s = s.replace(/]/gi,">");
return s;
},
yTb:function(s) {
s = s.replace(/,"["); ,"[");
s = s.replace(/,"["); ,"[");
s = s.replace(/> /gi,"]");
s = s.replace(/>/gi,"]");
s = s.replace(/ /gi," ");
return s;
}
}
/*================================================ ==============================================
【 Get the width and height of the form]
Mainly some system methods
*/
XiaoFeng.System = {
Event: function(){
var e = Object.Event();
var o = {x : 0,y : 0};
switch(arguments[0]){
case 0 :/*relative position of mouse*/
o.x = e.clientX;
o.y = e.clientY;
break;
case 1:/*Absolute position of mouse*/
o.x = e.clientX Object.Scroll().Left;
o.y = e. clientY Object.Scroll().Top;
break;
default:/*relative position of the mouse*/
o.x = e.clientX;
o.y = e.clientY;
break;
}
return o;
},
Size : function(){//[Get the width and height of the form]
var s = {x : 0,y : 0};
if(window.innerWidth){
s.x = window.innerWidth;
s.y = window.innerHeight;
}else if(document.compatMode=='CSS1Compat'){
if( arguments[0] == 1){
s.x = document.body.clientWidth;
s.y = document.body.clientHeight;
}else if(arguments[0] == 2){
s.x = parseInt(document.documentElement.clientWidth) parseInt(document.documentElement.scrollLeft);
s.y = parseInt(document.documentElement.clientHeight) parseInt(document.documentElement.scrollTop);
}else{
s.x = document.documentElement.clientWidth;
s.y = document.documentElement.clientHeight;
}
}else if(document.body){
if(arguments[0] == 1){
s.x = document.body.scrollWidth;
s.y = document.body.scrollHeight
}else if(arguments[0] == 2){
s.x = document.body.clientWidth document.body. scrollLeft;
s.y = document.body.clientHeight document.body.scrollTop;
}else{
s.x = document.body.clientWidth;
s.y = document.body.clientHeight;
}
}
return s;
},
Scroll : function(){//[Get the scroll bar of the form]
var s = {x : 0,y : 0};
if(document.compatMode=='CSS1Compat'){
s.x = document.documentElement.scrollTop;
s.y = document.documentElement.scrollLeft;
}else if(document.body){
s.x = document.body.scrollTop;
s.y = document.body.scrollLeft;
}
return s;
},
getRnd : function(){return Math.floor( Math.random()*1000000);}
}
/*================================ ================================================== ==========
[Get the file name and file extension]
[2009-04-20]
*/
function FileType(FName){
FName = FName.replace(/\/gi,"/");
FName = FName.substr(FName.lastIndexOf("/") 1);
return {Name : FName.substr(0, FName.indexOf(".")),Type : FName.substr(FName.indexOf(".") 1)};
}
/*============= ================================================== ============================
[Open the selection window and save window]
[2009-05-28]
First method:
var dialog = new XiaoFeng.Dialog("Please select a file", "txt file (*.txt)|*.txt|all files (*.*)|*.*", ".txt");
Second method:
var dialog = new XiaoFeng.Dialog({
Title: "Please select a file",
Filter: "txt file (*.txt) |*.txt|All files (*.*)|*.*",
DefaultExt : ".txt"
});
dialog.Open();
Note: The parameters can be different If filled in, it will be the default.
*/
XiaoFeng.Dialog = function(){
this.DialogTitle = "Please select the file to open";
this.DialogFilter = "Excel file( *.xls)|*.xls|All files(*.*)|*.*";
this.DialogDefaultExt = ".xls";
this.Query = arguments;
var self = this ;
this.Init = function(){
if(typeof self.Query[0] == "string"){
self.DialogTitle = self.Query[0]?self.Query[0 ]:self.DialogTitle;
self.DialogFilter = self.Query[1]?self.Query[1]:self.DialogFilter;
self.DialogDefaultExt = self.Query[2]?self.Query[2 ]:self.DialogDefaultExt;
}else if(typeof self.Query[0] == "object"){
self.DialogTitle = self.Query[0].Title?self.Query[0]. Title:self.DialogTitle;
self.DialogFilter = self.Query[0].Filter?self.Query[0].Filter:self.DialogFilter;
self.DialogDefaultExt = self.Query[0].DefaultExt ?self.Query[0].DefaultExt:self.DialogDefaultExt;
}
try{
if(!$("Dialog_OpenSave")){
var _Dialog_Open = $C("object") ;
_Dialog_Open.id = "Dialog_OpenSave";
_Dialog_Open.classid = "CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB";
_Dialog_Open.style.display = "none";
document .body.appendChild(_Dialog_Open);
}
$("Dialog_OpenSave").CancelError = true;
}catch(e){}
}
this.Open = function() {
$("Dialog_OpenSave").DialogTitle = this.DialogTitle;
$("Dialog_OpenSave").Filter = this.DialogFilter;
$("Dialog_OpenSave").DefaultExt = this.DialogDefaultExt;
$("Dialog_OpenSave").ShowOpen();
return $("Dialog_OpenSave").FileName;
}
this.Save = function(){
$("Dialog_OpenSave") .DialogTitle = this.DialogTitle.replace("Open","Save");
$("Dialog_OpenSave").Filter = this.DialogFilter;
$("Dialog_OpenSave").DefaultExt = this.DialogDefaultExt;
$("Dialog_OpenSave").ShowSave();
return $("Dialog_OpenSave").FileName;
}
this.Init();
}
/*================================================ ==============================================
【 Infinite drop-down list]
[2009-06-13]
Place a control where the drop-down list is to be placed, usually a hidden field
Using XML as the data source, you can directly call the XML form
var XMLDOM = LoadXml("CreateXML.ashx?RootId=15&sd=101");
Root = XMLDOM.documentElement;
You can also use Ajax to call up the data source
var ajax = new XiaoFeng. AjaxRequest();
ajax.Url = "CreateXML.ashx?RootId=15&sd=101";
ajax.CallBack = function(e){
if(e.Error != "undefined")return ;
var Root = e.responseXML.documentElement;
}
var ClassSelect = new SelectClass();
ClassSelect.Source = Root;
ClassSelect.Name = "ClassId";
ClassSelect.FirstOption = [["==Please select==","0"]];
ClassSelect.SelectFirst = true;
ClassSelect.Fun = function(e){}
ClassSelect.Select = "101";
ClassSelect.Run();

Parameter description: Source is the drop-down list. The data source is XMLDOM.
Name is the hidden control ID, usually a hidden field.
FirstOption is the drop-down list. The text displayed in the first line of the list, if you want to have different text for each one, you can set multiple text, for example [["==Please select your province==","0"],["==Please select your city ==","0"],["==Please select your county==","0"]] If FirstOption = "" or FirstOption = [], these words will not be displayed. The default is [["== Please select ==",""]]
SelectFirst is true whether to display the text to be set after loading. False is whether to display the first row of data or the set row. The default is true
Fun This function is The onchange selection event of each drop-down list triggers the interface function
Select defaults to "" for the selected attribute
Run runs this category
*/
var SelectClass = XiaoFeng.SelectClass = function() {
this.Name = "";
this.Source = new Object();
this.FirstOption = [["==Please select==","0"]];
this.SelectFirst = true;
this.Select = "";
this.Fun = function(e){return;}
this.Run = function(){
if(!$( this.Name)){
var _Input = $C("input");
_Input.type = "hidden";
_Input.name = this.Name;
_Input.id = this .Name;
document.body.appendChild(_Input);
}
$(this.Name).value = this.Select;
if(typeof this.Source == "object")
if(this.Source.hasChildNodes){
this.CreateSelect(this.Source);
if(this.Select == ""){
var __Select = $(this.Name) .parentNode.getElementsByTagName("select");
if(this.SelectFirst)
$(this.Name).value = __Select[__Select.length - 1].value;
else
$ (this.Name).value = __Select[__Select.length - 1].options[1].value;
}
}else{
var _Span = $C("span");
_Span.innerHTML = "The data source is empty. ";
$(this.Name).parentNode.appendChild(_Span);
}
else{
var _Span = $C("span");
_Span.innerHTML = " There is an error in the data source.";
$(this.Name).parentNode.appendChild(_Span);
}
}
this.CreateSelect = function(node){
if(!node.hasChildNodes){this._SelectFirstName();return;}
var Select = $C("select");
Select.id = Select.name = "select_" (new Date().getTime());
var _f = false,_s = 0;
if(typeof this.FirstOption == "string")this.FirstOption = [];
if(typeof this.FirstOption == "object" && this.FirstOption.length > 0)
Select.add(this.CreateOption("==请选择==","0",false));
for(var i = 0;i if(node.childNodes[i].getAttribute("s") == null){_f = false;}else{_f = true;_s = i;}
Select.add(this.CreateOption(node.childNodes[i].getAttribute("Name"),node.childNodes[i].getAttribute("Id"),_f));
}
$(this.Name).parentNode.insertBefore(Select,$(this.Name));
if(_s > 0)
this.CreateSelect(node.childNodes[_s]);
else{
this.CreateSelect(node.childNodes[0]);
if(this.SelectFirst)
if(this.FirstOption.length == 0)
Select.options[0].selected = true;
else
Select.options[1].selected = true;
}
}
this.CreateOption = function(t,v,f){
var OptionSub = new Option();
OptionSub.text = t;
OptionSub.value = v;
if(f)OptionSub.selected = f;
return OptionSub;
}
this._SelectFirstName = function(){
var _Select = $(this.Name).parentNode.getElementsByTagName("select");
var self = this,_f = true;
var _FirstOption = [],_FirstLength = this.FirstOption.length;
if(this.FirstOption.length == 0)_f = false;
for(var i = 0;i if(_f){
if(i >= _FirstLength)
_FirstOption = this.FirstOption[0];
else
_FirstOption = this.FirstOption[i];
_Select[i].options[0].text = _FirstOption[0];
_Select[i].options[0].value = _FirstOption[1];
}
if(i == _Select.length - 1)
_Select[i].setAttribute("onchange",function(){
var __Select = this.parentNode.getElementsByTagName("select");
$(self.Name).value = __Select[__Select.length - 1].value;
if(self.FirstOption.length != 0 && this.selectedIndex == 0)
if(_Select.length > 1)
$(self.Name).value = __Select[__Select.length - 2].value;
self.Fun(this);
});
else
_Select[i].setAttribute("onchange",function(){
self._RemoveSelect(this);
self._SelectNode(self.Source,this.value);
var __Select = this.parentNode.getElementsByTagName("select");
if(self.SelectFirst){
$(self.Name).value = __Select[__Select.length - 1].value;
}else
$(self.Name).value = __Select[__Select.length - 1].options[1].value;
if(self.FirstOption.length != 0 && this.selectedIndex == 0)
if(_Select.length > 1)
$(self.Name).value = __Select[__Select.length - 2].value;
self.Fun(this);
});
}
}
this._SelectNode = function(node,s){
for(var i = 0;i if(node.childNodes[i].getAttribute("Id") == s)
this.CreateSelect(node.childNodes[i]);
else
if(node.childNodes[i].hasChildNodes)this._SelectNode(node.childNodes[i],s);
}
this._RemoveSelect = function(o){
var _Select = $(this.Name).parentNode.getElementsByTagName("select");
var _f = false;
for(var i = 0;i if(_Select[i] == o){_f = true;continue;}
if(_f){_Select[i].parentNode.removeChild(_Select[i]);i--;}
}
}
}

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to evaluate the cost-effectiveness of commercial support for Java frameworks How to evaluate the cost-effectiveness of commercial support for Java frameworks Jun 05, 2024 pm 05:25 PM

Evaluating the cost/performance of commercial support for a Java framework involves the following steps: Determine the required level of assurance and service level agreement (SLA) guarantees. The experience and expertise of the research support team. Consider additional services such as upgrades, troubleshooting, and performance optimization. Weigh business support costs against risk mitigation and increased efficiency.

How does the learning curve of PHP frameworks compare to other language frameworks? How does the learning curve of PHP frameworks compare to other language frameworks? Jun 06, 2024 pm 12:41 PM

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

How do the lightweight options of PHP frameworks affect application performance? How do the lightweight options of PHP frameworks affect application performance? Jun 06, 2024 am 10:53 AM

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

Performance comparison of Java frameworks Performance comparison of Java frameworks Jun 04, 2024 pm 03:56 PM

According to benchmarks, for small, high-performance applications, Quarkus (fast startup, low memory) or Micronaut (TechEmpower excellent) are ideal choices. SpringBoot is suitable for large, full-stack applications, but has slightly slower startup times and memory usage.

Golang framework documentation best practices Golang framework documentation best practices Jun 04, 2024 pm 05:00 PM

Writing clear and comprehensive documentation is crucial for the Golang framework. Best practices include following an established documentation style, such as Google's Go Coding Style Guide. Use a clear organizational structure, including headings, subheadings, and lists, and provide navigation. Provides comprehensive and accurate information, including getting started guides, API references, and concepts. Use code examples to illustrate concepts and usage. Keep documentation updated, track changes and document new features. Provide support and community resources such as GitHub issues and forums. Create practical examples, such as API documentation.

How to choose the best golang framework for different application scenarios How to choose the best golang framework for different application scenarios Jun 05, 2024 pm 04:05 PM

Choose the best Go framework based on application scenarios: consider application type, language features, performance requirements, and ecosystem. Common Go frameworks: Gin (Web application), Echo (Web service), Fiber (high throughput), gorm (ORM), fasthttp (speed). Practical case: building REST API (Fiber) and interacting with the database (gorm). Choose a framework: choose fasthttp for key performance, Gin/Echo for flexible web applications, and gorm for database interaction.

Detailed practical explanation of golang framework development: Questions and Answers Detailed practical explanation of golang framework development: Questions and Answers Jun 06, 2024 am 10:57 AM

In Go framework development, common challenges and their solutions are: Error handling: Use the errors package for management, and use middleware to centrally handle errors. Authentication and authorization: Integrate third-party libraries and create custom middleware to check credentials. Concurrency processing: Use goroutines, mutexes, and channels to control resource access. Unit testing: Use gotest packages, mocks, and stubs for isolation, and code coverage tools to ensure sufficiency. Deployment and monitoring: Use Docker containers to package deployments, set up data backups, and track performance and errors with logging and monitoring tools.

What are the common misunderstandings in the learning process of Golang framework? What are the common misunderstandings in the learning process of Golang framework? Jun 05, 2024 pm 09:59 PM

There are five misunderstandings in Go framework learning: over-reliance on the framework and limited flexibility. If you don’t follow the framework conventions, the code will be difficult to maintain. Using outdated libraries can cause security and compatibility issues. Excessive use of packages obfuscates code structure. Ignoring error handling leads to unexpected behavior and crashes.

See all articles