iUI a complete bust?

35 views
Skip to first unread message

Roger

unread,
Jan 7, 2009, 3:41:17 PM1/7/09
to iPhoneWebDev
Is it ever. And of course, its proponents will all chime in that I
hate frameworks and like wasting money. You can listen to morons or
you can listen to me.

And be sure to read to the end as it was a journey. The biggest
bombshell is about three quarters of the way through.

Executive summary: You'd have to be completely mental to consider
using this on a Website.

/*
Copyright (c) 2007, iUI Project Members

That should give you pause.

See LICENSE.txt for licensing terms
*/


(function() {

Assuming this is an iPhone/iPod script only (which should also give
you pause), otherwise it would certainly leak memory in IE.

var slideSpeed = 20;
var slideInterval = 0;

var currentPage = null;
var currentDialog = null;

var currentWidth = 0;
var currentHash = location.hash;

Implied global. Use window.location.hash.

var hashPrefix = "#_";
var pageHistory = [];
var newPageCount = 0;
var checkTimer;

//
*************************************************************************************************

window.iui =

This is a mistake. The window object is a host object, so it should
not be augmented. This also assumes that the global window property
references the Global Object. The proper way to do this is to store a
reference to the Global Object prior to entering the one-off function.

{
showPage: function(page, backwards)
{
if (page)
{

Sloppy. Why would the code call this with a "falsy" page argument?

if (currentDialog)
{
currentDialog.removeAttribute("selected");

So - currentDialog - is a reference to an element. Apparently
"selected" is an expando, which is a bad idea.

currentDialog = null;
}

if (hasClass(page, "dialog"))

Will be interesting to see the latest re-invention of this particular
wheel.

showDialog(page);
else
{
var fromPage = currentPage;
currentPage = page;

if (fromPage)
setTimeout(slidePages, 0, fromPage, page,
backwards);

Implied global. Use window.setTimeout and don't pass arguments like
this. And assuming this is some sort of timed effect, why should it
be called from a timeout?

else
updatePage(page, fromPage);

The missing curly brackets are a mistake (especially for an open
source project with multiple contributors.)

}
}
},

showPageById: function(pageId)
{
var page = $(pageId);

The "$" function is silly (and always has been.)

if (page)
{
var index = pageHistory.indexOf(pageId);

Compatibility issue.

var backwards = index != -1;
if (backwards)
pageHistory.splice(index, pageHistory.length);

iui.showPage(page, backwards);
}
},

showPageByHref: function(href, args, method, replace, cb)
{
var req = new XMLHttpRequest();
req.onerror = function()
{
if (cb)
cb(false);
};

req.onreadystatechange = function()
{
if (req.readyState == 4)
{
if (replace)
replaceElementWithSource(replace,
req.responseText);
else
{
var frag = document.createElement("div");
frag.innerHTML = req.responseText;
iui.insertPages(frag.childNodes);
}
if (cb)
setTimeout(cb, 1000, true);

A one-second delay on the callback?

}
};

if (args)
{
req.open(method || "GET", href, true);
req.setRequestHeader("Content-Type", "application/x-www-
form-urlencoded");
req.setRequestHeader("Content-Length", args.length);
req.send(args.join("&"));
}
else
{
req.open(method || "GET", href, true);
req.send(null);

Repetitious.

}
},

insertPages: function(nodes)
{
var targetPage;
for (var i = 0; i < nodes.length; ++i)

Inefficient loop condition.

{
var child = nodes[i];
if (child.nodeType == 1)
{
if (!child.id)
child.id = "__" + (++newPageCount) + "__";

var clone = $(child.id);

Think about that one for a moment ($ is just a wrapper for gEBI.)

if (clone)
clone.parentNode.replaceChild(child, clone);

So this replaces the child with itself (not a clone of itself.)

else
document.body.appendChild(child);

if (child.getAttribute("selected") == "true" || !
targetPage)

The use of get/set/removeAttribute for these flags is ridiculous.
Clearly they all have ID's, so why not store this information in an
object (as opposed to invalidating the markup.)

targetPage = child;

--i;

This is an odd loop indeed.

}
}

if (targetPage)
iui.showPage(targetPage);
},

getSelectedPage: function()
{
for (var child = document.body.firstChild; child; child =
child.nextSibling)
{
if (child.nodeType == 1 && child.getAttribute("selected")
== "true")
return child;
}
}

This is what I'm talking about. There should be a flag of some sort
for this. Looping through every child of the body is outrageously
inefficient.

Also, as this loop is only concerned with element nodes, it would be
far more efficient as:

var childElements = document.body.getElementsByTagName('*');
var index = childElements.length;

while (index--) {
...
}

};

//
*************************************************************************************************

addEventListener("load", function(event)

Implied global. That's the first time I've seen that one. And it
would be more standard to attach this listener to the document body.

{
var page = iui.getSelectedPage();
if (page)
iui.showPage(page);

Then why does showPage check for a truthy page argument?

setTimeout(preloadImages, 0);
setTimeout(checkOrientAndLocation, 0);
checkTimer = setInterval(checkOrientAndLocation, 300);

Implied global hat trick.

}, false);

addEventListener("click", function(event)
{

Is this really meant to be a click listener on the (implied) window
object? That's clearly a mistake (leave the window object alone.)

var link = findParent(event.target, "a");

It really is. Delegation from a window listener. Don't try *that* at
home.

if (link)
{
function unselect() { link.removeAttribute("selected"); }

Don't nest function declarations (and don't create them every time the
user clicks!)

if (link.href && link.hash && link.hash != "#")
{
link.setAttribute("selected", "true");

As mentioned, this is a ludicrous design.

iui.showPage($(link.hash.substr(1)));
setTimeout(unselect, 500);
}
else if (link == $("backButton"))
history.back();

Why duplicate the back button? There is no way to enable or disable
the faux back button, so it makes little sense from a usability
standpoint.

else if (link.getAttribute("type") == "submit")
submitForm(findParent(link, "form"));
else if (link.getAttribute("type") == "cancel")

This thing really plays fast and loop with the DOM. Outside of this
warped universe, what sort of links have such type attributes?

cancelDialog(findParent(link, "form"));

And what sort of dialog interface would use links for buttons?

else if (link.target == "_replace")
{
link.setAttribute("selected", "progress");
iui.showPageByHref(link.href, null, null, link, unselect);
}
else if (!link.target)
{
link.setAttribute("selected", "progress");
iui.showPageByHref(link.href, null, null, null, unselect);
}
else
return;

event.preventDefault();
}
}, true);

addEventListener("click", function(event)
{

Again?!

var div = findParent(event.target, "div");
if (div && hasClass(div, "toggle"))
{
div.setAttribute("toggled", div.getAttribute("toggled") !=
"true");

This seems like a complete waste of time.

event.preventDefault();
}
}, true);

function checkOrientAndLocation()
{
if (window.innerWidth != currentWidth)
{
currentWidth = window.innerWidth;
var orient = currentWidth == 320 ? "profile" : "landscape";

There's a bad assumption.

document.body.setAttribute("orient", orient);

No way to query this property?

setTimeout(scrollTo, 100, 0, 1);

I hate this (and see it everywhere in scripts for this device.)
Passing a host method to setTimeout is insanity.

}

if (location.hash != currentHash)
{
var pageId = location.hash.substr(hashPrefix.length)
iui.showPageById(pageId);
}
}

function showDialog(page)
{
currentDialog = page;
page.setAttribute("selected", "true");

Why? They stored a reference to the "current dialog."

if (hasClass(page, "dialog") && !page.target)
showForm(page);
}

function showForm(form)
{
form.onsubmit = function(event)
{
event.preventDefault();
submitForm(form);
};

Why re-create this function every call? And why is this done with
DOM0?

form.onclick = function(event)
{
if (event.target == form && hasClass(form, "dialog"))
cancelDialog(form);
};

Same and same. And why should clicking the form background hide it?

}

function cancelDialog(form)
{
form.removeAttribute("selected");
}

OMFG. Just realized why they are twiddling with non-standard
attributes. The style sheets tell the tale (they have no clue what
they are doing!) All of these calls to set/removeAttribute should
instead be adding or removing classes.

function updatePage(page, fromPage)
{
if (!page.id)
page.id = "__" + (++newPageCount) + "__";

Seen that before. This is a tiny script, yet it has lots of
duplication. Is anybody minding this store?

location.href = currentHash = hashPrefix + page.id;
pageHistory.push(page.id);

var pageTitle = $("pageTitle");
if (page.title)
pageTitle.innerHTML = page.title;

if (page.localName.toLowerCase() == "form" && !page.target)

Use nodeName instead.

showForm(page);

var backButton = $("backButton");
if (backButton)
{
var prevPage = $(pageHistory[pageHistory.length-2]);
if (prevPage && !page.getAttribute("hideBackButton"))
{
backButton.style.display = "inline";

That should be part of a class (what if you don't want "inline?")
Alternatively, set the display style to "".

backButton.innerHTML = prevPage.title ? prevPage.title :
"Back";
}
else
backButton.style.display = "none";
}
}

function slidePages(fromPage, toPage, backwards)
{
var axis = (backwards ? fromPage : toPage).getAttribute("axis");
if (axis == "y")
(backwards ? fromPage : toPage).style.top = "100%";
else
toPage.style.left = "100%";

toPage.setAttribute("selected", "true");
scrollTo(0, 1);
clearInterval(checkTimer);

var percent = 100;
slide();
var timer = setInterval(slide, slideInterval);

function slide()
{
percent -= slideSpeed;
if (percent <= 0)
{
percent = 0;
if (!hasClass(toPage, "dialog"))
fromPage.removeAttribute("selected");
clearInterval(timer);
checkTimer = setInterval(checkOrientAndLocation, 300);
setTimeout(updatePage, 0, toPage, fromPage);
}

if (axis == "y")
{
backwards
? fromPage.style.top = (100-percent) + "%"
: toPage.style.top = percent + "%";
}
else
{
fromPage.style.left = (backwards ? (100-percent) :
(percent-100)) + "%";
toPage.style.left = (backwards ? -percent : percent) +
"%";
}
}

That is going to be one hellaciously slow animation. Why aren't
people using those Web 2.0 wonder libraries for this stuff? Oh yeah,
they are too big, too slow and aren't cross-browser at all. So here
we are re-inventing animations.

}

function preloadImages()
{
var preloader = document.createElement("div");
preloader.id = "preloader";
document.body.appendChild(preloader);

How very interesting. Leave the cache alone.

}

function submitForm(form)
{
iui.showPageByHref(form.action || "POST", encodeForm(form),
form.method);
}

function encodeForm(form)
{
function encode(inputs)
{
for (var i = 0; i < inputs.length; ++i)
{
if (inputs[i].name)
args.push(inputs[i].name + "=" + escape(inputs
[i].value));
}
}

Not even close. Here we are re-inventing form serialization.
Prototype, jQuery, etc. didn't really work out as advertised, did
they?

var args = [];
encode(form.getElementsByTagName("input"));

Don't use gEBTN to fetch form elements (use the elements collection.)

encode(form.getElementsByTagName("select"));

Same.

return args;
}

function findParent(node, localName)
{
while (node && (node.nodeType != 1 || node.localName.toLowerCase
() != localName))

Use nodeName. Test is ridiculous.

node = node.parentNode;
return node;
}

function hasClass(self, name)
{
var re = new RegExp("(^|\\s)"+name+"($|\\s)");

Don't create regular expressions endlessly.

return re.exec(self.getAttribute("class")) != null;

Use self.className and the test method.

}

function replaceElementWithSource(replace, source)
{
var page = replace.parentNode;
var parent = replace;
while (page.parentNode != document.body)
{
page = page.parentNode;
parent = parent.parentNode;
}

God only knows what this is meant to be. I'm sure that further
investigation would be a waste of time.

var frag = document.createElement(parent.localName);
frag.innerHTML = source;

page.removeChild(parent);

while (frag.firstChild)
page.appendChild(frag.firstChild);
}

function $(id) { return document.getElementById(id); }

Have we learned nothing from Prototype's mistakes? It's been what?
Four years?

function ddd() { console.log.apply(console, arguments); }

That is almost as bad a name as "$".

})();

Not a single comment. Currently patched by whomever. Whole idea is
ill-advised (Ajax navigation and emulating the default native
interface of the iPhone.) Design is ridiculous (see the CSS for more
info.) Implementation is botched (see above.) What is the point of
leaning on this thing? Have developers become so conditioned to
leaning on other people's do-everything-for-me scripts that they will
jump on any old thing? And old is the operative word. This was
slapped together two years ago (for whatever reason) and is still
completely lacking today.

Leo Lin

unread,
Jan 7, 2009, 4:14:31 PM1/7/09
to iphone...@googlegroups.com
Roger,
 
I think your opions could be much better presented if you stop screaming at us first.
 
If you think the work could be done better, maybe you can contribute to it.
 
Best,
Leo

Roger

unread,
Jan 7, 2009, 4:22:02 PM1/7/09
to iPhoneWebDev


On Jan 7, 4:14 pm, "Leo Lin" <leoli...@gmail.com> wrote:
> Roger,
>
> I think your opions could be much better presented if you stop screaming at
> us first.

Who is screaming and who is "us?"

>
> If you think the work could be done better, maybe you can contribute to it.

So you are an iUI "contributor?" Is the "us" meant to mean iUI. Yes,
good luck with that. Perhaps if there is truly a demand for Ajaxified
navigation, faux native interfaces, etc., I will write a competent
alternative and sink this thing for good. Looks like a couple of
hours of scripting to me. Again, why would anyone feel compelled to
rely on this thing? There's not much there and what is there is
poorly done. It apparently hasn't budged since 2007 either.

Thanks for your concern.

[snip]

Leo Lin

unread,
Jan 7, 2009, 4:38:22 PM1/7/09
to iphone...@googlegroups.com
From my point of view, you are screaming.
 
"Us" are people subscribed to iPhoneWebDev mailing list, and I am not yet a contributor. Perhaps, I shoud not use the word "us".
 
If you think you are presenting your idea in the right way, then go ahread. It is a free world anyway.
 
I am looking forward to your own work.
 
Best,
Leo 

Roger

unread,
Jan 7, 2009, 5:09:00 PM1/7/09
to iPhoneWebDev
On Jan 7, 4:38 pm, "Leo Lin" <leoli...@gmail.com> wrote:
> From my point of view, you are screaming.

I look like I'm screaming, do I? From where I sit, you look like you
are whining.

>
> "Us" are people subscribed to iPhoneWebDev mailing list, and I am not yet a
> contributor. Perhaps, I shoud not use the word "us".

Um, that clears things up. (?)

>
> If you think you are presenting your idea in the right way, then go ahread.
> It is a free world anyway.

Glad I have your approval.

>
> I am looking forward to your own work.
>

What work would that be?

Jorge Chamorro

unread,
Jan 7, 2009, 5:18:07 PM1/7/09
to iphone...@googlegroups.com
On 07/01/2009, at 21:41, Roger wrote:

>
> You can listen to morons or you can listen to me.
>


LOL, Joe Hewitt a moron, you mean, sure ?
Who exactly are you to say so ?

--
Jorge.

Roger

unread,
Jan 7, 2009, 5:23:33 PM1/7/09
to iPhoneWebDev


On Jan 7, 5:18 pm, Jorge Chamorro <jorgechamo...@mac.com> wrote:
> On 07/01/2009, at 21:41, Roger wrote:
>
>
>
> > You can listen to morons or you can listen to me.
>
> LOL, Joe Hewitt a moron, you mean, sure ?

Haven't heard a thing out of him. As for his abandoned project, it
indicates a severe lack of proficiency in Web development and is
obviously a rather poor choice for a mobile Web app.

> Who exactly are you to say so ?

Who are you to ask me who I am? And where is your rebuttal? You just
snipped the whole thing, so what was the point of posting this?

Jay Zeschin

unread,
Jan 7, 2009, 4:12:00 PM1/7/09
to iphone...@googlegroups.com
Instead of continually pelting the list with diatribes about how much IUI sucks, why don't you fork the project and fix it up to your standards?  It's mirrored up on github at http://github.com/pjhyett/iui/tree/master - takes 20 seconds to sign up for an account and another 10 to fork the project.

That way everybody wins.

anmldr

unread,
Jan 7, 2009, 9:30:36 PM1/7/09
to iPhoneWebDev
Roger/David--

If you have not yet been booted off, please contact me by email.

Thank you,
Linda

Mr Junk

unread,
Jan 7, 2009, 10:20:20 PM1/7/09
to iphone...@googlegroups.com
Moderator, can you shut this obnoxious jerk off, or is this list his
platform to abuse anyone and everyone?

Chrilith

unread,
Jan 8, 2009, 4:40:46 AM1/8/09
to iPhoneWebDev
Roger, I usuggest you to learn a bit more how javascript works.

> This is a mistake. The window object is a host object, so it should
> not be augmented. This also assumes that the global window property
> references the Global Object. The proper way to do this is to store a
> reference to the Global Object prior to entering the one-off function.

Try this:

var a = "test";
alert(window.a);

Oh, my god, I've expanded the window object!!!! As you said earlier
yes, context is important in javascript (this is why there are apply
and call methods which let us change the context), and the default
context here is "window" - so what's wrong with expando, could you
argument on this?

> if (hasClass(page, "dialog"))
>
> Will be interesting to see the latest re-invention of this particular
> wheel.

Not sure you've taken a look at "mylib" by David Mark.... what's the
purpose of the "createElement" function, oh reinvent the wheel....
ok... Well, ok, I must admit that I haven't take a deeper look at
"mylib", but it seems you haven't too with iUI (even if I don't really
like iUI and widely agree with you very last comment) - Anyway, what
javascript method let you know if the element have a particular class?

