富贵资源网 Design By www.hznty.com
jProviderData
复制代码 代码如下:
/// <reference path="jUtil.js" />
$j = jQuery.noConflict();
(function ($j) {
$j.providerData={
defaultSettings: {
select_Span_Items: false,
select_TD_Items: false,
select_LI_Items: false
},
init:function(options){
opts = $j.extend({}, $j.providerData.defaultSettings, options);
singleItemJsonFormat='"{0}":"{1}"';
divItemFormat='{{0}}';
tableItemFormat='{0}';
},
getDataName:function(item){
var dataName = item.attr("dataname");
if(typeof dataName === 'undefined'||dataName==""){
dataName = item.attr("Id");
}
if(typeof dataName === 'undefined'||dataName==""){
dataName=item.text();
}
if(typeof dataName === 'undefined'||dataName==""){
dataName=item[0].innerText;
}
return dataName;
},
getData:function(selector){
//var selector=opts.selector;
var items;
if(typeof selector!=="object"){
items=$j(selector);
}
else{
items=selector;
}
var retJsonValue="";
var subSelector=":input";
if (opts.select_Span_Items) {
subSelector = subSelector + ",span";
}
if (opts.select_LI_Items) {
subSelector = subSelector + ",li";
}
if(opts.select_TD_Items){
subSelector = subSelector + ",td";
}
$j.each(items,function(i,item){
var t=$j(this);
var dataName=$j.providerData.getDataName(t);
//return:'{"dataname":"value"}'
if($j.util.isInput(t)){
var value=t.val();
var itemStr= String.format(singleItemJsonFormat,dataName,value);
retJsonValue=retJsonValue+itemStr+",";
retJsonValue=retJsonValue.trimEnd(",");
}
//return:'{"dataname1":"value1","dataname2":"value2"}'
else if($j.util.isDiv(t)){
var subItems = t.find(subSelector);
var subStr = "";
$j.each(subItems, function (i, subItem) {
//递归调用 处理子元素
var tempSubItemStr = $j.providerData.getData("#"+$j(this).attr("id"));
subStr = subStr + "," + tempSubItemStr;
})
subStr=subStr.trimStart(",");
retJsonValue=String.format(divItemFormat,subStr);
}
//return:'[{"dataname1":"value1","dataname2":"value2"},{"dataname1":"value3","dataname2":"value4"}]'
else if($j.util.isTable(t)){
var trItems=t.find("TR:gt(0)");
//迭代处理Table中的每一行
$j.each(trItems,function(i,trItem){
//处理行,找出行中的要收集数据的元素
var subItems =$j(this).find(subSelector);
var subStr = "";
//迭代处理行中所有需要收集数据的元素
$j.each(subItems,function(i,subItem){
if($j.util.isInput($j(this))){
var tempSubItemStr = $j.providerData.getData("#"+$j(this).attr("id"));
subStr = subStr + "," + tempSubItemStr;
}
else{
//如果是TD元素,且他里面不包含INPUT元素
if( $j.util.isTD($j(this)) && ($j(this).find(":input").length==0)){
var tempSubItemStr = $j.providerData.getData($j(this));
subStr = subStr + "," + tempSubItemStr;
}
}
});
subStr=subStr.trimStart(",");
retJsonValue= retJsonValue+String.format(divItemFormat,subStr)+",";
});
retJsonValue=retJsonValue.trimEnd(",");
retJsonValue="["+retJsonValue+"]";
}
//return:'{"dataname":"value"}'
else if($j.util.isLi(t)){
var value=t.text();
var itemStr= String.format(singleItemJsonFormat,dataName,value);
retJsonValue=retJsonValue+itemStr+",";
retJsonValue=retJsonValue.trimEnd(",");
}
//return:'{"dataname":"value"}'
else if($j.util.isTD(t)){
var value=t.text();
// var rowIndex = t.parent().prevAll().length;
//获取当前列的列索引
var colIndex = t.prevAll().length;
//dataName由列的的列头中dataName属性决定,如果找不到由列头的内容决定
var thItem=t.parent().parent().parent().find("th:eq("+colIndex+")");
if(thItem.length==1){
dataName=$j.providerData.getDataName(thItem);
}
var itemStr= String.format(singleItemJsonFormat,dataName,value);
retJsonValue=retJsonValue+itemStr+",";
retJsonValue=retJsonValue.trimEnd(",");
}
});
return retJsonValue;
}
};
jProviderData=function(options){
$j.providerData.init(options);
return $j.providerData.getData(options.selector);
};
})(jQuery);
复制代码 代码如下:
String.prototype.trimStart = function(trimStr){
if(!trimStr){return this;}
var temp = this;
while(true){
if(temp.substr(0,trimStr.length)!=trimStr){
break;
}
temp = temp.substr(trimStr.length);
}
return temp;
};
String.prototype.trimEnd = function(trimStr){
if(!trimStr){return this;}
var temp = this;
while(true){
if(temp.substr(temp.length-trimStr.length,trimStr.length)!=trimStr){
break;
}
temp = temp.substr(0,temp.length-trimStr.length);
}
return temp;
};
String.prototype.trim = function(trimStr){
var temp = trimStr;
if(!trimStr){temp=" ";}
return this.trimStart(temp).trimEnd(temp);
};
String.format = function () {
if (arguments.length == 0) {
return null;
}
var str = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
str = str.replace(re, arguments[i]);
}
return str;
}
(function ($j) {
$j.util = {
_compareTagName : function (item, tagName) {
return item.attr("tagName").toUpperCase() == tagName.toUpperCase();
},
isTable: function (item) {
return $j.util._compareTagName(item, "TABLE");
},
isDiv: function (item) {
return $j.util._compareTagName(item, "DIV");
},
isInput: function (item) {
return $j.util._compareTagName(item, "INPUT");
},
isSpan: function (item) {
return $j.util._compareTagName(item, "SPAN");
},
isLi: function (item) {
return $j.util._compareTagName(item, "LI");
},
isTD: function (item) {
return $j.util._compareTagName(item, "TD");
}
};
})(jQuery);
复制代码 代码如下:
/// <reference path="jUtil.js" />
$j = jQuery.noConflict();
(function ($j) {
$j.providerData={
defaultSettings: {
select_Span_Items: false,
select_TD_Items: false,
select_LI_Items: false
},
init:function(options){
opts = $j.extend({}, $j.providerData.defaultSettings, options);
singleItemJsonFormat='"{0}":"{1}"';
divItemFormat='{{0}}';
tableItemFormat='{0}';
},
getDataName:function(item){
var dataName = item.attr("dataname");
if(typeof dataName === 'undefined'||dataName==""){
dataName = item.attr("Id");
}
if(typeof dataName === 'undefined'||dataName==""){
dataName=item.text();
}
if(typeof dataName === 'undefined'||dataName==""){
dataName=item[0].innerText;
}
return dataName;
},
getData:function(selector){
//var selector=opts.selector;
var items;
if(typeof selector!=="object"){
items=$j(selector);
}
else{
items=selector;
}
var retJsonValue="";
var subSelector=":input";
if (opts.select_Span_Items) {
subSelector = subSelector + ",span";
}
if (opts.select_LI_Items) {
subSelector = subSelector + ",li";
}
if(opts.select_TD_Items){
subSelector = subSelector + ",td";
}
$j.each(items,function(i,item){
var t=$j(this);
var dataName=$j.providerData.getDataName(t);
//return:'{"dataname":"value"}'
if($j.util.isInput(t)){
var value=t.val();
var itemStr= String.format(singleItemJsonFormat,dataName,value);
retJsonValue=retJsonValue+itemStr+",";
retJsonValue=retJsonValue.trimEnd(",");
}
//return:'{"dataname1":"value1","dataname2":"value2"}'
else if($j.util.isDiv(t)){
var subItems = t.find(subSelector);
var subStr = "";
$j.each(subItems, function (i, subItem) {
//递归调用 处理子元素
var tempSubItemStr = $j.providerData.getData("#"+$j(this).attr("id"));
subStr = subStr + "," + tempSubItemStr;
})
subStr=subStr.trimStart(",");
retJsonValue=String.format(divItemFormat,subStr);
}
//return:'[{"dataname1":"value1","dataname2":"value2"},{"dataname1":"value3","dataname2":"value4"}]'
else if($j.util.isTable(t)){
var trItems=t.find("TR:gt(0)");
//迭代处理Table中的每一行
$j.each(trItems,function(i,trItem){
//处理行,找出行中的要收集数据的元素
var subItems =$j(this).find(subSelector);
var subStr = "";
//迭代处理行中所有需要收集数据的元素
$j.each(subItems,function(i,subItem){
if($j.util.isInput($j(this))){
var tempSubItemStr = $j.providerData.getData("#"+$j(this).attr("id"));
subStr = subStr + "," + tempSubItemStr;
}
else{
//如果是TD元素,且他里面不包含INPUT元素
if( $j.util.isTD($j(this)) && ($j(this).find(":input").length==0)){
var tempSubItemStr = $j.providerData.getData($j(this));
subStr = subStr + "," + tempSubItemStr;
}
}
});
subStr=subStr.trimStart(",");
retJsonValue= retJsonValue+String.format(divItemFormat,subStr)+",";
});
retJsonValue=retJsonValue.trimEnd(",");
retJsonValue="["+retJsonValue+"]";
}
//return:'{"dataname":"value"}'
else if($j.util.isLi(t)){
var value=t.text();
var itemStr= String.format(singleItemJsonFormat,dataName,value);
retJsonValue=retJsonValue+itemStr+",";
retJsonValue=retJsonValue.trimEnd(",");
}
//return:'{"dataname":"value"}'
else if($j.util.isTD(t)){
var value=t.text();
// var rowIndex = t.parent().prevAll().length;
//获取当前列的列索引
var colIndex = t.prevAll().length;
//dataName由列的的列头中dataName属性决定,如果找不到由列头的内容决定
var thItem=t.parent().parent().parent().find("th:eq("+colIndex+")");
if(thItem.length==1){
dataName=$j.providerData.getDataName(thItem);
}
var itemStr= String.format(singleItemJsonFormat,dataName,value);
retJsonValue=retJsonValue+itemStr+",";
retJsonValue=retJsonValue.trimEnd(",");
}
});
return retJsonValue;
}
};
jProviderData=function(options){
$j.providerData.init(options);
return $j.providerData.getData(options.selector);
};
})(jQuery);
复制代码 代码如下:
String.prototype.trimStart = function(trimStr){
if(!trimStr){return this;}
var temp = this;
while(true){
if(temp.substr(0,trimStr.length)!=trimStr){
break;
}
temp = temp.substr(trimStr.length);
}
return temp;
};
String.prototype.trimEnd = function(trimStr){
if(!trimStr){return this;}
var temp = this;
while(true){
if(temp.substr(temp.length-trimStr.length,trimStr.length)!=trimStr){
break;
}
temp = temp.substr(0,temp.length-trimStr.length);
}
return temp;
};
String.prototype.trim = function(trimStr){
var temp = trimStr;
if(!trimStr){temp=" ";}
return this.trimStart(temp).trimEnd(temp);
};
String.format = function () {
if (arguments.length == 0) {
return null;
}
var str = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
str = str.replace(re, arguments[i]);
}
return str;
}
(function ($j) {
$j.util = {
_compareTagName : function (item, tagName) {
return item.attr("tagName").toUpperCase() == tagName.toUpperCase();
},
isTable: function (item) {
return $j.util._compareTagName(item, "TABLE");
},
isDiv: function (item) {
return $j.util._compareTagName(item, "DIV");
},
isInput: function (item) {
return $j.util._compareTagName(item, "INPUT");
},
isSpan: function (item) {
return $j.util._compareTagName(item, "SPAN");
},
isLi: function (item) {
return $j.util._compareTagName(item, "LI");
},
isTD: function (item) {
return $j.util._compareTagName(item, "TD");
}
};
})(jQuery);
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。