To view parent comment, click here.
To read all comments associated with this story, please click here.
I explained what the additional code does. For example, if you hit Nokia Services and opera mini 2.0, you set an additional variable. Then, in your code, you say something like this:
if nokia services version 3.01 and opera mini 2.0, width 95% instead of 100%.
Stuff like that. You simply create special variables to identify some bugs of some versions/browsers and then you code the cHTML in a different way. I have some such code for nokia communicator, links etc.
If you really want to know about all these bugs these browsers have, you will have to experiment yourselves, get devices, emulators etc. I had to do all that.
Edited 2008-04-25 03:09 UTC
I understand that there's a historical reason to separate the ifs rather than running the more efficient 'if/else', but since the code no longer needs to function in that manner, why not convert all but the first clause into an 'else' statement? Really seems baffling that you've left it as-is. Or have I misunderstood something?
Feel free to put the keywords on arrays. I just put together on the zip file a cleaned up version of what we use, I didn't refactor it. Besides, you will need to change the istr() too, so some work will have to be done if some people want to use it anyway.
I don't do osnews much anymore, neither I code mobile sites anymore, so I didn't put lots of love on this version.
That was my first reaction looking at the code - Even WITH overloading, you overload the ones you NEED TO and not overload the others.
I can 'kind of' see why it's not done, but in that case you just reverse the orders. Right now EVERY run of this code would execute all 267 if statements - when most of the time there should be a way to run a LOT less of those.
For example, how many of those also return 'internet explorer' in their user agent strings? Separate those off so that you aren't testing those unless you need to. One extra IF saving you several dozen unneccessary ones... How many of those return width and height with their string? If that's overloading, test those first and short-circuit testing the rest...
And if you need to add special conditions, wouldn't a case statement AFTER the if's be just as good?
I also notice in the comments that it used to use preg_match - Wouldn't that cut down on false positives and remove the need for a lot of the extra checks?
Silly question, do you have a list formed of the user agent strings on which you made this code? I'm thinking there has to be a faster/easier/cleaner way of handling this, but I can't entirely make assumptions because I'm not certain what conditions would overload others and what takes precedence.






Member since:
2005-06-28
No, there was a reason why I wanted each keyword on its own line: so I can identify keywords and add a set of special variables if a specific keyword is set, and then later, modify my HTML code based on these variables. Because you see, there were some phones or some versions of browsers that required special cHTML writing because of bugs, so I had to exclude them like that. You don't see that in the version of the code I provided, but the original we used on osnews has those exceptions in. It was much more readable for me to do it like this instead of putting everything into arrays.
Edited 2008-04-25 02:36 UTC