> That is going to be one hellaciously slow animation. Why aren't
> people using those Web 2.0 wonder libraries for this stuff? Oh yeah,
> they are too big, too slow and aren't cross-browser at all. So here
> we are re-inventing animations.

> Not even close. Here we are re-inventing form serialization.
> Prototype, jQuery, etc. didn't really work out as advertised, did
> they?

http://www.cinsoft.net/mylib-doc.asp?view=object
Yes, "mylib" never reinvents the wheel (again)...

This time you did some interesting remarks, you're going the right way
and I must admit that "mylib" seems interesting in some points and
have a good documentation.

Please, stop denigrate and be more constructive.

Rick Schramm

unread,
Jan 8, 2009, 10:49:36 AM1/8/09
to iPhoneWebDev


On Jan 8, 4:40 am, Chrilith <chril...@gmail.com> wrote:
> Roger, I usuggest you to learn a bit more how javascript works.
>

Oh brother.

> > This is a mistake.  The window object is a host object, so it should
> > not be augmented.  This also assumes that the global window property
> > references the Global Object.  The proper way to do this is to store a
> > reference to the Global Object prior to entering the one-off function.
>
> Try this:
>
> var a = "test";
> alert(window.a);

And what is that supposed to prove?

>
> Oh, my god, I've expanded the window object!!!! As you said earlier

