Re: [xwiki-users] how to escape quote in velocity for javascript ?
Thank you for your response. I have already used the escapetool but he doesn't seem work : this tool adds one backslash before the quote but the script looks wrong. (onclick=function(\param\,callback); doesn't work) I've read this page : http://www.xwiki.org/xwiki/bin/view/FAQ/HowCanIescapeOutQuotationMarksFromAStringWithVelocity But whithout success ... On Mon, 11 Jun 2012 16:42:43 +0200, Paul Libbrecht p...@hoplahup.net wrote: Le 11 juin 2012 à 16:31, Sergiu Dumitriu a écrit : var userInput = $!escapetool.javascript($request.userInput); Actually... is there a list of such predefined variables? Or... what's the way to list them? With their class. paul ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to escape quote in velocity for javascript ?
On 06/12/2012 02:51 AM, mathieu.canzer...@intech.lu wrote: Thank you for your response. I have already used the escapetool but he doesn't seem work : this tool adds one backslash before the quote but the script looks wrong. (onclick=function(\param\,callback); doesn't work) What's that supposed to do? It doesn't look like semantically correct Javascript in the first place, regardless of quote escaping. Is function here a placeholder for a real function name, or is it really used like this in your code? You shouldn't use onclick, try this instead: http://www.prototypejs.org/api/element/observe I've read this page : http://www.xwiki.org/xwiki/bin/view/FAQ/HowCanIescapeOutQuotationMarksFromAStringWithVelocity But whithout success ... On Mon, 11 Jun 2012 16:42:43 +0200, Paul Libbrecht p...@hoplahup.net wrote: Le 11 juin 2012 à 16:31, Sergiu Dumitriu a écrit : var userInput = $!escapetool.javascript($request.userInput); Actually... is there a list of such predefined variables? Or... what's the way to list them? With their class. paul -- Sergiu Dumitriu http://purl.org/net/sergiu/ ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to escape quote in velocity for javascript ?
Okay i'm going to try your suggestion. Thank you for your help. Mathieu On Tue, 12 Jun 2012 03:13:22 -0400, Sergiu Dumitriu ser...@xwiki.com wrote: On 06/12/2012 02:51 AM, mathieu.canzer...@intech.lu wrote: Thank you for your response. I have already used the escapetool but he doesn't seem work : this tool adds one backslash before the quote but the script looks wrong. (onclick=function(\param\,callback); doesn't work) What's that supposed to do? It doesn't look like semantically correct Javascript in the first place, regardless of quote escaping. Is function here a placeholder for a real function name, or is it really used like this in your code? You shouldn't use onclick, try this instead: http://www.prototypejs.org/api/element/observe I've read this page : http://www.xwiki.org/xwiki/bin/view/FAQ/HowCanIescapeOutQuotationMarksFromAStringWithVelocity But whithout success ... On Mon, 11 Jun 2012 16:42:43 +0200, Paul Libbrecht p...@hoplahup.net wrote: Le 11 juin 2012 à 16:31, Sergiu Dumitriu a écrit : var userInput = $!escapetool.javascript($request.userInput); Actually... is there a list of such predefined variables? Or... what's the way to list them? With their class. paul ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to escape quote in velocity for javascript ?
I don't really understand if your problem is in velocity or pure javascript ? Anyway, in pure javascript you would just have to escape the single and double quotes, something like the following (I did not test it, just found it by googling) : var escapedString = inputValue.replace(/([\\'])/g, \\$1).replace(/\0/g, \\0); BR, Jeremie 2012/6/11 mathieu.canzer...@intech.lu: Hello everybody, I've a simple problem. I've a text input where people can enter some text. After, I want to send that text as a param to a javascript function. However, when user types a quote (simple or double), there is a problem in my javascript syntax. I've tred to add backslash but no effect. Thanks for your help. Mathieu Canzerini. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to escape quote in velocity for javascript ?
On 06/11/2012 08:43 AM, mathieu.canzer...@intech.lu wrote: Hello everybody, I've a simple problem. I've a text input where people can enter some text. After, I want to send that text as a param to a javascript function. However, when user types a quote (simple or double), there is a problem in my javascript syntax. I've tred to add backslash but no effect. var userInput = $!escapetool.javascript($request.userInput); Thanks for your help. Mathieu Canzerini. -- Sergiu Dumitriu http://purl.org/net/sergiu/ ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to escape quote in velocity for javascript ?
I've often used $escapetool.javascript($request.param) maybe that helps? paul Le 11 juin 2012 à 14:43, mathieu.canzer...@intech.lu a écrit : Hello everybody, I've a simple problem. I've a text input where people can enter some text. After, I want to send that text as a param to a javascript function. However, when user types a quote (simple or double), there is a problem in my javascript syntax. I've tred to add backslash but no effect. Thanks for your help. Mathieu Canzerini. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to escape quote in velocity for javascript ?
Le 11 juin 2012 à 16:31, Sergiu Dumitriu a écrit : var userInput = $!escapetool.javascript($request.userInput); Actually... is there a list of such predefined variables? Or... what's the way to list them? With their class. paul ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] how to escape quote in velocity for javascript ?
On Mon, Jun 11, 2012 at 5:42 PM, Paul Libbrecht p...@hoplahup.net wrote: Le 11 juin 2012 à 16:31, Sergiu Dumitriu a écrit : var userInput = $!escapetool.javascript($request.userInput); Actually... is there a list of such predefined variables? Or... what's the way to list them? With their class. You mean http://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity+Module#HVelocityTools ? Hope this helps, Marius paul ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users