Saturday, January 31, 2009

[jQuery] Problem with dynamic XML

I have the following code:

var cartXml = $("<data><carttotals><items>33</items></carttotals></
data>");

alert(cartXml.find("items").text());

this will spit out 33 in both safari and firefox

However in IE it does not produce anything

Here is what I have figured out so far:

if I change to the following:

alert($("<div><span><p>33</items></span></p>").find("p").text());

this works in IE, Safari, and firefox

it seems with IE you need to use real html tag names and not ones that
are made up.

Does anyone know how I can fix this?

[jQuery] Re: Making Web Game- Need Hitpoint XP histogram/line graph

flot

http://code.google.com/p/flot/

On Jan 31, 7:06 am, TrixJo <tri...@gmail.com> wrote:
> Hi there, I have been using Yahoo UI for the past couple of years and
> finally jumped ship and have come over to JQuery mainly because of all
> of the amazing things I am seeing!
>
> I am making a simple web game.  Users can level their avatars and
> engage in combat.
>
> Therefore, I require a horizontal histogram for the player's health
> meter and XP meter.
>
> Stats are stored in mySQL (LAMP)
>
> I have googled for a number of plugins and haven't been able to find a
> simple one that allows for horizontal line bars for the situation I
> require.
>
> Anyone know of any?
>
> thanks

comp.lang.c++ - 25 new messages in 9 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* syncronization - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/b83eb8425cee1175?hl=en
* Logical Value Of A Pointer - 5 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/e9c0b3e622d74ae6?hl=en
* STL map with "count" method - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/44ba4e1927010e5f?hl=en
* Header files with "header.h" or <header.h> ?? - 5 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/02f708a44830afbc?hl=en
* C++0x: unique_ptr and std::move - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/8fb40687c0b160b9?hl=en
* A question about iterators - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/8e6025132806498c?hl=en
* abstract base class containing class - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/5bfe26b47a4e6f79?hl=en
* templated function help - 5 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/5b281279cd4b281c?hl=en
* don't want to retype the base class ctor - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/685377ed59f258c2?hl=en

==============================================================================
TOPIC: syncronization
http://groups.google.com/group/comp.lang.c++/t/b83eb8425cee1175?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Jan 30 2009 10:00 pm
From: Chunekit Pong


On Fri, 30 Jan 2009 20:06:48 -0800, red floyd
<no.spam.here@example.com> wrote:

>Chunekit Pong wrote:
>> when when I run the VirtualScreen.cpp code, it will crash like this
>> (screen shot captured)
>>
>> http://www.oniva.com/upload/1356/crash.jpg
>>
>> it is something related to pointers which i am no familiar with.
>>
>> Basically,
>> 1) RFIDSock Class - i defined a key value pair - ID / timestamp, then
>> I insert the key value pair into a queue.
>>
>> 2) VirtualScreen Class - I have a reference to RFIDSock object
>> (pointer) and I am accessing RFIDSock's "queue" object (*IDs) and pop
>> any object the timestamp is old enough.
>>
>> since both RFIDSock / VirtualScreen Class - both function is keep
>> calling every seconds or miliseconds.
>>
>> RFIDSock - is inserting to the queue
>> VirtualScreen - is removing element from the queue
>>
>> will there be some syncrohization problem for both function accessing
>> the queue every mililseconds / seconds?
>>
>> I am very messed up in pointers, is the crash related to just simple
>> mistake in pointers?
>>
>> =====================
>> RFIDSock.h
>> =====================
>> #include <map>
>> #include <list>
>> #include <string>
>> #include <queue>
>> #include "VirtualScreen.h"
>>
>> typedef const char* id_type;
>> typedef unsigned int timestamp_type;
>> typedef std::pair<id_type, timestamp_type> entry_type;
>>
>> //class CVirtualScreen;
>> class CVirtualScreen;
>>
>> class RFIDSock
>> {
>> public:
>> std::queue< entry_type > *IDs;
>>
>> };
>>
>> =====================
>> RFIDSock.cpp
>> =====================
>> #include "RFIDSock.h"
>> #include <queue>
>> #include <time.h>
>>
>> class CVirtualScreen;
>>
>> //--------------------------------------------------------------
>> void RFIDSock::OnDataReceived(const LPBYTE lpBuffer, DWORD dwCount)
>> {
>> entry_type entry;
>> entry.first = (const char*)m_bReceiveBuffer;
>> entry.second = seconds;
>>
>> IDs->push( entry );
>>
>> }
>> =====================
>> VirtualScreen.h
>> =====================
>> RFIDSock *rfidsock;
>>
>> =====================
>> VirtualScreen.cpp
>> =====================
>> void VirtualScreen::ProcessMessages()
>> {
>> unsigned int current = time (NULL);
>> while ( current - rfidsock->IDs->front().second > duration){
>> rfidsock->IDs->pop();
>> }
>> }
>>
>
>What Kai-Uwe said, plus the obvious. ARe you initializing IDs properly
>in the constructor? Why are you using a pointer to a queue?
>
>To do what Kai-Uwe suggests, rewrite the loop:
>
> while (!rfidsock->IDs->empty())
> {
> if (current - rfidsock->IDs->front().second > duration)
> rfidsock->IDs->pop();
> else
> break;
> }

I don't know how to initialize IDs object (a pointer)

do I do somethign like
std::queue< entry_type > *IDs = new queue():

== 2 of 2 ==
Date: Sat, Jan 31 2009 4:47 am
From: SG


On 31 Jan., 07:00, Chunekit Pong <worlman...@yahoo.com> wrote:
> I don't know how to initialize IDs object (a pointer)
>
> do I do somethign like
> std::queue< entry_type > *IDs = new queue():

You can't expect people to teach you these basics. Get a book and
learn for yourself. It is important for you to show that you put some
effort into solving your problems. Otherwise you may not get helpful
comments besides "Read a book about C++".

Cheers!
SG

==============================================================================
TOPIC: Logical Value Of A Pointer
http://groups.google.com/group/comp.lang.c++/t/e9c0b3e622d74ae6?hl=en
==============================================================================

== 1 of 5 ==
Date: Sat, Jan 31 2009 2:00 am
From: Lionel B


On Fri, 30 Jan 2009 16:00:41 -0800, James Kanze wrote:

> On 30 jan, 14:08, Lionel B <m...@privacy.net> wrote:
>> On Thu, 29 Jan 2009 17:07:41 +0000, Andrew Koenig wrote:
>> > "James Kanze" <james.ka...@gmail.com> wrote in message
>> >news:11b0ce6c-69ed-4764-aa5a-
c3f8b971e2d5@s1g2000prg.googlegroups.com...
>> > On Jan 13, 8:46 am, Nosophorus <Nosopho...@gmail.com> wrote:
>
>> >> For historical reasons, a pointer implicitly converts to bool, with
>> >> a null pointer converting to false, and all other pointer values
>> >> converting to true. In general, it's better to avoid the implicit
>> >> convertion, and write what you mean:
>> >> if ( a != NULL ) ...
>
>> > Why do you think it's better? I don't think so, but maybe you can
>> > convince me.
>
>> It makes the intent of the coder clearer?
>
>> If I see "if (a != NULL)" I immediately know that a is a pointer and
>> that we're checking that it's not a null pointer. Or more precisely, if
>> this is /not/ the case, then I'm dealing with such a perverse coder
>> that all bets are off...
>
>> If I see "if (a != 0)" then I have fewer clues what's going on and
>> quite likely have to check a lot of other code to find out.
>
> That wasn't the point.

Yes, I jumped into he middle of the thread.

> While I also prefer NULL to 0 when pointers are
> involved, there are serious problems with both solution, and I
> understand the arguments for 0. I don't think that there is a
> conclusive argument one way or the other there---it's a question of
> which problems you consider the most serious.

Sure, that's been done to death (repeatedly) on this ng.

> The issue is
> if ( a == NULL )
> or if ( a == 0 )
> vs if (!a)
> ; the implicit conversion to bool.

See my posts else thread.

--
Lionel B


== 2 of 5 ==
Date: Sat, Jan 31 2009 2:05 am
From: Lionel B


On Sat, 31 Jan 2009 00:09:17 +0000, Andrew Koenig wrote:

> "Lionel B" <me@privacy.net> wrote in message
> news:gluu3l$hhg$2@south.jnrs.ja.net...
>
>> It makes the intent of the coder clearer?
>
>> If I see "if (a != NULL)" I immediately know that a is a pointer and
>> that we're checking that it's not a null pointer. Or more precisely, if
>> this is /not/ the case, then I'm dealing with such a perverse coder
>> that all bets are off...
>
> To me, "if (a != NULL)" is saying the same thing twice.

Pardon?

To me, it just looks like comparing 'a' with something called 'NULL'
which is a bit of bodge, but nonetheless associated with pointers. So I
would /suspect/ that 'a' is something pointer-like, although to be sure I
would have to check some code.

> That is... I
> don't think that code should mention a variable's type more than once if
> it is reasonably possible to avoid doing so.

--
Lionel B


== 3 of 5 ==
Date: Sat, Jan 31 2009 3:39 am
From: peter koch


On 31 Jan., 01:07, "Andrew Koenig" <a...@acm.org> wrote:
> "James Kanze" <james.ka...@gmail.com> wrote in message
>
> news:13127edb-2688-44f0-820b-75b9603b06a7@i24g2000prf.googlegroups.com...
> On Jan 29, 6:07 pm, "Andrew Koenig" <a...@acm.org> wrote:
>
> >>> For historical reasons, a pointer implicitly converts to
> >>> bool, with a null pointer converting to false, and all other
> >>> pointer values converting to true.  In general, it's better
> >>> to avoid the implicit convertion, and write what you mean:
> >>>     if ( a != NULL ) ...
> >> Why do you think it's better?  I don't think so, but maybe you
> >> can convince me.
> > For the same reason implicit conversions in general are to be
> > avoided.  A pointer isn't a bool, so it doesn't make sense to
> > use it as one; doing so only leads to confusion.  Say what you
> > mean, and mean what you say.
> > (BTW: you're the co-author of the original proposal for bool.
> > And there, unless I'm remembering wrong, you proposed
> > deprecating the above conversion.  Have you changed your mind?
> > And if so, what made you change it?)
>
> I'd love to deprecate conversion of pointers to bool ... but I don't
> consider
>
>     if (p) { /* ... */ }
>
> to be an instance of such a conversion.  After all, this usage was around
> for years before anyone considered the conversion!
>
> Rather, I consider
>
>     if (p) { /* ... */ }
>
> to be an abbreviation for
>
>     if (p != 0) { /* ... */ }
>
> which is an implicit conversion of 0 to a pointer, not of p to bool.
>
> I understand that the standard doesn't describe it that way, but that's just
> a matter of descriptive convenience, and doesn't affect how I personally
> think about it.

I have mixed feelings about if (ptr): when I began programming C, I
always wrote if (ptr != NULL). That was many years ago, and I have now
changed attitude and consider it idiomatic (replacing NULL with 0 and
C with C+++) and in line with other common shorthands such as while
(stream >> i).
What is a big shame in my opinion is the automatic conversion to (and
also from) bool: It has caused so many problems and inconveniences for
everyone. I wonder what the rationale was.

/Peter


== 4 of 5 ==
Date: Sat, Jan 31 2009 4:45 am
From: James Kanze


On 31 jan, 01:07, "Andrew Koenig" <a...@acm.org> wrote:
> "James Kanze" <james.ka...@gmail.com> wrote in message

> news:13127edb-2688-44f0-820b-75b9603b06a7@i24g2000prf.googlegroups.com...
> On Jan 29, 6:07 pm, "Andrew Koenig" <a...@acm.org> wrote:

> >>> For historical reasons, a pointer implicitly converts to
> >>> bool, with a null pointer converting to false, and all other
> >>> pointer values converting to true. In general, it's better
> >>> to avoid the implicit convertion, and write what you mean:
> >>> if ( a != NULL ) ...
> >> Why do you think it's better? I don't think so, but maybe you
> >> can convince me.
> > For the same reason implicit conversions in general are to be
> > avoided. A pointer isn't a bool, so it doesn't make sense to
> > use it as one; doing so only leads to confusion. Say what you
> > mean, and mean what you say.
> > (BTW: you're the co-author of the original proposal for bool.
> > And there, unless I'm remembering wrong, you proposed
> > deprecating the above conversion. Have you changed your mind?
> > And if so, what made you change it?)

> I'd love to deprecate conversion of pointers to bool ... but I don't
> consider

> if (p) { /* ... */ }

> to be an instance of such a conversion.

But the standard does. And IIRC, so did your original paper.

> After all, this usage was around for years before anyone
> considered the conversion!

Yes, because early C was rather flippant about types. An
attitude left over from B, I suppose. (In B, and in other
"untyped" languages, like AWK, I have no problems with this.
Although even in AWK, if I'm using a variable as a number or a
string, rather than as a boolean, I'll write the test out.)

> Rather, I consider

> if (p) { /* ... */ }

> to be an abbreviation for

> if (p != 0) { /* ... */ }

Why?

> which is an implicit conversion of 0 to a pointer, not of p to
> bool.

> I understand that the standard doesn't describe it that way, but that's just
> a matter of descriptive convenience, and doesn't affect how I personally
> think about it.

I'm not sure I follow you: are you saying that anytime a
variable (pointer or arithmetic type) is used in a condition, it
should automatically be treated as if there was a != 0 behind
it? A sort of a short cut way of writing it?

--
James Kanze


== 5 of 5 ==
Date: Sat, Jan 31 2009 5:05 am
From: James Kanze


On 31 jan, 06:50, Jeff Schwab <j...@schwabcenter.com> wrote:
> Andrew Koenig wrote:
> > I consider

> > if (p) { /* ... */ }

> > to be an abbreviation for

> > if (p != 0) { /* ... */ }

> > which is an implicit conversion of 0 to a pointer, not of p to bool.

> > I understand that the standard doesn't describe it that way,
> > but that's just a matter of descriptive convenience, and
> > doesn't affect how I personally think about it.

> This may go without saying, but you obviously have a very deep
> understanding of how C++ syntax can be used to reflect
> high-level semantic meaning. I wish that level of
> understanding were more widespread.

> To a human reader, the != 0 ought to be considered noise,
> AFAICS.

It specifies what you are testing for. If a pointer only had
two possible values, it would be noise. Since that's not the
case, it's important information.

> The ability to test things other than raw bools is not just
> for pointers, either; e.g: while (std::cin >> s) { ... }. I
> don't consider p != 0 any better than b != false. And don't
> even get me started on NULL. :)

> This argument seems to be a perennial favorite on Usenet. It
> seems to come down to a division between people who think
> generically, and others who think (or at least code)
> orthogonally.

The argument goes back long before generic programming. The
argument is between those who believe in static type checking,
and those who are too lazy to type.

Just kidding, of course---but the issue IS type checking.

With regards to "generic" programming, I can understand the need
for some sort of "generic" is valid. The problem is that we
don't have it. Whether you write "if ( p == NULL )", or just
"if (p)", the constraints on p are identical. The difference is
that in the first case, it's clearly apparent what those
constraints are.

> The first of these camps, the Generics, believe that syntax
> should convey abstract meaning, with low-level details
> supplied by context. The second camp, the Orthogonals,
> believe that a particular syntax should mean exactly the same
> thing in all contexts, and that even (or especially) subtly
> things should always look different.

I don't think you've understood the argument. In a well
designed language, pointers aren't boolean values (since they
have more than two values), and can't be used as such. And type
checking is strict, because that reduces the number of errors.

The problem is that the implicit conversion doesn't cover all of
the cases. Even in the case of pointers, we have three cases
which can legally occur: the pointer points to an object, it
points to one behind the end of an array of objects, or it is
null. So which one do you priviledge by the conversion?

> I consider myself in the Generic camp. The advantage of this
> style is that similar ideas are implemented by similar-looking
> code. A single piece of source code can often be reused in
> multiple contexts, even if the compiler generates wildly
> different object code for each of them. For example, I like
> the fact that the following all look the same:

> throw_if(!p, "null pointer");
> throw_if(!cin, "input error");
> throw_if(!divisor, "attempted division by zero");