You don't seem to get it. In the vast majority of browsers, the
window object is a reference to the Global Object. Assuming that is
true in all browsers is not good practice.

> yes, context is important in javascript (this is why there are apply
> and call methods which let us change the context), and the default

I think he meant the context of the application. Of course, it is
hard to tell as he is now "banned." That's the problem with moderated
discussions.

> context here is "window" - so what's wrong with expando, could you
> argument on this?

Actually, the context is the Global Object, which by coincidence is
the same as the window object.

>
> >             if (hasClass(page, "dialog"))
>
> > Will be interesting to see the latest re-invention of this particular
> > wheel.
>
> Not sure you've taken a look at "mylib" by David Mark.... what's the

Sure have!

> purpose of the "createElement" function, oh reinvent the wheel....

Don't follow that, but the createElement wrapper is there so apps can
support HTML or XHTML DOM's. Never seen it anywhere else either.

> ok... Well, ok, I must admit that I haven't take a deeper look at
> "mylib", but it seems you haven't too with iUI (even if I don't really
> like iUI and widely agree with you very last comment) - Anyway, what
> javascript method let you know if the element have a particular class?

The point appears to be that part of this library is a rewrite of the
previous magic bullet libraries like jQuery, Prototype, etc.
Ironically, if those libraries really were magic, we wouldn't need yet
another do-everything library for these devices. And the rewrites are
severely lacking, indicating a lack of experience by the author.

