[Lift] Re: url encoded javascript
If you use jQuery it's even simpler: jQuery.getScript(http://foo.com/js/markCurrent.js?marklet=1234http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) On Wed, Mar 4, 2009 at 2:21 AM, Lee Mighdoll leemighd...@gmail.com wrote: Ah, sorry to be so cryptic. The idea is to create a link containing a 'javascript:' url that the user can then drag to the browser's bookmark bar. I had something like this: a href=javascript:(function(){var%20e=document.createElement('script');e.type='text/javascript';e.setAttribute('src',' http://foo.com/js/markCurrent.js?marklet=1234');document.getElementsByTagName('head')[0].appendChild(e)})(http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) Bookmarklet /a But the script is a little tricky to read and edit in that form, so I wanted to programmatically convert it from a more readable version. I figured out how to run mvn yui-compressor to remove comments from the script. Then I read the compressed version of the script file in the snippet code. If I were to polish it further, I'd next find a java version of encodeUriComponent... but it's probably enough for now. Lee On Sun, Mar 1, 2009 at 2:48 PM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, If you want to include a JavaScript script on the page, the easiest mechanism is: import net.liftweb.http._ import js._ import JsCmds._ import JE._ Script(JsRaw(a String containing the raw script)) This will create a script tag on the page and put a // ![CDATA[ in it followed by your script followed by //]] and the closing /script tag. If this is not what you were looking to do, please let us know. Thanks, David On Thu, Feb 26, 2009 at 11:28 AM, Lee Mighdoll leemighd...@gmail.comwrote: I'd like to make a bookmarklet snippet. So I want to take a short javascript file, encode it as url, and then include it in a snippet. Any suggestions? Not sure whether to solve this with mvn or lift -- I'm new to both. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: url encoded javascript
That would be nice, and would work on the page containing the link, but not for a bookmarklet. With bookmarklets, the user drags the link to the browser bookmark menu or bookmark bar. Then the bookmarklet runs in the context of whatever page they're currently looking at. Lee On Wed, Mar 4, 2009 at 1:38 AM, Viktor Klang viktor.kl...@gmail.com wrote: If you use jQuery it's even simpler: jQuery.getScript(http://foo.com/js/markCurrent.js?marklet=1234http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) On Wed, Mar 4, 2009 at 2:21 AM, Lee Mighdoll leemighd...@gmail.comwrote: Ah, sorry to be so cryptic. The idea is to create a link containing a 'javascript:' url that the user can then drag to the browser's bookmark bar. I had something like this: a href=javascript:(function(){var%20e=document.createElement('script');e.type='text/javascript';e.setAttribute('src',' http://foo.com/js/markCurrent.js?marklet=1234');document.getElementsByTagName('head')[0].appendChild(e)})(http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) Bookmarklet /a But the script is a little tricky to read and edit in that form, so I wanted to programmatically convert it from a more readable version. I figured out how to run mvn yui-compressor to remove comments from the script. Then I read the compressed version of the script file in the snippet code. If I were to polish it further, I'd next find a java version of encodeUriComponent... but it's probably enough for now. Lee On Sun, Mar 1, 2009 at 2:48 PM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, If you want to include a JavaScript script on the page, the easiest mechanism is: import net.liftweb.http._ import js._ import JsCmds._ import JE._ Script(JsRaw(a String containing the raw script)) This will create a script tag on the page and put a // ![CDATA[ in it followed by your script followed by //]] and the closing /script tag. If this is not what you were looking to do, please let us know. Thanks, David On Thu, Feb 26, 2009 at 11:28 AM, Lee Mighdoll leemighd...@gmail.comwrote: I'd like to make a bookmarklet snippet. So I want to take a short javascript file, encode it as url, and then include it in a snippet. Any suggestions? Not sure whether to solve this with mvn or lift -- I'm new to both. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: url encoded javascript
thx - I'll keep an eye out for that. I think IE had a max url length of 2K or so, but I'll watch our for maximum attribute lengths as well. The basic idea is to use the bookmarklet to load and insert a larger script -- so hopefully it can stay small. Lee On Wed, Mar 4, 2009 at 10:37 AM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, Be careful. Different browsers have different maximum attribute lengths and, at least in the case of Safari, if the maximum length is exceeded, Safari will silently discard the attribute. Thanks, David On Wed, Mar 4, 2009 at 10:29 AM, Lee Mighdoll leemighd...@gmail.comwrote: That would be nice, and would work on the page containing the link, but not for a bookmarklet. With bookmarklets, the user drags the link to the browser bookmark menu or bookmark bar. Then the bookmarklet runs in the context of whatever page they're currently looking at. Lee On Wed, Mar 4, 2009 at 1:38 AM, Viktor Klang viktor.kl...@gmail.comwrote: If you use jQuery it's even simpler: jQuery.getScript(http://foo.com/js/markCurrent.js?marklet=1234http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) On Wed, Mar 4, 2009 at 2:21 AM, Lee Mighdoll leemighd...@gmail.comwrote: Ah, sorry to be so cryptic. The idea is to create a link containing a 'javascript:' url that the user can then drag to the browser's bookmark bar. I had something like this: a href=javascript:(function(){var%20e=document.createElement('script');e.type='text/javascript';e.setAttribute('src',' http://foo.com/js/markCurrent.js?marklet=1234');document.getElementsByTagName('head')[0].appendChild(e)})(http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) Bookmarklet /a But the script is a little tricky to read and edit in that form, so I wanted to programmatically convert it from a more readable version. I figured out how to run mvn yui-compressor to remove comments from the script. Then I read the compressed version of the script file in the snippet code. If I were to polish it further, I'd next find a java version of encodeUriComponent... but it's probably enough for now. Lee On Sun, Mar 1, 2009 at 2:48 PM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, If you want to include a JavaScript script on the page, the easiest mechanism is: import net.liftweb.http._ import js._ import JsCmds._ import JE._ Script(JsRaw(a String containing the raw script)) This will create a script tag on the page and put a // ![CDATA[ in it followed by your script followed by //]] and the closing /script tag. If this is not what you were looking to do, please let us know. Thanks, David On Thu, Feb 26, 2009 at 11:28 AM, Lee Mighdoll leemighd...@gmail.comwrote: I'd like to make a bookmarklet snippet. So I want to take a short javascript file, encode it as url, and then include it in a snippet. Any suggestions? Not sure whether to solve this with mvn or lift -- I'm new to both. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Viktor Klang Senior Systems Analyst -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: url encoded javascript
On Wed, Mar 4, 2009 at 11:09 AM, Lee Mighdoll leemighd...@gmail.com wrote: thx - I'll keep an eye out for that. I think IE had a max url length of 2K or so, but I'll watch our for maximum attribute lengths as well. The basic idea is to use the bookmarklet to load and insert a larger script -- so hopefully it can stay small. Perhaps the bookmarklet could be kind of like a TinyURL... a durable, unique URL that points back to your server. When the user clicks on the link, your server can serve up as much as it needs to. Lee On Wed, Mar 4, 2009 at 10:37 AM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, Be careful. Different browsers have different maximum attribute lengths and, at least in the case of Safari, if the maximum length is exceeded, Safari will silently discard the attribute. Thanks, David On Wed, Mar 4, 2009 at 10:29 AM, Lee Mighdoll leemighd...@gmail.comwrote: That would be nice, and would work on the page containing the link, but not for a bookmarklet. With bookmarklets, the user drags the link to the browser bookmark menu or bookmark bar. Then the bookmarklet runs in the context of whatever page they're currently looking at. Lee On Wed, Mar 4, 2009 at 1:38 AM, Viktor Klang viktor.kl...@gmail.comwrote: If you use jQuery it's even simpler: jQuery.getScript(http://foo.com/js/markCurrent.js?marklet=1234http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) On Wed, Mar 4, 2009 at 2:21 AM, Lee Mighdoll leemighd...@gmail.comwrote: Ah, sorry to be so cryptic. The idea is to create a link containing a 'javascript:' url that the user can then drag to the browser's bookmark bar. I had something like this: a href=javascript:(function(){var%20e=document.createElement('script');e.type='text/javascript';e.setAttribute('src',' http://foo.com/js/markCurrent.js?marklet=1234');document.getElementsByTagName('head')[0].appendChild(e)})(http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) Bookmarklet /a But the script is a little tricky to read and edit in that form, so I wanted to programmatically convert it from a more readable version. I figured out how to run mvn yui-compressor to remove comments from the script. Then I read the compressed version of the script file in the snippet code. If I were to polish it further, I'd next find a java version of encodeUriComponent... but it's probably enough for now. Lee On Sun, Mar 1, 2009 at 2:48 PM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, If you want to include a JavaScript script on the page, the easiest mechanism is: import net.liftweb.http._ import js._ import JsCmds._ import JE._ Script(JsRaw(a String containing the raw script)) This will create a script tag on the page and put a // ![CDATA[ in it followed by your script followed by //]] and the closing /script tag. If this is not what you were looking to do, please let us know. Thanks, David On Thu, Feb 26, 2009 at 11:28 AM, Lee Mighdoll leemighd...@gmail.com wrote: I'd like to make a bookmarklet snippet. So I want to take a short javascript file, encode it as url, and then include it in a snippet. Any suggestions? Not sure whether to solve this with mvn or lift -- I'm new to both. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Viktor Klang Senior Systems Analyst -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: url encoded javascript
That's basically what the link above does -- hard to read in compressed form. :-). The server sends an arbitrarily script that's inserted and executed in the document that the user is currently viewing. The inserted script does the real work. The marklet parameter is issued per user, for security/manageability. And the server issued script is inserted into the head not the body to handle frameset documents. I suppose I could combine the requested script and marklet parameter into a bitly url, but I'm not sure it'd save much. The script insertion code needs to remain as part of the url so the browser will execute it without navigating to a new page. Lee On Wed, Mar 4, 2009 at 11:24 AM, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Mar 4, 2009 at 11:09 AM, Lee Mighdoll leemighd...@gmail.comwrote: thx - I'll keep an eye out for that. I think IE had a max url length of 2K or so, but I'll watch our for maximum attribute lengths as well. The basic idea is to use the bookmarklet to load and insert a larger script -- so hopefully it can stay small. Perhaps the bookmarklet could be kind of like a TinyURL... a durable, unique URL that points back to your server. When the user clicks on the link, your server can serve up as much as it needs to. Lee On Wed, Mar 4, 2009 at 10:37 AM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, Be careful. Different browsers have different maximum attribute lengths and, at least in the case of Safari, if the maximum length is exceeded, Safari will silently discard the attribute. Thanks, David On Wed, Mar 4, 2009 at 10:29 AM, Lee Mighdoll leemighd...@gmail.comwrote: That would be nice, and would work on the page containing the link, but not for a bookmarklet. With bookmarklets, the user drags the link to the browser bookmark menu or bookmark bar. Then the bookmarklet runs in the context of whatever page they're currently looking at. Lee On Wed, Mar 4, 2009 at 1:38 AM, Viktor Klang viktor.kl...@gmail.comwrote: If you use jQuery it's even simpler: jQuery.getScript(http://foo.com/js/markCurrent.js?marklet=1234http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) On Wed, Mar 4, 2009 at 2:21 AM, Lee Mighdoll leemighd...@gmail.comwrote: Ah, sorry to be so cryptic. The idea is to create a link containing a 'javascript:' url that the user can then drag to the browser's bookmark bar. I had something like this: a href=javascript:(function(){var%20e=document.createElement('script');e.type='text/javascript';e.setAttribute('src',' http://foo.com/js/markCurrent.js?marklet=1234');document.getElementsByTagName('head')[0].appendChild(e)})(http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) Bookmarklet /a But the script is a little tricky to read and edit in that form, so I wanted to programmatically convert it from a more readable version. I figured out how to run mvn yui-compressor to remove comments from the script. Then I read the compressed version of the script file in the snippet code. If I were to polish it further, I'd next find a java version of encodeUriComponent... but it's probably enough for now. Lee On Sun, Mar 1, 2009 at 2:48 PM, David Pollak feeder.of.the.be...@gmail.com wrote: Lee, If you want to include a JavaScript script on the page, the easiest mechanism is: import net.liftweb.http._ import js._ import JsCmds._ import JE._ Script(JsRaw(a String containing the raw script)) This will create a script tag on the page and put a // ![CDATA[ in it followed by your script followed by //]] and the closing /script tag. If this is not what you were looking to do, please let us know. Thanks, David On Thu, Feb 26, 2009 at 11:28 AM, Lee Mighdoll leemighd...@gmail.com wrote: I'd like to make a bookmarklet snippet. So I want to take a short javascript file, encode it as url, and then include it in a snippet. Any suggestions? Not sure whether to solve this with mvn or lift -- I'm new to both. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Viktor Klang Senior Systems Analyst -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To
[Lift] Re: url encoded javascript
Ah, sorry to be so cryptic. The idea is to create a link containing a 'javascript:' url that the user can then drag to the browser's bookmark bar. I had something like this: a href=javascript:(function(){var%20e=document.createElement('script');e.type='text/javascript';e.setAttribute('src',' http://foo.com/js/markCurrent.js?marklet=1234');document.getElementsByTagName('head')[0].appendChild(e)})(http://foo.com/js/markCurrent.js?marklet=1234%27%29;document.getElementsByTagName%28%27head%27%29%5B0%5D.appendChild%28e%29%7D%29%28 ) Bookmarklet /a But the script is a little tricky to read and edit in that form, so I wanted to programmatically convert it from a more readable version. I figured out how to run mvn yui-compressor to remove comments from the script. Then I read the compressed version of the script file in the snippet code. If I were to polish it further, I'd next find a java version of encodeUriComponent... but it's probably enough for now. Lee On Sun, Mar 1, 2009 at 2:48 PM, David Pollak feeder.of.the.be...@gmail.comwrote: Lee, If you want to include a JavaScript script on the page, the easiest mechanism is: import net.liftweb.http._ import js._ import JsCmds._ import JE._ Script(JsRaw(a String containing the raw script)) This will create a script tag on the page and put a // ![CDATA[ in it followed by your script followed by //]] and the closing /script tag. If this is not what you were looking to do, please let us know. Thanks, David On Thu, Feb 26, 2009 at 11:28 AM, Lee Mighdoll leemighd...@gmail.comwrote: I'd like to make a bookmarklet snippet. So I want to take a short javascript file, encode it as url, and then include it in a snippet. Any suggestions? Not sure whether to solve this with mvn or lift -- I'm new to both. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: url encoded javascript
Lee, If you want to include a JavaScript script on the page, the easiest mechanism is: import net.liftweb.http._ import js._ import JsCmds._ import JE._ Script(JsRaw(a String containing the raw script)) This will create a script tag on the page and put a // ![CDATA[ in it followed by your script followed by //]] and the closing /script tag. If this is not what you were looking to do, please let us know. Thanks, David On Thu, Feb 26, 2009 at 11:28 AM, Lee Mighdoll leemighd...@gmail.comwrote: I'd like to make a bookmarklet snippet. So I want to take a short javascript file, encode it as url, and then include it in a snippet. Any suggestions? Not sure whether to solve this with mvn or lift -- I'm new to both. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---