
var FavRightClick=J16.Class.extend({start:function(username){this.cid=0;this.curlist=$('#kindlist>li:first');this.showInfo(username);this.events();},events:function(){var self=this;$('#title').suggest();$('#listarr').click(function(e){e.stopPropagation();$('#kindlist').toggle().find('>li').mouseover(function(){self.curlist.removeClass('hover');$(this).addClass('hover');self.curlist=$(this);}).click(function(){self.cid=$(this).attr('cid');$('#kind').val($(this).text());});});$(document).click(function(){$('#kindlist').hide();});$('#add_url_confirm').click(function(){self.addUrl();});$('#add_url_cancel').click(function(){window.close();});},hideWindow:function(){J16.util.dialog.hide();},showInfo:function(username){var self=this,query=J16.util.getQueryString,dc=decodeURIComponent,title=dc(query('title')),uri=dc(query('uri'));$('#username').text(username);$('#title').val(title);$('#url').val(uri);},addKind:function(n){var ret=0;$.ajax({type:'POST',async:false,url:'update.php?type=category&do=update',data:$.param({id:0,name:n}),success:function(d){if(d==-1){alert('文件名已经存在');return false;}
if(d==0){alert('添加失败!');return false;}
ret=d;}});return ret;},addUrl:function(){var self=this,title=$('#title').val(),url=$('#url').val(),kind=$('#kind').val();var cid=$.trim(kind).length==0?0:$.inArray(kind,fav_list)==-1?self.addKind(kind):self.cid;$.post('update.php?type=site&do=update',{id:0,name:title,url:url,cid:cid},function(d){if(d==0){alert('添加失败!');return false;}
$('#error_tip').text('文件夹收藏成功!').show();setTimeout(function(){window.close();},800);});}});var favRightClick=new FavRightClick();function checkLogin(e){if(e.code==1){favRightClick.start(e.desc);}else{J16.util.dialog.show({title:'用户登录',left:50,top:50,height:210,width:345,iframe:'login.htm',opacity:0.2});}}