Template talk:jsOverrides

Our volunteers haven't translated this article into 日本語 yet. Join us and help get the job done!
You can also read the article in English (US).

Earlier this year, I decided to take advantage of DekiScript which came along with the move MindTouch by replacing the old Template:JSInherits. The problem with that template is that for each use, you have  to give parameters for each property you want to inherit. Basically, the parameter list consists of a JavaScript global object (which is most often Object or Function), the word "Properties" or "Methods", then enumerating values obtained by P−L where P is the set of properties or methods (respective to the previous parameter) in the prototype of the first argument, and L is the set of properties or methods that override the prototype. You have to do this on every page. The problem is that L is generally smaller than P−L, so you end up listing a lot of parameters. Another problem is that since these parameters are inclusive rather than exclusive, it's possible to leave out some of the prototype's properties and methods. This is a big issue when new properties and methods are added to the prototype in new releases of Mozilla, because all the pages that say they inherit from Object.prototype have to be updated to list those new properties and methods. Oh yeah, it only takes 2 + 30 parameters, and each parameter has to have code to individually format it.

So this proof of concept was supposed to fix that. You specify a global object, the word "Properties" or "Methods", and enumerate the properties that override the prototype for that global object. When new properties and methods are added to that prototype, just update the table hardcoded into this template, and all pages that say they inherit from that prototype now reflect the addition. It's not locale-friendly yet, because I didn't complete it. I was waiting on an upgrade to MindTouch that made writing XML/XHTML from DekiScript more elegant, and figuring out problems in the template code from the wiki error messages was frustrating. I think both of those issues have been fixed or reduced in subsequent upgrades to MindTouch, but I haven't messed with this anymore since February. -- Sevenspade


 このページの貢献者: Sevenspade
 最終更新者: Sevenspade,