>
> > That is going to be one hellaciously slow animation.  Why aren't
> > people using those Web 2.0 wonder libraries for this stuff?  Oh yeah,
> > they are too big, too slow and aren't cross-browser at all.  So here
> > we are re-inventing animations.
> > Not even close.  Here we are re-inventing form serialization.
> > Prototype, jQuery, etc. didn't really work out as advertised, did
> > they?
>
> http://www.cinsoft.net/mylib-doc.asp?view=object
> Yes, "mylib" never reinvents the wheel (again)...

Not sure what that means.

>
> This time you did some interesting remarks, you're going the right way
> and I must admit that "mylib" seems interesting in some points and
> have a good documentation.
>
> Please, stop denigrate and be more constructive.

This from the person who stirred up trouble with the moderators and
got this poster "banned?" Seems anything that criticizes iUI in here
is "denigration." The suggested alternative was to rewrite it instead
of reviewing it. This really is the Twilight Zone.

richard....@gmail.com

unread,
Jan 7, 2009, 10:26:50 PM1/7/09
to iPhoneWebDev


On Jan 7, 10:20 pm, Mr Junk <j...@stuffthis.net> wrote:
> Moderator, can you shut this obnoxious jerk off, or is this list his  
> platform to abuse anyone and everyone?

You do understand that this is a thread in a discussion group right?
The thread was started as a technical review of a much-discussed
framework. I don't see any abuse from the OP, but several OT comments
from various parties (including you.)

Rick Schramm

unread,
Jan 8, 2009, 1:39:51 PM1/8/09
to iPhoneWebDev


On Jan 7, 4:12 pm, "Jay Zeschin" <j.zesc...@gmail.com> wrote:
> Instead of continually pelting the list with diatribes about how much IUI

Other than this thread, what "diatribes" are you referring to?

> sucks, why don't you fork the project and fix it up to your standards?  It's

So, rather than reviewing the merits (or lack thereof) of this blob of
script and its accompanying style sheet, not to mention the futility
of the design, he should have forked these files and rewrote them.
Doesn't make sense to rewrite something that is a bad idea to begin
with. And don't you think that virtually anyone could rewrite those
files, especially given the basic information provided by the OP? If
it isn't a complete drop-in rewrite then you are not interested.

> mirrored up on github athttp://github.com/pjhyett/iui/tree/master- takes
> 20 seconds to sign up for an account and another 10 to fork the project.
> That way everybody wins.

