function applet() { }; applet.prototype.init = function() { as.yui.one(this.getField("_btnSearch")).on('click', function(e) { e.preventDefault(); var value = as.yui.one(as.corex.getModule("applet").getField("_youtubeQuery")).get("value"); if (value) { value = value.replace(/ /gi, "-"); value = value.replace(/\//gi, ""); window.location.href = "/portfolio/youtube-search/"+encodeURI(value)+".htm"; }; }); }; function pagination() { }; pagination.prototype.init = function() { this.setFilename("/common/pagination"); this.getParams().totalpages = Math.ceil(this.getParams().total / this.getParams().pagesize); this.loadSetting({previous: "<< Previous", next: "Next >>", showone: false, showsize: 10}); }; pagination.prototype.render = function() { try { if ((this.getParams().totalpages > 1) || (this.getParams().setting.showone == true)) { var html = this.buildPrevious() +this.buildCenter() +this.buildNext() +"
"; this.getField("divList").set("innerHTML", html); }; } catch(e) { }; }; pagination.prototype.buildPrevious = function() { var html = ""; var previous = this.getParams().setting.previous; if (previous && (this.getParams().page > 1)) { html = "
"+this.buildLink(previous, this.getParams().page-1)+"
"; }; return html; }; pagination.prototype.buildCenter = function() { var html = ""; var page = 0; var length = this.getParams().totalpages; var startCount = (parseInt(this.getParams().page)-5 > 0) ? parseInt(this.getParams().page) - 5 : 0; var endCount = (parseInt(this.getParams().page)+5 > length) ? length : parseInt(this.getParams().page)+5; var checkCount = endCount - startCount; if (checkCount < this.getParams().setting.showsize) { startCount += checkCount - parseInt(this.getParams().setting.showsize); } if (endCount < this.getParams().setting.showsize) { endCount = this.getParams().setting.showsize; if (endCount > this.getParams().totalpages) { endCount = this.getParams().totalpages; } } if (startCount < 0) startCount = 0; html = "
"; for (var x=startCount; x"; } else { html += this.buildLink(page, page); }; }; // Build jump to html += "
" +" Jump to page: " +"
"; return html; }; pagination.prototype.jumpto = function(el) { try { if (this.getParams().callback) this.loadPage(el[el.selectedIndex].value); else this.handlePagination(params); } catch(e) { as.logs.addError(this.filename, "'buildLink' >> "+e); } } pagination.prototype.buildNext = function() { var html = ""; var next = this.getParams().setting.next; if (next && (this.getParams().page < this.getParams().totalpages)) { html = "
"+this.buildLink(next, parseInt(this.getParams().page)+1)+"
"; }; return html; }; pagination.prototype.buildLink = function(txt, page) { var params = this.buildParams(page); try { if (this.getParams().callback) url = "javascript:"+this.getHTMLReference()+".loadPage("+page+");"; else url = this.handlePagination(params); } catch(e) { as.logs.addError(this.filename, "'buildLink' >> "+e); }; return ""+txt+""; }; pagination.prototype.loadPage = function(page) { this.getParent().loadPage(this.buildParams(page)); }; pagination.prototype.buildParams = function(page) { return {page: page, total: this.getParams().total, pagesize: this.getParams().pagesize }; }; pagination.prototype.loadSetting = function(value) { this.getParams().setting = value; }; pagination.prototype.setCSS = function(value) { this.getField("divList").addClass(value); }; pagination.prototype.getBodyHTML = function() { var html = "
"; return html; };