<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 * @filesource */ // ------------------------------------------------------------------------ /** * CodeIgniter Benchmark Class * * This class enables 能够 you to mark points and calculate 计算 the time difference 差异 * between them. Memory consumption can also be displayed. * * @package CodeIgniter * @subpackage Libraries * @category Libraries * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/libraries/benchmark.html */ class CI_Benchmark { /** * List of all benchmark markers and when they were added * 用来存储基准测试类标记的数组 * @var array */ var $marker = array(); // -------------------------------------------------------------------- /** * Set a benchmark marker * 设置一个标记点 * Multiple calls to this function can be made so that several * execution points can be timed * * @access public * @param string $name name of the marker * @return void */ function mark($name) { // 在程序的任意地方调用方法时,会记录当前的时间点。 $this->marker[$name] = microtime(); } // -------------------------------------------------------------------- /** * Calculates the time difference between two marked points. * 计算出两个时间点之间的时间。 * If the first parameter is empty this function instead returns the * {elapsed_time} pseudo-variable 虚假变量. This permits 许可 the full system * execution time to be shown in a template. The output class will * swap the real value for this variable. * * @access public * @param string a particular marked point * @param string a particular marked point * @param integer the number of decimal places * @return mixed */ function elapsed_time($point1 = '', $point2 = '', $decimals = 4) { /* * 如果没有给出明确的时间点,那么会计算出整个程序运行的时间。 * 怎么可以做到计算出整个程序的运行时间的呢?其实执行此计算的是Output组件。 * 而调用Benchmark::elapsed_time();(无参数)的时候,实质上先返回的并不是 * 整个程序运行的时间,也不可能做到,实质返回的是一个{elapsed_time}标签,然后 * Output在处理输出的时候,再计算出整个程序运行时间,因为处理输出阶段程序可以视 * 为处于最后阶段,于是可以近似计算出总时间,然后把输出中的{elapsed_time}替换掉。 * 下面的memory_usage()原理相同。 */ if ($point1 == '') { return '{elapsed_time}'; } if ( ! isset($this->marker[$point1])) { return ''; } if ( ! isset($this->marker[$point2])) { $this->marker[$point2] = microtime(); } //这里为什么要用到list,是因为microtime();返回值是“msec sec”的格式。 list($sm, $ss) = explode(' ', $this->marker[$point1]); list($em, $es) = explode(' ', $this->marker[$point2]); return number_format(($em + $es) - ($sm + $ss), $decimals); } // -------------------------------------------------------------------- /** * Memory Usage * * This function returns the {memory_usage} pseudo-variable. * This permits it to be put it anywhere in a template * without the memory being calculated until the end. * The output class will swap the real value for this variable. * * @access public * @return string */ function memory_usage() { return '{memory_usage}'; } } // END CI_Benchmark class /* End of file Benchmark.php */ /* Location: ./system/core/Benchmark.php */
'overrideEvents': ['onSelectError', 'onDialogClose'],
//返回一个错误,选择文件的时候触发
'onSelectError': function (file, errorCode, errorMsg) {
switch (errorCode) {
case -100:
alert("上传的文件数量已经超出系统限制的" + $('#file_upload').uploadify('settings', 'queueSizeLimit') + "个文件!");
break;
case -110:
alert("文件 [" + file.name + "] 大小超出系统限制的" + $('#file_upload').uploadify('settings', 'fileSizeLimit') + "大小!");
break;
case -120:
alert("文件 [" + file.name + "] 大小异常!");
break;
case -130:
alert("文件 [" + file.name + "] 类型不正确!");
break;
}
return false;
},
//检测FLASH失败调用
'onFallback': function () {
alert("您未安装FLASH控件,无法上传!请安装FLASH控件后再试。");
}
注意添加'overrideEvents'选项,要不默认的错误此时还是会出现。
本文链接
ztree 3.5提供了复选/单选树形,这里补充个单选/复选树形,在ztree3.5 demo上加到页面,纯属交流,废话结束,附件在我的资源里面,
效果如下:
代码如下:
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE> ZTREE DEMO - radio&checkbox </TITLE>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href=/css/demo.css" type="text/css">
<link rel="stylesheet" href=/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src=/js/jquery-1.4.4.min.js"></script>_br/index.html>
<script type="text/javascript" src=/js/jquery.ztree.core-3.5.js"></script>_br/index.html>
<!-- <script type="text/javascript" src=/js/jquery.ztree.excheck-3.5.js"></script>_br/index.html>
<script type="text/javascript" src=/js/jquery.ztree.exedit-3.5.js"></script>-->_br/index.html>
<SCRIPT type="text/javascript">
<!--
//定义全局zTree,用于使用zTree.getNodesByParam("checked", true, null);取得选择节点
var zTree;
var IDMark_A = "_a";
var setting = {
view: {
addDiyDom: addDiyDom
},
data: {
simpleData: {
enable: true
}
}
};
var zNodes =[
{ id:1, pId:0, name:"父节点 1", open:true},
{ id:11, pId:1, name:"叶子节点 1-1"},
{ id:12, pId:1, name:"叶子节点 1-2"},
{ id:13, pId:1, name:"叶子节点 1-3"},
{ id:2, pId:0, name:"父节点 2", open:true},
{ id:21, pId:2, name:"叶子节点 2-1"},
{ id:22, pId:2, name:"叶子节点 2-2"},
{ id:23, pId:2, name:"叶子节点 2-3"},
{ id:3, pId:0, name:"父节点 3", open:true},
{ id:31, pId:3, name:"叶子节点 3-1"},
{ id:32, pId:3, name:"叶子节点 3-2"},
{ id:33, pId:3, name:"叶子节点 3-3"}
];
//判断节点是否在已选择的节点中,判断重复选择
function isNodeInChecked(curId){
if(zTree==null){
return false;
}
var selectedNodes=zTree.getNodesByParam("checked", true, null);
var selectedNode;
if(selectedNodes == null || selectedNodes.length==0){
return false;
}
for(var i=0; i<selectedNodes.length;i++){
selectedNode = selectedNodes[i];
if(selectedNode.id==curId){
return true;
}
}
return false;
}
//自定义的树形规则
function addDiyDom(treeId, treeNode) {
var aObj = $("#" + treeNode.tId + IDMark_A);
if (treeNode.level == 0) {
var editStr = "<input type='radio' id='radio_" +treeNode.id+"_"+treeNode.pId+"' onfocus='this.blur();'></input>";
aObj.before(editStr);
var btn = $("#radio_"+treeNode.id+"_"+treeNode.pId);
if (btn) {
btn.bind("click", function() {checkAccessories(treeNode, btn);});
}
} else {
var editStr = "<input type='checkbox' id='checkbox_" +treeNode.id+"_"+treeNode.pId+ "' name='checkbox_"+treeNode.getParentNode().id+"_"+treeNode.pId+ "' onfocus='this.blur();'></input>";
aObj.before(editStr);
var btn = $("#checkbox_"+treeNode.id+"_"+treeNode.pId);
if (btn){
btn.bind("change", function() {checkBrand(treeNode, btn);});
var isNodeInChecked = false;
var selectedNodes=null;
if(zTree!=null){
selectedNodes = zTree.getNodesByParam("checked", true, null);
}
var selectedNode;
//初始化时判断是否需要选择,这里可以去掉或者通过在zNodes中定义中添加checked:true来代替
if(selectedNodes != null && selectedNodes.length > 0){
for(var i=0; i<selectedNodes.length;i++){
selectedNode = selectedNodes[i];
if(selectedNode.id==treeNode.pId){
&