Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

ItalicSquirrel posted:

Is there an easy way to do this without creating a whole WYSIWYG editor?

You shouldn't need to create your own WYSIWYG editor. The easiest approach might be to use something like TinyMCE, and just set it up so that the toolbar only includes bold, along with a tag whitelist that also only permits bold to be used.

Adbot
ADBOT LOVES YOU

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Lumpy posted:

What Avenging Dentist said, and here's some good reading on this stuff: http://javascript.crockford.com/private.html

That's a nice link (as much as that stuff looks like a hack than a programming "convention", it's cool that that stuff is possible).

On that note, are there any good reference books that examine JavaScript outside the context of web development? JS has some interesting and powerful capabilities on its own as a language (especially in the latest versions) and I'd love to read a volume on advanced techniques like the one above. (This was spawned by my using JavaScript as part of the Eclipse BIRT reporting engine in order to transform data in reports I'm working with.)

Unfortunately I've never seen such a book -- everything published about JavaScript seems to focus on "here's how you make your web page to wacky things!!!"

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Mercator posted:

Actionscript :rimshot:.

There's always Rhino.

Err, I think you misread my question. I'm not looking for a JS interpreter (in fact BIRT comes with Rhino for doing its reports), I'm looking for a comprehensive reference that talks about advanced JavaScript feature more in terms of a programming language in its own right and less as a web development add-on.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

SuckerPunched posted:

Douglas Crockford's books are pretty good for this. His latest, java script: The Good Parts is a great resource and is probably along the lines of what you're looking for. Take a look through the Table of Contents.

Awesome, that's exactly the kind of reference I was looking for (and it looks fairly recent which is probably why I never came across it before). Thanks!

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Kekekela posted:

JSLint gives me a "Bad escapement" message on the following line, I'm guessing its something with that which follows the backslash but I suck at regex and can't get it cleaned up, halp:

code:
var regex = new RegExp("(?=\.(xls|xlsx))");

People have explained how to use the regex /.../ syntax to fix this, but let me explain why it's happening real quick. What you're passing into the RegExp constructor isn't a regex, but rather a regular old string that represents a regex. So, you have to follow character escaping rules inside that string, and "\." isn't a valid escape sequence. You would have to say "\\." to get the correct result.

That's why using the /.../ sequence is better, because you're entering the regex verbatim instead of encoding it as a string, so the escaping rules don't apply and you can avoid the double-backslash nonsense that can get really messy.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Are there any good JavaScript + canvas/SVG/whatever libraries out there that will let me draw interactive graphs? The graph-theoretical kind with nodes and edges, not charts. Basically I'd like to be able to let a user create finite automata diagrams and then be able to do things to them on the backend, so being able to label nodes/edges, and distinguish between different types of nodes, would be a necessity.

Adbot
ADBOT LOVES YOU

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

almostkorean posted:

OK, so I'm making a custom site using the Google Data API, but I'm having trouble getting this HTML stuff right. What I'm trying to do is make a blockquote that calls my function calcRoute("string") where string is an address. My code looks like this:

code:
      newdiv.innerHTML = "<blockquote><div onClick=calcRoute( \" " + 
			postalAddress + " \"); hideContacts(); > " +
			 contactEntry.getTitle().getText() +
			 "</div></blockquote>";

You're missing a quote after the equals sign on the onClick attribute (and the corresponding one after the "hideContacts();" call to close it off). So your HTML string will look something like this:

code:
<blockquote><div onClick=calcRoute(" 1201 S. Main St. Ann Arbor...
So each of those address parts is equivalent to an attribute with an empty value.

You'd be better off using single quotes to surround the address in your calcRoute call, making sure to escape any single quotes that might already be in the address. Something like this should work:

code:
      newdiv.innerHTML = "<blockquote><div onClick=\"calcRoute('" + 
				s.replace(/'/,'\\\'') + "'); hideContacts();\"> " +
			 contactEntry.getTitle().getText() +
			 "</div></blockquote>";
Fake edit: In fact, that will only deal with single quotes properly inside the address string. If you have the possibility of double quotes in the address string, you'll need to escape those too.


vvv Duh, yes, do what Nigglypuff says. I was focusing too much on the exact bug you posted instead of realizing a much better way of doing it.

Flobbster fucked around with this message at 23:22 on Mar 23, 2010

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply