MyException - 我的异常网
当前位置:我的异常网» JavaScript » js轨范

js轨范

www.MyException.Cn  网友分享于:2018-05-16  浏览:0次
js规范


(function(e) {
    function questions_list() {
        this.addId = "";    //添加页页签id
    };
    questions_list.prototype = {
        inital : function inital() {

        },

        /**
         * 添加
         */
        create : function create(type) {
            this.addId = questionsList.randomNum(1,100000);
            openPage(this.addId,ctx+"/system/examstack/question/questions/formPage.chtml?type="+type+"&tabId="+this.addId,"添加" + (type == 'naire'?'问题':'试题'));
        },

        /**
         * 修改
         */
        edit : function edit(id) {
            dialogShow("修改分类",900,600,ctx+"/system/examstack/question/questions/update/"+id+".chtml");

        },

        /**
         * 预览
         */
        preview : function preview(id) {
            dialogShowNoButton("试题预览",900,600,ctx+"/system/examstack/question/questions/preview/"+id+".chtml");
        },

        /**
         * 打开新窗口预览
         * @param id
         */
        previewBlank : function previewBlank(id) {
            window.open(ctx+"/system/examstack/question/questions/preview/"+id+".chtml");
        },

        /**
         * 导出
         * @constructor
         */
        BTNexport : function BTNexport(type) {
            dialogShow("导出数据",350,350,ctx+"/system/examstack/question/questions/formExport.chtml?type=" + type);
        },

        composeEntity : function composeEntity() {

            var data = new Object();

            var question_entity = new Object();

            var pointList = new Array();

            var pointOpts = $("#point-to-select option");

            for (var i = 0; i < pointOpts.length; i++) {
                pointList.push($(pointOpts[i]).attr("value"));
            }

            question_entity.pointList = pointList;
            question_entity.id = $("#add-update-questionid").val();
            question_entity.analysis = $(".form-question-analysis textarea").val();
            question_entity.reference = $(".form-question-reference input").val();
            question_entity.examingPoint = $(".form-question-examingpoint input").val();
            question_entity.keyword = $(".form-question-keyword input").val();

            data.question = question_entity;
            return data;

        },

        /**
         * 绑定更新操作
         * @returns {boolean}
         */
        bindUpdate : function bindUpdate() {
            if ($("#kn-selected option").length == 0) {
                util.error("请选择知识类");
                return false;
            }
            parent.loading();
            var data = questionsList.composeEntity();
            $.ajax({
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                type : "POST",
                url : ctx + "/system/examstack/question/questions/update.chtml",
                data : JSON.stringify(data),
                success : function(message, tst, jqXHR) {
                    if(message.errorCode == "0") {
                        //
                        setTimeout("parent.location.href = ctx + '/system/examstack/question/questions.chtml?type=questions'", 1000);
                    }else {
                        failmsg(message.message);
                    }
                },
                error : function(jqXHR, textStatus) {
                    util.error("操作失败请稍后尝试");
                    $(".df-submit").removeAttr("disabled");
                }
            });
        },

        /**
         * 生成随机数
         */
        randomNum : function randomNum(Min, Max) {
            var Range = Max - Min;
            var Rand = Math.random();
            if(Math.round(Rand * Range)==0){
                return Min + 1;
            }else if(Math.round(Rand * Max)==Max)
            {
                index++;
                return Max - 1;
            }else{
                var num = Min + Math.round(Rand * Range) - 1;
                return num;
            }
        }
    };
    window.questionsList = new questions_list();
    questionsList.inital();
})(jQuery);

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有