throw_if( p != 0, "null pointer");
throw_if( cin != 0, "input error");
throw_if( divisor != 0, "attempted division by zero");

They all look the same to me. Even better:

throw_if( isValid( p ), "null pointer");
throw_if( isValid( cin ), "input error");
throw_if( isValid( divisor ), "attempted division by zero");

With isValid defined with an appropriate overload (which would
return false for a pointer one past the end as well---except
that I don't know how to implement that).

> Once I understand the pattern, I don't want to have to
> optically grep the details of expressions like p == NULL,
> !cin.good(), and divisor == 0. They all have the same
> high-level meaning, and that's usually what I care about.

The problem is that no one really knows what that high-level
meaning is, since it is radically different for each type.

> The apparent down side to this style is that subtle mistakes
> can hide in it. It's easy for the reader to see the author's
> intent,

The problem is that it's impossible for the reader to see the
author's intent (except from the string literal in your
example---but that's not typically present). It's a recepe for
unreadable code.

> but relatively difficult to see the bit-level reality.
> However, I would argue that this is the price we pay for
> abstraction, and attempts to include context-specific
> information in our code without loss of abstraction give only
> the illusion of clarity.

> The ostensible advantage of something like p != NULL is that p
> is clearly a pointer.

No. The advantage is that it isn't "p != 0", and that 0 clearly
isn't a pointer.

The whose system is broken. The problem is that both "p != 0"
and "p != NULL" are lies. The next version of the standard will
fix it somewhat, with nullptr (but for historical reasons, of
course, 0 and NULL must still remain legal).

> Or is it? The compiler has no problem with a comparison of
> the form std::cin != NULL. In p != NULL, the word NULL seems
> to hint that p is a pointer, but that information is neither
> relevant to the expression, nor enforceable by the compiler.

G++ warns if you use NULL in a non-pointer context. It could
just as easily generate an error. So this is enforceable by the
compiler.

> When it becomes necessary to understand that p is a pointer,
> the fact should become evident, as in an expression like
> p->size(). Even then, p might be a raw pointer, an iterator,
> or some kind of fancy smart pointer. In decent C++ code, IMO,
> we shouldn't have to know.

Except that we do, since neither "if (p)" nor "if ( p != NULL )"
nor "if ( p != 0 )" work if p is an iterator.

The real solution here is an appropriate set of overloaded
functions. I use Gabi::begin(), and Gabi::end(), for example;
they work with C style arrays, and are easily made to work with
STL containers. (In other words, if the STL had been designed
for genericity, it would have defined a function begin(
std::vector<> ), and not std:vector<>::begin().)

--
James Kanze

==============================================================================
TOPIC: STL map with "count" method
http://groups.google.com/group/comp.lang.c++/t/44ba4e1927010e5f?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 31 2009 5:42 am
From: Joe Gottman


Victor Bazarov wrote:
> thomas wrote:
>> A STL map doesn't allow two keys having the same value.
>
> But std::multimap does.
>
>> That's to say, a "count()" method will always return 1 or 0.
>> So why a "count()" is needed while we better call it "exist()"?
>
> Could it be for the consistency's sake? std::multimap would *not*
> always return only 1 or 0, yes?
>
> You're free to define a stand-alone function 'exist' and implement it in
> terms of 'count'. Curiously, for both std::map and std::multimap you
> could either use 'count() != 0' or 'find() != end()' ...
>

Both would give correct results, but 'find() != end()' would be more
efficient in the multimap case. If count() equaled 100 the first
implementation would have to actually count to 100, while the second
could return true as soon as the first was found. This is the same
reason why empty() is implemented as 'begin() != end()' and not 'count()
> 0'.

Joe Gottman


==============================================================================
TOPIC: Header files with "header.h" or <header.h> ??
http://groups.google.com/group/comp.lang.c++/t/02f708a44830afbc?hl=en
==============================================================================

== 1 of 5 ==
Date: Sat, Jan 31 2009 6:35 am
From: "mlt"


I have a header only library containing various .h files. One of the header
files, all.h, includes all the other header files. When I include all.h I
therefore get all the other header files.

all.h looks like this:

#include <header1.h>
#include <header2.h>
#include <header3.h>
#include <header4.h>


When I include the all.h in my application:

#include "all.h"

I get an error that header1.h cannot be found. But if I change all.h to:

#include "header1.h"
#include "header2.h"
#include "header3.h"
#include "header4.h"


I works fine. But I don't want to change all.h, so how do I use all.h
unchanged (with <> instead of "")??

== 2 of 5 ==
Date: Sat, Jan 31 2009 6:49 am
From: "Bo Persson"


mlt wrote:
> I have a header only library containing various .h files. One of
> the header files, all.h, includes all the other header files. When
> I include all.h I therefore get all the other header files.
>
> all.h looks like this:
>
> #include <header1.h>
> #include <header2.h>
> #include <header3.h>
> #include <header4.h>
>
>
> When I include the all.h in my application:
>
> #include "all.h"
>
> I get an error that header1.h cannot be found. But if I change
> all.h to:
> #include "header1.h"
> #include "header2.h"
> #include "header3.h"
> #include "header4.h"
>
>
> I works fine. But I don't want to change all.h, so how do I use
> all.h unchanged (with <> instead of "")??

You have to check with your compiler!

The only difference is that "" tells the compiler to first look
somewhere (implementation specific) and, if not found there, perform
another search just like for <>.


Bo Persson


== 3 of 5 ==
Date: Sat, Jan 31 2009 6:54 am
From: Jean-Marc Bourguet


"mlt" <asdf@asd.com> writes:

> I have a header only library containing various .h files. One of the header
> files, all.h, includes all the other header files. When I include all.h I
> therefore get all the other header files.
>
> all.h looks like this:
>
> #include <header1.h>
> #include <header2.h>
> #include <header3.h>
> #include <header4.h>
>
>
> When I include the all.h in my application:
>
> #include "all.h"
>
> I get an error that header1.h cannot be found. But if I change all.h to:
>
> #include "header1.h"
> #include "header2.h"
> #include "header3.h"
> #include "header4.h"
>
>
> I works fine. But I don't want to change all.h, so how do I use all.h
> unchanged (with <> instead of "")??

Short answer: add -Idir to your compilation options (or equivalent with
your IDE GUI).

Long answer: the standard doesn't define where included files (the "" form)
and headers (the <> form) are searched, excepted that if no file is found
an header is searched.

In practice, most compilers will search files included with ""
- in the same directory as the file containing the directive
- in a user specified list of directories
- in a list of default directories
while header included with <> are searched in the two last lists. But
there are variations on that which may break your build if you depend too
much on the search order to resolve ambiguities. And most compilers also
have other possibilities.

Yours,

--
Jean-Marc


== 4 of 5 ==
Date: Sat, Jan 31 2009 6:57 am
From: Sam


mlt writes:

> I have a header only library containing various .h files. One of the header
> files, all.h, includes all the other header files. When I include all.h I
> therefore get all the other header files.
>
> all.h looks like this:
>
> #include <header1.h>
> #include <header2.h>
> #include <header3.h>
> #include <header4.h>
>
>
> When I include the all.h in my application:
>
> #include "all.h"
>
> I get an error that header1.h cannot be found. But if I change all.h to:
>
> #include "header1.h"
> #include "header2.h"
> #include "header3.h"
> #include "header4.h"
>
>
> I works fine. But I don't want to change all.h, so how do I use all.h
> unchanged (with <> instead of "")??

With most compilers, use the -I option to specify where the header files are
installed.

== 5 of 5 ==
Date: Sat, Jan 31 2009 7:46 am
From: Pete Becker


On 2009-01-31 09:35:35 -0500, "mlt" <asdf@asd.com> said:

>
>
> I works fine. But I don't want to change all.h, so how do I use all.h
> unchanged (with <> instead of "")??

You really should change it. The convention is that < ... > is for
system-supplied headers and " ... " is for everything else. That way
your users won't run into the problem you've just seen.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)


==============================================================================
TOPIC: C++0x: unique_ptr and std::move
http://groups.google.com/group/comp.lang.c++/t/8fb40687c0b160b9?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 31 2009 7:37 am
From: SG


