Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Nao
3376
Off-topic / Re: Lint checker
« on March 23rd, 2013, 12:10 PM »
Fun fact: topic about typos--- has a typo in its body 8-)
3377
Plugins / [Plugin] Re: Notifications system (1.0)
« on March 22nd, 2013, 06:09 PM »
I'm only getting started... ;)
3378
Development blog / Re: It only took two guys two years...
« on March 22nd, 2013, 06:08 PM »
+1...
3379
Features / Re: JavaScriptEscape headaches
« on March 22nd, 2013, 05:12 PM »
I don't understand your story about the behavio(u)r..?
Is there a problem with the chr() I've implemented to get rid of any problems for JSE? (It needs to be turned back manually whenever ob_sessrewrite isn't called, e.g. $txt handling in JS files.)

I'm not thrilled with the idea of a separate file for JS strings.
I would, however, be opened with a convention such as putting the js_ prefix to any string that should be in JS code, but even that is not needed with my trick... ^^
3380
Archived fixes / Re: Menu lines are not showing here
« on March 22nd, 2013, 04:56 PM »
Sorry, a small inheritance blunder on my side.
Fixed...

(I'm resuming my work on wedge.org -- spent a day on the mentions code and I'm so tired of it... Feeling like I won't be implementing this in Wysiwyg for some time...!!)
3381
Plugins / [Plugin] Re: Notifications system (1.0)
« on March 22nd, 2013, 03:55 PM »
'kay, back from the outer world, immediately jumped onto this...
I was hoping changing .height() to .innerHeight would help, but it didn't.
After multiple tests, I managed to reduce the delay to under 200ms. Another stroke of genius, or maybe not: I simply increased the width of the span... If it's 5px instead of 1px, you need 5 times less additions to get the width, obviously... And a 5px difference doesn't matter much in the final result. It's not rocket science...

I'll still try to find other solutions. Apparently, just changing the display:inline of that span to display:inline-block seems to increase the speed, but I'm not sure if it's related to that... :^^;:
Posted: March 22nd, 2013, 01:01 PM

Doing Wysiwyg is a nightmare... :-/
3382
Plugins / [Plugin] Re: Notifications system (1.0)
« on March 22nd, 2013, 10:38 AM »
Quote from Nao on March 21st, 2013, 05:40 PM
I actually used an external jQuery plugin for that, but it needed to be rewritten a bit because it's old and incompatible.
I'm the first surprised, but I managed to take it down to 340 gzipped bytes.... 8-)

Basically, I gave up on the plugin I was using, and took some ideas here and there. Which didn't work...

Here's how I did it. In times like that, I feel really smart... :lol:

- Getting the Y position: reproducing the same text (up to the caret position) in a div that inherits the textarea's font values. That's the classic way of doing it. It's quick, and it works: you just take the div's height (default overflow), and you're done :)

- Getting the X position: here's the tricky part -- the one I figured out by myself. I'm initializing a count variable, and getting the height from above. Then I add a single-pixel width span, and calculate the div's height again. If it's the same, increment the count and continue. If it's not, then it means the div overflowed, and I stop it. Well... By this point, guess what count stands for? It's the number of horizontal pixels between the caret and the right end of the div! Then, all I need to do is $test.width() - count... And voilà, we've got our X position!

Worst part is, it really works :lol:
It could be faster, though... I'll have to consider doing that in pure JavaScript (not jQuery), I don't know. I'll just see.

This isn't tested in Wysiwyg, though. I suspect it won't work there... And I'll have to do a different codepath for it. Which will increase the size of the code. Meh. Well, right now it's at 1130 bytes, gzipped, and it's short enough to warrant being enabled by default here. ;)
Posted: March 22nd, 2013, 10:34 AM

Bugger... Just did a quick benchmark.
With innerHTML: 8 seconds to execute!!
With .append(): 1.4 second.
It's still very slow... Dunno how I can optimize.
3383
Plugins / [Plugin] Re: Notifications system (1.0)
« on March 21st, 2013, 05:40 PM »
@Dragooon> I actually used an external jQuery plugin for that, but it needed to be rewritten a bit because it's old and incompatible. Basically, IE provides a x/y position in its select range object, so that's perfect, but other browsers don't, so the plugin creates a hidden textarea with no scrollbars, fills it with the text up to the caret position, and gets the caret position from that. Well, it's easy to get the vertical position, but as for the horizontal position, I'm not too sure, haven't delved too deeply into its code... All I know, is that it works ;)