Wins what? If you are unfortunate enough to have used these files on
projects, then you will have to deal with that. What would be in it
for someone who thinks the very idea is folly?

[snip]

Rick Schramm

unread,
Jan 8, 2009, 1:48:26 PM1/8/09
to iPhoneWebDev


On Jan 7, 3:41 pm, Roger <roger.gilre...@gmail.com> wrote:

[...]

> var childElements = document.body.getElementsByTagName('*');

Nobody is paying attention to anything but the critical nature of this
review. This is an obvious mistake, which reinforces the idea that you
should not accept any code based on the name of the author, domain,
company or whatever.The rest looks pretty reasonable to me. The author
was very smart to move on from what looks like an initial effort.

Any real rebuttals to this review at all? This is a discussion forum
related to the deployment of CSS, Javascript and HTML on mobile
devices, specifically the iPhone, right?

Justin Kozuch

unread,
Jan 9, 2009, 4:02:13 PM1/9/09
to iPhoneWebDev
I just joined up, and I wanted to pass on this link about the iUI js
framework.

It seems that there is a patched version of the iui.js file out there,
and it was recently rewritten (September 2008).

Details at: http://www.steveworkman.com/projects/2008/patching-iui/

I'm not a JS programmer with alot of experience, but this may solve
problems/code improvements some of you have been asking about.

Hope this helps.

- Justin

RobG

unread,
Jan 10, 2009, 8:50:53 AM1/10/09
to iPhoneWebDev


On Jan 8, 1:20 pm, Mr Junk <j...@stuffthis.net> wrote:
> Moderator, can you shut this obnoxious jerk off

Why? If you have trouble with what was posted, respond with reasoned
argument. If Roger has been banned because of this post, I request
that his account is restored.


>, or is this list his  
> platform to abuse anyone and everyone?

What? iUI was criticised, not anyone who replied. As I remember it,
Joe created iUI in an hour or so as a bit of fun when the iPhone was
first released. Because if its popularity, he added some features and
put it on Google as a project so others could maintain it if they
wished. He doesn't seem to have had much input in the last 18 months
or so.

<URL: http://groups.google.com.au/group/iphonewebdev/browse_frm/thread/c87939d6e6bcda8d/b2b6e318b7fcd540?hl=en#b2b6e318b7fcd540
>


--
Rob

RobG

unread,
Jan 10, 2009, 9:19:02 AM1/10/09
to iPhoneWebDev


On Jan 8, 7:40 pm, Chrilith <chril...@gmail.com> wrote:
> Roger, I usuggest you to learn a bit more how javascript works.

I suggest you learn how to quote. Put your reply below the text
you're responding too, trim the bits you aren't. You removed the
line:

window.iui =

which is indeed poor form, though it is not a particularly severe
issue. It assumes a window object exists and can be extended, however
since iUI is written for browsers it's probably pretty harmless.

If the intention was to create a global variable, then:

var global = (function(){return this;})();
global.iui = ...

will do the job without fear of throwing an error in UAs that don't
have a window object.

>
> > This is a mistake.  The window object is a host object, so it should
> > not be augmented.  This also assumes that the global window property
> > references the Global Object.  The proper way to do this is to store a
> > reference to the Global Object prior to entering the one-off function.
>
> Try this:
>
> var a = "test";
> alert(window.a);
>
> Oh, my god, I've expanded the window object!!!!

No you haven't, you've added a property to the global object.
Browsers have a window object which is synonymous with the global
object.


> As you said earlier
> yes, context is important in javascript (this is why there are apply
> and call methods which let us change the context),

"Context"? Presumably you mean execution context, the call and apply
methods set the value of a called function's this keyword, that's it.
They don't do anything with regard to the execution context of the
current function. But that has nothing to do with the issue being
discussed.


> and the default
> context here is "window" - so what's wrong with expando, could you
> argument on this?

You've completely missed the point, see above. There is no "window"
context, the execution context is the anonymous function that wraps
the rest of the code, it isn't global code. The authors are trying to
create a global variable, if it was global code they'd have written:

var iui = ...


(at least I hope so).


--
Rob

RobG

unread,
Jan 10, 2009, 10:59:57 AM1/10/09
to iPhoneWebDev


