chengkun
2025-08-06 b54e02d98e42ae73071e3c01e59f12671d13d06a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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();
})