I searched the GCC bug database and it seems there is already a report
on a similar case (#36744)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36744

Even in the case of a missing move constructor the copy must not be
elided because the object in question is not a temporary.

Cheers!
SG

==============================================================================
TOPIC: A question about iterators
http://groups.google.com/group/comp.lang.c++/t/8e6025132806498c?hl=en
==============================================================================

== 1 of 4 ==
Date: Sat, Jan 31 2009 9:20 am
From: hagai


Hi,
I am doing all sorts of stuff with iterators, I am passing an iterator
to the start and end to generic functions. All iterators are at least
bi-directional.
My question is how do I get an iterator to the item before the end? I
am currently doing it like this:

_It itOneBeforeEnd = itEnd;
--itOneBeforeEnd;

This is not really comfortable, is there another short way of doing
it?

Thanks,
Hagai.


== 2 of 4 ==
Date: Sat, Jan 31 2009 9:34 am
From: Pete Becker


On 2009-01-31 12:20:28 -0500, hagai <hagai.sela@gmail.com> said:

> I am doing all sorts of stuff with iterators, I am passing an iterator
> to the start and end to generic functions. All iterators are at least
> bi-directional.
> My question is how do I get an iterator to the item before the end? I
> am currently doing it like this:
>
> _It itOneBeforeEnd = itEnd;
> --itOneBeforeEnd;
>
> This is not really comfortable, is there another short way of doing
> it?
>

No, that's it. If you had a random access iterator you could use itEnd
- 1, but for bidirectional iterators all you can do is increment and
decrement.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

== 3 of 4 ==
Date: Sat, Jan 31 2009 9:50 am
From: Jeff Schwab


hagai wrote:
> Hi,
> I am doing all sorts of stuff with iterators, I am passing an iterator
> to the start and end to generic functions. All iterators are at least
> bi-directional.
> My question is how do I get an iterator to the item before the end? I
> am currently doing it like this:
>
> _It itOneBeforeEnd = itEnd;
> --itOneBeforeEnd;
>
> This is not really comfortable, is there another short way of doing
> it?

Well, you could get that onto one line with something like:

iterator const next_to_last = advance(a_collection.end(), -1);

std::advance is in <iterator>. A better alternative might be a little
utility function:

template<class Iterator>
Iterator prior(Iterator i) {
return --i;
}

iterator const next_to_last = prior(a_collection.end());

Of course, these both assume the collection is large enough for "one
before the end" to make sense. You might prefer a next_to_last function
template that accepts the collection, rather than just its end-iterator,
in order to detect out-of-range errors.

iterator const next_to_last = penultimate(a_collection);

One other thing you might want to consider is changing your naming
convention. Any identifier beginning with and underscore and a capital
letter is supposed to be reserved for use in system libraries. There
are other restrictions on leading underscores (and double underscores),
as well.


== 4 of 4 ==
Date: Sat, Jan 31 2009 10:19 am
From: "Andrew Koenig"


"hagai" <hagai.sela@gmail.com> wrote in message
news:6eef8841-03b9-45b6-a273-1e0ac693d308@35g2000pry.googlegroups.com...

> My question is how do I get an iterator to the item before the end? I
> am currently doing it like this:

> _It itOneBeforeEnd = itEnd;
> --itOneBeforeEnd;

> This is not really comfortable, is there another short way of doing
> it?

The real question is why you want to do this. Note in particular that it
will fail if the iterator refers to an empty container.

If you are trying to iterate backward through a container, it is tempting to
do this:

It = itEnd;
--It;
while (It != itBegin) {
// do something with *It
--It;
}

but this technique doesn't work -- not only does it fail immediately if the
container is empty, but it ultimately attempts to decrement a value equal to
itBegin, which will also fail if itBegin refers to the first element of a
nonempty container.

Here's the right way to step backward through a container:

It = itEnd;
while (It != itBegin) {
--It;
// do something with *It
}

General rule: Decrement before you use the iterator; increment after you use
it.

==============================================================================
TOPIC: abstract base class containing class
http://groups.google.com/group/comp.lang.c++/t/5bfe26b47a4e6f79?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 31 2009 9:50 am
From: scg_


What follows is a question by an absolute beginner – you have been warned:
I am using the following class layout, which is inspired by Bruce
Eckel's "Thinking in C++":

template <class T>
class B {
private:
T* data_;
int size_;
public:
int size() const {return size_;}
class iterator;
friend class iterator;
class iterator {
T* p;
public:
iterator(): p(0) {}
iterator(const B<T>& x): p(x.data) {}
T& operator*() {return *p;}
T* operator++(){return ++p;}
};
iterator begin() const {return iterator(*this);}

\\...

};

Furthermore, I define a function operating on B objects,
essential_function(const B &), which relies on the member function
explicitly listed above. Since I recently decided to change the
implementation of some of the details of B, I thought setting up an
abstract base class would be auspicious. In particular, I was hoping to
implement the algorithm in terms of the purely virtual member functions
of the abstract class:

template <class T>
class A {
public:
virtual int size() const = 0;
class iterator;
friend class iterator;
class iterator {
public:
virtual T& operator*() const = 0;
virtual T* operator++() = 0;
};
virtual iterator begin() const = 0; // error
};

class B : public A<T> {
//...
};

Unfortunately, this class A layout does not compile due to covariant
return type issues, i.e. B<T>::iterator B<T>::begin() overrides
A<T>::iterator A<T>::begin().
When I comment the line "virtual iterator begin() const = 0", it
compiles. However, not much is gained, since I can not implement
essential_function(const A &) in terms of the abstract class A:

template <class T>
void essential_function(const A<T>& x) {
typename A<T>::iterator iter;
iter = x.begin();
}

error: cannot declare variable `iter' to be of type `A<T>::iterator'
because virtual functions are abstract ... and A<T> has no has no
member named 'begin'.

Don't get me wrong - I am not particularly surprised about the errors
(now that I spend some time thinking about it).
Still, how can I implement what I (in essence) suggest above?

Thanks

==============================================================================
TOPIC: templated function help
http://groups.google.com/group/comp.lang.c++/t/5b281279cd4b281c?hl=en
==============================================================================

== 1 of 5 ==
Date: Sat, Jan 31 2009 10:45 am
From: Francesco Montorsi


Hi,
I'm quite new to templates... I was asked to transform the following macro

#define DECLARE_STRING_CHECK(func) \
inline bool func##String(const MyString& val) \
{ \
for ( MyString::const_iterator i = val.begin(); \
i != val.end(); \
++i ) \
if (func(*i) == 0) \
return false; \
return true; \
}

DECLARE_STRING_CHECK(isalpha) // declares isalphaString()
DECLARE_STRING_CHECK(isalnum)
DECLARE_STRING_CHECK(isdigit)

in a template.
I blindly tried:

template<typename T>
inline bool StringCheck(const MyString& val)
{
for ( MyString::const_iterator i = val.begin();
i != val.end();
++i )
if (T(*i) == 0)
return false;
return true;
}

Needless to say it doesn't work. I.e. if I write

if (!StringCheck<isalpha>(str))
return false;

I get "error: no matching function for call to 'StringCheck(const MyString&)'"
with GCC...

Can you help me with some hints :) ?

Thanks!!
Francesco


== 2 of 5 ==
Date: Sat, Jan 31 2009 11:09 am
From: Daniel Pitts


Francesco Montorsi wrote:
> Hi,
> I'm quite new to templates... I was asked to transform the following
> macro
>
> #define DECLARE_STRING_CHECK(func) \
> inline bool func##String(const MyString& val) \
> { \
> for ( MyString::const_iterator i = val.begin(); \
> i != val.end(); \
> ++i ) \
> if (func(*i) == 0) \
> return false; \
> return true; \
> }
>
> DECLARE_STRING_CHECK(isalpha) // declares isalphaString()
> DECLARE_STRING_CHECK(isalnum)
> DECLARE_STRING_CHECK(isdigit)
>
> in a template.
> I blindly tried:
>
> template<typename T>
> inline bool StringCheck(const MyString& val)
> {
> for ( MyString::const_iterator i = val.begin();
> i != val.end();
> ++i )
> if (T(*i) == 0)
> return false;
> return true;
> }
>
> Needless to say it doesn't work. I.e. if I write
>
> if (!StringCheck<isalpha>(str))
> return false;
>
> I get "error: no matching function for call to 'StringCheck(const
> MyString&)'" with GCC...
>
> Can you help me with some hints :) ?
>
> Thanks!!
> Francesco
>
>
I tried this in GCC.

