var font_size=12;var current_id;var book_id;function textSize(size){font_size=size;$("#mainBody").css("font-size",size);$("#mainBody p").css("line-height",(Number(size)+10)+"pt");}function getContent(id){current_id=id;if(id==null)current_id=book_id;$("#WikiContent_cc").hide();$("#rightContent").hide();$("#loading").show();$.ajax({type: "POST",url: "/get_ajax/GetContent.aspx",data: "id="+id+"&ta="+$("input:hidden").val(),success: function(msg){$("#rightContent").html(msg);textSize(font_size);document.getElementById('raRight').scrollTop=0;$("#"+id).addClass("pn_visited").parents("ul, li").add($("#"+id).next()).show();if($("#nochild").text()=="n"){ra_OpenCollapse("raSplitter","raLeft");$("#TopicTagEditor_panel").hide();};$("#rightContent").focus();$("#loading").hide();$("#rightContent").show();$("#WikiContent_cc").show();document.getElementById('raRight').scrollTop=0;}});};function submitfeedback(){if (($("#complementary").val()).length>=50) {alert("补充说明的内容太多！");return false;}if($("#feedText").val().toUpperCase()!=bodani.GetCookie('yzm_bdn_code')){$("#imsg").text("*").show().fadeOut(1000);$("#feedText").focus();return false;}$.ajax({type: "POST",url: "/get_ajax/submitDiscuss.aspx",data: "typ=fk&cid="+current_id+"&ttl="+$("#feedbackform input:radio:checked").val()+"&cnt="+$("#complementary").val(),success: function(msg){alert(msg);$("#complementary").val("");$("#feedText").val("");$("#feedbackbox").hide("slow");}});return true;};function submitComment(){var nl=($("#nickname").val()).length;var tl=($("#tb_textarea").val()).length;if (nl <= 1||nl>=15){$("#errmsg").text("昵称需要2-15个字符！").show().fadeOut(1000);return false;}if($("#TB_checkCode").val().toUpperCase()!=bodani.GetCookie('yzm_bdn_code')){$("#lb_checkCode").text("验证码错误").show().fadeOut(1000);return false;}if (tl <= 1||tl>=500) {$("#errmsg").text("请输入2-500个字符的内容！").show().fadeOut(1000);return false;}$.ajax({type: "POST",url: "/get_ajax/submitDiscuss.aspx",data: "typ=fl&bid="+book_id+"&cid="+current_id+"&ttl="+$("#mainTitle").text()+"&nnm="+$("#nickname").val()+"&cnt="+$("#tb_textarea").val(),success: function(msg){alert(msg);loadDiscuss();$("#TB_checkCode").val("");$("#tb_textarea").val("");$(".checkCode").attr("src", function() {return "/get_ajax/imagecode.aspx?s="+Math.random();});$("#commentbox").hide("slow");}});return true;};function loadDiscuss(){$.post("/get_ajax/GetDiscuss.aspx",{id: book_id},function(data){$("#commentContainer").html(data);});};var bodani = new function(){this.GetCookie = function(name){var start = document.cookie.indexOf( name + "=" );var len = start + name.length + 1;if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ){return null;}if ( start == -1 ) return null;var end = document.cookie.indexOf( ";", len );if ( end == -1 ) end = document.cookie.length;return unescape( document.cookie.substring( len, end ) );}};
function submitbm(dt){$.ajax({type:"POST",url:"/get_ajax/Add_bookmark.aspx",data:dt,success:function(msg){alert(msg);},error:function(){alert("错误：请稍后再试！");}});}function addbookmark(obj){if(bodani.GetCookie("userid")+bodani.GetCookie("username")<1){return alert('对不起，请先登录！');}else{var user_id = bodani.GetCookie("userid");var mark_id = current_id;if($(obj).text()=='加入书架'){if(bodani.GetCookie("addbook_id")==book_id){return alert("您已经加过此书！")}var title = $('#booktitle').text();var data="&type=book&user_id=" + user_id + "&book_id=" + book_id + "&mark_id="+mark_id+"&title="+title;submitbm(data);}else{if(bodani.GetCookie("addmark_id")==current_id){return alert("您已经加过本节书签！")}if($('#mainTitle').text().length>0){var title = $('#mainTitle').text();var data="&type=mark&user_id=" + user_id + "&book_id=" + book_id + "&mark_id="+mark_id+"&title="+title;submitbm(data);}else{return alert('你好，没有内容加入到你的书签！');}}}};
function loadingimg() { var offset = $("#loading").offset(); offset.left = ($("#raRight").width() / 2) - 75; $("#loading").css("left", offset.left); } $(document).ready(function() { $("#tree").treeview({ collapsed: true, animated: "medium", control: "#sidetreecontrol", persist: "location" }); $("#treecontent").show(); var gc = getQueStr(bodani_url, "bk").split("#")[1]; book_id = getQueStr(bodani_url, "bk").split("#")[0]; if (gc == null) gc = book_id; getContent(gc); loadDiscuss(); loadingimg(); $("#raRight,#top").click(function() { $("#feedbackbox,#commentbox,#loginbox,#mybook_List,#mymark_List").hide(); }); $("#top").mouseover(function() { $("#feedbackbox,#commentbox").hide(); }); $("#b_bookmark,#b_bookshelf").click(function() { addbookmark(this); }); $("#b_feedback").click(function() { $("#feedbackbox").show(); $("#commentbox").hide(); }); $(".f_size").click(function() { textSize($(this).attr("title")); }); $("#b_feeling").mouseover(function() { $("#commentbox").show("slow"); $("#feedbackbox").hide(); $("#treecontent a").click(function() { getContent(this.id); }); }); }); var bodani_url = location.href; function getQueStr(url, ref) { var str = url.substr(url.indexOf('?') + 1); if (str.indexOf('&') != -1) { var arr = str.split('&'); for (i in arr) { if (arr[i].split('=')[0] == ref) return arr[i].split('=')[1]; } } else { return url.substr(url.indexOf('=') + 1) } } function submitLogin() { $("#password").focus(); var nl = $("#username").val(); var pl = $("#password").val(); if ((nl.length <= 1 || nl.length >= 21) || (pl.length <= 4 || pl.length >= 17)) { $("#errorInfo").text("对不起，输入不正确！").show().fadeOut(1000); return false; } $.ajax({ type: "POST", url: "/Get_Ajax/Passport_Login.aspx", data: "username=" + nl + "&password=" + pl + "&type=at", success: function(msg) { if (msg.length > 10) { $("#loginbar").html(msg); loginSuccess(); $("#username").val(""); } else { $("#errorInfo").html("用户名或密码错误,请重新登录！"); $("#errorInfo").show(); } $("#password").val(""); } }); return true; }; function ra_OnResizeableAreaToggle(isCollapsing) { }; var ra_WidthCookieName = "tocwidth"; var ra_CollapsedCookieName = "toccollapsed"; function ra_OnPageResize() { var object = document.getElementById("rs1_ra1"); if ($.browser.version == "6.0") { while (document.getElementById("raRight").offsetWidth != object.offsetWidth - document.getElementById("raSplitter").offsetWidth - document.getElementById("raLeft").offsetWidth - 5) { document.getElementById("raRight").style.width = object.offsetWidth - document.getElementById("raSplitter").offsetWidth - document.getElementById("raLeft").offsetWidth - 5 + "px"; } } else { object.style.height = object.parentNode.offsetHeight; } loadingimg(); }; function show_case_mark(objt) { var user_id = $(objt).attr("uid"); if ($(objt).text() == "我的书架") { $("#mybook_List").css("left", $(objt).offset().left - 10); if ($("#mybook_List").css("display") == "none") { $("#mybook_List").show(); $("#mymark_List").hide(); $.post("/Get_Ajax/Get_Bookmark.aspx", { user_id: user_id, type: "book" }, function(data) { $("#mybook_List").html(data); }); } } else { $("#mymark_List").css("left", $(objt).offset().left - 10); if ($("#mymark_List").css("display") == "none") { $("#mymark_List").show(); $("#mybook_List").hide(); $.post("/Get_Ajax/Get_Bookmark.aspx", { user_id: user_id, type: "mark" }, function(data) { $("#mymark_List").html(data); }); } } }
function Login_User(ee) { var loginbar = '<nobr><a href="http://www.bodani.cn/" target=\"_blank\" >伯大尼首页</a>&nbsp;|&nbsp;<a href="javascript:;" onclick="userLogin(TopLoginSuccess, TopLoginFail,\'login\');" id="log_in">登录</a></nobr>'; if (ee != "enter") { $.post("/Get_Ajax/Passport_Login.aspx", { exit: "true" }, function() { $("#loginbar").html(loginbar); }); return false; } if (bodani.GetCookie("userid") + bodani.GetCookie("username") < 1) { $("#loginbar").html(loginbar); } else { var nml = bodani.GetCookie("username"); var idl = bodani.GetCookie("userid"); if (nml.length > 0 && idl.length > 0) { $.ajax({ type: "POST", url: "/Get_Ajax/Passport_Login.aspx", data: "username=" + nml + "&userid=" + idl + "&type=at", success: function(msg) { $("#loginbar").html(msg); }, error: function() { $("#loginbar").html(loginbar); } }); } return true; } } function agree_discuss(obj, id) { var a_count = Number($("#amen_" + id).text()); $("#amen_" + id).text(a_count + 1); } function mo_bookmark(obj, color) { $(this).css("background-color", color); };