On Jan 8, 6:41 am, Roger <roger.gilre...@gmail.com> wrote:
> Is it ever.  And of course, its proponents will all chime in that I
> hate frameworks and like wasting money.  You can listen to morons or
> you can listen to me.
>
> And be sure to read to the end as it was a journey.  The biggest
> bombshell is about three quarters of the way through.
>
> Executive summary: You'd have to be completely mental to consider
> using this on a Website.
>
> /*
>          Copyright (c) 2007, iUI Project Members
>
> That should give you pause.
>
>          See LICENSE.txt for licensing terms
>  */
>
> (function() {
>
> Assuming this is an iPhone/iPod script only (which should also give
> you pause), otherwise it would certainly leak memory in IE.

While this pattern has the potential to cause leaks (as the point of
using it is generally to use closures in lieu of global variables), it
is the use of closures with circular references that cause leaks in
IE. But this script doesn't work in IE anyway.


[...]
>
> var currentWidth = 0;
> var currentHash = location.hash;
>
> Implied global.  Use window.location.hash.

Further down, you criticize the use of window.iui, presumably because
it infers the existence of a window object. If that is your position,
then:

var currentHash = window && window.location && window.location.hash;

seems suitable. However, in a script for visual user agents and
browsers, perhaps:

if (!window) return;

should be the first line of the script.


[...]
>
> window.iui =
>
> This is a mistake.  The window object is a host object, so it should
> not be augmented.  This also assumes that the global window property
> references the Global Object.  The proper way to do this is to store a
> reference to the Global Object prior to entering the one-off function.

Or to get a reference to the global object from inside the function:

var global = (function(){ return this; })();
global.iui = ...

[...]
>
>             if (hasClass(page, "dialog"))
>
> Will be interesting to see the latest re-invention of this particular
> wheel.

It seems to be a pretty standard implementation.


[...]
>                 if (fromPage)
>                     setTimeout(slidePages, 0, fromPage, page,
> backwards);
>
> Implied global.  Use window.setTimeout and don't pass arguments like
> this.

Yes, extra parameters don't work in IE. Most developers of iPhone web
apps don't seem to consider other environments. I also get annoyed by
sites that force me to access their crappy iPhone version when I want
to see the full version of their site on my iPhone.


> And assuming this is some sort of timed effect, why should it
> be called from a timeout?

So that the rest of the function completes before any animation
starts.


[...]
>         var page = $(pageId);
>
> The "$" function is silly (and always has been.)

Yes.


[...]
>
>                 if (child.getAttribute("selected") == "true" || !
> targetPage)
>
> The use of get/set/removeAttribute for these flags is ridiculous.
> Clearly they all have ID's, so why not store this information in an
> object (as opposed to invalidating the markup.)

Or store it in the class attribute, which is designed for such stuff.


[...]
>     getSelectedPage: function()
>     {
>         for (var child = document.body.firstChild; child; child =
> child.nextSibling)
>         {
>             if (child.nodeType == 1 && child.getAttribute("selected")
> == "true")
>                 return child;
>         }
>     }
>
> This is what I'm talking about.  There should be a flag of some sort
> for this.  Looping through every child of the body is outrageously
> inefficient.

It may not be, the body element usually doesn't have that many direct
children.

>
> Also, as this loop is only concerned with element nodes, it would be
> far more efficient as:
>
> var childElements = document.body.getElementsByTagName('*');
> var index = childElements.length;
>
> while (index--) {

Ooops! The collection of body.childNodes will almost certainly be far
fewer nodes than the set of all elements in the body. But your point
is still valid - a reference to the 'selected' element should be
stored so it can be retrieved much more easily.

[...]

> addEventListener("load", function(event)
>
> Implied global.  That's the first time I've seen that one.

And another reason why this will go belly-up in IE. What happens when
the site is supposed to work with Windows Mobile?

[...]
>     if (link)
>     {
>         function unselect() { link.removeAttribute("selected"); }
>
> Don't nest function declarations (and don't create them every time the
> user clicks!)

It is, strictly, a syntax error, but various implementations allow it.


[...]
> function checkOrientAndLocation()
> {
>     if (window.innerWidth != currentWidth)
>     {
>         currentWidth = window.innerWidth;
>         var orient = currentWidth == 320 ? "profile" : "landscape";
>
> There's a bad assumption.
>
>         document.body.setAttribute("orient", orient);
>
> No way to query this property?

There is window.orientation.

>
>         setTimeout(scrollTo, 100, 0, 1);
>
> I hate this (and see it everywhere in scripts for this device.)
> Passing a host method to setTimeout is insanity.

Why, other than it is a DOM 0 method that might not be supported and
hasn't be properly tested for?


>     }
[...]
> function cancelDialog(form)
> {
>     form.removeAttribute("selected");
>
> }
>
> OMFG.  Just realized why they are twiddling with non-standard
> attributes.  The style sheets tell the tale (they have no clue what
> they are doing!)  All of these calls to set/removeAttribute should
> instead be adding or removing classes.

Yes.

[...]
> function encodeForm(form)
> {
>     function encode(inputs)
>     {
>         for (var i = 0; i < inputs.length; ++i)
>         {
>             if (inputs[i].name)
>                 args.push(inputs[i].name + "=" + escape(inputs
> [i].value));
>         }
>     }
>
> Not even close.  Here we are re-inventing form serialization.
> Prototype, jQuery, etc. didn't really work out as advertised, did
> they?

It also doesn't check if the 'input' has been disabled, or if
checkboxes and radio buttons are checked.


[...]
> function findParent(node, localName)
> {
>     while (node && (node.nodeType != 1 || node.localName.toLowerCase
> () != localName))
>
> Use nodeName.

localName is part of DOM 2, I guess you think it's not cross browser?


> Test is ridiculous.

Yes.


>         node = node.parentNode;
>     return node;
>
> }
>
> function hasClass(self, name)
> {
>     var re = new RegExp("(^|\\s)"+name+"($|\\s)");
>
> Don't create regular expressions endlessly.

It has to be created 'endlessly', how do you use a regular expression
that matches the value of a string passed to the function otherwise?
I would probably have used "cName" rather than "name".


[...]
> Not a single comment.  Currently patched by whomever.  Whole idea is
> ill-advised (Ajax navigation and emulating the default native
> interface of the iPhone.)  Design is ridiculous (see the CSS for more
> info.)  Implementation is botched (see above.)  What is the point of
> leaning on this thing?  Have developers become so conditioned to
> leaning on other people's do-everything-for-me scripts that they will
> jump on any old thing?  And old is the operative word.  This was
> slapped together two years ago (for whatever reason) and is still
> completely lacking today.

All correct. Maintenance and further development is a big issue for
such libraries.


--
Rob

Mr Junk

unread,
Jan 10, 2009, 2:53:51 PM1/10/09
to iphone...@googlegroups.com
He was verbally abusing everyone, calling people names and with no
useful solutions or help.

Nothing but complaints and badness about whatever he touched on.

I will probably leave the group if he is reinstated.

The noise to signal ration was far too high and I don't have time to
keep making filters.


On Jan 10, 2009, at 5:50 AM, RobG wrote:

>
>
>
> On Jan 8, 1:20 pm, Mr Junk <j...@stuffthis.net> wrote:
>> Moderator, can you shut this obnoxious jerk off
>
> Why? If you have trouble with what was posted, respond with reasoned
> argument. If Roger has been banned because of this post, I request
> that his account is restored.
>
>
>> , or is this list his
>> platform to abuse anyone and everyone?
>
> What? iUI was criticised, not anyone who replied.

I and several other were called all the names in the book including
nincompoop.

This isn't about IUI but respect for others on the list.

RobG

unread,
Jan 10, 2009, 5:50:16 PM1/10/09
to iPhoneWebDev


On Jan 11, 5:53 am, Mr Junk <j...@stuffthis.net> wrote:
> He was verbally abusing everyone, calling people names

Everyone? The only bit that might be called abuse was:

| And of course, its proponents will all chime in that I
| hate frameworks and like wasting money. You can
| listen to morons or you can listen to me.

Which is a straw man argument. It's a sad day when that is sufficient
to get banned from a group.


> and with no  
> useful solutions or help.

You didn't read the post then or are deliberately misrepresenting the
content.


> Nothing but complaints and badness about whatever he touched on.

The intention of the post was to point out why he thought iUI should
be avoided. I didn't see anyone directly address the points raised,
presumably they agree with his criticism of iUI.


> I will probably leave the group if he is reinstated.

Petulant too, good riddance. This is the most active and interesting
thread in the group for quite some time, I'd say he's done a good job.


> The noise to signal ration was far too high and I don't have time to  
> keep making filters.

One post? If it upsets you, don't read his posts or follow the
thread. I don't see how it's easier to write a post asking for
someone to be banned than to kill-file them.


> On Jan 10, 2009, at 5:50 AM, RobG wrote:

I wish you would reply below trimmed quotes of what you are replying
too, it makes life a lot easier.


> > On Jan 8, 1:20 pm, Mr Junk <j...@stuffthis.net> wrote:
> >> Moderator, can you shut this obnoxious jerk off
>
> > Why?  If you have trouble with what was posted, respond with reasoned
> > argument.  If Roger has been banned because of this post, I request
> > that his account is restored.
>
> >> , or is this list his
> >> platform to abuse anyone and everyone?
>
> > What? iUI was criticised, not anyone who replied.
>
> I and several other were called all the names in the book including  
> nincompoop.

You're making things up, that is why it is important to actually quote
the text you are replying too. The OP didn't reply to any of your
posts, nor call anyone a "nincompoop" anywhere in the thread, nor was
anyone who directly responded to his post called any names by him.

Read his posts, then post the actual words used.


> This isn't about IUI but respect for others on the list.

Respect? So because you think you saw things that weren't there, you
ask for him to be banned? If you don't like the criticism of iUI,
deal with the issues raised directly, not by shooting the messenger.


--
Rob

Lance Dyas

unread,
Jan 10, 2009, 6:03:08 PM1/10/09
to iphone...@googlegroups.com
RobG wrote:
> You didn't read the post then or are deliberately misrepresenting the
> content.
>
Im sure you are assuming the response is to a single thread perhaps that
might be your error.

ade

unread,
Jan 10, 2009, 6:14:20 PM1/10/09
to iphone...@googlegroups.com
ok - everyone - i am bored by this flame war

i managed to this evening successfully create a simple app version of a website using phonegap after not knowing buggar all 24r hours before hand  (and being pc based and having to do it on a friends macbook) - there were simple spelling errors in using phonegap at first (talk about having to cross t's and dot i's) and their tutorial has a misleading copy and paste which if you followed it blindly wouldnt work

hopefully i'll do an idiots guide once its finally done so that anyone who searches later on can find it - i'm documenting the process at mrlk.wordpress.com - but be warned its not just about this - its a personal blog (and no this isnt some sort of spam)

the worst thing is that after now being able to create the app i know i want to create a purpose built app - anyone got any links of where to start? so i can bookmark them for later and for anyone who searches this group ?

--
ade
...........................................................................................
www.iphoneibiza.com
www.podcast-ibiza.com
www.ibizaA-Z.com
www.ishopibiza.com
Ibiza NOW - The Islands Magazine

waynepan

unread,
Jan 12, 2009, 3:23:44 PM1/12/09
to iPhoneWebDev
As much as I enjoy a good flamewar both sides are correct. iUI was
made in a couple days by Joe Hewitt who has since abandoned the
project. The community has tried to keep the project alive but it is
outdated and not many contributions have been made to it.

The key concepts of iUI are sound, however if it were remade from
scratch in the world of Mobile Safari 2.0 it be far better. In my
opinion, iUI allows developers to make a decent "looking" web app
without much knowledge of css or javascript. It's a decent scaffold
and should be treated as such.

-Wayne

Rick Schramm

unread,
Jan 12, 2009, 6:47:44 PM1/12/09
to iPhoneWebDev


On Jan 10, 2:53 pm, Mr Junk <j...@stuffthis.net> wrote:
> He was verbally abusing everyone, calling people names and with no  
> useful solutions or help.

As mentioned, that is complete rubbish.

>
> Nothing but complaints and badness about whatever he touched on.

So? It all looks pretty bad from where I am sitting. How does that
affect you?

>
> I will probably leave the group if he is reinstated.

Happy trails! He's already "reinstated." The moderator is playing
the role of Sysyphus.

>
> The noise to signal ration was far too high and I don't have time to  
> keep making filters.

That's ironic as the signal from "Roger" was hardly noisy. You must
be one of the cranks that writes to the moderator every time somebody
posts anything critical of anything. That doesn't work very well in a
technical discussion (and somehow the moderator doesn't understand
that.) There will always be outspoken cranks in any group.

>
> On Jan 10, 2009, at 5:50 AM, RobG wrote:
>
>
>
> > On Jan 8, 1:20 pm, Mr Junk <j...@stuffthis.net> wrote:
> >> Moderator, can you shut this obnoxious jerk off
>
> > Why?  If you have trouble with what was posted, respond with reasoned
> > argument.  If Roger has been banned because of this post, I request
> > that his account is restored.
>
> >> , or is this list his
> >> platform to abuse anyone and everyone?
>
> > What? iUI was criticised, not anyone who replied.
>
> I and several other were called all the names in the book including  
> nincompoop.

I think you are delusional. Try citing something next go.

>
> This isn't about IUI but respect for others on the list.

No, it is about a vocal minority, who are set in their ways and
consider this their little domain and anything said that does not fit
into their mindset is labeled as "unhelpful" (usually with some behind-
the-scenes threats to cancel subscriptions if the offending party
isn't banned.) Some things never change.

Rick Schramm

unread,
Jan 12, 2009, 6:48:31 PM1/12/09
to iPhoneWebDev
I'm sure that you don't understand how a discussion group works.

Rick Schramm

unread,
Jan 12, 2009, 6:54:18 PM1/12/09
to iPhoneWebDev


On Jan 10, 5:50 pm, RobG <rg...@iinet.net.au> wrote:
> On Jan 11, 5:53 am, Mr Junk <j...@stuffthis.net> wrote:
>
> > He was verbally abusing everyone, calling people names
>
> Everyone? The only bit that might be called abuse was:
>
> |  And of course, its proponents will all chime in that I
> |  hate frameworks and like wasting money.  You can
> |  listen to morons or you can listen to me.
>
> Which is a straw man argument.  It's a sad day when that is sufficient
> to get banned from a group.

It was a preemptive strike a reference to a previous thread. IIRC,
iUI was criticized as a bad choice and somebody chimed in with all of
the usual non-arguments related to re-inventing wheels, wasting money
and the "real world." Tired of hearing that sort of parroting.

>
> > and with no  
> > useful solutions or help.
>
> You didn't read the post then or are deliberately misrepresenting the
> content.

It seems few posters here read anything before flying off the handle,
requesting bans, threatening to cancel their "subscriptions", etc.
(you've got to love that last one.). Good to have you back RobG! And
thanks for picking up on the mistakes made by the OP. Clearly he was
(very) tired when he wrote his review. ;)

Lance Dyas

unread,
Jan 12, 2009, 7:27:29 PM1/12/09
to iphone...@googlegroups.com

I'm quite certain I do, and how easy it is t o get multiple email addresses

Rick Schramm

unread,
Jan 12, 2009, 8:00:18 PM1/12/09
to iPhoneWebDev
I am *quite* certain you do not or you wouldn't continue with your off-
topic blithering. If you have something smart (or otherwise) to say
to a poster, say it to *them*. The rest of the cranks who whine about
"noise" should take note of this as well. Thank you for your
cooperation.

And kudos for uncovering what is clearly out in the open.

Rick Schramm

unread,
Jan 12, 2009, 8:10:06 PM1/12/09
to iPhoneWebDev


On Jan 9, 4:02 pm, Justin Kozuch <justinkoz...@gmail.com> wrote:
> I just joined up, and I wanted to pass on this link about the iUI js
> framework.
>
> It seems that there is a patched version of the iui.js file out there,
> and it was recently rewritten (September 2008).

Doesn't matter how often it is patched. It isn't a good idea to start
with. And, at a glance, I don't see any real improvement.

>
> Details at:http://www.steveworkman.com/projects/2008/patching-iui/
>
> I'm not a JS programmer with alot of experience, but this may solve
> problems/code improvements some of you have been asking about.

Nope.

[snip]

Jorge Chamorro

unread,
Jan 14, 2009, 6:08:15 AM1/14/09
to iphone...@googlegroups.com

I agree 100%. See what the great Crockford (no more no less) blogs
about frameworks in general and jquery and prototype in particular:

<http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=954>

--
Jorge.

Fred Grott(shareme)

unread,
Jan 15, 2009, 10:04:56 AM1/15/09
to iPhoneWebDev
I would say point to my youtube channel iUI being used on Android:)

http://www.youtube.com/user/memine44



On Jan 7, 3:12 pm, "Jay Zeschin" <j.zesc...@gmail.com> wrote:
> Instead of continually pelting the list with diatribes about how much IUI
> sucks, why don't you fork the project and fix it up to your standards?  It's
> mirrored up on github athttp://github.com/pjhyett/iui/tree/master- takes
> 20 seconds to sign up for an account and another 10 to fork the project.

shelly

unread,
Jan 17, 2009, 7:34:30 PM1/17/09
to iPhoneWebDev
IUI may not be perfect but it does what it intends too. There are a
few open source addons to IUI that extends it functionality.

It seems pretty robust, and if your going to stick with javascript and/
or php you don't have much choice. Dashcode is pretty good , but does
not offer all the functionality IUI does, there are a couple really
good dashcode templates, I suggest the book Developing iphone hybrid
applications available on Sams publishing Safari books online.

If you want to move to a more robust backend like java you have a few
more choices.

Google web toolkit, there have been some applications developed with
this, but I'm not sure performance is that good for a resource
intensive application.

Our choice was icefaces because we wanted an api that provided server
push and allowed for easy creation of custom components.

Our open source project www.mooncatventures.com combines dashcode
developed code with the server push capablilites of icefaces. ie. all
the nasty xmlhttprequest logic is replaced by higher level javascript
code.

So there are the choices, and the type of ranting in this thread is
uncalled for, Hewett has created a very nice starting point.

SteveWorkman

unread,
Jan 26, 2009, 12:47:27 PM1/26/09
to iPhoneWebDev
Thanks for the exposure Justin & Rick. The patched file contains a
roll-up of some of the more important fixes on the iUI google code
site. It is in no way intended to be an official patch, I just thought
some other people might be interested in some easy fixes.

Steve
Reply all
Reply to author
Forward
0 new messages