Quote generator - could use some help [Solved]

Quote generator - could use some help [Solved]
0

#1

http://www.davidalley.net/projects/quotes/

My tweet function truncates the tweet whenever it encounters a semicolon or a quotation mark (either single quote or double quote). Colons and periods have no effect. I use the ‘encodeURI’ function, but that doesn’t help. Can anyone point me to a helpful resource?

Also, I had to use a Chrome extension to enable cross-origin resource sharing for the quote API to work correctly. Is this normal?


#2

You add unencoded quote marks to the href when building it. Might be worth looking into. Also, encodeURIComponent() might be better, because you are encoding an URI component :wink:

As for the cross-origin problems, it is a little strange. You are using jsonp to get data from the API, so that’s one thing that should sidestep the issue right here. And when I view your page, I see the quotes all right, and I don’t have any special extensions installed.


#3

Just an idea here. Before you inject the quote into the html link, you could try to modify the quote content somehow and inject backslashes to escape the semicolon/quotation mark.

There are a number ways you could do this, but I’ll leave it up to you to decide.

Slightly off topic, but I like your overall design.


#4

The problem was that the quote API was generating ‘curly’ quotes which caused errors in the URL for the Twitter API. I couldn’t find anything to automagically convert them so I brute-force converted the curly quotes to straight quotes using some Regex.

I also added some animation to the quote button and copied in some Twitter-supplied JS code to implement the tweet in a pop-up window instead of a new tab.

Thanks for the suggestions. They were really helpful.

http://www.davidalley.net/projects/quotes/


#5

I saw something with propetie cache: false provided in ajax perimeter object to polyfill cors…