日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

一段js面向对象的写法

發布時間:2024/1/23 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 一段js面向对象的写法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

paper.js 文件中的內容


var PaperListPage = {}; PaperListPage.TimeOutID = null; PaperListPage.REPORTTYPE = 2 ; PaperListPage.REPROTROOTTYPE = 1; //1為固定報表 2 為自定義報表 PaperListPage.CURRENTREPORT = null; //當前報表類型 1:固定報表日報 2:固定報表月報 3:固定報表實時報表 4:自定義報表日報 5:自定義報表月報 PaperListPage.lastReportId = 1; //當前報表ID /*** 加載所有報表頁面*/PaperListPage.loadAll = function(reportType,areaType,dateType) {PaperPage.DateParam.date == null;// PaperListPage.REPORTTYPE = 2;PaperListPage.REPORTTYPE = dateType;PaperListPage.CURRENTREPORT = reportType;alert("clearHistory");clearHistory();alert("showLoading");showLoading();// $('#reportTypeSelected').text("月報");clearTimeout(PaperListPage.TimeOutID);PaperListPage.TimeOutID = setTimeout(function() {showLoadend("PaperListPage");}, 10000);$.ui.updatePanel("#paper_list_all_ul", "");// Api.getPaperList("2", "1", "PaperListPage.updateListContent");Api.getPaperList(reportType, areaType, "PaperListPage.updateListContent");$("#searchTxt").bind("input propertychange", function() {$("#paper_list_all_div").scroller().scrollToTop();var keyword = $(this).val();var cns = $(".paper_toggle_item");//var ens = $(".nameEN");$.each($(".paper_list_block"), function(n, value) {// alert("keyword"+keyword);PaperListPage.showPaperItem($(value));if ($(value).text().match(keyword)) {$(value).removeClass("none");} else {$(value).addClass("none");}});for (var i = 0; i < cns.length; i++) {if ($(cns[i]).text().match(keyword)) {$(cns[i]).removeClass("none");} else {$(cns[i]).addClass("none");}}});} /*** 加載日報*/ PaperListPage.loadDay = function() {//alert("1241241");PaperPage.DateParam.date == nullPaperListPage.REPORTTYPE = 1;clearHistory();showLoading();clearTimeout(PaperListPage.TimeOutID);PaperListPage.TimeOutID = setTimeout(function() {showLoadend("PaperListPage");}, 10000);$.ui.updatePanel("#paper_list_day_ul", "");Api.getPaperList("1", "1", "PaperListPage.updateListContentDay");$(".search-btn").children(".turn-text").text("省版");$("#daysearchTxt").bind("input propertychange", function() {$("#paper_list_day_div").scroller().scrollToTop();var keyword = $(this).val();// alert(keyword);var cns = $(".paper_toggle_item");$.each($(".paper_list_block"), function(n, value) {// alert("keyword"+keyword);PaperListPage.showPaperItem($(value));if ($(value).text().match(keyword)) {$(value).removeClass("none");} else {$(value).addClass("none");}});for (var i = 0; i < cns.length; i++) {if ($(cns[i]).text().match(keyword)) {$(cns[i]).removeClass("none");} else {$(cns[i]).addClass("none");}}});} /*** 加載實時*/ PaperListPage.loadReal = function() {PaperPage.DateParam.date == nullPaperListPage.REPORTTYPE = 1;clearHistory();showLoading();clearTimeout(PaperListPage.TimeOutID);PaperListPage.TimeOutID = setTimeout(function() {showLoadend("PaperListPage");}, 10000);$.ui.updatePanel("#paper_list_real_ul", "");Api.getPaperList("3", "2", "PaperListPage.updateListContentReal");$("#realsearchTxt").bind("input propertychange", function() {$("#paper_list_real_div").scroller().scrollToTop();var keyword = $(this).val();var cns = $(".paper_toggle_item");//var ens = $(".nameEN");$.each($(".paper_list_block"), function(n, value) {// alert("keyword"+keyword);PaperListPage.showPaperItem($(value));if ($(value).text().match(keyword)) {$(value).removeClass("none");} else {$(value).addClass("none");}});for (var i = 0; i < cns.length; i++) {if ($(cns[i]).text().match(keyword)) {$(cns[i]).removeClass("none");} else {$(cns[i]).addClass("none");}}});} //日報 切換省版和市版 PaperListPage.turnDayCity = function(el) {//alert(1);$("#paper_list_day_ul").html("");if ($(el).children(".turn-text").text() == "市版") {$(el).children(".turn-text").text("省版");//if(ServerInfo.AREACODE=='0010'){if(ServerInfo.userType=='1'&&ServerInfo.AREACODE=='0010'){showLoading();Api.getPaperList("1", "1", "PaperListPage.updateListContentDay"); }else{$("#paper_list_all_ul").html("");}} else {$(el).children(".turn-text").text("市版");if(ServerInfo.userType=='1'){showLoading();Api.getPaperList("1", "2", "PaperListPage.updateListContentDay");}else{$("#paper_list_all_ul").html("");}} }//實時報表 PaperListPage.turnRealCity = function(el) {$("#paper_list_real_ul").html("");if ($(el).children(".turn-text").text() == "市版") {$(el).children(".turn-text").text("省版");$("#paper_list_real_ul").html("");} else {$(el).children(".turn-text").text("市版");if(ServerInfo.userType=='1'){showLoading();Api.getPaperList("3", "2", "PaperListPage.updateListContentReal");}else{$("#paper_list_all_ul").html("");}} }PaperListPage.turnMonthCity = function(el) { // $.ui.updatePanel("#paper_list_all_ul", "");//$("#paper_list_all_ul").html("");if ($(el).children(".turn-text").text() == "市版") {$(el).children(".turn-text").text("省版"); // if(ServerInfo.AREACODE=='0010'){if(ServerInfo.userType=='1'&&ServerInfo.AREACODE=='0010'){showLoading();Api.getPaperList(PaperListPage.CURRENTREPORT, "1", "PaperListPage.updateListContentNew"); }else{$("#paper_list_all_ul").html("");}} else {$(el).children(".turn-text").text("市版");if(ServerInfo.userType=='1'){showLoading();Api.getPaperList(PaperListPage.CURRENTREPORT, "2", "PaperListPage.updateListContentNew");}else{$("#paper_list_all_ul").html("");}} } /*** 加載最近訪問頁面*/ PaperListPage.loadRecently = function() {clearHistory();showLoading();$.ui.updatePanel("#paper_list_recent_ul", "");Api.getRecentPaperList("PaperListPage.updateRecentListContent"); } /*** 加載我的收藏頁面*/ PaperListPage.loadFavorite = function() {clearHistory();showLoading();$.ui.updatePanel("#paper_list_fav_ul", "");Api.getFavPaperList("1", "1", "PaperListPage.updateFavListContent"); } /*** 跳轉最近訪問*/ PaperListPage.turnRecently = function() {$.ui.loadContent("#paper_list_recently", true, true, "none"); } /*** 跳轉我的收藏*/ PaperListPage.turnFavorite = function() {$.ui.loadContent("#paper_list_favorite", true, true, "none"); } /*** 跳轉報表詳情*/ PaperListPage.turnDetail = function(el) {// $.ui.updateContentDiv("#paper_detail_iframe", "");var id = $(el).attr("data-report-id");var reportType = $(el).attr("data-report-type");var isFav = $(el).attr("data-isFav");var title = $(el).attr("data-report-title");$("#paper_detail").attr("data-reportId", id);$("#paper_detail").attr("data-reportType", reportType);$("#paper_detail").attr("data-isFav", isFav);$(".paper-d-title").text(title);$.ui.loadContent("#paper_detail", false, false, "none");// alert("加載滾動條");} /*** 跳轉所有報表*/ PaperListPage.turnAll = function() {$.ui.loadContent("#paper_list_all",true,true,"none");PaperListPage.REPORTTYPE = 1;if(ServerInfo.userType == 1){//領導用戶PaperListPage.REPROTROOTTYPE = 1; //固定報表//$('#reportTypeRoot').text("固定");$("#reportTypeRoot1").addClass("on_un").siblings("a").removeClass("on_un");$('#reportTypeSelected').text("實時");$(".turn-text").parent().parent().show();$("#searchTxt").parent().css("width","70%");$(".turn-text").text("市版");PaperListPage.loadAll("3","2","1");}else if (ServerInfo.userType == 0){PaperListPage.REPROTROOTTYPE = 2; //自定義報表類型//$('#reportTypeRoot').text("自定義");$("#reportTypeRoot2").addClass("on_un").siblings("a").removeClass("on_un");$('#reportTypeSelected').text("日報");$(".turn-text").parent().parent().hide();$("#searchTxt").parent().css("width","100%");PaperListPage.loadAll("4","1","1");}} /*** 更新列表內容*/ PaperListPage.updateListContent = function(result) {//alert(result);var data = decodeJson(result);var mychildrn = data.DATA[0].CHILDREN;if(data.DATA[0].NAME=='自定義報表'){if (mychildrn == null || mychildrn == '') {//$("#myPopup").trigger("close");//alert("未配置自定義報表");//$("#paper_list_all_div").scroller().scrollToTop();/*showLoadendErr("PaperListPage","未配置自定義報表");comfirm("未配置自定義報表");setTimeout(function() {$("#myPopup").trigger("close");}, 3000);clearTimeout(PaperListPage.TimeOutID);*/if(Api.isAndroid){window.wst.show_noReportsDialog("未配置自定義報表");}else{sweetAlert("未配置自定義報表");clearTimeout(PaperListPage.TimeOutID);}}}else if (mychildrn == null || mychildrn == '') {//$("#myPopup").trigger("close");//alert("權限不足");//showLoadend("PaperListPage");//$("#paper_list_all_div").scroller().scrollToTop();/*showLoadendErr("PaperListPage","權限不足");comfirm("權限不足");setTimeout(function() {$("#myPopup").trigger("close");}, 3000);*/if(Api.isAndroid){window.wst.show_noReportsDialog("權限不足");}else{sweetAlert("權限不足");clearTimeout(PaperListPage.TimeOutID);}}var listData = {};// listData.DataBlocks = [];listData.DataBlocks = data.DATA;var html = template('paper_list_all_itemtpl', listData);//$.ui.updatePanel("#paper_list_all_ul", html);$("#paper_list_all_ul").html(html);var height = $(window).height() - $("#header").height() - $("#navbar").height() - $('.searchBar').height();$("#paper_list_all_div").height(height);$("#paper_list_all_div").scroller().enable();$(".paper_toggle_item").hide();//隱藏所有2級菜單// $(TitleUl).find("img").attr("src", "img/main/arrow_d.png");$.each($(".paper-list-divider"), function(n, value) {// alert(n+"------>:"+value.innerHTML);if (n < 1) {var tmp = $(value);$(value).find("img").attr("src", "img/main/arrow_d.png");var b = tmp.parent().children(".paper_toggle_item");b.css('display', 'block');}});hideLoading();//取消延遲彈框$("#myPopup").trigger("close");clearTimeout(PaperListPage.TimeOutID);$("#paper_list_all_div").scroller().scrollToTop(); }PaperListPage.updateListContentNew = function(result) {var data = decodeJson(result);var listData = {};listData.DataBlocks = data.DATA;var html = template('paper_list_all_itemtpl', listData); // $.ui.updatePanel("#paper_list_all_ul", html);$("#paper_list_all_ul").html(html);var height = $(window).height() - $("#header").height() - $("#navbar").height() - $('.searchBar').height();$("#paper_list_all_div").height(height);$("#paper_list_all_div").scroller().enable();$(".paper_toggle_item").hide();$.each($(".paper-list-divider"), function(n, value) {// alert(n+"------>:"+value.innerHTML);if (n < 1) {var tmp = $(value);$(value).find("img").attr("src", "img/main/arrow_d.png");var b = tmp.parent().children(".paper_toggle_item");b.css('display', 'block');}});hideLoading();$("#paper_list_all_div").scroller().scrollToTop();//取消延遲彈框$("#myPopup").trigger("close");clearTimeout(PaperListPage.TimeOutID); }PaperListPage.updateListContentDay = function(result) {// alert(result);var data = decodeJson(result);var listData = {};listData.DataBlocks = data.DATA;var html = template('paper_list_day_itemtpl', listData);// alert(html);$("#paper_list_day_ul").html(html);var height = $(window).height() - $("#header").height() - $("#navbar").height() - $('.searchBar').height();$("#paper_list_day_div").height(height);$("#paper_list_day_div").scroller().enable();$(".paper_toggle_item").hide();$.each($(".paper-list-divider"), function(n, value) {if (value.innerHTML.indexOf("收入用戶")>0) {// if (n < 1) {var tmp = $(value);$(value).find("img").attr("src", "img/main/arrow_d.png");var b = tmp.parent().children(".paper_toggle_item");b.css('display', 'block');}});hideLoading();$("#paper_list_day_div").scroller().scrollToTop();//取消延遲彈框$("#myPopup").trigger("close");clearTimeout(PaperListPage.TimeOutID); }PaperListPage.updateListContentReal = function(result) {var data = decodeJson(result);var listData = {};listData.DataBlocks = data.DATA;var html = template('paper_list_real_itemtpl', listData); // $.ui.updatePanel("#paper_list_all_ul", html);$("#paper_list_real_ul").html(html);var height = $(window).height() - $("#header").height() - $("#navbar").height() - $('.searchBar').height();$("#paper_list_real_div").height(height);$("#paper_list_real_div").scroller().enable();$(".paper_toggle_item").hide();$.each($(".paper-list-divider"), function(n, value) {// alert(n+"------>:"+value.innerHTML);if (value.innerHTML.indexOf("實時放號報表")>0) {var tmp = $(value);// alert(tmp.innerHTML);$(value).find("img").attr("src", "img/main/arrow_d.png");var b = tmp.parent().children(".paper_toggle_item");b.css('display', 'block');}});hideLoading();$("#paper_list_real_div").scroller().scrollToTop();//取消延遲彈框$("#myPopup").trigger("close");clearTimeout(PaperListPage.TimeOutID); }/*** 更新我的收藏列表內容*/ PaperListPage.updateFavListContent = function(result) {// alert("我的收藏:"+result);if (result == "null") {hideLoading();return;}var data = decodeJson(result);if (data.RESPONSECODE != "200") {hideLoading();return;}var data = decodeJson(result);var listData = {};listData.DataBlocks = data.DATA;var html = template('paper_list_fav_itemtpl', listData);$.ui.updatePanel("#paper_list_fav_ul", html);var height = $(window).height() - $("#header").height() - $("#navbar").height() - $('.searchBar').height();$("#paper_list_fav_div").height(height);$("#paper_list_fav_div").scroller().enable();hideLoading(); }/*** 更新列表內容*/ PaperListPage.updateRecentListContent = function(result) {if (result == null) {hideLoading();return;}var data = decodeJson(result);if (data.RESPONSECODE != "200") {hideLoading();return;}var listData = {};listData.DataBlocks = data.DATA;var html = template('paper_list_recent_itemtpl', listData);$.ui.updatePanel("#paper_list_recent_ul", html);var height = $(window).height() - $("#header").height() - $("#navbar").height() - $('.searchBar').height(); // $("#paper_list_recent_div").height(height); // $("#paper_list_recent_div").scroller().enable();hideLoading(); }PaperListPage.togglePaperItem = function(el) {var block = $(el).parent(".paper_list_block");var showFlag = block.attr('SHOW');if (!showFlag) {PaperListPage.showPaperItem(block);} else {PaperListPage.hidePaperItem(block);} }PaperListPage.showPaperItem = function(block) {block.attr('SHOW', "SHOW");var ChartDiv = block.children(".paper_toggle_item");var TitleUl = block.children(".paper-list-divider");$(TitleUl).find("img").attr("src", "img/main/arrow_d.png");ChartDiv.css('display', 'block');var top =TitleUl.offset().top;if(top > 400){document.getElementById('paper_list_all_div').scrollTop =100;}}PaperListPage.hidePaperItem = function(block) {block.removeAttr('SHOW');var ChartDiv = block.children(".paper_toggle_item");var TitleUl = block.children(".paper-list-divider");$(TitleUl).find("img").attr("src", "img/main/arrow_r.png");ChartDiv.css('display', 'none');// var top =TitleUl.offset().top;// $("#paper_list_all_div").css("top",top);// document.getElementById('paper_list_all_div').scrollTop = top-25;$("#paper_list_fav_div").scroller().enable(); } var PaperPage = {}//數據參數 -- 日期 PaperPage.DateParam = {date : null,//檢查初始化checkInit : function() {if (this.date == null) {this.date = new Date();var dateStr = getLastMonth(this.date) + '-1'this.date = dateStr.toDate();}$("#paper_detail_header .date_text").text(this.date.Format("yyyy-MM"));},setDate:function(result){//alert("返回日期:"+result);if(result.indexOf('null')>-1){var d = new Date();var vYear = d.getFullYear();var vMon = d.getMonth()+1;var vDay = d.getDate();if (PaperListPage.REPORTTYPE == 1){var vDayStr = (vDay-1)+"";if(vDayStr=="0"){var vMonStr = (vMon-1)+"";if(vMonStr=="0"){vYear=vYear-1;result = vYear+"-12-31";}else{if(vMonStr=="2"||vMonStr=="4"||vMonStr=="6"||vMonStr=="7"||vMonStr=="9"){result = vYear+"-"+ ((vMon-1) < 10 ? "0" + (vMon-1) : (vMon-1)) +"-31";}else if(vMonStr=="3"||vMonStr=="5"||vMonStr=="8"||vMonStr=="10"){result = vYear+"-"+ ((vMon-1) < 10 ? "0" + (vMon-1) : (vMon-1)) +"-30";}else{result = vYear+"-"+ ((vMon-1) < 10 ? "0" + (vMon-1) : (vMon-1)) +"-28";}}}else{vDay = vDay -1;result = vYear+"-"+ (vMon < 10 ? "0" + vMon : vMon)+"-" + (vDay < 10 ? "0" + vDay : vDay);}} else if(PaperListPage.REPORTTYPE == 2){vMon-1==0result = (vMon-1==0?vYear-1:vYear) + "-" + (vMon-1==0?"12": (vMon-1<10?"0" + vMon : vMon));//alert(result);this.date = new Date(result);}}if (this.date == null) {this.date = new Date(result);}var dateStr = null;if (PaperListPage.REPORTTYPE == 1){dateStr = PaperPage.DateParam.date.Format("yyyy-MM-dd");} else if(PaperListPage.REPORTTYPE == 2){dateStr = PaperPage.DateParam.date.Format("yyyy-MM");}$("#paper_detail_header .date_text").text(dateStr);//開始加載數據并顯示PaperPage.loadPage();},//調用日歷控件change : function() {//alert(PaperListPage.REPORTTYPE);//alert("現在時間PaperPage.DateParam:"+this.date);if (PaperListPage.REPORTTYPE == 1){Api.showCalendar(this.date, "PaperPage.DateParam.update");} else if(PaperListPage.REPORTTYPE == 2){Api.showCalendar(this.date, "PaperPage.DateParam.update", true);}},//回調更新update : function(dateStr) {//回調,注意this為空//alert("返回的日期1:"+dateStr);var prev = null;if (PaperListPage.REPORTTYPE == 1){prev = PaperPage.DateParam.date.Format("yyyy-MM-dd");} else if(PaperListPage.REPORTTYPE == 2){prev = PaperPage.DateParam.date.Format("yyyy-MM");}// var prev = PaperPage.DateParam.date.Format("yyyy-MM");if (prev == dateStr) {return;}dateStr = new Date(dateStr); // alert("返回的日期2:"+dateStr);PaperPage.DateParam.date = dateStr;// alert("返回的日期3:"+PaperPage.DateParam.date);if (PaperListPage.REPORTTYPE == 1){dateStr = PaperPage.DateParam.date.Format("yyyy-MM-dd");} else if(PaperListPage.REPORTTYPE == 2){dateStr = PaperPage.DateParam.date.Format("yyyy-MM");}$("#paper_detail_header .date_text").text(dateStr);PaperPage.reload();} } /*** 初始化將報表iframe增加到最大,詳情數據*/ PaperPage.loadPage = function() {showLoading();//PaperListPage.TimeOutID = //setTimeout(function() {// hideLoading();//}, 3000);var id = $("#paper_detail").attr("data-reportId");var isFav = $("#paper_detail").attr("data-isFav");if (isFav == "1") {$("#paper_detail_header .img_fav").attr("src","img/paper/bb_fav.png");} else{$("#paper_detail_header .img_fav").attr("src","img/paper/bb_fav_a.png");}Api.addRecent(id,"doNothing");var reportType = $("#paper_detail").attr("data-reportType");// PaperPage.DateParam.checkInit();var reportidsList = "["+id+"]";PaperPage.DateParam.date == null;if(PaperPage.DateParam.date == null){Api.getCanSelectDate(reportidsList,PaperListPage.REPORTTYPE,0,"PaperPage.DateParam.setDate");return}PaperPage.FavParam.checkInit();//格式化請求時間var dateStr = null;if (PaperListPage.REPORTTYPE == 1){dateStr = PaperPage.DateParam.date.Format("yyyy-MM-dd");} else if(PaperListPage.REPORTTYPE == 2){dateStr = PaperPage.DateParam.date.Format("yyyy-MM");}// alert("111");if(Api.isAndroid){// reportType = 1;// alert("報表類型:"+reportType+",報表ID :"+id);// alert(reportType);Api.getReportHTML(id,reportType,1,dateStr,"useIframeFunc2");// Api.getReportHTML(id,reportType,1,dateStr,"useIframeFunc");}else{var contentWidth = window.screen.width - $("#header").height() - $("#navbar").height();var contentHeight = window.screen.height - $("#header").height() - $("#navbar").height() - 49;// alert("寬:"+contentWidth+",高:"+contentHeight)// $("#paper_detail_iframe").attr("src", "iframe/singletable.html");// Api.getReportHTML(id,reportType,1,dateStr,"reportResult"); //監測報表是否有數據//IOS判斷同一個報表是否存在數據//如果同一個報表什么也不做。報表ID變化之后重置遞減的次數,并記錄當前指標// alert("上一個報表ID:"+PaperListPage.lastReportId+",當前報表ID:"+id+",減數次數:"+monthDown);// if( id == PaperListPage.lastReportId){// // isSameReport = true;// // alert("887978-----------:"+monthDown);// }else{// monthDown = 1;// PaperListPage.lastReportId = id;// }// ServerInfo.URL=ServerInfo.URL.substr(0,ServerInfo.URL.length-1);// alert(ServerInfo.URL);// var url = ServerInfo.URL+"gducdc/phone.html;jsessionid="+ServerInfo.JSESSIONID+"?action=getData&REPORTID="+id+"&PID=-1&ISHTML=1&DATE="+dateStr+"&TOKEN="+ServerInfo.TOKEN+"&MOBILE="+ServerInfo.MOBILE+"&DIGFLAG=0&ISINDEX=1&MUTILDATE=true&REPORTTYPE="+reportType+"&width="+contentWidth+"&height="+contentHeight;var url = ServerInfo.URL+"gducdc/phone.html;jsessionid="+ServerInfo.JSESSIONID+"?action=getData&REPORTID="+id+"&PID=-1&ISHTML=1&DATE="+dateStr+"&TOKEN="+ServerInfo.TOKEN+"&MOBILE="+ServerInfo.MOBILE+"&DIGFLAG=0&MUTILDATE=true&REPORTTYPE="+reportType+"&width="+contentWidth+"&height="+contentHeight;///alert(url);$("#paper_detail_iframe").attr("src", url);$('#paper_detail_iframe').load(function(){hideLoading(); }); }PaperPage.updateFrameSize();$(window).bind('resize', PaperPage.updateFrameSize);// }PaperPage.reload = function() {PaperPage.loadPage();showLoading();setTimeout(function() {hideLoading();}, 2000); }PaperPage.unloadPage = function() { // $("#paper_detail_iframe").attr("src", ""); PaperPage.DateParam.date = null; }PaperPage.updateFrameSize = function() {// alert("111");//獲得高度var height = IndexPage.getContentAreaHeight();//高度賦值var frame = $("#paper_detail_iframe");frame.height(height); }PaperPage.FavParam = {status : null,//檢查初始化checkInit : function() {var isFav = $("#paper_detail").attr("data-isFav");if (isFav == "1") {PaperPage.FavParam.status = 1;} else{PaperPage.FavParam.status = 0;}},//調用改變狀態change : function() {var reportId = $("#paper_detail").attr("data-reportId");Api.updateFavStatus(reportId, "PaperPage.FavParam.update");// alert(document.getElementById("paper_detail").innerHTML);},//回調更新update : function(dateStr) {//回調,注意this為空dateStr = decodeJson(dateStr);$("#afui").popup({title : "提示",message : dateStr.MESSAGE,cancelText : "確定",cancelCallback: function(){$.ui.unblockUI();},cancelOnly : true});if (PaperPage.FavParam.status == 1) {PaperPage.FavParam.status = 0;$("#paper_detail").attr("data-isFav","0");$("#paper_detail_header .img_fav").attr("src","img/paper/bb_fav_a.png");} else {PaperPage.FavParam.status = 1;$("#paper_detail").attr("data-isFav","1");$("#paper_detail_header .img_fav").attr("src","img/paper/bb_fav.png");}} }//彈出報表名稱和報表時間 PaperPage.showTitleDetail = function (el) { // //alert($(el).children(".paper-d-title").text()) // //alert($(el).children(".date_text").text())$.ui.actionsheet('<p>報表名稱:' + $(el).children(".paper-d-title").text() + '</p><p>統計時段:' + $(el).children(".date_text").text() + '</p>'); }function chooseReportType(type) {if(type == 3){$('#reportTypeSelected').text("月報");document.getElementById("mor").style.display="none";// var f = "http://localapp/mdcApp/index.html#paper_list_all";$.ui.loadContent("#paper_list_all",true,true,"none");// PaperListPage.loadAll();if(PaperListPage.REPROTROOTTYPE == 1){PaperListPage.CURRENTREPORT = 2;}else if(PaperListPage.REPROTROOTTYPE == 2){PaperListPage.CURRENTREPORT = 5;}if(ServerInfo.userType=='1'){if(ServerInfo.AREACODE=='0010'){PaperListPage.loadAll(PaperListPage.CURRENTREPORT,"1","2");$(".turn-text").text("省版");}else{PaperListPage.loadAll(PaperListPage.CURRENTREPORT,"2","2");$(".turn-text").text("市版");}}else{if(PaperListPage.REPROTROOTTYPE==2){if(Api.isAndroid){window.wst.show_noReportsDialog("未配置自定義報表");}else{sweetAlert("未配置自定義報表");clearTimeout(PaperListPage.TimeOutID);}}else{if(Api.isAndroid){window.wst.show_noReportsDialog("權限不足");}else{sweetAlert("權限不足");clearTimeout(PaperListPage.TimeOutID);}}$("#paper_list_all_ul").html("");}PaperListPage.REPORTTYPE = 2;}else if(type == 2){$('#reportTypeSelected').text("日報");document.getElementById("mor").style.display="none";if(PaperListPage.REPROTROOTTYPE == 1){PaperListPage.CURRENTREPORT = 1;}else if(PaperListPage.REPROTROOTTYPE == 2){PaperListPage.CURRENTREPORT = 4;}// var f = "http://localapp/mdcApp/index.html#paper_list_day";$.ui.loadContent("#paper_list_all",true,true,"none");PaperListPage.REPORTTYPE = 1;// PaperListPage.loadDay();if(ServerInfo.userType=='1'){if(ServerInfo.AREACODE=='0010'){PaperListPage.loadAll(PaperListPage.CURRENTREPORT,"1","1");$(".turn-text").text("省版");}else{PaperListPage.loadAll(PaperListPage.CURRENTREPORT,"2","1");$(".turn-text").text("市版");}}else{if(PaperListPage.REPROTROOTTYPE==2){if(Api.isAndroid){window.wst.show_noReportsDialog("未配置自定義報表");}else{sweetAlert("未配置自定義報表");clearTimeout(PaperListPage.TimeOutID);}}else{if(Api.isAndroid){window.wst.show_noReportsDialog("權限不足");}else{sweetAlert("權限不足");clearTimeout(PaperListPage.TimeOutID);}}$("#paper_list_all_ul").html("");}}else if(type == 1){$('#reportTypeSelected').text("實時");document.getElementById("mor").style.display="none";// var f = "http://localapp/mdcApp/index.html#paper_list_real";if(PaperListPage.REPROTROOTTYPE == 1){PaperListPage.CURRENTREPORT = 3;}else if(PaperListPage.REPROTROOTTYPE == 2){PaperListPage.CURRENTREPORT = 6;}$.ui.loadContent("#paper_list_all",true,true,"none");PaperListPage.REPORTTYPE = 1;// PaperListPage.loadReal();if(ServerInfo.userType=='1'){PaperListPage.loadAll(PaperListPage.CURRENTREPORT,"2","1");$(".turn-text").text("市版");}else{if(PaperListPage.REPROTROOTTYPE==2){if(Api.isAndroid){window.wst.show_noReportsDialog("未配置自定義報表");}else{sweetAlert("未配置自定義報表");clearTimeout(PaperListPage.TimeOutID);}}else{if(Api.isAndroid){window.wst.show_noReportsDialog("權限不足");}else{sweetAlert("權限不足");clearTimeout(PaperListPage.TimeOutID);}}$("#paper_list_all_ul").html("");}}}function chooseReport(type) {if(type == 1){PaperListPage.REPROTROOTTYPE = 1; //固定報表類型if(ServerInfo.userType=='1'){$('#reportTypeSelected').text("實時");$(".turn-text").text("市版");// var f = "http://localapp/mdcApp/index.html#paper_list_all";$.ui.loadContent("#paper_list_all",true,true,"none");PaperListPage.loadAll("3","2","1");PaperListPage.REPORTTYPE = 1;$(".turn-text").parent().parent().show();$("#searchTxt").parent().css("width","77%");}else{if(Api.isAndroid){window.wst.show_noReportsDialog("權限不足");}else{sweetAlert("權限不足");clearTimeout(PaperListPage.TimeOutID);}$("#paper_list_all_ul").html("");}}else if(type == 2){$('#reportTypeSelected').text("日報");// var f = "http://localapp/mdcApp/index.html#paper_list_day";$.ui.loadContent("#paper_list_all",true,true,"none");PaperListPage.REPORTTYPE = 1;PaperListPage.loadAll("4","1","1");PaperListPage.REPROTROOTTYPE = 2; //自定義報表類型$(".turn-text").parent().parent().hide();$("#searchTxt").parent().css("width","100%");}}
調用方式

首先引入paper.js

然后在當前js文件中使用

if(page == "PaperListPage"){ //報表列表PaperListPage.loadAll(); }

總結

以上是生活随笔為你收集整理的一段js面向对象的写法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。