//定义setTimeout执行方法 var TimeFn = null; //点击次数 var isclick = 0; //护眼模式组 var eyecareArr = ['original','filter-ha','filter-rh','filter-gl','filter-gdb','filter-hd'] //当前皮肤 var isskin = window.localStorage.getItem('slh_isskin') || 'original'; //字号 var isfont = window.localStorage.getItem('slh_isfont') || 18; //行高 var isline = window.localStorage.getItem('slh_isline') || 0; //语速 var speech = window.localStorage.getItem('slh_speech') || 1; //护眼 var iseyecare = window.localStorage.getItem('slh_iseyecare') || 0; //是否开启语音 var isAudio = window.localStorage.getItem('slh_isAudio') || 0; //是否开启适老化 var isSlh = window.localStorage.getItem('slh_isSlh') || 0; //上一个点击元素 var istopDom = null; var isoldDom = null; // 初次加载 $(function(){ if(isSlh == 1){ initialLoad() } //开启适老化 $("#shilaohuas").click(function(){ openSLH() }) }) // 加载 function initialLoad(){ domInitializefun() initializefun() $("body *:not(table,tbody,thead,tfoot,tr)").off("click", onyuying); $("body *:not(table,tbody,thead,tfoot,tr)").on("click",onyuying) $(".setup-title div").click(function(){ $(".suit-old-setup").slideUp() }) //设置切换 $(".setup-nav-item").click(function(){ $(this).addClass("active").siblings().removeClass("active") $(".setup-cont").eq($(this).index()).show().siblings(".setup-cont").hide() }) //设置护眼模式 $(".eyecare .eyecare-itembox div").click(function(){ if(isskin == 'original'){ // setTimeout(function(){ // tts_audio('护眼模式需先设置主题') // },600); return false } $(this).addClass("active").siblings().removeClass("active") $("html").removeClass().addClass(eyecareArr[$(this).index()]) iseyecare = $(this).index() window.localStorage.setItem('slh_iseyecare',iseyecare); }) //子页面元素添加语音 if($("iframe").length > 0){ $("iframe").each(function(i,item){ console.log(666) document.getElementsByTagName('iframe')[i].contentWindow.document.body.setAttribute("jm","jm") $(item).contents().find("body *:not(table,tbody,thead,tfoot,tr)").addClass("zjm") $(item).contents().find("body *:not(table,tbody,thead,tfoot,tr)").off("click", onyuying); $(item).contents().find("body *:not(table,tbody,thead,tfoot,tr)").on("click",onyuying); }) } setTimeout(function(){ console.log(777) $("body *:not(table,tbody,thead,tfoot,tr)").addClass("zhang") $("body *:not(table,tbody,thead,tfoot,tr)").off("click", onyuying); $("body *:not(table,tbody,thead,tfoot,tr)").on("click",onyuying) //子页面元素添加语音 if($("iframe").length > 0){ $("iframe").each(function(i,item){ document.getElementsByTagName('iframe')[i].contentWindow.document.body.setAttribute("mm","mm") $(item).contents().find("body *:not(table,tbody,thead,tfoot,tr)").addClass("zhang") $(item).contents().find("body *:not(table,tbody,thead,tfoot,tr)").off("click", onyuying); $(item).contents().find("body *:not(table,tbody,thead,tfoot,tr)").on("click",onyuying); }) } },2000) } //触发语音 function onyuying(e){ //双击计算 isclick++ let that = $(this) // let parent = that.parents("a") let parentType = parentEach(that) if(parentType != false && parentType[0].tagName == 'A' && parentType.attr("href").indexOf("javascript") == -1){ e.stopPropagation(); // let parentType = parentEach(that) let target = parentType != false ? parentType.attr("target") : false console.log(target,444) if(!target || target == "_blank" || target == "_self" || target == "_parent" || target == "_top"){ console.log(target,'aaaa') e.preventDefault(); } }else{ let isoldDomtxt = isoldDom != null ? isoldDom.parent().text() : false let thattxt = that.text() if(isoldDomtxt == thattxt){ isclick = 0 isoldDom = null return false } } isoldDom = that console.log(that,111) if(isAudio != 1){ if(that[0].tagName == 'A'){ towclick($(this)) }else{ // let parentType = parentEach(that) if(parentType != false){ towclick(parentType) }else{ isclick = 0 } } }else{ //语音开启后执行 //阻止链接跳转 $(".audio-line").removeClass("audio-line") if($("iframe").length > 0){ $("iframe").each(function(i,item){ $(item).contents().find(".audio-line").removeClass("audio-line") }) } // if(istopDom != null){ // istopDom.css("box-shadow","") // } that.addClass("audio-line") // that.css("box-shadow","inset 0 0 2px 2px red") istopDom = that //判断父级 let type = parentEach(that) // if(type[0].tagName == 'A'){ // e.preventDefault(); // } if(isclick > 1 && type != false && type[0].tagName == 'A'){ console.log(222) clearTimeout(TimeFn); towclick(type) }else{ console.log(333) clearTimeout(TimeFn); TimeFn = setTimeout(function(){ isclick = 0 let ttsText = that.text() if(that[0].tagName == 'IMG'){ ttsText = '图片' }else if(type != false && type[0].tagName == 'A'){ ttsText = '链接'+that.text()+'连续点击后跳转' } tts_audio(ttsText) },500); } //不判断父级 // e.stopPropagation(); // if(that[0].tagName == 'A'){ // e.preventDefault(); // } // if(isclick > 1 && that[0].tagName == 'A'){ // clearTimeout(TimeFn); // towclick(that) // }else{ // let type = parentEach(that) // if(isclick > 1 && type != false && type[0].tagName == 'A'){ // clearTimeout(TimeFn); // towclick(type) // }else{ // clearTimeout(TimeFn); // TimeFn = setTimeout(function(){ // isclick = 0 // let ttsText = that.text() // if(that[0].tagName == 'IMG'){ // ttsText = '图片' // }else if(type != false && type[0].tagName == 'A'){ // ttsText = '链接,'+that.text()+'双击后跳转' // } // tts_audio(ttsText) // },500); // } // } } if(isSlh == 1){ setTimeout(function(){ $("body *").addClass('skin-'+isskin) $("body *").addClass('font'+isfont) $("body *").addClass('line'+isline) },100); } if(isSlh == 1 && $("iframe").length > 0){ setTimeout(function(){ $("iframe").each(function(i,item){ if($(item).contents().find(".shilaohuaCSS").length < 1){ let csslink = $(".shilaohuaCSS").attr("href") let str = `` $(item).contents().find("body").append(str) } $(item).contents().find("body").addClass('skin-'+isskin); $(item).contents().find("body *").addClass('skin-'+isskin); $(item).contents().find("body *").addClass('font'+isfont) $(item).contents().find("body *").addClass('line'+isline) }) },1000); } } //初始化 function initializefun(){ if(isSlh == 1){ $(".suit-old-box").show() $("#bottomPaddingDom").show() $("body").addClass("onButtom") } //皮肤 let arr = ['original','blue','red','black','green'] $.each(arr,function(i,item){ $("body").removeClass('skin-'+item) $("body *").removeClass('skin-'+item) }) $("body").addClass('skin-'+isskin) $("body *").addClass('skin-'+isskin) //子页面元素修改 if($("iframe").length > 0){ setTimeout(function(){ $("iframe").each(function(i,item){ if($(item).contents().find(".shilaohuaCSS").length < 1){ let csslink = $(".shilaohuaCSS").attr("href") let str = `` $(item).contents().find("body").append(str) } $.each(arr,function(j,item2){ $(item).contents().find("body").removeClass('skin-'+item2) $(item).contents().find("body *").removeClass('skin-'+item2) }) $(item).contents().find("body").addClass('skin-'+type); $(item).contents().find("body *").addClass('skin-'+type); }) },1000) } $(".default-"+isskin).addClass("active").siblings().removeClass("active") // 护眼 if(isskin == 'original'){ $("html").removeClass().addClass('original') }else{ $("html").removeClass().addClass(eyecareArr[iseyecare]) } $(".eyecare-itembox div").eq(iseyecare).addClass("active").siblings().removeClass("active") // 字号 $("body *").removeClass('font18 font22 font26') if($("iframe").length > 0){ setTimeout(function(){ $("iframe").each(function(i,item){ $(item).contents().find("body *").removeClass('font18 font22 font26'); }) },1000) } if(isSlh == 1){ $("body *").addClass('font'+isfont) //子页面元素修改字号 if($("iframe").length > 0){ setTimeout(function(){ $("iframe").each(function(i,item){ $(item).contents().find("body *").addClass('font'+isfont); }) },1000) } $(".font-but.default-font"+isfont).addClass("active").parent().siblings().find(".font-but").removeClass("active") } // 行高 $("body *").removeClass('line0 line150 line200') $("body *").addClass('line'+isline) //子页面元素修改行高 if($("iframe").length > 0){ setTimeout(function(){ $("iframe").each(function(i,item){ $(item).contents().find("body *").removeClass('line0 line150 line200') $(item).contents().find("body *").addClass('line'+isline); }) },1000) } $(".font-line.default-line"+isline).addClass("active").siblings().removeClass("active") //语速 $(".speech"+speech).addClass("active").siblings().removeClass("active") //语音 if(isAudio == 0){ $(".suit-old-item.audio-switch").removeClass("isopen") }else{ $(".suit-old-item.audio-switch").addClass("isopen") } } //dom初始化 function domInitializefun(){ if($("#bdtts_div_id").length > 0){ return false } let str = `