6 lines
31 KiB
JavaScript
6 lines
31 KiB
JavaScript
<<<<<<< HEAD
|
|
function trimLeft(a,b){if(!b||" "==b)return $.trim(a);for(;0==a.indexOf(b);)a=a.substring(b.length);return a}function json(str){return eval("("+str+")")}function t(){var a=arguments;if(a.length<=1)return a[0];var b=a[0];if(!b)return b;var c="LEAAEL";b=b.replace(/\?/g,c);for(var d=1;d<=a.length;++d)b=b.replace(c,a[d]);return b}function arrayEqual(a,b){return a=a||[],b=b||[],a.join(",")==b.join(",")}function isArray(a){return"[object Array]"===Object.prototype.toString.call(a)}function isEmpty(a){return a?isArray(a)&&0==a.length?!0:!1:!0}function getFormJsonData(a){var b=formArrDataToJson($("#"+a).serializeArray());return b}function formArrDataToJson(a){var b={},c={};for(var d in a){var e=a[d].name,f=a[d].value;"[]"!=e.substring(e.length-2,e.length)?b[e]=f:(e=e.substring(0,e.length-2),void 0==c[e]?c[e]=[f]:c[e].push(f))}return $.extend(b,c)}function formSerializeDataToJson(a){for(var b=a.split("&"),c={},d={},e=0;e<b.length;++e){var f=b[e].split("="),g=decodeURI(f[0]),h=decodeURI(f[1]);"[]"!=g.substring(g.length-2,g.length)?c[g]=h:(g=g.substring(0,g.length-2),void 0==d[g]?d[g]=[h]:d[g].push(h))}return $.extend(c,d)}function _ajaxCallback(a,b,c){if(a===!0||"true"==a||"object"==typeof a){if(a&&"object"==typeof a&&"NOTLOGIN"==a.Msg)return alert("\u4f60\u8fd8\u6ca1\u6709\u767b\u5f55, \u8bf7\u5148\u767b\u5f55!"),void 0;"function"==typeof b&&b(a)}else"function"==typeof c?c(a):alert("error!")}function _ajax(a,b,c,d,e,f){return log("-------------------ajax:"),log(b),log(c),f="undefined"==typeof f?!0:!1,$.ajax({type:a,url:b,data:c,async:f,success:function(a){_ajaxCallback(a,d,e)},error:function(a){_ajaxCallback(a,d,e)}})}function ajaxGet(a,b,c,d,e){return _ajax("GET",a,b,c,d,e)}function ajaxPost(a,b,c,d,e){_ajax("POST",a,b,c,d,e)}function ajaxPostJson(a,b,c,d,e){log("-------------------ajaxPostJson:"),log(a),log(b),e="undefined"==typeof e?!0:!1,$.ajax({url:a,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:e,data:JSON.stringify(b),success:function(a){_ajaxCallback(a,c,d)},error:function(a){_ajaxCallback(a,c,d)}})}function findParents(a,b){if($(a).is(b))return $(a);for(var c=$(a).parents(),d=0;d<c.length;++d)if(log(c.eq(d)),c.eq(d).is(b))return c.seq(d);return null}function editorIframeTabindex(a){var b=$("#editorContent_ifr");0==b.size()?setTimeout(function(){editorIframeTabindex(a)},100):b.attr("tabindex",a)}function switchEditor(a){LEA.isM=a,a?($("#mdEditor").css("z-index",3).show(),editorIframeTabindex(3),$("#wmd-input").attr("tabindex",2),$("#leanoteNav").hide()):($("#editor").show(),$("#mdEditor").css("z-index",1),editorIframeTabindex(2),$("#wmd-input").attr("tabindex",3),$("#leanoteNav").show())}function setEditorContent(a,b,c){if(a||(a=""),b)$("#wmd-input").val(a),$("#wmd-preview").html(""),!a||c?($("#wmd-preview").html(c).css("height","auto"),ScrollLink&&ScrollLink.onPreviewFinished()):MarkdownEditor?($("#wmd-preview").html(previewToken+"<div style='text-align:center; padding: 10px 0;'><img src='http://leanote.com/images/loading-24.gif' /> \u6b63\u5728\u8f6c\u6362...</div>"),MarkdownEditor.refreshPreview()):setTimeout(function(){setEditorContent(a,!0,c)},200);else if($("#editorContent").html(a),"undefined"!=typeof tinymce&&tinymce.activeEditor){var d=tinymce.activeEditor;d.setContent(a),d.undoManager.clear()}else setTimeout(function(){setEditorContent(a,!1)},100)}function previewIsEmpty(a){return a&&a.substr(0,previewToken.length)!=previewToken?!1:!0}function getEditorContent(a){if(a)return[$("#wmd-input").val(),$("#wmd-preview").html()];var b=tinymce.activeEditor;if(b){var c=$(b.getBody());if(c.find("pinit").remove(),c.find(".thunderpin").remove(),c.find(".pin").parent().remove(),c=$(c).html())for(;;){var d=c.lastIndexOf("</script>");if(-1==d)return c;var e=c.length;if(e-9!=d)return c;var f=c.lastIndexOf("<script ");if(-1==f&&(f=c.lastIndexOf("<script>")),-1==f)return c;c=c.substring(0,f)}return c}}function disableEditor(){var a=tinymce.activeEditor;a&&(a.hide(),LEA.editorStatus=!1,$("#mceTollbarMark").show().css("z-index",1e3))}function enableEditor(){if(!LEA.editorStatus){$("#mceTollbarMark").css("z-index",-1).hide();var a=tinymce.activeEditor;a&&a.show()}}function showDialog(a,b){$("#leanoteDialog #modalTitle").html(b.title),$("#leanoteDialog .modal-body").html($("#"+a+" .modal-body").html()),$("#leanoteDialog .modal-footer").html($("#"+a+" .modal-footer").html()),delete b.title,b.show=!0,$("#leanoteDialog").modal(b)}function hideDialog(a){a||(a=0),setTimeout(function(){$("#leanoteDialog").modal("hide")},a)}function closeDialog(){$(".modal").modal("hide")}function showDialog2(a,b){b=b||{},b.show=!0,$(a).modal(b)}function hideDialog2(a,b){b||(b=0),setTimeout(function(){$(a).modal("hide")},b)}function showDialogRemote(a,b){b=b||{},a+="?";for(var c in b)a+=c+"="+b[c]+"&";$("#leanoteDialogRemote").modal({remote:a})}function hideDialogRemote(a){a?setTimeout(function(){$("#leanoteDialogRemote").modal("hide")},a):$("#leanoteDialogRemote").modal("hide")}function notifyInfo(a){$.pnotify({title:"\u901a\u77e5",text:a,type:"info",styling:"bootstrap"})}function notifyError(a){$.pnotify.defaults.delay=2e3,$.pnotify({title:"\u901a\u77e5",text:a,type:"error",styling:"bootstrap"})}function notifySuccess(a){$.pnotify({title:"\u901a\u77e5",text:a,type:"success",styling:"bootstrap"})}function goNowToDatetime(a){return a?a.substr(0,10)+" "+a.substr(11,8):""}function getCurDate(){return(new Date).format("yyyy-M-d")}function enter(a,b,c){a||(a="body"),$(a).on("keydown",b,function(a){13==a.keyCode&&c.call(this)})}function enterBlur(a,b){a||(a="body"),b||(b=a,a="body"),$(a).on("keydown",b,function(a){13==a.keyCode&&$(this).trigger("blur")})}function getObjectId(){return ObjectId()}function resizeEditor(){var b=$("#editorContent_ifr").parent();b.css("overflow","auto");var c=$("#editorContent").height();b.height(c),$("#editorContent_ifr").height(c)}function showMsg(a,b){$("#msg").html(a),b&&setTimeout(function(){$("#msg").html("")},b)}function showMsg2(a,b,c){$(a).html(b),c&&setTimeout(function(){$(a).html("")},c)}function showAlert(a,b,c,d){$(a).html(b).removeClass("alert-danger").removeClass("alert-success").removeClass("alert-warning").addClass("alert-"+c).show(),d&&$(d).focus()}function hideAlert(a,b){b?setTimeout(function(){$(a).hide()},b):$(a).hide()}function post(a,b,c,d){d&&$(d).button("loading"),ajaxPost(a,b,function(a){d&&$(d).button("reset"),"object"==typeof a?"function"==typeof c&&c(a):alert("leanote\u51fa\u73b0\u4e86\u9519\u8bef!")})}function isEmail(a){var b=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[0-9a-zA-Z]{2,3}$/;return b.test(a)}function isEmailFromInput(a,b,c,d){var e=$(a).val(),f=function(){};if(b&&(f=function(b,c){showAlert(b,c,"danger",a)}),e){if(isEmail(e))return e;f(b,d||getMsg("errorEmail"))}else f(b,c||getMsg("inputEmail"))}function initCopy(a,b){var c=new ZeroClipboard(document.getElementById(a),{moviePath:"/js/ZeroClipboard/ZeroClipboard.swf"});c.on("complete",function(a,c){b(c)})}function showLoading(){$("#loading").css("visibility","visible")}function hideLoading(){$("#loading").css("visibility","hidden")}function logout(){location.href=UrlPrefix+"/logout?id=1"}function getImageSize(a,b){function d(a,d){c.parentNode.removeChild(c),b({width:a,height:d})}var c=document.createElement("img");c.onload=function(){d(c.clientWidth,c.clientHeight)},c.onerror=function(){d()},c.src=a;var e=c.style;e.visibility="hidden",e.position="fixed",e.bottom=e.left=0,e.width=e.height="auto",document.body.appendChild(c)}function hiddenIframeBorder(){$(".mce-window iframe").attr("frameborder","no").attr("scrolling","no")}function getEmailLoginAddress(a){if(a){var b=a.split("@");if(b&&!(b.length<2)){var c=b[1];return email2LoginAddress[c]||"http://mail."+c}}}function reIsOk(a){return a&&"object"==typeof a&&a.Ok}function saveBookmark(){try{if(LEA.bookmark=tinymce.activeEditor.selection.getBookmark(),LEA.bookmark&&LEA.bookmark.id){var a=$($("#editorContent_ifr").contents()),b=a.find("body"),c=b.children().eq(0);if(c.is("span")){var d=c,e=d.eq(0);e.attr("id")==LEA.bookmark.id+"_start"?(LEA.hasBookmark=!1,e.remove()):LEA.hasBookmark=!0}else if(c.is("p")){var d=c.children();if(1==d.length&&""==$.trim(c.text())){var e=d.eq(0);e.attr("id")==LEA.bookmark.id+"_start"?(LEA.hasBookmark=!1,c.remove()):LEA.hasBookmark=!0}else LEA.hasBookmark=!0}}}catch(f){}}function restoreBookmark(){try{if(LEA.hasBookmark){var a=tinymce.activeEditor;a.focus(),a.selection.moveToBookmark(LEA.bookmark)}}catch(b){}}var LEA={},Notebook={cache:{}},Note={cache:{}},Tag={},Notebook={},Share={},Mobile={},Converter,MarkdownEditor,ScrollLink,tt=t;LEA.isM=!1,LEA.isMarkdownEditor=function(){return LEA.isM};var previewToken="<div style='display: none'>FORTOKEN</div>";LEA.editorStatus=!0,$(function(){$.pnotify&&($.pnotify.defaults.delay=1e3)}),Date.prototype.format=function(a){var b={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/.test(a)&&(a=a.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(var c in b)new RegExp("("+c+")").test(a)&&(a=a.replace(RegExp.$1,1==RegExp.$1.length?b[c]:("00"+b[c]).substr((""+b[c]).length)));return a};var email2LoginAddress={"qq.com":"http://mail.qq.com","gmail.com":"http://mail.google.com","sina.com":"http://mail.sina.com.cn","163.com":"http://mail.163.com","126.com":"http://mail.126.com","yeah.net":"http://www.yeah.net/","sohu.com":"http://mail.sohu.com/","tom.com":"http://mail.tom.com/","sogou.com":"http://mail.sogou.com/","139.com":"http://mail.10086.cn/","hotmail.com":"http://www.hotmail.com","live.com":"http://login.live.com/","live.cn":"http://login.live.cn/","live.com.cn":"http://login.live.com.cn","189.com":"http://webmail16.189.cn/webmail/","yahoo.com.cn":"http://mail.cn.yahoo.com/","yahoo.cn":"http://mail.cn.yahoo.com/","eyou.com":"http://www.eyou.com/","21cn.com":"http://mail.21cn.com/","188.com":"http://www.188.com/","foxmail.coom":"http://www.foxmail.com"};LEA.bookmark=null,LEA.hasBookmark=!1;var vd={isInt:function(a){var b=/^0$|^[1-9]\d*$/;return result=b.test(a)},isNumeric:function(a){return $.isNumeric(a)},isFloat:function(a){var b=/^0(\.\d+)?$|^[1-9]\d*(\.\d+)?$/;return result=b.test(a)},isEmail:function(a){var b=/^[^@.]+@([^@.]+\.)+[^@.]+$/;return result=b.test(a)},isBlank:function(a){return!$.trim(a)},has_special_chars:function(a){return/['"#$%&\^<>\?*]/.test(a)},init:function(form,rule_funcs){function is_required(a){var b=get_name(a),c=get_rules(a,b),d=c[0];return"required"==d.rule?!0:!1}function get_rules(target,name){return rules[name]||(rules[name]=eval("("+target.data("rules")+")")),rules[name]}function get_msg_target(a,b){if(!msg_targets[b]){var c=a.data("msg_target");if(c)msg_targets[b]=$(c);else{var d=$('<div class="help-block alert alert-warning" style="display: block;"></div>');a.parent().append(d),msg_targets[b]=d}}return msg_targets[b]}function hide_msg(a,b){var c=get_msg_target(a,b);c.hasClass("alert-success")||c.hide()}function show_msg(a,b,c,d){var e=get_msg_target(a,b);e.html(getMsg(c,d)).removeClass("hide alert-success").addClass("alert-danger").show()}function pre_fix(a){var b=a.data("pre_fix");if(b)switch(b){case"int":int_fix(a);break;case"price":price_fix(a);break;case"decimal":decimal_fix(a)}}function apply_rules(a,b){var c=get_rules(a,b);if(pre_fix(a),!c)return!0;for(var d=0;d<c.length;++d){var e=c[d],f=e.rule,g=e.msg,h=e.msgData;if(!rule_funcs[f](a,e))return show_msg(a,b,g,h),!1}hide_msg(a,b);var i=a.data("post_rule");return i&&setTimeout(function(){var a=$(i);apply_rules(a,get_name(a))},0),!0}function focus_func(a){var b=$(a.target),c=get_name(b);hide_msg(b,c),pre_fix(b)}function unfocus_func(a){var b=$(a.target),c=get_name(b);apply_rules(b,c)}function get_name(a){return a.data("u_name")||a.attr("name")||a.attr("id")}var get_val=function(a){if(a.is(":checkbox")){var b=a.attr("name"),c=$('input[name="'+b+'"]:checked').length;return c}return a.is(":radio")?void 0:a.val()},default_rule_funcs={required:function(a){return get_val(a)},min:function(a,b){var c=get_val(a);return""!==c||is_required(a)?c<b.data?!1:!0:!0},minLength:function(a,b){var c=get_val(a);return""!==c||is_required(a)?c.length<b.data?!1:!0:!0},email:function(a){var c=get_val(a);return""!==c||is_required(a)?isEmail(c):!0},noSpecialChars:function(a){var b=get_val(a);return b?/[^0-9a-zzA-Z_\-]/.test(b)?!1:!0:!0},password:function(a){var c=get_val(a);return""!==c||is_required(a)?c.length>=6:!0},equalTo:function(a,b){var c=get_val(a);return""!==c||is_required(a)?$(b.data).val()==c:!0}};rule_funcs=rule_funcs||{},rule_funcs=$.extend(default_rule_funcs,rule_funcs);var rules={},msg_targets={},$allElems=$(form).find("[data-rules]"),$form=$(form);$form.on({keyup:function(a){13!=a.keyCode&&focus_func(a)},blur:unfocus_func},'input[type="text"], input[type="password"]'),$form.on({change:function(a){$(this).val()?focus_func(a):unfocus_func(a)}},"select"),$form.on({change:function(a){unfocus_func(a)}},'input[type="checkbox"]'),this.valid=function(){for(var a=$allElems,b=!0,c=0;c<a.length;++c){var d=a.eq(c),e=get_name(d);if(!apply_rules(d,e))return b=!1,d.focus(),!1}return b},this.validElement=function(a){for(var a=$(a),b=!0,c=0;c<a.length;++c){var d=a.eq(c),e=get_name(d);apply_rules(d,e)||(b=!1)}return b}}};
|
|
=======
|
|
var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Mobile={};var LeaAce={};var Converter;var MarkdownEditor;var ScrollLink;var MD;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}var tt=t;function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}return $.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){return _ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failureFunc,async){_ajax("POST",url,param,successFunc,failureFunc,async)}function ajaxPostJson(url,param,successFunc,failureFunc,async){log("-------------------ajaxPostJson:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({url:url,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:async,data:JSON.stringify(param),success:function(ret,stats){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function findParents(target,selector){if($(target).is(selector)){return $(target)}var parents=$(target).parents();for(var i=0;i<parents.length;++i){log(parents.eq(i));if(parents.eq(i).is(selector)){return parents.seq(i)}}return null}function getVendorPrefix(){var body=document.body||document.documentElement,style=body.style,vendor=["webkit","khtml","moz","ms","o"],i=0;while(i<vendor.length){if(typeof style[vendor[i]+"Transition"]==="string"){return vendor[i]}i++}}function editorIframeTabindex(index){var $i=$("#editorContent");$i.attr("tabindex",index);setTimeout(function(){$i.attr("tabindex",index)},500);setTimeout(function(){$i.attr("tabindex",index)},1e3)}LEA.isM=false;LEA.isMarkdownEditor=function(){return LEA.isM};function switchEditor(isMarkdown){LEA.isM=isMarkdown;if(!isMarkdown){$("#editor").show();$("#mdEditor").css("z-index",1).hide();editorIframeTabindex(2);$("#wmd-input").attr("tabindex",3);$("#leanoteNav").show()}else{$("#mdEditor").css("z-index",3).show();editorIframeTabindex(3);$("#wmd-input").attr("tabindex",2);$("#leanoteNav").hide()}}var previewToken="<div style='display: none'>FORTOKEN</div>";var clearIntervalForSetContent;function setEditorContent(content,isMarkdown,preview){if(!content){content=""}if(clearIntervalForSetContent){clearInterval(clearIntervalForSetContent)}if(!isMarkdown){$("#editorContent").html(content);if(typeof tinymce!="undefined"&&tinymce.activeEditor){var editor=tinymce.activeEditor;editor.setContent(content);editor.undoManager.clear()}else{clearIntervalForSetContent=setTimeout(function(){setEditorContent(content,false)},100)}}else{if(MD){MD.setContent(content)}else{clearIntervalForSetContent=setTimeout(function(){setEditorContent(content,true)},100)}}}function previewIsEmpty(preview){if(!preview||preview.substr(0,previewToken.length)==previewToken){return true}return false}function getEditorContent(isMarkdown){if(!isMarkdown){var editor=tinymce.activeEditor;if(editor){var content=$(editor.getBody()).clone();content.find(".toggle-raw").remove();var pres=content.find("pre");for(var i=0;i<pres.length;++i){var pre=pres.eq(i);var id=pre.attr("id");var aceEditor=LeaAce.getAce(id);if(aceEditor){var val=aceEditor.getValue();val=val.replace(/</g,"<").replace(/>/g,">");pre.removeAttr("style","").removeAttr("contenteditable").removeClass("ace_editor");pre.html(val)}}content.find("pinit").remove();content.find(".thunderpin").remove();content.find(".pin").parent().remove();content=$(content).html();if(content){while(true){var lastEndScriptPos=content.lastIndexOf("</script>");if(lastEndScriptPos==-1){return content}var length=content.length;if(length-9==lastEndScriptPos){var lastScriptPos=content.lastIndexOf("<script ");if(lastScriptPos==-1){lastScriptPos=content.lastIndexOf("<script>")}if(lastScriptPos!=-1){content=content.substring(0,lastScriptPos)}else{return content}}else{return content}}}return content}}else{return[MD.getContent(),"<div>"+$("#preview-contents").html()+"</div>"]}}LEA.editorStatus=true;function disableEditor(){var editor=tinymce.activeEditor;if(editor){editor.hide();LEA.editorStatus=false;$("#mceTollbarMark").show().css("z-index",1e3)}}function enableEditor(){if(LEA.editorStatus){return}$("#mceTollbarMark").css("z-index",-1).hide();var editor=tinymce.activeEditor;if(editor){editor.show()}}function showDialog(id,options){$("#leanoteDialog #modalTitle").html(options.title);$("#leanoteDialog .modal-body").html($("#"+id+" .modal-body").html());$("#leanoteDialog .modal-footer").html($("#"+id+" .modal-footer").html());delete options.title;options.show=true;$("#leanoteDialog").modal(options)}function hideDialog(timeout){if(!timeout){timeout=0}setTimeout(function(){$("#leanoteDialog").modal("hide")},timeout)}function closeDialog(){$(".modal").modal("hide")}function showDialog2(id,options){options=options||{};options.show=true;$(id).modal(options)}function hideDialog2(id,timeout){if(!timeout){timeout=0}setTimeout(function(){$(id).modal("hide")},timeout)}function showDialogRemote(url,data){data=data||{};url+="?";for(var i in data){url+=i+"="+data[i]+"&"}$("#leanoteDialogRemote").modal({remote:url})}function hideDialogRemote(timeout){if(timeout){setTimeout(function(){$("#leanoteDialogRemote").modal("hide")},timeout)}else{$("#leanoteDialogRemote").modal("hide")}}$(function(){if($.pnotify){$.pnotify.defaults.delay=1e3}});function notifyInfo(text){$.pnotify({title:"通知",text:text,type:"info",styling:"bootstrap"})}function notifyError(text){$.pnotify.defaults.delay=2e3;$.pnotify({title:"通知",text:text,type:"error",styling:"bootstrap"})}function notifySuccess(text){$.pnotify({title:"通知",text:text,type:"success",styling:"bootstrap"})}Date.prototype.format=function(fmt){var o={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};if(/(y+)/.test(fmt))fmt=fmt.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length));for(var k in o)if(new RegExp("("+k+")").test(fmt))fmt=fmt.replace(RegExp.$1,RegExp.$1.length==1?o[k]:("00"+o[k]).substr((""+o[k]).length));return fmt};function goNowToDatetime(goNow){if(!goNow){return""}return goNow.substr(0,10)+" "+goNow.substr(11,8)}function getCurDate(){return(new Date).format("yyyy-M-d")}function enter(parent,children,func){if(!parent){parent="body"}$(parent).on("keydown",children,function(e){if(e.keyCode==13){func.call(this)}})}function enterBlur(parent,children){if(!parent){parent="body"}if(!children){children=parent;parent="body"}$(parent).on("keydown",children,function(e){if(e.keyCode==13){$(this).trigger("blur")}})}function getObjectId(){return ObjectId()}function resizeEditor(second){var ifrParent=$("#editorContent_ifr").parent();ifrParent.css("overflow","auto");var height=$("#editorContent").height();ifrParent.height(height);$("#editorContent_ifr").height(height);$("#editorContent").css("top",$("#mceToolbar").height())}function showMsg(msg,timeout){$("#msg").html(msg);if(timeout){setTimeout(function(){$("#msg").html("")},timeout)}}function showMsg2(id,msg,timeout){$(id).html(msg);if(timeout){setTimeout(function(){$(id).html("")},timeout)}}function showAlert(id,msg,type,id2Focus){$(id).html(msg).removeClass("alert-danger").removeClass("alert-success").removeClass("alert-warning").addClass("alert-"+type).show();if(id2Focus){$(id2Focus).focus()}}function hideAlert(id,timeout){if(timeout){setTimeout(function(){$(id).hide()},timeout)}else{$(id).hide()}}function post(url,param,func,btnId){var btnPreText;if(btnId){$(btnId).button("loading")}ajaxPost(url,param,function(ret){if(btnId){$(btnId).button("reset")}if(typeof ret=="object"){if(typeof func=="function"){func(ret)}}else{alert("leanote出现了错误!")}})}function isEmail(email){var myreg=/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[0-9a-zA-Z]{2,3}$/;return myreg.test(email)}function isEmailFromInput(inputId,msgId,selfBlankMsg,selfInvalidMsg){var val=$(inputId).val();var msg=function(){};if(msgId){msg=function(msgId,msg){showAlert(msgId,msg,"danger",inputId)}}if(!val){msg(msgId,selfBlankMsg||getMsg("inputEmail"))}else if(!isEmail(val)){msg(msgId,selfInvalidMsg||getMsg("errorEmail"))}else{return val}}function initCopy(aId,postFunc){var clip=new ZeroClipboard(document.getElementById(aId),{moviePath:"/js/ZeroClipboard/ZeroClipboard.swf"});clip.on("complete",function(client,args){postFunc(args)})}function showLoading(){$("#loading").css("visibility","visible")}function hideLoading(){$("#loading").css("visibility","hidden")}function setCookie(c_name,value,expiredays){var exdate=new Date;exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+(expiredays==null?"":";expires="+exdate.toGMTString())}function logout(){setCookie("LEANOTE_SESSION","",-1);location.href=UrlPrefix+"/logout?id=1"}function getImageSize(url,callback){var img=document.createElement("img");function done(width,height){img.parentNode.removeChild(img);callback({width:width,height:height})}img.onload=function(){done(img.clientWidth,img.clientHeight)};img.onerror=function(){done()};img.src=url;var style=img.style;style.visibility="hidden";style.position="fixed";style.bottom=style.left=0;style.width=style.height="auto";document.body.appendChild(img)}function hiddenIframeBorder(){$(".mce-window iframe").attr("frameborder","no").attr("scrolling","no")}var email2LoginAddress={"qq.com":"http://mail.qq.com","gmail.com":"http://mail.google.com","sina.com":"http://mail.sina.com.cn","163.com":"http://mail.163.com","126.com":"http://mail.126.com","yeah.net":"http://www.yeah.net/","sohu.com":"http://mail.sohu.com/","tom.com":"http://mail.tom.com/","sogou.com":"http://mail.sogou.com/","139.com":"http://mail.10086.cn/","hotmail.com":"http://www.hotmail.com","live.com":"http://login.live.com/","live.cn":"http://login.live.cn/","live.com.cn":"http://login.live.com.cn","189.com":"http://webmail16.189.cn/webmail/","yahoo.com.cn":"http://mail.cn.yahoo.com/","yahoo.cn":"http://mail.cn.yahoo.com/","eyou.com":"http://www.eyou.com/","21cn.com":"http://mail.21cn.com/","188.com":"http://www.188.com/","foxmail.coom":"http://www.foxmail.com"};function getEmailLoginAddress(email){if(!email){return}var arr=email.split("@");if(!arr||arr.length<2){return}var addr=arr[1];return email2LoginAddress[addr]||"http://mail."+addr}function reIsOk(re){return re&&typeof re=="object"&&re.Ok}LEA.bookmark=null;LEA.hasBookmark=false;function saveBookmark(){try{LEA.bookmark=tinymce.activeEditor.selection.getBookmark();if(LEA.bookmark&&LEA.bookmark.id){var $ic=$($("#editorContent_ifr").contents());var $body=$ic.find("body");var $p=$body.children().eq(0);if($p.is("span")){var $children=$p;var $c=$children.eq(0);if($c.attr("id")==LEA.bookmark.id+"_start"){LEA.hasBookmark=false;$c.remove()}else{LEA.hasBookmark=true}}else if($p.is("p")){var $children=$p.children();if($children.length==1&&$.trim($p.text())==""){var $c=$children.eq(0);if($c.attr("id")==LEA.bookmark.id+"_start"){LEA.hasBookmark=false;$p.remove()}else{LEA.hasBookmark=true}}else{LEA.hasBookmark=true}}}}catch(e){}}function restoreBookmark(){try{if(LEA.hasBookmark){var editor=tinymce.activeEditor;editor.focus();editor.selection.moveToBookmark(LEA.bookmark)}}catch(e){}}var vd={isInt:function(o){var intPattern=/^0$|^[1-9]\d*$/;result=intPattern.test(o);return result},isNumeric:function(o){return $.isNumeric(o)},isFloat:function(floatValue){var floatPattern=/^0(\.\d+)?$|^[1-9]\d*(\.\d+)?$/;result=floatPattern.test(floatValue);return result},isEmail:function(emailValue){var emailPattern=/^[^@.]+@([^@.]+\.)+[^@.]+$/;result=emailPattern.test(emailValue);return result},isBlank:function(o){return!$.trim(o)},has_special_chars:function(o){return/['"#$%&\^<>\?*]/.test(o)},init:function(form,rule_funcs){var get_val=function(target){if(target.is(":checkbox")){var name=target.attr("name");var val=$('input[name="'+name+'"]:checked').length;return val}else if(target.is(":radio")){}else{return target.val()}};var default_rule_funcs={required:function(target){return get_val(target)},min:function(target,rule){var val=get_val(target);if(val===""&&!is_required(target)){return true}if(val<rule.data){return false}return true},minLength:function(target,rule){var val=get_val(target);if(val===""&&!is_required(target)){return true}if(val.length<rule.data){return false}return true},email:function(target,rule){var val=get_val(target);if(val===""&&!is_required(target)){return true}return isEmail(val)},noSpecialChars:function(target){var val=get_val(target);if(!val){return true}if(/[^0-9a-zzA-Z_\-]/.test(val)){return false}return true},password:function(target,rule){var val=get_val(target);if(val===""&&!is_required(target)){return true}return val.length>=6},equalTo:function(target,rule){var val=get_val(target);if(val===""&&!is_required(target)){return true}return $(rule.data).val()==val}};rule_funcs=rule_funcs||{};rule_funcs=$.extend(default_rule_funcs,rule_funcs);var rules={};var msg_targets={};function is_required(target){var name=get_name(target);var rules=get_rules(target,name);var required_rule=rules[0];if(required_rule["rule"]=="required"){return true}return false}function get_rules(target,name){if(!rules[name]){rules[name]=eval("("+target.data("rules")+")")}return rules[name]}function get_msg_target(target,name){if(!msg_targets[name]){var t=target.data("msg_target");if(!t){var msg_o=$('<div class="help-block alert alert-warning" style="display: block;"></div>');target.parent().append(msg_o);msg_targets[name]=msg_o}else{msg_targets[name]=$(t)}}return msg_targets[name]}function hide_msg(target,name){var msgT=get_msg_target(target,name);if(!msgT.hasClass("alert-success")){msgT.hide()}}function show_msg(target,name,msg,msgData){var t=get_msg_target(target,name);t.html(getMsg(msg,msgData)).removeClass("hide alert-success").addClass("alert-danger").show()}function pre_fix(target){var fix_name=target.data("pre_fix");if(!fix_name){return}switch(fix_name){case"int":int_fix(target);break;case"price":price_fix(target);break;case"decimal":decimal_fix(target);break}}function apply_rules(target,name){var rules=get_rules(target,name);pre_fix(target);if(!rules){return true}for(var i=0;i<rules.length;++i){var rule=rules[i];var rule_func_name=rule.rule;var msg=rule.msg;var msgData=rule.msgData;if(!rule_funcs[rule_func_name](target,rule)){show_msg(target,name,msg,msgData);return false}}hide_msg(target,name);var post_rule=target.data("post_rule");if(post_rule){setTimeout(function(){var post_target=$(post_rule);apply_rules(post_target,get_name(post_target))},0)}return true}function focus_func(e){var target=$(e.target);var name=get_name(target);hide_msg(target,name);pre_fix(target)}function unfocus_func(e){var target=$(e.target);var name=get_name(target);apply_rules(target,name)}function get_name(target){return target.data("u_name")||target.attr("name")||target.attr("id")}var $allElems=$(form).find("[data-rules]");var $form=$(form);$form.on({keyup:function(e){if(e.keyCode!=13){focus_func(e)}},blur:unfocus_func},'input[type="text"], input[type="password"]');$form.on({change:function(e){if($(this).val()){focus_func(e)}else{unfocus_func(e)}}},"select");$form.on({change:function(e){unfocus_func(e)}},'input[type="checkbox"]');this.valid=function(){var $ts=$allElems;var is_valid=true;for(var i=0;i<$ts.length;++i){var target=$ts.eq(i);var name=get_name(target);if(!apply_rules(target,name)){is_valid=false;target.focus();return false}else{}}return is_valid};this.validElement=function(targets){var targets=$(targets);var ok=true;for(var i=0;i<targets.length;++i){var target=targets.eq(i);var name=get_name(target);if(!apply_rules(target,name)){ok=false}}return ok}}};function getHashObject(){var hash=location.hash;if(!hash){return{}}var hashKV=hash.substr(1);var kvs=hashKV.split("&");var kvsObj={};for(var i=0;i<kvs.length;++i){var kv=kvs[i].split("=");if(kv.length==2){kvsObj[kv[0]]=kv[1]}}return kvsObj}function getHash(key,value){var kvs=getHashObject();return kvs[key]}function setHash(key,value){var hash=location.hash;if(!hash){location.href="#"+key+"="+value;return}var kvs=getHashObject();kvs[key]=value;var str="";for(var i in kvs){if(kvs[i]){if(str){str+="&"}str+=i+"="+kvs[i]}}location.href="#"+str}
|
|
>>>>>>> dev-life
|