You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
11 KiB
JavaScript

2 years ago
"use strict";!function(){function t(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t,this.userName=this.getCookie("UserName"),this.unCollectIds=[],this.needCollectId=0,this.curFolderId=0,this.curCheckId=0,this.checkOptions()&&this.init()}!function(t){var e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href=t,document.getElementsByTagName("head")[0].appendChild(e)}("https://g.csdnimg.cn/collection-box/2.0.5/collection-box.css"),window.csdn&&window.csdn.userLogin||function(t,e){var o=document.createElement("script");o.type="text/javascript",o.readyState?o.onreadystatechange=function(){"loaded"!=o.readyState&&"complete"!=o.readyState||(o.onreadystatechange=null,e&&e())}:o.onload=function(){e&&e()},o.src=t,document.getElementsByTagName("head")[0].appendChild(o)}("https://g.csdnimg.cn/user-login/3.0.1/user-login.js"),t.prototype.init=function(){this.render().bindEvent().getList(this.renderList),this.data={url:this.options.url,source:this.options.source,source_id:Number(this.options.source_id,10),author:this.options.author,title:this.options.title,description:this.options.description||""}},t.prototype.sortListByTime=function(t){var e=this;t=t.sort(function(t,e){return+new Date(e.UpdatedAt)-+new Date(t.UpdatedAt)});var o=this.getNearItemFolderId(),n=e.findNearCollectionItem(o,t),i=t.filter(function(t){return t.ID!==n.ID});return n&&i.unshift(n),void 0,i},t.prototype.filterCollectionItems=function(t){var e=0,o=this;return t=t.map(function(t){return e=t.CheckStatus&&0===e?t.CheckStatus:e,t.CheckStatus!==e&&0!==t.CheckStatus&&(o.unCollectIds.push(t.CheckStatus),t.CheckStatus=0),t}),void 0,o.deleteCollectionItems(),t},t.prototype.findNearCollectionItem=function(t,e){var o="";return e.forEach(function(e){o=e.ID===t?e:o}),o},t.prototype.checkOptions=function(){var t=!0,e=this.options;return e?"url"in e&&""!==e.url?"source"in e&&""!==e.source?"source_id"in e&&""!==e.source_id?"author"in e&&""!==e.author?"title"in e&&""!==e.title||(void 0,t=!1):(void 0,t=!1):(void 0,t=!1):(void 0,t=!1):(void 0,t=!1):(void 0,t=!1),t},t.prototype.render=function(){var t=this.getThemeClass(),e=$('<div id="csdn-collection" class="'+t+'">\n <div class="csdn-collection-container">\n <div class="csdn-collection-header">添加收藏夹<span class="csdn-collection-close">x</span></div>\n <div class="csdn-collection-body">\n <ul class="csdn-collection-items"></ul>\n <div class="csdn-collection-folder">\n <span class="csdn-collection-tip"></span>\n <span class="csdn-collection-btn"><i></i>新建文件夹</span>\n <div class="csdn-collection-input">\n <input type="text" placeholder="最多可输入20个字">\n <button>新建</button>\n </div>\n </div>\n <p class="csdn-collection-msg"></p>\n </div>\n <div class="csdn-collection-footer">\n <button class="csdn-collection-submit">确 定</button>\n </div>\n </div>\n </div>');return this.box=e,this.list=this.box.find(".csdn-collection-items"),this.toggleBtn=this.box.find(".csdn-collection-btn"),this.inputBox=this.box.find(".csdn-collection-input"),this.input=this.box.find(".csdn-collection-input input"),this.addBtn=this.box.find(".csdn-collection-input button"),this.submitBtn=this.box.find(".csdn-collection-submit"),this.closeBtn=this.box.find(".csdn-collection-close"),this.tip=this.box.find(".csdn-collection-tip"),this.msg=this.box.find(".csdn-collection-msg"),$("body").append(e),this},t.prototype.bindEvent=function(){var t=this;return this.list.on("click","li",function(e){t.clickItemHandler.call(t,$(this))}),this.toggleBtn.on("click",function(e){t.clickToggleBtnHandler.call(t,e)}),this.input.on("keyup",function(e){t.keyupInputHandler.call(t,e)}).on("focus",function(e){!t.getTip