页面查看模式下,将元素转为文本展示

function view(type) {
    var dmt,bar;
    indexOfExpend();
    if (type == 1) {
        dmt = $(document);
        bar = $(parent.document);
    } else {
        dmt = $(document);
        bar = $(document);
    }
    //查看模式
    this.init = function() {
        if($(bar).find("#doctype").val() == ‘1‘ || $(bar).find("#statusidx").val() == ‘2‘
            || $(bar).find("#statusidx").val() == ‘4‘||$(bar).find("#statusidx").val() == ‘5‘){
            this.textSet();
            this.checkBoxSet();
            this.buttonSet();
            this.textAreaSet();
            this.radioSet();
            this.selectSet();
            this.aSet();
            this.imgSet();
            //单元格空白后移除
            this.hideBoxSet();

        }
    }
    this.textSet = function() {
        var tmp = "";
        $(dmt).find(":text").each(function() {
            tmp = $(this).val();
            $(this).replaceWith("<u>" + tmp + "</u>");
        });
    }
    this.checkBoxSet = function() {
        var len = $(dmt).find(".noremv").length;
        //判断是否是需要全部展示选中或没选中项
        if(len>0)
            $(dmt).find(".noremv").find("input[type=‘checkbox‘]").each(function() {
                if ($(this).attr("checked")) {
                    $(this).replaceWith("?");
                } else {
                    $(this).replaceWith("?");
                }
            });
        else//否则只显示选中项
        $(dmt).find("input[type=‘checkbox‘]").each(function() {
            if ($(this).attr("checked")) {
                $(this).replaceWith("");
            } else {
                //不显示其余的
                $(this).parents("li").replaceWith("");
                $(this).attr("disabled","disabled");
            }
        });
    }
    this.buttonSet = function() {
        if (type == 1) {
            $(dmt).find("input[type=‘button‘]:not(.ex)").each(function() {
                $(this).replaceWith("");
            });
        } else {
            $(dmt).find("input[type=‘button‘]:not(.ex)").each(function() {
                $(this).replaceWith("");
            });
        }
    }
    this.textAreaSet = function() {
        var tmp = "";
        $(dmt).find("textarea").each(function() {
            //判断是否为空
            if($(this).attr("class")==null){
                $(this).attr("readOnly",true);
                return;
            }
            if($(this).attr("class").indexOf("nov")==-1){
                tmp = $(this).val();
                $(this).replaceWith(tmp);
            }
        });
    }
    this.radioSet = function() {
        $(dmt).find("input[type=‘radio‘]").each(function() {
            if ($(this).is(":checked")) {
                $(this).remove();
            } else {
                //$(this).replaceWith("○");
                //不显示其余的
                $(this).parents("li").remove();
            }
        });
    }
    this.selectSet = function() {
        var tmp = "";
        $(dmt).find("select").each(function() {
            if($(this).attr("class")!="noremv"){
                tmp = $(this).find("option:selected").text();
                $(this).replaceWith("<u>" + tmp + "</u>");
            }

        });
    }
    this.aSet = function() {
        $(dmt).find("a").each(function() {
            //判断是否为空
            if($(this).attr("class")==null){
                return;
            }
            //设置不需要展示的超链接
            if ($(this).attr("class").indexOf("nov")!=-1) {
                $(this).replaceWith("");
            }
            //将超链接的文本由[修改]改为[查看]
            if ($(this).attr("class").indexOf("nov_")!=-1) {
                $(this).text("查看");
            }
        });

        $(dmt).find("a:contains(‘删除‘)").hide();

    }
    this.imgSet = function(){
        $(dmt).find("img").each(function(){
            if ($(this).attr("class") == ‘nov‘) {
                $(this).replaceWith("");
            }
        });
    }
    this.hideBoxSet = function(){
        $(dmt).find(".hidebox").each(function(){
            $(this).attr(‘style‘,‘width:0px;‘);
        });
    }
}

/**
 * indexOf
 */
function indexOfExpend(){
      if(typeof Array.indexOf !== ‘function‘ ){
             Array.prototype.indexOf = function(args){
                 var index = -1;
                 for(var i=0,l=this.length; i<l; i++){
                     if(this[i] === args){
                         index = i;
                         break;
                     }
                 }
                 return index;
             }
        }
}
时间: 2024-08-30 16:11:50

页面查看模式下,将元素转为文本展示的相关文章

RedHat Linux文本模式下乱码解决方法

如果在安装RedHat Linux时选择中文未缺省语言,在文本模式下会出现乱码情况,对于在CLI(command-line interface,命令行界面)方式下调试程序时诸多不便,因为出错信息全是乱码,下面说明乱码问题如何解决: 方法1: 1.locale命令查看当前系统使用的语言 可以看到当前系统使用中文语言 2.export LC_ALL=POSIX修改LC_ALL语言选项 3.locale命令再次查看 可以看到语言设置已修改,但该方法在用户注销或重启后会失效,若要保存设置请看方法2 方法

