User:CodeCat/lookup language

Fragment of a discussion from User talk:Rua
Jump to navigation Jump to search

I used the newNode function before, but then I switched to just writing out the HTML directly and didn't need it anymore, but I forgot to remove it.

I used { 'a' : ... because the key is named "class" which is a keyword. I assumed that would mean I couldn't use it.

I didn't add error handling for now because it seemed to work fine even without it. It was only a simple prototype anyway, more of a proof of concept that could be worked out and improved further. I am hoping that it could eventually become a fully fledged search engine for our data, allowing you to query and pattern match against it. I don't know if I will have the time or motivation to finish it, but even in this simple form it may be useful to some people?

And I don't really have a problem with jQuery, so I'll keep using it until I find out what reason I should have to dislike it.

CodeCat17:28, 24 August 2014

You want to use jQuery — fine. Just use it sensibly. Building DOM is actually more direct — HTML has to be parsed, and parsing is costly. DOM nodes can be put into variables to be later used directly (instead of going through a jQuery wrapper object, often completely unnecessary), like I showed; putting everything into one long string and later plucking out interesting fragments complicates things. Also, carelessly manipulating the markup instead of DOM can lead to problems, like it did at MediaWiki:Gadget-FastRevert.js.

Time to start building a library, it seems. Rather easy to start: just create a gadget in MediaWiki:Gadgets-definition, and set the |skins=none option to hide it from Special:Preferences. Then use it just like you did with LegacyScripts.

About the fifth point, I was referring to the comma, not the apostrophes. (Quoting keys is actually necessary for compatibility.)

Keφr18:35, 24 August 2014

What would I use instead of the comma then?

CodeCat18:53, 24 August 2014

Nothing? Comma is a separator, not a terminator.

Keφr19:49, 24 August 2014

Oh I see now. Some languages allow a comma at the end of the list, I know both Python and Lua do. Since I prefer to place the actual terminator of the list on the next line by itself, putting a comma after the last element looks a bit more consistent. It's more a matter of code style than it really being useful for anything. If not all browsers support it I won't do it for JS.

CodeCat19:54, 24 August 2014