MediaWiki:Chorke/YouTube/Channel.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/**
* This is the Number.lpad() method developed aim to support
* oracle like lpad single rows function for JS Engine.
*
* @public
* @package Number
* @class Number.lpad()
*/
;Number.prototype.lpad||(function(){
Number.prototype.lpad = function(width, fill, me, padded) {
me = this.toString();
if(me.length >= width){
return me;
}
padded = new Array(width - me.length + 1);
return padded.join(fill||'0') + me;
};
})();
/**
* This is the String.format() method developed aim to support
* Java like format String in perspectives of JS Engine.
*
* @public
* @package String
* @class String.format()
*/
;String.prototype.format||(function(){
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined' ? args[number] : match;
});
};
})();
/**
* This is the String.info() method developed aim to support
* Java like print String in perspectives of JS Engine.
*
* @public
* @package String
* @class String.info()
*/
;String.prototype.info||(function(){
String.prototype.info = function() {
if(console && console.info){
console.info(this.toString());
}
return this;
};
})();
/**
* This is the String.rpad() method developed aim to support
* Oracle like rpad single rows function for JS Engine.
*
* @public
* @package String
* @class String.rpad()
*/
;String.prototype.rpad||(function(){
String.prototype.rpad = function(width, fill, me, padded) {
me = this;
if(me.length >= width){
return me;
}
padded = new Array(width - me.length + 1);
return me + padded.join(fill||'0');
};
})();
/**
* This is the String.warn() method developed aim to support
* Java like print String in perspectives of JS Engine.
*
* @public
* @package String
* @class String.warn()
*/
;String.prototype.warn||(function(){
String.prototype.warn = function() {
if(console && console.warn){
console.warn(this.toString());
}
return this;
};
})();
/**
* @public
* @class Chorke
* @package Default
*/
var Chorke=Chorke||(function(me){
me = {
$class : 'Chorke',
$package : 'Default',
meta : function(ns, tpl, out){
tpl = '{\n "package" : "{0}",\n "class" : "{1}"\n}';
out = tpl.format(ns.$package, ns.$class);
return out;
}
};
return me;
})(),
/**
* @public
* @class CKi
* @package Default
*/
CKi=CKi||(function(me){
me.$class = 'CKi';
me.$meta = function(){return me.meta(me)};
return me;
})(Chorke);
/**
* @public
* @static
* @package CKi
* @class CKi.Edu
*/
;CKi.Edu||(function($, me){
me = {
$package : 'CKi',
$class : 'CKi.Edu',
$meta : function(){return $.meta(me)}
}
$.Edu = me;
})(CKi);
/**
* @public
* @static
* @package CKi.Edu
* @class CKi.Edu.YouTube
*/
;CKi.Edu.YouTube||(function($, me){
me = {
$package : 'CKi.Edu',
$class : 'CKi.Edu.YouTube',
$meta : function(){return $.meta(me)}
}
$.Edu.YouTube = me;
})(CKi);
/**
* @public
* @static
* @package CKi.Edu.YouTube
* @class CKi.Edu.YouTube.Channel
*/
;CKi.Edu.YouTube.Channel||(function($, me, channels){
channels = [];
me = {
$package : 'CKi.Edu.YouTube',
$class : 'CKi.Edu.YouTube.Channel',
$meta : function(){return $.meta(me)},
getIndex : function(name, index, channel){
for(index=0;index < channels.length;index++){
channel = channels[index];
if(channel.name.toLowerCase() == name.toLowerCase()){
return index;
}
}
return -1;
},
isExist : function(name, index){
index = me.getIndex(name);
return index >= 0;
},
add : function(name, lang, liked){
if(!me.isExist(name)){
channels.push({name: name, lang: lang||'English', like: liked||0});
} else {'"{0}" Already Exist!'.format(name).warn();}
return me;
},
del : function(name, index){
if(me.isExist(name)){
index = me.getIndex(name);
channels.splice(index, 1);
return me;
} else {'"{0}" Not Yet Found!'.format(name).warn();}
return me;
},
compare : function(prev, next) {
if (prev.name < next.name){
return -1;
} else if (prev.name > next.name){
return 1;
}
return 0;
},
sort : function(){
return channels.sort(me.compare);
},
format : function(index, channel, name, lang, like, tpl, out){
tpl = ' {0}. Chorke {1}, Inc. => {2}[{3}]\n';
out = '';me.sort();
for(index=0;index < channels.length;index++){
channel = channels[index];
name = channel.name;
lang = channel.lang;
like = channel.like;
out += tpl.format((index + 1).lpad(3), name, lang.rpad(12, ' '), (like ? 'x' : ' '));
out += ((index+1)%20) ? '' : '\n';
}
return out;
},
print : function(){
me.format().info();
return me;
}
}
$.Edu.YouTube.Channel = me;
})(CKi);
/**
* @public
* @static
* @package anonymous
* @class anonymous
*/
(function(Channel, Container){
Channel.add('Academia', 'Dutch', 1).add('Agronomy', 0, 1).add('AirCargo').add('AirLines').add('Antiques');
Channel.add('Aquarium', 0, 1).add('Artifact').add('Ascriber').add('Assembla', 'Catalan').add('Atlantic');
Channel.add('BabyCare').add('Beverage').add('BodyCare').add('Breeding').add('CareCure');
Channel.add('Composer').add('Composts', 0, 1).add('Crafting', 0, 1).add('Cruising').add('Cuisines', 0, 1);
Channel.add('Cultural').add('Diligent').add('Donation').add('Economia', 'Dutch').add('Emporium');
Channel.add('Exterior').add('Fabricat', 'Romanian').add('Fabulous').add('Farmacia', 'Italian').add('Festival');
Channel.add('Gardenia').add('Hatchery').add('Healthya', 'Romanian').add('Heritage', 0, 1).add('Historic');
Channel.add('HomeCare').add('HutBazar', 'Bangla').add('Hygienia', 'Finish').add('Imaginer').add('Imperial');
Channel.add('Interior').add('Inventor').add('Kingdoms').add('Kitchens').add('Literary');
Channel.add('MediCare', 0, 1).add('Medicina', 'Spanish ').add('Memorial').add('Netizens').add('Nursings');
Channel.add('Overseas', 0, 1).add('Painting').add('Pathsala', 'Bangla', 1).add('Populars', 'Catalan').add('Portrait');
Channel.add('Property').add('Recycles', 0, 1).add('Restaura', 'Bangla').add('Radiator').add('Robotica', 'Italian', 1);
Channel.add('Scholars', 0, 1).add('Seasonal').add('SelfCare').add('Socialia', 'Latin').add('Software', 0, 1);
Channel.add('Spectrum').add('Spicerys').add('Supposer').add('Travelia', 'Romanian', 1).add('Universe');
Channel.add('Vacation').add('Villager').add('Virtuals', 'Catalan').add('Abrasive').add('Afghanis');
Channel.add('Arakanee', 'Bangla').add('Autonomy').add('Ensemble').add('Freedoms').add('Analysis');
Channel.add('Galleria').add('Paradigm').add('Exemplar').add('Maritime').add('Mountain');
Channel.add('Navigate').add('Namenlos', 'German').add('Nameless').add('Nautical').add('Pilotage');
Channel.add('Pantheon').add('Ornament').add('Promises').add('Ridicule').add('Refugees');
Channel.add('Register').add('Resource').add('Rohingya').add('Renovate').add('Renowned');
Channel.add('Sciences').add('Scrutiny').add('Strategy').add('Souvenir').add('Emulator');
Channel.add('Undefine').add('Parallel').add('Paragons').add('Paradise').add('Infinite');
Channel.add('Mechanic').add('Premises');
Container&&Container.html(Channel.format());
})(CKi.Edu.YouTube.Channel, $('#cki-youtube-channel'));