template<int (T)(int)>
inline bool check(char * const str) {
return T(str[0]) == 0;
}

check<isalpha>("Foo"); seemed to work fine

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>


== 3 of 5 ==
Date: Sat, Jan 31 2009 11:19 am
From: SG


On 31 Jan., 19:45, Francesco Montorsi <f...@hotmail.com> wrote:
> template<typename T>
>      inline bool StringCheck(const MyString& val)
>      {
>          for ( MyString::const_iterator i = val.begin();
>                i != val.end();
>                ++i )
>              if (T(*i) == 0)
>                  return false;
>          return true;
>      }
>
> Needless to say it doesn't work. I.e. if I write
>
> if (!StringCheck<isalpha>(str))
>     return false;

"isalpha" is not a type. There are several possibilities:

template<int (&T)(int)> // T is a reference to a function
int foo() { // with *external* linkage.
return T(42);
}

int main() { foo<isalpha>(); }

But this way you can only use functions with the exact same signature
and only functions that have external linkage. You can also make T a
type for a function pointer (or function object) and pass the pointer
(or object) as additional parameter. This would be the "STL style":

template<typename T> // T is type (function pointer
int foo(T some_func) { // or function object)
return some_func(42);
}

int main() { foo(isalpha); } // function decays to pointer

HTH,
SG


== 4 of 5 ==
Date: Sat, Jan 31 2009 1:02 pm
From: Francesco Montorsi


Daniel Pitts ha scritto:
> I tried this in GCC.
>
> template<int (T)(int)>
> inline bool check(char * const str) {
> return T(str[0]) == 0;
> }
>
> check<isalpha>("Foo"); seemed to work fine
Thanks!! I've managed to fix it using "int (T)(int)" declaration!!

Francesco


== 5 of 5 ==
Date: Sat, Jan 31 2009 1:05 pm
From: Francesco Montorsi


Hi,

SG ha scritto:
> "isalpha" is not a type.
indeed :/

> There are several possibilities:
>
> template<int (&T)(int)> // T is a reference to a function
> int foo() { // with *external* linkage.
> return T(42);
> }
>
> int main() { foo<isalpha>(); }
>
> But this way you can only use functions with the exact same signature
> and only functions that have external linkage.
Thanks for the explanation! I think I'll go for this approach as the linkage is
not an issue for me.

> You can also make T a
> type for a function pointer (or function object) and pass the pointer
> (or object) as additional parameter. This would be the "STL style":
>
> template<typename T> // T is type (function pointer
> int foo(T some_func) { // or function object)
> return some_func(42);
> }
>
> int main() { foo(isalpha); } // function decays to pointer
Useful to know. Just out of curiosity: unless I'm wrong this second method
allows you to call functions also with internal linkage but they still need to
have the same exact signature as those of the function pointer type T, right?

Thanks!
Francesco

==============================================================================
TOPIC: don't want to retype the base class ctor
http://groups.google.com/group/comp.lang.c++/t/685377ed59f258c2?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 31 2009 12:21 pm
From: "Victor Bazarov"


Daniel T. wrote:
> Victor Bazarov <v.Abazarov@comAcast.net> wrote:
>
>> By the same token, B could be a template:
>>
>> template<int initialiser> class B {
>> protected:
>> B(int param = initialiser) : b(param) {}
>> public:
>> int b;
>> };
>>
>> class D1 : public B<42> {};
>> class D2 : public B<666> {};
>>
>> #include <iostream>
>> #include <ostream>
>> int main() {
>> D1 d1;
>> D2 d2;
>>
>> std::cout << d1.b << std::endl;
>> std::cout << d2.b << std::endl;
>> }
>>
>> Or you could even give the 'initialiser' template argument some
>> default value and not define it for those who should have the
>> default:
>>
>> template<int initialiser = 42> class B {
>> protected:
>> B(int param = initialiser) : b(param) {}
>> public:
>> int b;
>> };
>>
>> class D1 : public B<> {};
>> class D2 : public B<666> {};
>> class D3 : public B<> {};
>>
>> #include <iostream>
>> #include <ostream>
>> int main() {
>> D1 d1;
>> D2 d2;
>> D3 d3;
>>
>> std::cout << d1.b << std::endl;
>> std::cout << d2.b << std::endl;
>> std::cout << d3.b << std::endl;
>> }
>>
>> The problem, however, is that you still need to spell out the
>> template argument or rely on some default. You either do it in the
>> constructor of each Dx class or do it using your scheme or the
>> template.
>
> Another problem is that D1, D2 and D3 above all derive from different
> base classes.

All? No, only two of them. D1 and D3 derive from the same type.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

[jQuery] Re: getElementById with ajax

On Jan 31, 12:55 pm, efet <efetun...@gmail.com> wrote:
> When customer enters ReceiverPostalCode and ReceiverCountry on
> index.asp, I want quotes immediately appear in index.asp. How do I do
> this basing my codes on jQuery?

Assuming ship.asp returns some kind of value, you simply make a Ajax
request to ship.asp and do what you will with the response in
index.asp. Probably best to read up on both Ajax and jQuery's Ajax
implementation:

https://developer.mozilla.org/en/AJAX
http://docs.jquery.com/Ajax

Good luck!

[jQuery] Re: 1.3 and toggle()

On Jan 30, 7:08 pm, John Resig <jere...@gmail.com> wrote:
> It looks like you're trying to use a jQuery UI effect - maybe that's why?

Thanks John. Forgive my ignorance, but how does jQuery know that
you're calling the toggle() UI effect as opposed to the toggle() core
effect? For example:

// toggle UI
$("p").click(function () {
$("div").toggle("slide", {}, 1000);
});

// toggle core
$("button").click(function () {
$("p").toggle("slow");
});

[jQuery] Re: plugins.jquery.com does not have 1.3.x

Thanks, Ariel. I've also been in touch with Mike about this. 

Mika, it seems 1.3.x appears when you create a new project, but not when you add a release to an existing one. I'm sure Mike will get to the bottom of it and fix it soon. I'll post again here as soon as I see it has been fixed (unless someone else beats me to it).

--Karl

____________
Karl Swedberg




On Jan 31, 2009, at 12:02 PM, Ariel Flesler wrote:


Ping Mike Hostetler about this. I told him about this and he did
indeed added it. Maybe he forgot to add it somewhere else...

--
Ariel Flesler
http://flesler.blogspot.com

On Jan 30, 1:29 pm, Mika Tuupola <tuup...@appelsiini.net> wrote:
When submitting a new plugin or plugin release there is no 1.3.x  
option in the "plugins.jquery.com" pulldown. Can someone add it?

--
Mika Tuupolahttp://www.appelsiini.net/

[jQuery] Re: Click Links in the Nnavigation Bar

Hi Pedram,

I agree with Nic. Especially if you're only dealing with 4 elements, binding directly on them seems like the most sensible solution. 

Are you noticing performance problems? You shouldn't be seeing any, with scripts this basic. In any case, there are a couple selector optimizations you could implement, if necessary. Something like this:

var $navBarLinks = $('#your-nav-bar-id a');

$navBarLinks.click(function() {
  $navBarLinks.removeClass('active');
  $(this).addClass('active');
});

--Karl

____________
Karl Swedberg




On Jan 31, 2009, at 2:36 PM, Pedram wrote:


I'm looking to improve the performance ,  which of these 2 codes has
the best performance.

On Jan 30, 1:04 am, Nic Luciano <adaptive...@gmail.com> wrote:
What exactly are you trying to do, what is the issue? Maybe just preference
here (and I'm also just guessing what you're asking) but I don't see a
reason not to put the events on the elements themselves

$("ul li a").click(function() {
        $(this).parent().parent().find(".active").removeClass("active");
        $(this).addClass("active");
    });

On Fri, Jan 30, 2009 at 3:07 AM, Pedram <pedram...@gmail.com> wrote:

Dear Karl ,
I know You are Expert in these Issues do you have any idea for me
Thanks

