Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Selectbox
« Reply #15, on November 15th, 2011, 09:45 AM »
Quote
Pete, luv ya but you're not helpin' much
I haven't had my first cup of caffeine yet :P
Quote
What about jumpto?
*shrug* I really don't care too much about it, the only time I've ever used it was to figure out board ids when Pretty URLs was on a site. If it's set up to allow for multiple per page, that's just weird because it's never used that way anywhere and can be trimmed back easily enough.
Quote
The third is my current fave still but it fails to sync disabled states between it's own ui and the iOS ui. It's strange.
The iOS UI is strange generally.
Quote
Although we don't really use disabled states anyway.
No, but there's no reason to not to support it.
Quote
Also the ui for iOS needs a HTML to text fallback.
*nods*
Quote
In any case these will all require a rewrite. That's why I only choose MIT stuff.
*nods*
Re: Selectbox
« Reply #16, on November 15th, 2011, 11:13 PM »
Also, sidebar behaviour still not great on iPad. Haven't tried in portrait yet but can't imagine it would be much different.

The sidebar collapses to the left side as expected but the only way to trigger it being visible is to tap in the area where the thought edit option is, which forces it to be visible, and it doesn't perform any auto collapse after.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Selectbox
« Reply #17, on November 16th, 2011, 12:31 AM »
Even the latest rev?!

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Selectbox
« Reply #18, on November 16th, 2011, 12:40 AM »
That's based on whatever's on the demo site as of earlier today, which IIRC has 1164 on it? (Which is for all intents and purposes, is the latest rev.)

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Selectbox
« Reply #19, on November 28th, 2011, 06:47 PM »
Okay, I've split all posts related to select boxes, merged them into a single topic...

I've found a new one, in additions to the ones listed on page 1, that I think is particularly awesome:
http://harvesthq.github.com/chosen/
I don't know the gzipped size (will have to test), but it's 5.5KB when minified and zipped.
The big plus is that when you multi-select something, you see all items listed in a pretty neat way -- just have a look at the demo. It could inspire us, if only for the auto-suggest item...

Here are the things we need in a select box, I'd say:
- perfect accessibility fallbacks
- ability to have wide options while having a set width on the select box itself
- ability to show comments (like a dfn) below options -- I'm thinking we could put them inside HTML comments, and have the widget retrieve them and show them below the options when you open the select box. Also, we could show these comments next to the select box when it's updated with a new option.
- HTML elements in options
- would be nice to have a combo box...
- would be nice to have a script below 5KB when gzipped and minified.
- automatically update contents when changing the select
- automatically moving the HTML box when changing select box position

Also, I'd like us to discuss privacy settings (this is the thing that prompted me to change the select box in the first place.)
Are the privacy settings at Noisen/Wedge.org enough, would you reckon?
Is it needed/useful to have membergroups in the list?
Should we allow better granularity of friend access?
How do you suggest we store privacy in the database? As a bit-wise variable? A list of numbers? Or more?
Posted: November 28th, 2011, 06:02 PM

Please give your opinion on the intended feature lost, too.
Re: Selectbox
« Reply #20, on December 12th, 2011, 02:23 PM »Last edited on December 12th, 2011, 03:54 PM by Nao
Bump on the above... :whistle:

So, now that I'm done with mismatched tags, I'm trying to get back into the select box stuff.
Decided to try for jquery.sb.js for now, and try to optimize the size (since it's really the only thing I have against it.)

Pete, you remember the discussion we had on the oddities of gzipping? Well, it's back in full force...

something = function (event, params) { otherthing.call(event, params); };

So... I figured out that params was never used, so I removed both params calls.
As a result, the gzipped file is 5 bytes larger. Ah ah.

Now... I have plenty of if (...) { one_instruction(); } in the code. I removed the curly braces. As a result, the more braces I remove, the LARGER the gzipped file becomes.
Okay, so I figured, if it's crazy enough to do things like that, let's tag along and add a preg_replace[1] to add curly braces to all single-line tests...
And guess what? It's the exact same size as before it was modified. I looked into it a bit more, and there's just TWO cases where removing the curly braces will make the file bigger, while in other situations it'll usually save a byte.

Anyway, I'm pretty much done and saved about 350 bytes off the original ~3700 bytes. It's not fantastic, but at least it's getting closer to the other selectboxes, and with the extra features.

Now it's going to be realllllly funny when I actually try to run the plugin on Wedge... Yeah, I didn't even try :P
Posted: December 12th, 2011, 01:51 PM

And... it works :)
 1. for the record, preg_replace('~(\tif \([^{}\n]+\n\t+)([^{}\n]+);(\n)~', '$1{$2}$3', $cont)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Selectbox
