function stringnumber(x)
|
{
|
var filter=/^[\u0391-\uFFE5]+$/;
|
var y=0;
|
for(var i=0;i<x.length;i++){
|
if(!filter.test(x.substr(i,1)))
|
y=y+1;
|
else
|
y=y+2;
|
}
|
return y;
|
}
|
|
function countd(secs, idstr) {
|
if (--secs > 0)
|
setTimeout("countd(" + secs + ",'" + idstr + "')", 1000);
|
else {
|
$("#"+idstr).html('');
|
}
|
}
|
|
function jsonobj(str){
|
return eval('(' + str + ')');
|
}
|
|
function skipto(obj){
|
var url =obj.options[obj.selectedIndex].value;
|
document.location=url;
|
}
|
|
function getcount(id,showid){
|
if(showid==''){
|
showid='wordcount';
|
}
|
$('#'+showid).html($('#'+id).val().length);
|
}
|
function GetRandomNum(Min,Max){
|
var Range = Max - Min;
|
var Rand = Math.random();
|
return(Min + Math.round(Rand * Range));
|
}
|
|
$.fn.myPin = function (targetClass, extraClass, moveValue) {
|
var elm = $(targetClass);
|
var startPos = $(elm).offset().top;
|
$.event.add(window, "scroll", function () {
|
var p = $(window).scrollTop();
|
if (p + moveValue > startPos) {
|
$(elm).addClass(extraClass);
|
}
|
else {
|
$(elm).removeClass(extraClass);
|
}
|
});
|
};
|
//////选择日期/////////
|
function clickdate(obj) {
|
var current = obj;
|
WdatePicker({startDate:'%y-%M-%d', dateFmt:'yyyy-MM-dd', onpicked:function(dp){
|
$(obj).change();
|
}
|
});
|
}
|
|
//////选择日期+时间/////////
|
function clicktime(obj) {
|
var current = obj;
|
WdatePicker({startDate:'%y-%M-%d %H:%i:00', dateFmt:'yyyy-MM-dd HH:mm', onpicked:function(dp){
|
$(obj).change();
|
}
|
});
|
}
|
|
String.prototype.trim = function() {
|
return this.replace(/(^\s*)|(\s*$)/g, "");
|
}
|
String.prototype.lenB = function(){
|
var arr = this.match(/[^\x00-\xff]/ig);
|
return this.length + (arr == null ? 0 : arr.length);
|
}
|
|
function addToTree(data) {
|
//删除所有children,以防止多次调用
|
data.forEach(function (item) {
|
delete item.children;
|
});
|
var map = {};
|
data.forEach(function (item) {
|
map[item.id] = item;
|
});
|
var treeval = [];
|
data.forEach(function (item) {
|
var parent = map[item.parentid];
|
if (parent) {
|
(parent.children || ( parent.children = [] )).push(item);
|
} else {
|
treeval.push(item);
|
}
|
});
|
return treeval;
|
}
|
|
/////验证两位数字/////////////
|
function validnum(obj){
|
obj.value = obj.value.replace(/[^\d\.]/g,""); //清除"数字"和"."以外的字符
|
obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
|
obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
|
obj.value = obj.value.replace(/^(\d+)\.(\d\d).*$/,'$1.$2'); //只能输入两个小数
|
}
|
|
var forbiddenautocomplete=function(){
|
$("input[type='text']").attr('autocomplete','off');
|
}
|
$(function(){
|
forbiddenautocomplete();
|
})
|