On Jan 29, 5:44 pm, Pedram <pedram...@gmail.com> wrote:
Hi Folks ,
  I have some links in my Navigation bar such as below , I Used FIND
in my code , does anyone has any better solution for me ,
  I also used Event Delegation in the system .

<ul>
  <li><a href="#" class="active>a</a></li>
  <li><a href="#">b</a></li>
  <li><a href="#">c</a></li>
  <li><a href="#">d</a></li>
</ul>

  $("ul").bind("click",function(e){
      var clicked=$(e.target);
      $(this).find("a.active").removeClass("active");
      clicked.addClass("active");
  });

[jQuery] $.ajax Feed Aggregator

I was curious if someone could help me manipulate some code. Im still
pretty new to jQuery and this is over my head.

$(function() {

$.ajax({
type: "GET",
url: "http://www.msn.com/rss/alsoonmsn.aspx",
dataType: "xml",
success: function(rss) {
strRSS = "<h4>" + $("/rss/channel/title",rss).text() + "</
h4>";
$("/rss/channel/item/title:lt(5)",rss).each(function(i) {
strRSS += "<li><a href='";
strRSS += $("/rss/channel/item/link:eq(" + i +
")",rss).text();
strRSS += "'>";
strRSS += $(this).text();
strRSS += "</a><br />";
strRSS += ($("/rss/channel/item/description:eq(" + i +
")",rss).text()).substring(0,200) + "...</li>";
});
$("#feed_me").html(strRSS);
}
});

});

Pretty much what im trying to do is have it to where the <li> has
something like this: <li onclick="location.href='storyurlhere';">

Thanks a million.

[jQuery] Re: Click Links in the Nnavigation Bar

I'm looking to improve the performance , which of these 2 codes has
the best performance.

On Jan 30, 1:04 am, Nic Luciano <adaptive...@gmail.com> wrote:
> What exactly are you trying to do, what is the issue? Maybe just preference
> here (and I'm also just guessing what you're asking) but I don't see a
> reason not to put the events on the elements themselves
>
> $("ul li a").click(function() {
>         $(this).parent().parent().find(".active").removeClass("active");
>         $(this).addClass("active");
>     });
>
> On Fri, Jan 30, 2009 at 3:07 AM, Pedram <pedram...@gmail.com> wrote:
>
> > Dear Karl ,
> > I know You are Expert in these Issues do you have any idea for me
> > Thanks
>
> > On Jan 29, 5:44 pm, Pedram <pedram...@gmail.com> wrote:
> > > Hi Folks ,
> > >   I have some links in my Navigation bar such as below , I Used FIND
> > > in my code , does anyone has any better solution for me ,
> > >   I also used Event Delegation in the system .
>
> > > <ul>
> > >   <li><a href="#" class="active>a</a></li>
> > >   <li><a href="#">b</a></li>
> > >   <li><a href="#">c</a></li>
> > >   <li><a href="#">d</a></li>
> > > </ul>
>
> > >   $("ul").bind("click",function(e){
> > >       var clicked=$(e.target);
> > >       $(this).find("a.active").removeClass("active");
> > >       clicked.addClass("active");
> > >   });

[jQuery] Re: Large images IE ready event

Hi Alex, 

Which version of jQuery are you using? If it's 1.3.1, there was a regression that caused this problem. 

This has been fixed in the svn version. See the bug report here:

http://dev.jquery.com/ticket/3988

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Jan 30, 2009, at 10:19 AM, Alex wrote:


In IE 6 through 8, whenever I use $(document).ready(function(){ });,
it doesn't get triggered if there are still images trying to load. I
use a graphic engine to draw huge graphs and it can take up to 5
seconds parsing the images and the code between the ready event doesnt
get triggered until the images are fully loaded.

It works flawlessly in Firefox. Only IE6-8 has this problem. Is there
something I am missing in my code? Is this a known issue with IE?

Thanks.

[jQuery] Need help validating a dropdown list

Hi all,

I'm using the fantastic validation plugin (from bassistance.de) and
have run into a little glitch. I understand the plugin doesn't
currently handle dropdowns, but I found a possible solution on True
Tribe (http://www.thetruetribe.com/jquery/1-jquery-api/68-jquery-
plugin-validation-with-ajax
). I can't get it to work, though. I'm
pretty new to jQuery and am probably making an obvious error I can't
see. Here's my jQuery code:

$(document).ready(function(){
$("#reg_form").validate({

onfocusout: false,
onkeyup: false,
onclick: false,

rules: {
gender: {required:true},
spouse_attend: {required:true}
}

});

$validator.addMethod(
"select_class",
function(value, element) {
return this.optional(element) || ( value.indexOf("--Select One--") ==
-1);
},
"Please select a class.");

});

And here's the dropdown I'm trying to validate.

<select name='class_date' id='class_date' class='select_class'>
<option value='--Select One--'>--Select One--</option>
<option>Feb 16 - 20, 2009</option>
<option>Mar 16 - 20, 2009</option>
<option>Apr 13 - 17, 2009</option>
<option>May 11 - 15, 2009</option>
</select>

What am I doing wrong? Or is there another way to do this?

Thanks in advance!

Kathryn

[jQuery] Re: appendingTo a just created element

Hi Nicky,

where do the variables elm, and serial come from?