« Reply #21, on December 12th, 2011, 03:19 PM »
Interestingly but not really that surprising.

Let me explain the reason why it works. The Deflate algorithm doesn't work on single characters but repeating character strings; I'd imagine for example that 'if (' is one such string it notes and inserts a reference for. By putting in extra { and }, you elevate them from single characters that typically don't make much in the way of repeating patterns at the byte level, into something that *explicitly will* be a repeating pattern.

I'm not sufficiently au fait with the LZ77 and LZ78 algorithms and Huffman encoding that underpin Deflate but there's the base cause, that you're giving it a pattern to match rather than individual characters that will be largely just added verbatim in the stream.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Selectbox
« Reply #22, on December 12th, 2011, 03:57 PM »
As I said, I do remember our conversation :P

I simply tried to apply that philosophy to the code and it simply didn't make any sense... Obviously after seeing the param stuff, I looked for other similar functions and didn't find any. Even better -- $(this).each(...) isn't needed, you can simply do this.each(...) in prototypes, but it also adds more bytes... So I went ahead and changed all of the $(this).each() to this.each(), still the same, then I simply went through all $(this) and this, and there were far more this than $(this), actually if I simply used (this) instead of $(this), I'd end up with the same filesize as with $(this)... It would only go up when doing this with nothing else. That's really... funny, in a kind of way.

Anyway, it's only a few bytes so I'm just not going to bother either way...
The best way to save space is to removed dead functions and things like that. There were quite a few in this plugin!

Psychologically, one of my goals is to have the main javascript file under 10KB when zipped. With the original code, it was just a bit over 10KB. Now it sits comfortably under 10KB and I guess I can optimize script.js itself in more ways, too ;)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Selectbox
« Reply #23, on December 12th, 2011, 04:15 PM »
Quote
but it also adds more bytes...
Technically it's saving less bytes but yeah. Part of the reason is that the popularity of a repeated string affects the token size, so that can affect the saving generated by any given token. It's... complicated and is why I don't write compression algorithms.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Selectbox
« Reply #24, on December 12th, 2011, 04:32 PM »
This one's funny, too...
(packed version)

var b,e,h,b=c(this);

Realized my mistake, turned it into this...

var e,h,b=c(this);

And voilà! 3 extra bytes to the filesize, ah ah...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Selectbox
« Reply #25, on December 12th, 2011, 04:32 PM »
...weird. Compression is a harsh mistress.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Selectbox
« Reply #26, on December 12th, 2011, 05:17 PM »
Removed another 100 bytes... I'm starting to consider removing options we don't/won't need. For instance -- support for TIE. It's a plugin that will check the DOM for changes and report them to sb so that it can update the selectbox. However, I'd rather have full control over this and simply trigger sb's update process myself whenever I do changes to the select box... What do you think?
Also has some options like 'displayFormat' which allows you to customize the display... Only, it's not like we're releasing a selectbox plugin... We're simply using it in Wedge. I don't see any reasons to change the HTML outside of the (modified) plugin itself. Do you?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Selectbox
« Reply #27, on December 12th, 2011, 05:57 PM »
Quote
I don't see any reasons to change the HTML outside of the (modified) plugin itself. Do you?
Nope. I can't see a reason why mod authors would either if they used such a thing, but if they *did* they could include their own and deal with it themselves.
Quote
However, I'd rather have full control over this and simply trigger sb's update process myself whenever I do changes to the select box... What do you think?
This works for me :)

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Selectbox
« Reply #28, on December 12th, 2011, 07:09 PM »
Well, it's not like sb's source code is gonna disappear overnight anyway... There's plenty of code in it that's too "general" for my taste. For instance, it includes a library called jQuery-Proto that adds some nifty features to JS "classes". That's all good, but it also adds plenty of options that, ahem, aren't used by the SB object at all... So I simply deleted them all, restarted, and it still works... And is much lighter.

Now we're about at 3150 bytes, so that's over 500 bytes less than when I got started. I hope I can actually remove even more...
Re: Selectbox
« Reply #29, on December 16th, 2011, 07:21 PM »
Quote from Nao on December 12th, 2011, 07:09 PM
Now we're about at 3150 bytes, so that's over 500 bytes less than when I got started. I hope I can actually remove even more...
Nearly 600 bytes removed since that day... I'm pathetically sick ;)