awstats CGI模式下动态生成页面缓慢的改进

本文可以看做是 http://kaifly.blog.51cto.com/3209616/1719248 这篇文章的下篇,在使用过程中发现awstats在cgi模式下动态生成分析报告慢的问题 (尤其是有些站点每天两个多G的日志,查看起来简直是在考验人的耐性),本文分享一种改造这个缺点的思路. 首先再来总结下awstats的处理过程以及查看分析结果的两种方式,来看官方版说明: Process logs: Building/updating statistics database,建立/更新统计数据

RHEL/CentOS纯文本模式下的开机自动登录

• Linux系统启动登录过程 Linux系统从启动到登录的整个过程大致如下: 1> 加载BIOS信息:包含了CPU/显卡/内存/硬盘/网卡等硬件信息.设备启动顺序.时钟信息等等 2> 根据BIOS的启动顺序信息,依次执行,直到找到引导文件 3> Boot Loader:加载启动引导文件 4> 加载内核,完成Linux核心环境的建立 5> 执行/sbin/init程序,读取配置文件/etc/inittab,设定运行等级,如level 3(这是加载完内核后,系统执行的第一个程序

MySQL 解密 --&gt; 如何查看二进制日志ROW模式下最原始的SQL语句

MySQL的binlog的ROW模式解析          在mysql5.6以后,对主从数据一致性要求变高了,statement格式逐渐不太适合业务的需求了,所以生产环境大家都采用了row模式,row模式是传输最底层的数据变化的insert的模块来进行主从数据的传输,那么在binlog里面就和普通的statement模式有何差别?能否看到最原始的sql语句呢? 1.准备录入数据 mysql> create table test1(id int,c1 varchar(20),type int,a

Linux文本模式下监听鼠标事件

Linux文本模式下监听鼠标事件,这里是通过gpm这个来实现的,代码如下: 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <gpm.h> 5 6 void main(int argc,char **argv) 7 { 8 fd_set readset; 9 Gpm_Event event; 10 Gpm_Connect conn; 11 12 conn.

WIN7-X64内核模式下编程实现导出表列表查看

内核模式下查看导出表需要注意的事项比在用户模式下要考虑更加周详: X64环境倒不是变化太多,指针定是64位的,数据数据及指针指向的数据类型需要注意: 不费话,直接上源码,VS2010+WDK7600下编译通过: /// /// @file aux_list.c /// @author cntom90151 /// @date2015-09-24 /// #include <ntddk.h> #include <WinDef.h> #include <aux_klib.h>

如何在命令行模式下查看Python帮助文档---dir、help、__doc__

如何在命令行模式下查看Python帮助文档---dir.help.__doc__ 1.dir函数式可以查看对象的属性,使用方法很简单,举str类型为例,在Python命令窗口输入 dir(str) 即可查看str的属性,如下图所示: 2.如何查看对象某个属性的帮助文档 ?如要查看str的split属性,可以用__doc__, 使用方法为print(str.split.__doc__),如下图所示: 3.查看对象的某个属性还可以用help函数,使用方法为help(str.split),如下图所示:

HTML兼容性 不声明doctype,IE9标准模式下position:fixed定位失败,导致遮罩层(Mask Layer)显示在页面最下方,FF和Chrome正常

问题描述:ie9标准模式下,老系统中的页面很少有写doctype的,但是不写这个声明,浏览器对于文档的解析机制就不一样了,特别是对于table和样式中的width, height 为100%布局,以及高度自适应的实现方案有影响,不了解的可以自行百度先,那么不写的话,又想加1个遮罩层的效果,一般我们遮罩层是借助position绝对定位实现的,可以写fixed,也可以写absolute,设置为fixed的时候,文档没有doctype,就会导致遮罩层出现在文档最下方,而不是绝对定位的效果,切换为ie9

【FastReport教程】在报表的预览模式下复制或删除页面

下载FastReport.Net最新版本 在FastReport 2018.4中,出现了一个非常有趣的功能 - 在预览模式下复制和删除报表页面.也就是说,您可以选择特定的报表页面并根据需要多次克隆,或删除所选页面.在这种情况下,对模板本身没有影响.即使你只有一页,要使一切恢复到原始状态 - 只需再次构建报表. 例如,如果要打印报表以及多个实例中所需的任何特定页面.相反,不想打印的某些页面,在打印设置中,您可以选择所需的页码.但你必须记住这些数字.这不是很方便.使用新功能,您可以添加所需的页面.