config.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Produce for workbin-doing - PHP frame development system
  3. * http://produce.suwi.cn/
  4. *
  5. * @copyright Copyright (c) 2009-2011 Workbin development team CHINA Inc. (http://www.workbin.com)
  6. * @author smilewind(SuWi.bin)<dandeyu@sina.com>
  7. * @version $Id: config.script.js 2010-4-27 11:35 smilewind $
  8. */
  9. /***************************
  10. * 使用说明:
  11. * $_c_d 全局数组 | $_c_v(d,v) 设置全局数组的值 | $_c_g(d,v) 设置全局变量的值 | $_c_u(d,g) 取消全局数组或者全局变量的值 | $_c_r(a,b) 取url参数
  12. * $_c_j(s) 加载js | $_c_c(s) 加载css | $_c_i(s) 加载图片 | $_c_f(s) 加载flash | $_c_e(e) 执行代码 | $_c_w(e) 执行弹出
  13. ***************************/
  14. var $_c_d = [];
  15. var $_c_v = function(d,v){$_c_d[d]=v};
  16. var $_c_g = function(d,v){eval("window."+d+"='"+v+"'")};
  17. var $_c_u = function(d,g){g=='global'?eval("delete window."+d+""):delete $_c_d[d]};
  18. var $_c_r = function(a,b){if(!b) var b = location.href;var rs = new RegExp('[\&|\?]{1}'+a+'=([\\w]+)').exec(b);if(rs == null) return null;return rs[1];};
  19. var $_c_j = function(s){if(!$_c_d['root']){document.write('not root is defined!');$_c_v('root','no');return}document.write('<script type="text/javascript" language="javascript" src="' +$_c_d['root'] + s + '.script.f-js"></script>');};
  20. var $_c_c = function(s){if(!$_c_d['root']){document.write('not root is defined!');$_c_v('root','no');return}document.write('<LINK href="' + $_c_d['root'] + 'resource/css/' +s + '.css" type="text/css" rel="stylesheet">');};
  21. var $_c_i = function(s){if(!$_c_d['root']){document.write('not root is defined!');$_c_v('root','no');return}return $_c_d['root']+'resource/img/' +s;};
  22. var $_c_f = function(s){if(!$_c_d['root']){document.write('not root is defined!');$_c_v('root','no');return}return $_c_d['root']+'resource/swf/' +s;};
  23. var $_c_e = function(e){return $_c_d[e]?eval($_c_d[e]):eval(e)};
  24. var $_c_w = function(e){$_c_d[e]?$.alert($_c_d[e]):$.alert(e)};
  25. /************************************
  26. * 最基本与最简单的自定义函数
  27. ************************************/
  28. $_c_v('$','document.getElementById(arguments[1])'); //快速获取id
  29. $_c_v('jq','$(arguments[1])'); //jq获取id
  30. $_c_v('e','if(typeof(arguments[1]) == "string"){"\'"+escape(arguments[1])+"\'"}else{arguments[1]}');
  31. $_c_v('u','unescape(arguments[1])'); //加密解密
  32. $_c_v('null','if(!arguments[1] || arguments[1] == "" || arguments[1] == "undefined"){true}else{false}'); //判断字符串是否为空
  33. $_c_v('len','arguments[1].length'); //获取字符串长度
  34. $_c_v('os','if(navigator.userAgent.indexOf("MSIE")>0){1}else if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){2}else if(isSafari=navigator.userAgent.indexOf("Safari")>0){3}else if(isCamino=navigator.userAgent.indexOf("Camino")>0){4}else if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){4}else{0}'); //获取浏览器版本
  35. $_c_v('int','if(isNaN(arguments[1] = parseInt(arguments[1]))){0}else{arguments[1]}'); //转换为int型
  36. $_c_v('go','location.href=arguments[1];'); //跳转
  37. $_c_v('time','var time = "";if(arguments[1] >= 86400){time += parseInt(arguments[1]/86400)+"天";arguments[1] = arguments[1]%86400;}if(arguments[1] >= 3600){time += parseInt(arguments[1]/3600)+"时";arguments[1] = arguments[1]%3600;}if(arguments[1] >= 60){time += parseInt(arguments[1]/60)+"分";arguments[1] = arguments[1]%60;}if(arguments[1] < 60 && arguments[1] > 0){time += arguments[1]+"秒";}time'); //时间转换
  38. $_c_v('debug','var str="";var o=arguments[1];for(k in o){if(typeof o[k]=="function"){str+=k+"= function \\n";}else{str += k+"="+o[k]+"\\n";}}alert(str);'); //debug
  39. $_c_v('load','var onload=window.onload;if(typeof window.onload != "function"){window.onload = arguments[1];}else{window.onload = function() {onload();arguments[1]();}}');