Your posted code snipped looks ok, and it's working fine if you
populate the elm and serial with meaningful values. (see example:
http://jsbin.com/oxehe/edit)

I guess there is a problem with elm. Are you sure it holds exactly 1
DOM element?
Is serial a unique ID?

by(e)
Stephan


2009/1/31 Nicky <nhajal@gmail.com>:
>
> Ah, very sorry about that mistype, but that is in fact what I am doing
> (just replaced my code wrong when I changed what I have to 'someID')
>
> Here's what I have, exactly:
>
> $('<div/>')
> .attr('id', 'ntww-'+serial)
> .insertBefore(elm);
> $('<p/>')
> .appendTo('#ntww-'+serial);
>
> Sorry about that and thanks for the reply!
>
> -Nicky
>
> On Jan 31, 9:28 am, Stephan Veigl <stephan.ve...@gmail.com> wrote:
>> the selector for an id is #, sou you should use "#someID" instead of
>> "someID" for the appendTo() function.
>>
>> by(e)
>> Stephan
>>
>> 2009/1/31 Nicky <nha...@gmail.com>:
>>
>>
>>
>> > Hi All,
>>
>> > I'm fairly new to jQuery so I apologize if I'm missing something
>> > straightforward but doing this:
>>
>> > $('<div/>')
>> > .attr('id', 'someID')
>> > .insertBefore(elm);
>> > $('<p/>')
>> > .appendTo('someID');
>>
>> > Seems to give me errors. If I change "appendTo('someID')" to a
>> > different element's ID, it works fine, so I get the feeling that it
>> > can't append to the just-created div. Is this not the case? What
>> > should I do to move forward?
>>
>> > Thanks for the help!

[jQuery] getElementById with ajax

This will be my first application with using jQuery library, so I
might not make sense. I will try to explain what I want to do as
simple as possible.

I have two web pages, index.asp, ship.asp.

index.asp: I have a form with ReceiverPostalCode and ReceiverCountry
inputs.
ship.asp: this is where I submit form inputs from index.asp to receive
shipping quotes.

For example, I get quotes at
ship.asp?ShippingPostalCode=02116&ShippingCountry=US

When customer enters ReceiverPostalCode and ReceiverCountry on
index.asp, I want quotes immediately appear in index.asp. How do I do
this basing my codes on jQuery?

[jQuery] Re: insertAfter return value

Yeah, that's expected - you would need to bind the event handler,
attributes, etc. etc. before you run insertAfter. We might want to
look at making that not the case, at some point, but that would
require an API change.

If you're interested in that, you should file a feature ticket here:
http://dev.query.com/newticket

--John

2009/1/29 Dave Brondsema <dave@brondsema.net>:
>
> If I run $('<span>foo</span>').insertAfter('p') and there are for
> example 2 <p>s, it will insert 2 <span>s. But the return value of the
> code is only the first <span>. So if I want to chain an onclick
> handler after that, it only gets bound to the first <span> not all the
> inserted ones. Is that normal? Is there a better way to do it?
>
> See example at http://jsbin.com/eyuwo and look at the firebug console
> output.
>

[jQuery] Re: slideViewer v1.1 + Tooltip v1.3 + jQuery v1.3.1 = tooltips fail

Jörn,

Thanks for the response, and I agree that tooltips by themselves work
fine with your plugin.

I have the latest version in use, but for some reason it still does
not work. (The proper div with id="tooltip" gets inserted, but nothing
happens on hover)
http://jquery.oniegirl.com/svw/broken.htm

(Quick note: I had to modify the slideViewer plugin, line 54 from
"Tooltip" to "tooltip" for the div to get inserted properly)

Maybe something else is case-sensitive somewhere in there?


Or perhaps it's the way I'm calling it? Here's what I'm using:

$(window).bind("load", function() {
$("div#gallery").slideView({
easeFunc: "easeOutBounce",
easeTime: 500,
toolTip: true
});
});

Does the load order matter? Mine is:
1. jQuery 1.3.1
2. easing plugin
3. Tooltip 1.3
4. slideViewer 1.1


Matt


On Jan 31, 12:10 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
wrote:
> Could you give the latest revision a try? It seems to work fine with
> core 1.3:http://jqueryjs.googlecode.com/svn/trunk/plugins/tooltip/
>
> Jörn
>
> On Thu, Jan 29, 2009 at 4:52 PM, Matt <matthew.c.wag...@gmail.com> wrote:
>
> > I have a little demo up to check out.
>
> >http://jquery.oniegirl.com/svw/
>
> > (the pictures are not mine, just re-using one of the demos from the
> > slideviewer site)
>
> > 2 versions:
> > ----------------
> > the first works (using jQuery 1.2.6, easing 1.3, OLD tooltip plugin,
> > slideviewer 1.1)
>
> > the second does not (using jQuery 1.3.1, easing 1.3, tooltip 1.3,
> > slideviewer 1.1)
>
> > Can someone help me debug the problem? Thanks a bunch
>
>

[jQuery] Re: slideViewer v1.1 + Tooltip v1.3 + jQuery v1.3.1 = tooltips fail

Could you give the latest revision a try? It seems to work fine with
core 1.3: http://jqueryjs.googlecode.com/svn/trunk/plugins/tooltip/

Jörn

On Thu, Jan 29, 2009 at 4:52 PM, Matt <matthew.c.wagner@gmail.com> wrote:
>
> I have a little demo up to check out.
>
> http://jquery.oniegirl.com/svw/
>
> (the pictures are not mine, just re-using one of the demos from the
> slideviewer site)
>
>
> 2 versions:
> ----------------
> the first works (using jQuery 1.2.6, easing 1.3, OLD tooltip plugin,
> slideviewer 1.1)
>
> the second does not (using jQuery 1.3.1, easing 1.3, tooltip 1.3,
> slideviewer 1.1)
>
>
>
> Can someone help me debug the problem? Thanks a bunch
>

[jQuery] Re: Superfish Dropdown BG Problem

Thanks Joel,

I was the other guy a few days ago.

Does this code snippet go into the superfish.css file???

With regards,
Ron

On Jan 31, 6:08 am, Joel Birch <joeldbi...@gmail.com> wrote:
> Hello,
>
> This is the exact same issue someone else had just the other day, and
> they were also a Joomla user. Your problem is figure out by selecting
> the menu li element using Firebug. The Superfish background rule is
> being overridden by the #pillmenu li li rule which is in the green.css
> file. The reason this rule gets precedence over the Superfish CSS is
> because it uses an id in the selector, which trumps the .sf-menu class
> selector.
>
> Interestingly, 'pillmenu' was the exact same id that was involved with
> the other Joomla user's issue, so I assume it must be part of Joomla's
> templates. Solve your problem by adding the id to your Superfish
> selector in order to increase its 'specificity', like this:
>
> #pillmenu .sf-menu li { background: #BDD2FF url('../images/
> normal_bg.png') repeat-x 0 0; }
>
> Joel Birch.

[jQuery] Re: jquery and minify

You should keep the headers somewhere, preferably close to the code.
Something like this:

/**
* jQuery
*/
(function($){...............});
/**
* Plugin 1
*/
(function($){...............});
/**
* Plugin 2
*/
(function($){...............});

--
Ariel Flesler
http://flesler.blogspot.com

On Jan 29, 10:53 pm, Sam Sherlock <sam.sherl...@gmail.com> wrote:
> Having just seen this sitehttp://www.highpointvillage.co.uk& running it
> through yslow (it got an f 50/100), one way to improve it would be reducing
> the http requests - but:-
>
> Would combining the scripts on a site like this with minify be contrary to
> the license of jQuery?
> could jquery be minifed in a file with the comment header retained at the
> top of combined file?
> or would one have to have a jquery.js file minified with comment header
> intact and combine the plugins?

[jQuery] Re: plugins.jquery.com does not have 1.3.x

Ping Mike Hostetler about this. I told him about this and he did
indeed added it. Maybe he forgot to add it somewhere else...

--
Ariel Flesler
http://flesler.blogspot.com

On Jan 30, 1:29 pm, Mika Tuupola <tuup...@appelsiini.net> wrote:
> When submitting a new plugin or plugin release there is no 1.3.x  
> option in the "plugins.jquery.com" pulldown. Can someone add it?
>
> --
> Mika Tuupolahttp://www.appelsiini.net/

[jQuery] Re: Having a problem with checkboxes

Yes you can use : <input type="checkbox" name="paradigm[]"
value="{$value.ver_id}" />

Just modify your jquery code as well:

var checked_status=this.checked;$("input[name^='paradigm']").each
(function(){
this.checked=checked_status;
});

http://docs.jquery.com/Selectors/attributeStartsWith#attributevalue


On Jan 31, 12:48 am, James <james.gp....@gmail.com> wrote:
> Which version of Jquery are you using?
> From version 1.3 on has the @ in selectors deprecated, so the
> following is not valid anymore:
> $("input[@name=paradigm]")
>
> Just remove the @.
>
> http://docs.jquery.com/Release:jQuery_1.3#Upgrading
>
> On Jan 30, 5:27 am, heohni <heidi.anselstet...@consultingteam.de>
> wrote:
>
> > Hi,
>
> > I am using this:
>
> > <input type="checkbox" name="paradigm" value="{$value.ver_id}" />
>
> > $(document).ready(function(){
> >         $("#paradigm_all").click(function(){
> >                 var checked_status=this.checked;$("input[@name=paradigm]").each
> > (function(){
> >                         this.checked=checked_status;
> >                 });
> >         });
>
> > });
>
> > to check and uncheck a list of articles.
> > Now I want to sumbit the checked articles, but I don't know how to do
> > that.
>
> > I can't use <input type="checkbox" name="paradigm[]"
> > value="{$value.ver_id}" />
> > as then the jquery doesn#t work anymore.
>
> > But how can I transfer all checked Id's to the next page?
> > Any help?
>
> > Thanks a bunch!

[jQuery] Re: Selecting form ID from $(this)

$("#[$.variables.formID]") - that is a plain string, and there is no
need for the brackets. You probably meant to use

$("#"+$.variables.formID).append(...)

But it's much easier to save the current form itself, instead of it's
ID:

$('[id^=credit]').change(function() {
var $self = $(this);
$.ajax({
type: "POST",
url: "/credits/edit",
data: $self.serialize(),
beforeSend: function(){
$self.append("<div>YAY</div>");
},
success: function(html) {
//...
} //make sure you don't have a comma after the last object, syntax
error
})

On Jan 31, 5:32 am, frodosghost <jamesmon...@gmail.com> wrote:
> Howdy Guys,
> A bit of a problem I have been struggling with for a number of hours,
> and some help would go a long way.
>
> Its not really a problem with the $.ajax() function. It is more a
> problem with selecting live variables on the fly. I have multiple
> forms on one page, so selecting that one form to use and update data
> is what I am looking at doing.
>
> $.variables = {}; //Sets up an array so I can call the vars in which
> ever function I'd like to.
>
> $('[id^=credit]').change(function() {
>   $.variables = {formID : $(this).attr('id')}; // Meant to pass the
> id, but passes an object.
>   $.ajax({
>     type: "POST",
>     url: "/credits/edit",
>     data: $(this).serialize(),
>     beforeSend: function(){
>       $("#[$.variables.formID]").append("YAY"); //Just to put
> something in this form id.
>       console.log($( [$.variables.formID] )); // Returns this in the
> console: Object length=1 0=credit1 jquery=1.3.1
>     },
>     success: function(html) {},
>   })
>
> So I have set the variable.formID after the .change function. It
> passes an object, but I am looking at passing the actual id, so that I
> can put some data into that form id...
>
> If I use this $("#[$.variables.formID][0]").append("YAY"); code in the
> first line of the before send (in an effort to get to the [0] in the
> object it passes, it updates all forms on the page with the .append.
> But it only sends the data from that one form.
>
> Because there is a number of forms on this one page, I'd just like to
> be able to select the id for the form, so I can update data in that
> form - At this stage I can get data into any form with an ID, but not
> the form that has been used.
>
> Am I missing something? I could have completely stuffed up how to do
> it. Any tips would be welcome.
>
> Thanks

[jQuery] Re: Using $_POST to transmit large key/pair

&key=pair within the URL will always be GET parameter, no matter what
you do or what you use ($.post, $.get, $.ajax, $.load, etc.)

POST has nothing to do with the URL.


On Jan 31, 2:26 am, Mark Livingstone <namematters...@msn.com> wrote:
> ah, I thought that { key : pair } was just a replacement for
> &key=pair...
>
> On Jan 30, 2:25 pm, Beres Botond <boton...@gmail.com> wrote:
>
> > As shown in the docs (link I gave you), it should work
>
> > $.post("order_send_email.php",
> >        {order_message : order_message}, // {key : variable}
> >        function(data)
> >          {
> >          alert(data);
> >          // do something
> >          });
>
> > On Jan 30, 4:03 pm, Mark Livingstone <namematters...@msn.com> wrote:
>
> > > Thanks, Beres.
>
> > > I am reading this order_message from a DIV. How do I 'POST' it? By
> > > using form?
>
> > > Also, to url encode... do I use "escape(....)"?
>
> > > On Jan 30, 3:08 am, Beres Botond <boton...@gmail.com> wrote:
>
> > > > You want to use POST, but you are sending your data as GET (without
> > > > url encoding).
> > > > So I'm pretty sure it cuts before "#", because # is a non-alphanumeric
> > > > character and you haven't urlencoded your data.
>
> > > > Data in URL  = GET, not POST, even if you are using $.post .
>
> > > >http://docs.jquery.com/Post
>
> > > > So either urlencode your data before putting it in the request or send
> > > > it as POST.
>
> > > > Also I'm not sure how it worked for you on server-side, if you were
> > > > expecting $_POST... I assume you were expecting
> > > > $_REQUEST instead, which is not a good idea in my opinion.
>
> > > > On Jan 30, 8:08 am, Mark Livingstone <namematters...@msn.com> wrote:
>
> > > > > I have the following code:
>
> > > > > $.post(order_send_email.php?order_message='+order_message)
>
> > > > > my 'order_message' is:
>
> > > > > 'Dear '+data['salutation']+" "+data['first_name']+" "+data['last_name']
> > > > > +', \n\nThis is to inform you that your order #'+key+" and payment in
> > > > > the amount of...';
>
> > > > > When using $.POST... the message gets cut before "#". Is there a limit
> > > > > on how much cam be transmitted or am I doing something wrong?
>
> > > > > Thanks.- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -

[jQuery] Re: appendingTo a just created element

Do you use Firebug? First check if the element has been really
inserted to the DOM.

$('<div/>')
.attr('id', 'someID')
.insertBefore(elm);

alert( $('#someID').length );
// console.info( $('#someID').length );

I'm sure if you post a full test case at jsbin.com or somewhere else
on-line your problem will be spotted in no time!

On Jan 31, 12:59 pm, Nicky <nha...@gmail.com> wrote:
> Ah, very sorry about that mistype, but that is in fact what I am doing
> (just replaced my code wrong when I changed what I have to 'someID')
>
> Here's what I have, exactly:
>
>         $('<div/>')
>                 .attr('id', 'ntww-'+serial)
>                 .insertBefore(elm);
>         $('<p/>')
>                 .appendTo('#ntww-'+serial);
>
> Sorry about that and thanks for the reply!
>
> -Nicky
>
> On Jan 31, 9:28 am, Stephan Veigl <stephan.ve...@gmail.com> wrote:
>
> > the selector for an id is #, sou you should use "#someID" instead of
> > "someID" for the appendTo() function.
>
> > by(e)
> > Stephan
>
> > 2009/1/31 Nicky <nha...@gmail.com>:
>
> > > Hi All,
>
> > > I'm fairly new to jQuery so I apologize if I'm missing something
> > > straightforward but doing this:
>
> > > $('<div/>')
> > >        .attr('id', 'someID')
> > >        .insertBefore(elm);
> > > $('<p/>')
> > >        .appendTo('someID');
>
> > > Seems to give me errors. If I change "appendTo('someID')" to a
> > > different element's ID, it works fine, so I get the feeling that it
> > > can't append to the just-created div. Is this not the case? What
> > > should I do to move forward?
>
> > > Thanks for the help!

[jQuery] Re: Triggering a link with no click event

I'm not sure, but I think click() will only fire the events bound with
jQuery itself. RokBox seems to be based on mootools, have you tried
the mootools way?

$('test').fireEvent('click');

Also, are you sure you're not having conflicts between jQuery and
mootools? Which one is using the caret symbol ($)? Best would be to
stick to a single library, as you'll have overlapping functionality
(longer download times) and the possibility of problems like this.

On Jan 31, 5:38 am, Andy789 <e...@abcstudio.com.au> wrote:
> As I can see quite many posts on this subject I wanted to explain why
> I need this. I generate links for RokBox modal window - something like
>
> <a id="test" href="flash/pdfs/test.html" rel="rokbox">test</a>
>
> next, I need to trigger these links from jscript function (from the
> external flash application). I could not figure out the way how to
> call RokBox directly and have to finc out the way how to trigger links
> via jquery or mootools or whatsoever.
>
> Any suggestions?

[jQuery] Re: Superfish

I think the issue is more simple than you though!
This
http://www.stcyril.net/site/templates/rhuk_milkyway/images/normal_bg.png
is missing! And you are missing other images! Example:
mw_menu_normal_bg.png,...

Please go to line 42 in green.css and put a correct path, i tried to
put a correct path with Firebug and it works!
Try to put a absolute URL first...

2009/1/31 bklyn2cali <sean@mediajelly.com>:
>
> Hi,
>
> I'm setting up my first Joomla site and had a request to add drop down
> menus. I located Superfish and installed it. Simple, clean, no
> problems. But wait...
>
> It all works well, except for the fact that there is no background
> image or color on the dropdown items. I cannot seem to address the
> background of the list items. All are ignored in the superfish.css
> file. The odd thing is that the drop shadow shows up if I opt it. And
> the direction arrows work fine too. I don't know why the bg does not.
>
> Here's the code that I'm changing that has no effect:
>
> .sf-menu li {
> background: #BDD2FF; /* this is the superfish default that does not
> appear
> background: url('../images/normal_bg.png') 0 0 repeat-x; /*ths is
> the bg image that does not appear
> }
> .sf-menu li li {
> background: #AABDE6;
> background: url('../images/normal_bg.png') 0 0 repeat-x;
> }
> .sf-menu li li li {
> background: #9AAEDB;
> background: url('../images/normal_bg.png') 0 0 repeat-x;
> }
> .sf-menu li:hover, .sf-menu li.sfHover,
> .sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
> background: #CFDEFF;
> background: url('../images/normal_bg.png') 0 0 repeat-x;
> outline: 0;
> }
>
>
> I've been lost many hours on this one and cannot solve it. Can someone
> take a look and see what I'm doing incorrectly? The site is
> http://www.stcyril.net/site/
>
> Thanks in advance.
>

--
Kurei@UrbanJar.Info
/********************************************
* Người ta thưởng chỉ chú ý đến những kẻ lên như diều gặp gió! Nhưng
hỡi ôi, chỉ có cát, bụi và lông hồng mới là những thứ lên nhanh nhất
*/