1 /** 2 * id数组转换为json字符串 3 */ 4 function arrayTojson(arr) { 5 var jsonIds = "["; 6 for ( var i = 0; i < arr.length; i++) { 7 if (i == arr.length - 1) { 8 jsonIds += arr[i].eventid; 9 } else { 10 jsonIds += arr[i].eventid + ","; 11 } 12 } 13 return jsonIds += "]"; 14 }
1 /** 2 * 获取系统的url 3 * @returns fullUrl:系统访问路径,例如:http://localhost:8080/amudraya/amudraya 4 */ 5 function getURL(){ 6 var fullUrl = window.location.href; 7 var a=fullUrl.lastIndexOf('/'); 8 fullUrl=fullUrl.substring(0,a); 9 var b=fullUrl.lastIndexOf('/'); 10 fullUrl=fullUrl.substring(0,b); 11 var c=fullUrl.lastIndexOf('/'); 12 fullUrl=fullUrl.substring(0,c); 13 return fullUrl; 14 }
Js验证码
1 /**========================验证码开始=============**/ 2 var code ; //在全局 定义验证码 3 function createCode(){ 4 code = ""; 5 var codeLength = 4;//验证码的长度 6 var checkCode = document.getElementById("checkCode"); 7 checkCode.value = ""; 8 var selectChar = new Array(1,2,3,4,5,6,7,8,9, 9 'a','b','c','d','e','f','g','h','j','k','l','m','n','p','q', 10 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F', 11 'G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z'); 12 13 for(var i=0;i<codeLength;i++) { 14 var charIndex = Math.floor(Math.random()*60); 15 code +=selectChar[charIndex]; 16 } 17 if(code.length != codeLength){ 18 createCode(); 19 } 20 checkCode.value = code; 21 } 22 function validate () { 23 var inputCode = document.getElementById("loginCodeId").value.toUpperCase(); 24 var codeToUp=code.toUpperCase(); 25 if(inputCode.length <=0) { 26 alert("请输入验证码!"); 27 return false; 28 } 29 else if(inputCode != codeToUp ){ 30 alert("验证码输入错误!"); 31 createCode(); 32 return false; 33 } 34 else { 35 return true; 36 } 37 } 38 /**======================验证码结束==================**/ 39 /** 40 * 关闭忘记密码页面 41 */ 42 function closeWindow(){ 43 $win.window('close'); 44 }