@Arantor> Yup I did notice that, and I'm planning to fix it, but right now I'm lost in a larger rewrite of the notification code and that error gets in my way :lol: Also, I edited your link out -- it's a public page, and I don't want Google following a link that generates errors for guests..!
3384
Features: Posts & Topics / Re: Automatic Quote splitter
« on March 21st, 2013, 04:53 PM »
@Dragooon> Hmm, not an option. Okay I've enabled it on wedge.org... You may test on your mobile device if you want ;)

@Dragooon: maybe the colon is an issue..? Nope... Then your plugins are crappy :lol:
3385
Features / Re: JavaScriptEscape headaches
« on March 21st, 2013, 01:27 PM »
Note to self: grepWin supports search history. Just needed to double-click the search box... :)
Still doesn't have a preview pane, though. Only offers one line of preview if choosing 'contents' in the bottom of the window. Better than nothing, I suppose...
3386
Features: Posts & Topics / Re: Automatic Quote splitter
« on March 21st, 2013, 11:53 AM »
Ah, bugger... That's a good suggestion. I just don't like having this kind of feature forced on users, they might not understand what is happening.. :-/
Touch[1]-only tweak, to begin with... At least that's what I'd do.

@Arantor, what's up with the perms then..?
 1. Rather than mobile
3387
Features / JavaScriptEscape headaches
« on March 21st, 2013, 11:48 AM »
So, I don't know why, but today I decided to tackle JSE quirks...
If you'll remember (or not), six months ago I mentioned in rev 1767 that I was looking for a volunteer to go through the codebase with on[a-z]+="[^"]*JavaScriptEscape and ensure these calls are properly escaped.

Well, six months ago I didn't know about grepWin, which is a great tool (I would gladly replace my other search'n'replace tool if it supported both a history of previous searches, and a quick preview of matches 'in context'), and most importantly, supports multi-line regex searches.

