Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[question] decode function for gmnotes field on graphic?

For gmnotes on a graphic, I am seeing "this%20is%20a%20test" when log(graphic.get('gmnotes')). This looks to me like URI encoding.  IIs there a decode function available on the object, maybe as a utility?  Im not looking to use GM as a datastore, just want to pretty print the contents to chat as a gm whisper.
fyi, decodeURIComponent() does work for simple encoded strings, but errors out with more advanced encodings.
There is indeed a method for decoding URI, built into JavaScript. You're going to want to do something like var foo = log(graphic.get('gmnotes') decodeURI(foo) This is as opposed to decodeURIComponent(), of course.
I say this, but after testing, that actually doesn't work; please, disregard that. decodeURIComponent() is the only thing that properly, well, decodes, but even that fails under intense scrutiny.
1374506523
Alex L.
Pro
Sheet Author
This is from the start of the API when i used to store stuff in the notes (before the state object was added): jsonStr = decodeURIComponent(jsonStr); // Removes URI encoding. jsonStr = jsonStr.replace(/<[^>]+>/ig,""); // Removes HTML.