(function(n){function t(){function i(){if(!r){t=$e.path("data/bookmark.cfg");var n=0+$e.datafile("query",t,"version");n==0&&$e.datafile("update",t,"version",1),r=!0}}function u(n){var t=jsonParse(n.value);return typeof t.index=="undefined"?null:{key:n.key,id:n.key.split(/_/ig)[0],title:t.title,url:t.url,chapter:t.chapter,index:t.index,scrollTop:t.scrollTop,dbtime:n.time,time:$e.timestamp("yyyy-mm-dd",n.time)}}var t="",r=!1;return this.query=function(n){var r,e,f,o;for(i(),r=null,e=[],r=n.search(/_/ig)>-1?$e.datafile("query",t,n):$e.datafile("query",t,n+"_(*)"),f=0;f<r.length;f++)try{if(o=u(r[f]),o==null)continue;e.push(o)}catch(s){}return e},this.queryAll=function(){return i(),$e.datafile("queryKeys",t)},this.queryList=function(){var r,f,n,e;for(i(),r=$e.datafile("query",t,"(*)"),f=[],n=0;n<r.length;n++)try{if(e=u(r[n]),e==null)continue;f.push(e)}catch(o){}return f},this.remove=function(n){return i(),n.search(/_/ig)>-1?$e.datafile("delete",t,n):$e.datafile("delete",t,n+"_(*)")},this.update=function(n,r,u){var f,o,e;i(),f="{",o=0;for(e in u)o++>0&&(f+=","),f+='"'+e+'":"'+(u[e]+"").addslashes()+'"';return f+="}",$e.datafile("update",t,n+"_"+r,f)},this.bind=function(t,i){var r=n.mzTpl("tpl_bookmark_pop"),u=t?$(t).find((i?i:"*")+"[data-markid]"):$((i?i:"*")+"[data-markid]");u.each(function(){var t=$(this);t.cluetip({cluetipClass:"jtip",width:"300px",sticky:!0,local:!0,showTitle:!0,dropShadow:!1,mouseOutClose:!0,closePosition:"title",closeText:"X",cluezIndex:9999,delayedClose:500,titleAttribute:"data-marktitle",onActivate:function(){var i=t.data("tip"),f=t.data("markcache"),u;if(i!="no"||f=="no"){if(i="",u=n.bookMark.query($(this).data("markid")),u.length==0)return t.data("tip","no"),$("#cluetip").hide(),!1;i=r({list:u}),t.data("tip",i)}return i&&i!="no"?($("#markList").html(i),!0):($("#cluetip").hide(),!1)}})})},this}n.bookMark=t()})(window,document)