So there are about 75 matches across Wedge + plugins (without counting some special cases like 'onclick' => 'return something' which I didn't test for), that's a lot but it's doable.
Now I'd like to discuss the JSE function itself, and the situations in which it can cause problems.

As $txt protections inside .js files

Nothing to say... It works well. JS files use single quotes everywhere, so it's well optimized, too. One has to remember, though, not to use a $txt inside a double-quoted string. No reason to do that, though..?

Inside an inline event

Ah, this...
echo 'onclick="return', JavaScriptEscape('I say "Hello!" and you say "Get lost!"...'), ';"'; isn't gonna work, because you can't escape a double-quote properly inside an inline event... So, that's why I added an extra bool param to JSE to tell the engine that we're within a HTML param, and that we need to turn any double quotes to "...

That's good.
Especially since I (somehow foolishly, but I stand by my decision) turned all quot entities to double-quotes in language files, to make them more readable. (I think the upside is better than the downside here.)

Now, the thing that REALLY matters, is that Wedge doesn't leave inline events as they are... You know that. It loads jQuery at the end of the page, so it moves inline events to the end, too. I was thinking, it's pretty silly to bother with that...?!
I can very, very easily allow for escaped double-quotes (\") in inline events. They'll just get moved out of the HTML anyway... But, does that mean I should escape all double-quotes inside JSE without distinction..? I don't think so. Outside of an inline event, the double-quotes will remain escaped, and I don't like the idea.
And yes, I need to escape double quotes, there's no other realistic option.
So, do I need to use the bool in every use of JSE inside an inline event..?

Inside footer JS

I think that's the last possibility..?!
This is where I've been looking today. Fact is, in a Wedge HTML page, all tag params are surrounded by double quotes. There are tons of double-quotes in every page. There are very little single quotes. So I did a quick test, and instead of JSE returning 'string', it returned "string', and guess what? I saved about 10 gzipped bytes just by doing that on the home page. It's not MUCH, and certainly not enough to warrant this topic, but... It's my hobby, after all.

Where is JSE used the most, then..?

Here's a solution I was thinking of... It's crazy, at least as much as I can be.
In JSE, return the string surrounded by chr(15) (or whatever unused character in the invisible ASCII range), and escape double-quotes in the string with chr(16) or whatever.
Then, at ob_sessrewrite time, once the event delaying process is completed, turn back chr(15) to double-quotes, and turn chr(16) to double-quotes only if they're not inside a string, otherwise turn them to " entities. I'm thinking of this as I'm typing, so it probably doesn't make a lot of sense... But I'd love being able to solve the need for the 'escape double quotes' boolean param. I think I'll do that *at least* for chr(16)...

Also, I think we could use double-quotes by default in JSE, and only use single-quotes when called within $txt protection code in JS files.

Okay, that's it... The proverbial headache is coming up. I can feel it.
3388
Plugins / [Plugin] Re: Notifications system (1.0)
« on March 21st, 2013, 11:04 AM »
Quote from Dragooon on March 21st, 2013, 10:19 AM
Quote
We should also make sure that all unread notifs are sent by e-mail before they're pruned... Is it accounted for?
Unread notifications aren't pruned, only read ones.
I'm not sure it works like this... It seems to me that as soon as you click the popup, it gets marked as read, even if not visiting the topic itself. I may be wrong, but this is what I gathered yesterday... And I haven't looked at the notification code too deeply for now.
Quote
Did you disable mark read on topic display (See Notification::markReadForNotifier, it handles all auto mark reads for areas other than the notifications action)? Because otherwise one way or the another it'll end up mark it read on click.
That's not a problem... As long as I don't read the Birthday topic (which by tradition I'm not supposed to post on for a while :P), it won't get marked in my notifications. (Oh, and I'd appreciate if someone could post another @Nao in that topic, so that I get two notifications to style... :P)

Oh, I love the popup that comes up when I mention someone... It will need some refining, though! For instance, sometimes it doesn't close... (Like now. It's still opened.) Also, I tried locally to position the popup next to the name I entered, and while it works, which is great, it adds another gzipped kilobyte of JS, so I'll try to make it shorter or something, or maybe it's worth it I don't know...
3389
Plugins / [Plugin] Re: Notifications system (1.0)
« on March 21st, 2013, 10:09 AM »
I've made a few changes to the notification stuff, and uploaded them here, but not committed, so you can easily compare with your local install...
More importantly -- I've (temporarily..?) disabled auto-markread when clicking the notification, so that I can actually have time to style the popup at all... :whistle:

I think it would be best if we went for an approach more similar to Facebook's. Not that all they do is great, but in particular, their notification system is pretty good, and pretty much the only thing I use on their site...
Quote from Dragooon on March 19th, 2013, 10:16 AM
Go ahead, it's a part of Wedge anyway
Hopefully today I'll have included that in script.js, but first I'll commit a changed version of notifications.js so that it's easier for you guys to track all the changes I made, then I'll make another commit where I merge both files together.

File size of original notifications.js when gzipped: 744 bytes
Current file size: 578 bytes

Ideally, getting it under 500 bytes before the merging would be satisfying for me. This will require rethinking some of the code, though, and I'll put the priority on getting it to look nice.
Quote
There isn't one :P, there is only one setting for setting the number of days before which read notifications are pruned and that doesn't have an UI yet.
Alrighty.
We should also make sure that all unread notifs are sent by e-mail before they're pruned... Is it accounted for?

Also, a strange error in the log...
A *guest* accessed a ;area=getunread page. I don't know how the hell they found the link to that..?! I tried logging off, but nothing showed up. Hmm, maybe it's in the footer JS...? I'll have a look again.
3390
Features / Re: New revs
« on March 20th, 2013, 07:05 PM »
rev 2012 - D'you like this music?[1] / I'm breakin' a sweat, it's all right. I'm breakin' a sweat! Come on baby light my fire.[2] / Who are you Mr. Blue, Mr. Blue Mr. Blue? How do you do Mr. Blue, Mr. Blue Mr. Blue?[3]
(5 files, 1kb -- oh, come on..??!!)

! Notification hook was sending the wrong variable. (Class-Notification.php)

! afterNotify method expected Notification object, was sent an array of Notification objects. Changed the declaration to expect an array. (Class-Notifier.php)

* Renamed ;area= to ;sa= in notification action (these are really sub-actions, not areas...), and ;id= to ;in=, to avoid the infamous (but probably quite rare) security protection against these. (Notifications.php)

* Finished notification translation. FWIW. (Notifications.french.php)

* Another remaining location.href needed to be reduced. (install.php)
 1. That's pretty much the only lyric in that song, ah ah... It's from SQ Party #3's Live set by the Stealth Boys. A remix of Chrono Trigger and other Square soundtracks. If you like these, go check it out! http://www.youtube.com/watch?v=Qa7wYR3mUjg
 2. I didn't know of this guy till a few weeks ago... So, apparently everyone hates him and he's a boys band or something like that. Still, I love that lesser-known song which I heard by chance, "Breakn' a sweat", from Skrillex. Probably because it reminds me of SQ Party..?! From what I've read, the SQ Party albums have plenty of dubstep in them. So, for the first time in like 20 years, am I actually liking a *current musical trend*..? I'm finished!
 3. And that would be my favorite rap/funk album of 2012... Hopefully a nice new trend in France -- 70's-inspired funk albums with English vocals, anoother example being the excellent G'S WAY released in 2011. Also, Roberto Fonseco's "Yo" album has great funk songs.