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
3421
Off-topic / Re: Some advice when using jquery.ajax()
« on March 15th, 2013, 04:07 PM »
Yes, JSON is best. I've been through Hell and back again, and JSON is better than XML, however you view it. It's not better than a plain text response, but if you need multiple entries, obviously it's better :)
So, your server is returning double quotes around the string..? Very odd. I don't see anything that would cause that in your code. (You may want to use the more common 'echo' instead of 'print', though, but it's just a personal preference...)
Also, I'm surprised it would return an extra ',' before the closing }. I mean, this is something that would make it break in IE6 (more recent browsers don't have problems with it though.) And because JSON was created after IE6's release, I'd say they accounted for that. So... I don't really see how json_encode() could generate that.
You could also use a fallback json_encode, I removed that particular code from the sample I posted above to make it simpler for you, but what I do is test for function_exists('json_encode') (which has a 99.99% chance of being enabled in our setups), and if not found, it includes the PEAR version of json_encode, which works extremely well, albeit very slowly.
There's also this quick one: http://snipplr.com/view/13911.22389/
Which I fine-tuned into this:
Code: [Select]
function json_encode_fallback($v)
{
if ($v == null)
return 'null';

if (is_array($v))
{
// Non-associative array..?
if (!count($v) || array_keys($v) === range(0, count($v) - 1))
return '[' . join(',', array_map(__FUNCTION__, $v)) . ']';

foreach ($v as $k => $val)
$v[$k] = call_user_func(__FUNCTION__, $k) . ':' . call_user_func(__FUNCTION__, $val);

return '{' . join(',', $v) . '}';
}

return '"' . addslashes(preg_replace('/(\n|\r|\t)/i', '', strval($v))) . '"';
}

Please note, however, that I ended up using PEAR as fallback, instead of that, because it didn't generate exactly the same code, so it might have compatibility issues with jQuery's parser, too. You're never too careful...
3422
Features / Re: New revs
« on March 15th, 2013, 03:18 PM »
rev 1997 - Around the world, around the world (bis repetita) / La vie est belle, le destin s’en écarte, personne ne joue avec les mêmes cartes / Rain down, rain down... Come on rain down on me, from a great height.. / Estuans interius, ira vehementi, estuans interius, ira vehementi, Sephiroth! Sephiroth! / Whatever I've done, I've been staring down the barrel of a gun... / Endless, timeless, faceless terror! To the isle of deadly shores! Sightless, countless, ageless torture! To behold the sight of Medusa's eyes / Baby I'll be good. Pray for me, Praying for the light...[1]
(8 files, 23kb)

! Fixed strict errors in post editor (add_button is a per-instance method, not a static one), and in captcha (both animated and sound). Rewrote create_led and paint_led to use the same parameters in both versions, but I'll let Pete decide whether to do a 'proper' rewrite of these -- maybe simply different function names..? (Class-Editor.php, Subs-Sound.php, captcha/captcha-ledicons.php, captcha/captcha-ledicons_anim.php)

! SFTP code had nearly 2 kilobytes of unneeded whitespace, and was missing newlines, or things like that. I think I fixed most of them, at least the ones that hurt the most... I'm going to have nightmares about this one for months. (Class-SFTP.php)

* Harmonized whitespace around $context['menu_separator'] and page index. (Display.template.php, index.template.php, PersonalMessage.template.php)
 1. And again, an excellent musical year... With plenty of great instrumental albums (Philip Glass's Kundun, Jean Michel Jarre's Oxygen 7-13...) and tons of others I loved. I should say that I listened exclusively to Japanese music between 1989 and early 1996, so in 1997 I really spent a lot of time 'catching up' with recent music. Okay, I'll be nice and tell you what I mentioned, since I decided to be more thorough (don't worry, 16 commits to go and I'll be back to my one-liner commit comments!)

Daft Punk's 1st album -- not the best but still;
IAM's best album (and also the best rap album I've ever listened to) "L'école du micro d'argent";
Paranoid Android, from Radiohead's best album and arguably one of the best and most influential pop albums ever released;
Final Fantasy VII's final boss song, need I say more??;
My favorite album from Depeche Mode;
Symphony X's The Divine Wings of Tragedy: one of my top 3 metal albums, the other 2 being released soon after... Maybe I'll mention them :P;
Craig Armstrong's first solo album was also fantastic, heck, even Yôko Kanno totally ripped him off over the years...
I wanted to quote Berserk's opening, but I'm not a big fan of it, I really prefer the instrumentals, which are gorgeous. Can't quote instrumentals, eh?
3423
Off-topic / Re: Some advice when using jquery.ajax()
« on March 15th, 2013, 12:22 PM »
Don't have time to read it all... Hopefully I didn't misunderstand the question ;)

- Make sure you're not using jQuery 2.0 beta 1 (beta 2 is out, with its own problems too), as it's not correctly parsing data on the end (although it's mostly a problem with XML, I wouldn't trust that version with anything),
- Data received from $.ajax normally doesn't require parsing,
- Also ensure that you're sending the proper headers.

This is part of my code for Wedge... I've simplified it for your needs.

