/** * myCharctor Profiles * @author Tenderfeel * @ver 1.0 * @HOME http://tenderfeel.xsrv.jp/ * MIT Style License. */ var myCharctors = new Class({ Implements: [Options], options: { url:"char.json", method:"get", id:"characters", sectionElement:"div", nameElement:"h4", textElement:"p", className:"group-" }, initialize: function(key,options) { this.setOptions(options); this.cookey = key; this.container = $(this.options.id); this.myCookie = Cookie.read(this.cookey); if(!$chk(this.myCookie)) this.myCookie=1; this.getChar(); }, getChar:function(){ var self = this; new Request.JSON({ url:this.options.url, method:this.options.method, onSuccess: function(char){ self.create(char); } }).get(); }, create:function(char){ var self = this; $each(char,function(data,n){ if(self.myCookie >= data.id){ var sec = new Element(self.options.sectionElement,{"class":self.options.className+data.id}); var name = new Element(self.options.nameElement,{"text":n}); name.inject(sec); $each(data.text,function(txt,i){ if(self.myCookie >= i.toInt()) new Element(self.options.textElement,{"text":txt}).inject(sec); }); } sec.inject(self.container); }); } });