").appendTo($("ul#pageButtonsForMobile")); } } function gotoPage(e, event, page){ event.preventDefault(); $('#HIDE_NOWPAGE').val(page); //History.pushState({state:parseInt($('#HIDE_NOWPAGE').val()), sort:$('#HIDE_SORT').val(), showModel:$('#HIDE_SHOWMODEL').val() ,rand:Math.random()}, "", "#" + $('#HIDE_NOWPAGE').val()); $("html, body").animate({ scrollTop: 0 }, 600); //loadViewData(); location.href = "/rwd_searchResult.html?keyType%5B%5D=2&keyword%5B%5D=%E8%82%AF%E5%B0%BC%E6%96%AF%EF%BC%8E%E6%A0%BC%E6%A0%B9&prodKind=0&prodCatId=0&catId=0&saleDiscStart=0&saleDiscEnd=0&salePriceStart=&salePriceEnd=&publishDateStart=&publishDateEnd=&prodRank=0&addMarkFlg=0&force=0&catFocus=&orgFocus=A&mainCatFocus=2&catNmFocus=&catIdFocus=&layout=A&nowPage=" + page + "&sort="; } function historyStatByListView(e, event, index_position){	event.preventDefault(); //History.pushState({state:parseInt($('#HIDE_NOWPAGE').val()), sort:$('#HIDE_SORT').val(), showModel:$('#HIDE_SHOWMODEL').val() ,rand:Math.random()}, "", "#" + $('#HIDE_NOWPAGE').val()); location.href = $(e).attr("href"); } function sortBy(e, event){	event.preventDefault(); var elm = $(e); $('#HIDE_SORT').val(elm.attr("rel")); $('#HIDE_NOWPAGE').val(1); //History.pushState({state:parseInt($('#HIDE_NOWPAGE').val()), sort:$('#HIDE_SORT').val(), showModel:$('#HIDE_SHOWMODEL').val() ,rand:Math.random()}, "", "#" + $('#HIDE_NOWPAGE').val()); //$("#selectSort").html( elm.html() + " "); $("html, body").animate({ scrollTop: 0 }, 600); var sort; switch(elm.attr("rel")){ case '1': sort = "publishdate"; break; case '2': sort = "salesrank"; break; case '3': sort = "price"; break; case '4': sort = ""; break; } location.href = "/rwd_searchResult.html?keyType%5B%5D=2&keyword%5B%5D=%E8%82%AF%E5%B0%BC%E6%96%AF%EF%BC%8E%E6%A0%BC%E6%A0%B9&prodKind=0&prodCatId=0&catId=0&saleDiscStart=0&saleDiscEnd=0&salePriceStart=&salePriceEnd=&publishDateStart=&publishDateEnd=&prodRank=0&addMarkFlg=0&force=0&catFocus=&orgFocus=A&mainCatFocus=2&catNmFocus=&catIdFocus=&layout=A&nowPage=1&sort=" + sort ; //loadViewData(); } function layoutByGrid(e){	var elm = $(e);	if(!elm.hasClass("disabled")){ $("#HIDE_SHOWMODEL").val(1); $('#HIDE_PAGESIZE').val(24); $('#HIDE_NOWPAGE').val(1); $("#layoutGrid").addClass("disabled"); $("#layoutList").removeClass("disabled"); //History.pushState({state:parseInt($('#HIDE_NOWPAGE').val()), sort:$('#HIDE_SORT').val(), showModel:$('#HIDE_SHOWMODEL').val() ,rand:Math.random()}, "", "#" + $('#HIDE_NOWPAGE').val()); $("html, body").animate({ scrollTop: 0 }, 600); //loadViewData(); location.href = "/rwd_searchResult.html?keyType%5B%5D=2&keyword%5B%5D=%E8%82%AF%E5%B0%BC%E6%96%AF%EF%BC%8E%E6%A0%BC%E6%A0%B9&prodKind=0&prodCatId=0&catId=0&saleDiscStart=0&saleDiscEnd=0&salePriceStart=&salePriceEnd=&publishDateStart=&publishDateEnd=&prodRank=0&addMarkFlg=0&force=0&catFocus=&orgFocus=A&mainCatFocus=2&catNmFocus=&catIdFocus=&layout=B&nowPage=1&sort="; }	} function layoutByList(e){ var elm = $(e);	if(!elm.hasClass("disabled")){ $("#HIDE_SHOWMODEL").val(2); $('#HIDE_PAGESIZE').val(10); $('#HIDE_NOWPAGE').val(1); $("#layoutGrid").removeClass("disabled"); $("#layoutList").addClass("disabled"); //History.pushState({state:parseInt($('#HIDE_NOWPAGE').val()), sort:$('#HIDE_SORT').val(), showModel:$('#HIDE_SHOWMODEL').val() ,rand:Math.random()}, "", "#" + $('#HIDE_NOWPAGE').val()); $("html, body").animate({ scrollTop: 0 }, 600); //loadViewData(); location.href = "/rwd_searchResult.html?keyType%5B%5D=2&keyword%5B%5D=%E8%82%AF%E5%B0%BC%E6%96%AF%EF%BC%8E%E6%A0%BC%E6%A0%B9&prodKind=0&prodCatId=0&catId=0&saleDiscStart=0&saleDiscEnd=0&salePriceStart=&salePriceEnd=&publishDateStart=&publishDateEnd=&prodRank=0&addMarkFlg=0&force=0&catFocus=&orgFocus=A&mainCatFocus=2&catNmFocus=&catIdFocus=&layout=A&nowPage=1&sort="; }	} $(".mMenuTitles").on('click',function(){ var mIndex = $(this).index(); if($(this).find('strong').eq(0).hasClass("glyphicon-folder-open")){ $(this).find('strong').eq(0).removeClass("glyphicon-folder-open"); $(this).find('strong').eq(0).addClass("glyphicon-th-list"); $(".menuSubTitles").eq(mIndex).hide(); }else{ $(".mMenuTitles").each(function(i,v){ if($(v).find('strong').eq(0).hasClass("glyphicon-folder-open")){ $(v).find('strong').eq(0).removeClass("glyphicon-folder-open"); } if(!$(v).find('strong').eq(0).hasClass("glyphicon-th-list")){ $(v).find('strong').eq(0).addClass("glyphicon-th-list"); } }); $(this).find('strong').eq(0).removeClass("glyphicon-th-list"); $(this).find('strong').eq(0).addClass("glyphicon-folder-open"); $(".menuSubTitles").each(function(i,v){ if(i==mIndex){ $(v).show(); }else{ $(v).hide(); } }); } }); function add2ShoppingCart(prodId, orgProdId) { var success = true; if(orgProdId == "62100001056") { var date = new Date('2014/04/02'); var today = new Date(); if(today.getTime() < date.getTime()) { location.href = $("#SINGLE_WEB_URL").val()+"/april_youFool.html"; } else { return false; } } else { var flg=""; var url = "/insertShopping.html"; var prod_cat_id = prodId.substring(0,2); var cartDetail = alertCartItem(prodId); var outFlg = false; if(cartDetail!=null){ if(cartDetail.total>0){ for(var i=0; i
提醒您，您所購買的是電子書。', { theme: 'smoke ' }); } else { $.jGrowl('商品已放入購物車', { theme: 'smoke ' }); //alertify.alert('商品已放入購物車'); } if(success) { $(".cartQty").each(function(i,v){ $(v).html(model.totalQty==0?"":model.totalQty); if(model.totalQty > 0){ $(v).show(); $("#mShopCart>img").hide(); }else{ $(v).hide(); $("#mShopCart>img").show(); } }); } } }); } } } //二手書徵求 function wantSnd(i){ orgProdId = $("#hide_org_prod_Id"+i+"").val(); if($('#hideLogin').val()== "true" && $("#hideCustId").val()!= "null"){ console.log($("#hide_is_wanted"+i+"").val()); if($("#hide_is_wanted"+i+"").val() == i+1 ){ cancelWantedSize(orgProdId,i); $("div#mySndWantp").hide(); $("div#mySndWant").show(); }else{ //$(e).tooltipster('open'); //$("#addToWant").appendTo($(e)); //$(e).dropdown(); var evt = window.event || e; evt.preventDefault(); $("#addWantModal"+i+"").on('show.bs.modal',function(){ var top = ($(window).height()-$(this).find('.modal-dialog').height())/2; $(this).css('display','block'); $(this).find('.modal-dialog').css({'margin-top':top+'px'}) }); $("#addWantModal"+i+"").modal({backdrop: 'static'}); } }else{ loginFirst(); } } //$("#AddWant"+i).on('click',function(){ //savaSndWant(i); //}); function savaSndWant(i){ var is_shared = false; var valid = false; var isCheck = false; var target = $("#addToWant"+i+""); if($('div.fb_shared', target).attr("rel") == "checked") { is_shared = true; } var update_type = "A"; var update_value; $(target).find("div[role=radio]").each(function(i,v){ if($(v).children("div.checkY").attr("rel")=='Y'){ isCheck = true; var radioVal = $(v).attr("radioVal"); if(radioVal == 'A'){ if(!isNaN($(target).find("#want_price").val())) { if(parseInt($(target).find("#want_price").val()) < 45) { alert("徵求價不可以低於45元"); } else if(parseInt($(target).find("#want_price").val()) > parseInt($(target).find("#want_price").attr("rel"))) { var want_price=parseInt($(target).find("#want_price").val()); //feynman_安全最大整數 9007199254740991=2^53-1 < java long 2^63-1 if(want_price<=Number.MAX_SAFE_INTEGER){ if($(target).find("#want_price").attr("rel2") == "N") { // feynman_絕版書Y var outOfPrint=$(target).find("#want_price").attr("rel4");	if(outOfPrint == "Y"){ valid = true;	}else{ alert("徵求價不可以高於新書售價"); } } else { valid = true; } }else{ alert("請輸入合理金額") }	} else { valid = true; } } else { if($(target).find("#want_price").val() != "") { alert("請輸入正確金額"); } } if($(target).find("#want_price").val() == "") { update_value = parseInt($(target).find("#want_price").attr("rel")); } else { update_value = parseInt($(target).find("#want_price").val()); } }else{ if($(target).find(".want_discount").val() == "0") { update_value = parseInt($(target).find("#want_price").attr("rel")); } else { update_type = "B"; update_value = parseInt($(target).find(".want_discount").val()); } valid = true; } return false; } }); if(!isCheck){ alert("請確定是否有勾選徵求條件"); } if(valid) { var url = "/new_ec/single/addToSeek.jsp"; $.ajax({ type: 'get', url:"/single_addToSeek.html", timeout:2000, cache: false, dataType: 'json', async:false, data:"prid="+$("#hide_org_prod_Id"+i+"").val()+"&update_flg=Y&type="+update_type+"&value="+update_value+"&ci="+$("#hideCuId").val(), error: function(err){console.log(err)}, success: function(data){ if(data.error_code == 100) { //$(".wantSndLink2").show(); //$("#wantSndLink").hide(); var hidden = $("#mySndWant>span").html(); if(hidden == "") { $("#mySndWant>span").html("1"); $("#mySndWant2>span").html("1"); } else { $("#mySndWant>span").html(parseInt(hidden)+1); $("#mySndWant2>span").html(parseInt(hidden)+1); } if(is_shared) { fb_sync('S',$("#hide_org_prod_Id").val(),'','0'); } else { alertify.alert("加入二手書徵求完成！",function(){},"alert_center"); $("#addWantModal"+i+"").css('display','none'); $ ('body').removeClass( 'modal-open' ); $ ('div').removeClass( 'modal-backdrop fade in' ); changeWantedCSSSuccess(i); } //$("#mySndWant>span").css("background","#e2007e"); //$("#mySndWant2>span").css("background","#e2007e"); $("#hide_is_wanted"+i+"").val(i+1); } else { alertify.alert(data.error_desc,function(){},"alert_center"); } }, complete:function(){ $('#CancelWant').trigger('click'); } }); }else{ } } //二手書徵求 function changeWantedCSSSuccess(i){ document.getElementById("wantSnd"+i+"").style.border="1px solid #444"; //document.getElementById("wantSnd"+i+"").style.color="#444"; document.getElementById("wantSnd"+i+"").innerHTML="您已徵求"; } function changeWantedCSSCancel(i){ document.getElementById("wantSnd"+i+"").style.border="1px solid #E3007F"; document.getElementById("wantSnd"+i+"").style.color="#E3007F"; document.getElementById("wantSnd"+i+"").innerHTML="二手書徵求"; } //二手書徵求取消 function cancelWantedSize(orgProdId,i) { $.ajax({ type: 'get', url:"/single_addToSeek.html", dataType: 'json', cache: false, async:false, data:"prid="+orgProdId+"&update_flg=Y&type=A&value=0&ci="+$("#hideCuId").val(), error: function(err){console.log(err)}, success:function(data){ if(data.error_code == 100) { alertify.alert("取消二手書徵求完成！",function(){},"alert_center"); var hidden = $("#mySndWant>span").html(); //console.log(hidden); if((parseInt(hidden)-1)<=0){ $("#mySndWant>span").html(""); $("#mySndWant2>span").html(""); }else{ $("#mySndWant>span").html(parseInt(hidden)-1); $("#mySndWant2>span").html(parseInt(hidden)-1); } //$(target).find("#want_price").attr("value",$("#want_price").attr("rel")); //$(target).find(".want_discount").attr("value","0"); //$(target).find("input[name='want_type']").eq(0).prop("checked", true); //$(".wantSndLink2").hide(); //$("#wantSndLink").show(); $("#hide_is_wanted"+i+"").val("false"); changeWantedCSSCancel(i); //$("#mySndWant>span").css("background",""); //$("#mySndWant2>span").css("background",""); } else { alertify.alert(data.error_desc,function(){},"alert_center"); } }, complete:function(){ //alert("complete"); } }); } //二手書徵求取消 //應該也是二手書徵求 $("div[name=mySndWant]").tooltipster({ trigger:'custom', triggerClose: { click: true, tap: true }, contentAsHTML: true, interactive: true, animation: 'grow', content: $("div#addToWant").html(), side: 'right', arrow: 'false', theme: 'tooltipster-customized-white', functionReady: function(instance, helper){ var savaSndWant = $(helper.tooltip).find("#AddWant"); var CancelWant = $(helper.tooltip).find("#CancelWant"); var fb_share = $(helper.tooltip).find(".fb_shared"); fb_share.click(function(){ if(fb_share.attr("rel")=="checked"){ fb_share.find("div").hide(); fb_share.attr("rel","uncheck"); }else if(fb_share.attr("rel")=="uncheck"){ fb_share.find("div").show(); fb_share.attr("rel","checked"); } }); CancelWant.click(function(){ instance.close(); }); } }); $(".what_sndPrice").tooltipster({ contentAsHTML: true, interactive: true, animation: 'grow', content: $("#what_sndPrice_info").html(), side: 'right', theme: 'tooltipster-customized', functionReady: function(){ } }); $("#setSaleMethodB").tooltipster({ contentAsHTML: true, interactive: true, animation: 'grow', content: $("#setSaleMethodB_info").html(), side: 'right', theme: 'tooltipster-customized', functionReady: function(){ } }); $("div[role=radio]").each(function(i,v){ $(v).on('click',function(){ var group = v.name; $("[name="+group+"],div[role=radio]").each(function(i2,v2){ if($(v2).hasClass("checkY")){ $(v2).removeClass("active"); $(v2).attr("rel","N"); }else{ $(v2).find(".checkY").each(function(i3,v3){ $(v3).removeClass("active"); $(v3).attr("rel","N"); }); } }); changeCheckDiv(v); }); }); //應該也是二手書徵求 $("select.want_discount").eq(0).on('change',function(){ var rel = $("[name=sndRequire]").eq(0).children('.checkY').attr('rel'); if(rel=='N'){ $("[name=sndRequire]").eq(0).trigger('click'); } }); $("#want_price").on('change',function(){ var rel = $("[name=sndRequire]").eq(1).children('.checkY').attr('rel'); if(rel=='N'){ $("[name=sndRequire]").eq(1).trigger('click'); } }); function changeCheckDiv(e){ if($(e).hasClass("checkY")){ if($(e).attr("rel")=="N"){ $(e).addClass("active"); $(e).attr("rel","Y"); }else if($(e).attr("rel")=="Y"){ $(e).removeClass("active"); $(e).attr("rel","N"); } }else{ $(e).find(".checkY").each(function(i,v){ if($(v).attr("rel")=="N"){ $(v).addClass("active"); $(v).attr("rel","Y"); }else if($(v).attr("rel")=="Y"){ $(v).removeClass("active"); $(v).attr("rel","N"); } }); } } //可購買時通知我 function add2ShoppingNotic(prodId, orgProdId){ if(orgProdId != "62100001056") { if($('#hideLogin').val()== "true" && $("#hideCustId").val()!= "null"){ var url = "/api/saveShoppingSeeklist.html"; $.get(url, { prid: prodId }, function(data) { if(data==null||data=="") { $.jGrowl('抱歉，未知錯誤！', { theme: 'smoke ' }); return; } if(data=="SAVE") { $.jGrowl('開放訂購時，將寄送通知給您', { theme: 'smoke ' }); } else { $.jGrowl('已為您取消訂購通知', { theme: 'smoke ' }); } }); } else { alertify.confirm("請先登入，或立即加入會員！", function (e) { if (e) { // user clicked "ok" window.location = "/single_loginProcess.html?act=shoppingNotic&opid=" + orgProdId + "&pid=" + prodId; } else { // user clicked "cancel" return false; } },"alert_center"); } } else { return false; } } $("[name=shoppingNotic]").on("click",function(){ add2ShoppingNotic($("#hide_prod_Id").val(),$("#hide_org_prod_Id").val()); }); //可購買時通知我 //加入暫存清單 function add2WishList(prodId, orgProdId){ if(orgProdId != "62100001056"){ var qty; if($("[name=wishButton]").attr("rel")=="false"){ if($('#hideLogin').val()== "true" && $("#hideCustId").val()!= "null"){ $.ajax({ url:"/insertWatch.html", data:{prid: prodId}, dataType:'json', success:function(data){ qty = data.watchTotalQty; //$("#HIDE_INPUUT_CUST_WATCHQTY").val(qty.toString()); //$("#wishButton").hide(); //$("#wishButtonCancel").show(); $.jGrowl('已放入暫存清單', { theme: 'smoke ' }); $("[name=wishButton]").attr("rel","true"); $("#listWatchQty").html(qty); //$("[name=wishButton]").html("從暫存清單移除"); //alertify.alert('商品已放入暫存清單'); } }); }else{ alertify.set({ labels : { ok: "確定", cancel: "取消" } }); alertify.confirm("請先登入，或立即加入會員！", function (e) { if (e) { // user clicked "ok" //window.location = "/single_loginProcess.html?act=wish&opid=" + orgProdId + "&pid=" + prodId; loginFirst(); } else { // user clicked "cancel" return false; } },"alert_center"); } }else if($("[name=wishButton]").attr("rel")=="true"){ $.ajax({ url:"/deleteWatchByAjax.html?flg="+Math.random(), data:{sdc: prodId}, dataType:'text', success:function(data){ console.log(data); if(data=='success') { //$("#wishButton").show(); //$("#wishButtonCancel").hide(); var qty = parseInt($("#listWatchQty").html()) - 1; $("#listWatchQty").html(qty==0?"":qty); $("[name=wishButton]").attr("rel","false"); //$("[name=wishButton]").html("放入暫存清單"); alertify.alert("已從暫存清單移除！", function(){},"alert_center"); } } }); } } else { var date = new Date('2014/04/02'); var today = new Date(); if(today.getTime() < date.getTime()) { location.href = $("#SINGLE_WEB_URL").val()+"/april_youFool.html"; } else { return false; } } } $("[name=wishButton]").each(function(i,v){ $(v).on("click",function(){ add2WishList($("#hide_prod_Id").val(),$("#hide_org_prod_Id").val()); }); }); //加入暫存清單 function overShow(i){ document.getElementById("wantSnd"+i+"").style.color="#FFFFFF"; } function outHide(i){ document.getElementById("wantSnd"+i+"").style.color="#E3007F"; } //搜尋回饋開始 function feedbackYes(){ $("#feedbackYes").css('display','inline-block'); $(".feedbackBtn").css('display','none'); feedbackType = "滿意"; subFeedbackToDB(); } function feedbackNo(){ $("#resultFeedback0").css('margin','15px -10px 0px 0px'); $("#feedbackNo").css('display','block'); $("#feedbackBtnY").css('display','none'); $("#feedbackBtnN").css('display','none'); $("#askFeedback").css('display','none'); //$("#feedbackBtnN").css('background-color','#e3007f'); //$("#feedbackBtnN").css('color','#FFFFFF'); $("#feedbackBtnY").removeAttr("onclick"); } function feedbackNoSelect(){ var feedback = $("#HIDE_FEEDBACK").val(); if(feedback=="A"){ $("#feedbackNoSelect").html("我不滿意搜尋結果的商品順序 "); feedbackType = "我不滿意搜尋結果的商品順序"; } else if(feedback=="B"){ $("#feedbackNoSelect").html("我查不到想要的商品 "); feedbackType = "我查不到想要的商品"; } else if(feedback=="C"){ $("#feedbackNoSelect").html("是否能新增功能？ "); feedbackType = "是否能新增功能"; } else if(feedback=="D"){ $("#feedbackNoSelect").html("好像故障了？ "); feedbackType = "好像故障了？"; } else if(feedback=="E"){ $("#feedbackNoSelect").html("其他建議 "); feedbackType = "其他建議"; } //console.log(feedbackType); } function select(e, event){	event.preventDefault(); var elm = $(e); $('#HIDE_FEEDBACK').val(elm.attr("rel")); feedbackNoSelect(); } function getFeedbackText(){ FeedbackText = $("#feedbackText").val(); $("#feedbackSub").css('display','inline-block'); $(".feedbackBtn").css('display','none'); $("#feedbackNo").css('display','none'); subFeedbackToDB(FeedbackText); } function subFeedbackToDB(FeedbackText){ var setURL = "http://192.168.100.28:8085/search?key=%E8%82%AF%E5%B0%BC%E6%96%AF%EF%BC%8E%E6%A0%BC%E6%A0%B9&prodKind=0&prodCatId=0&mainCatLimit=2&orgLimit=A&keyType=2&force=0&page=1&layout=A".replace(/&/g,"!"); var realURL = setURL.replace(/192.168.100.28:8085/,""); var MailMain = ""; var CustId = ""; var textData = "subDateCheck=20200409 16:04&UserAgent=CCBot/2.0 (https://commoncrawl.org/faq/)&keyWord="+search_input+"&URL="+realURL+"&feedbackType="+feedbackType+"&feedbackText="+FeedbackText+"&MailMain="+MailMain+"&CustId="+CustId; $.ajax({ type: "post", url: "/new_ec/rwd/sendFeedback.jsp", timeout:2000, data: textData, dataType: "json", async: false, error: function(err){ //console.log("沒傳到"); }, success: function(d){ //console.log("ㄎㄎ"); } }); //location.href="https://www.taaze.tw/rwd_sendFeedback.html?"+textData; } $("#feedbacktype").click(function(){ $("#feedbacktype").slideUp(); }); $("#feedbackNoSelect").click(function(){ $("#feedbacktype").slideDown(); }); //搜尋回饋結束