Code: [Select]
<?php
function returnAjax($json)
{
clean_output();
header('Content-Type: application/json; charset=UTF-8');
echo str_replace('\\/''/'json_encode($json));
obExit(false);
}

Don't remember if clean_output() is part of Wedge or SMF, but it's not the point anyway ;)
3424
Archived fixes / Re: Error in wedit::add_button()
« on March 15th, 2013, 10:57 AM »
Indeed, you can simply remove the static keyword to fix this.
Thanks for the report. Good thing I've decided to let strict errors be reported, I really prefer having a 'clean' system.
I've double-checked all functions, and only add_button was incorrectly set as static while still referring to $this.
3425
Features / Re: Icon alignment
« on March 15th, 2013, 12:33 AM »
Just this...: is it really worth defaulting vertical-align to anything at all..? Why not just set inline-block and be done with?

Oh, I think I already removed it in an earlier commit, so it means we'd have to remove it from sort_down as well...
I'm getting a bit lot in my refactoring process... ;)
3426
Off-topic / Re: One souce for Mini icons
« on March 15th, 2013, 12:27 AM »
One of my problems with icon packs, is that usually they'll all skip some of the icons we have and need, and instead have tons of icons for filetypes and desk-oriented thematics, which gets boring quickly...
3427
Features / Re: New revs
« on March 15th, 2013, 12:17 AM »
rev 1996 - Dakishimete itai, subete wo wasurete, kiken na kurai Ray, kimi wo...[1]
(1 file, 1kb -- had more to commit, but wasn't confident enough in their stability.)

* Slightly optimized Pretty URLs handling, using rtrim() everywhere it can be used, instead of just in a couple of lines. (Subs-Template.php)

! PM viewing mode was broken... And apparently had been for a while... Because the quick URLs ended with a '=', and PURLs would 'optimize' and remove them. So, I rewrote the lines to prevent removing these if they're at the end of a URL. I couldn't think of a single case where this would be a problem... Then again, nobody ever noticed this was broken in the first place, right..? (Subs-Template.php)
 1. Okay, apparently I got it :P It's Ray, by Luna Sea. Another fantastic rock song. I'd love to quote more instrumental albums, there are so many, but that's gonna be hard... Stay tuned for rev 1997, which will probably have my last 'cult' J-Rock album. Oh, and I skipped X Japan's 1993 Art of Life. Shouldn't have. Okay, time for bed. Or the psychiatric ward.
3428
Archived fixes / Re: flexbox and opera 12.14
« on March 14th, 2013, 03:38 PM »
That's interesting, I was sure I'd tested in all major browsers...
Can reproduce. Will look into it right now.

:edit: Hmm... Browser bug? The error disappeared once I got page to the page...
Posted: March 14th, 2013, 03:12 PM

Okay, definitely a browser bug... In the post you mention, I have no problem. But Pete's first post in that topic gets the signature bug.
I disabled all CSS except for the flex, and it was still broken... Then I removed the first quote from his post (through Dragonfly), and it got fixed. Then I re-added it, and it was still working...

When something is so inconsistently broken, it's a flawed implementation.
Given how much time I spent on making it work in Firefox and Chrome, and given how Opera is doomed to be extinct in a couple of years (to my great disappointment), I don't see a reason to spend more time working on 'fixing' their own bugs.

So... I could remove Opera from the list of browsers that support flexbox (the can_flex variable), or add Opera-specific hacks to prevent it from using flexbox (i.e. @if can_flex && !opera), or just let it go.
What do you think, guys..?

Unless someone can find a reason for the bug... :-/
3429
Features / Re: New revs
« on March 14th, 2013, 12:29 PM »
rev 1995 - Mesecina, mesecina, joj, joj! Joj, joj! Sunce sija ponoc bije, joj, joj! Joj, joj! Sa nebesa, zaproklija... Niko ne zna! Niko ne zna![1]
(8 files, 4kb)

! Yes, I know redirectexit() doesn't require <URL>, but if it's *forced* upon it, it would actually fail. So, fixed the function to accept <URL>, and dropped the test for 'about:', because I couldn't find any Wedge file that makes use of that, and can't think of any reason for a plugin to redirect to an internal browser page either. (Subs.php)

- Removed ;xml from a few remaining URLs. This is no longer needed, as all of our tests are done on the AJAX constant now. Or other variables (usernamecheck for instance). (post.js, register.js, suggest.js, topic.js)

* Saved over 50 bytes in topic.js by not giving a damn about oldIE. So, it no longer gets a hover effect in IconList..? Who cares? Have you ever seen a moderator/admin ever using IE6? Do you *want* them to be your own admin? Anyway... The location.hash trick is probably a leftover from dinosaurIE because it works in IE7 for me. Same for the width-forcing hack... IE7 doesn't need it. IE6, I probably won't bother to test anything anymore. (topic.js)

* Moved .iconbox and #iconlist selectors to the member file, as these elements are never available to guests. (sections.css, index.member.css)

* Minor cleanup. (Subs-Media.php)

:edit: Fixed a copy'n'paste disaster.
 1. It's a beautiful song from one of my favorite movies. I had, for a long time, a subdomain at cyna.net that was called 'mese'... For some reason ;)
3430
Well, with my S3 + Chrome Mobile + Foxhound custom ROM, I didn't have any problems at that step...
3431
Works but doesnt auto-post the file.
URL redirects to ://wedge.org/do/media/?%3CURL%3E?sa=item;in=139;noh=message
So this is a bug in my automated scripturl conversions but shouldn't have affected your older alpha...?
3432
Mass Media upload = uses Flash. My plans are to use pure HTML+JS in the near future; haven't worked on it yet.
Regular Media upload = uses HTML, should work..?
3433
Features / Re: New revs
« on March 13th, 2013, 11:23 PM »
rev 1994 - Yoake yo ima, boku wo sukue, ai ga hoshii, ai-shite hoshii...[1]
(12 files, 5kb)

* Wess mixins will now accept: mixin names with a '.' in them (seriously, if you prefer to use a pseudo-class name, I'm not going to blame you), and mixin bodies now accept empty lines, allowing for @if tests and comments to be added in them. This was long overdue. (Class-CSS.php)

* The reason why .inline-block was an extend-type class, is that I wasn't able to get mixins to close and reopen back in the day. Well, to make things short: I found a clever workaround for that, and here's how I'm turning .inline-block into a mixin. Gzipping is much more efficient when meeting plenty of 'display: inline-block' than when seeing two occurrences of many different classes/IDs in the whole file. Obviously. This saves over 100 bytes of code. And is just clean. (common.css, index.css, index.member.css, editor.css, mana.css, Wuthering/extra.css)

! Topic titles weren't aligned correctly in IE7. (extra.ie7.css, sections.css)

! I was just going to fix a missing semi-colon in this JS code (just for consistency), but ended up rewriting it, hmm... (ManageNews.template.php)

! Fixed search popup position. (index.css)

! Fixed per-post user-box list circles. (index.css)

* Renamed #ajax_in_progress to #ajax. Why? Well, #ajax was unused in our codebase, and it saves 10 bytes in the JS file, and a few bytes as well in CSS. Isn't that enough? (script.js, index.css, extra.ios.css -- hmm... Is this really necessary in iOS? I think iOS 5 fixed 'position: fixed', can someone double-check for me?)
 1. http://namida.cyna.fr/english/ls-mother.html -- not their best album, but I can't count on rev 1996 being free for me :P
3434
Features / Re: New revs
« on March 13th, 2013, 11:40 AM »
rev 1993 - My dearest friend, if you don't mind... I'd like to join you by your side, where we can gaze into the stars, and sit together, now and forever... For it is plain as anyone can see, we're simply meant to be...[1]
(3 files, 2kb)

* Now that all strict errors seem to have been fixed, E_STRICT will also be recorded in database errors -- mostly to encourage plugin authors to write clean PHP. (Errors.php)

! Fixed missing global. (Class-System.php)

! Fixed wrong constant name. (Aeva-Gallery.php)
 1. Another of my long-lasting forum sigs! I went to see a subtitled copy of tNbC at a local art theater back then, and I was the only one in the room! After an hour, the projectionist actually came and joined me!
3435
Features / Re: Icon alignment
« on March 12th, 2013, 07:06 PM »
Quote from Arantor on March 12th, 2013, 04:07 PM
I'm not mixing anything up.
Well, I'm not the one who mentioned going back to a non-embedded solution for sort_down/sort_up... :^^;: I was always going to keep them embedded.
Quote
Inlining, whether or not you sprite, means you don't make HTTP roundtrips.
I wrote the feature, I know that... :niark:
Quote
That's a bandwidth saving of a surprising magnitude - anything between 100 and 1500 bytes per request, or more in some particularly vile cases.
Large cookies FTW.
Quote
There are two separate issues here and I think you missed what my commit actually did to a point ;)
You wanted to embed sort_down/sort_up to save bandwidth. I understand that. These files aren't used on every page, but it's all right. I don't see the other issue.
Quote
I'm well aware that I didn't need to sprite them. However, the byte saving seemed worth it to me ;)
Did you try without spriting..?

I should say -- there are a few icons (can't remember which) that I wanted to sprite, then I tested the results and was surprised to see that the sprite file was making the CSS file bigger after gzipping, and there was no way around it. So I'd personally try to avoid spriting anything without some serious tests.
Again, sort.gif is a perfect candidate for spriting because both files are a variation on each other.
Quote
And it would make for easier CSS not to have to make sprites, but it would tend to make larger CSS if you have a bunch of images with common palette.
Not always... Again: 5 bytes, is it worth the hassle? In this case, probably, but in other situations, we'll always need to compare file sizes.
Quote
I don't know, didn't sleep well, feel like crap and I need to hike out in a bit to get more bread and stuff - in the several inches of snow we had yesterday.
Oh, so that annoying snow came from your place eh? Here in Paris, it's been snowing since last night, no end in sight. Between last Saturday (right when I came back from vacation) and today, the temperature dropped by 18°C. I think the C stands for "Come on?!"

More seriously, it's still something I want to explore, although I have to admit it won't be interesting to a lot of people...