From bibiko@eva.mpg.de Thu Sep 25 10:05:08 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 12:04:53 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5854716710932818938==" --===============5854716710932818938== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, up to now it is not possible to use the JavaScript functions alert() and confirm() within TM's HTML output window. But there is a solution (unfortunately this does not work for the HTML preview :( ). The only thing I do is to write a kind of wrapper for these functions by using TextMate.system('"$DIALOG" -e ...'). The try block will be only executed if the code will be showed up in TM HTML output window. If you put these lines into your HTML code the page will work within a normal browser as well as in TM's HTML output window. Attached is a demo command. Simply press the buttons ;) BTW With this approach I can prompt JavaScript errors by using simply "alert(err)" inside of TM ;) --Hans --===============5854716710932818938== Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="JSAlertAndConfirm.tmCommand" MIME-Version: 1.0 PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBV QkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20v RFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4K CTxrZXk+YmVmb3JlUnVubmluZ0NvbW1hbmQ8L2tleT4KCTxzdHJpbmc+bm9wPC9zdHJpbmc+Cgk8 a2V5PmJ1bmRsZVVVSUQ8L2tleT4KCTxzdHJpbmc+M0NDMUE5ODQtRUY5My00MDExLUFEREMtRkUy RTEwQzZGQjIzPC9zdHJpbmc+Cgk8a2V5PmNvbW1hbmQ8L2tleT4KCTxzdHJpbmc+Y2F0Jmx0OyZs dDstSFRNTAombHQ7aHRtbCZndDsK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Z3Q7CiZsdDtib2R5Jmd0OwogICAgJmx0O2J1dHRvbiBv bmNsaWNrPSJhbGVydCgnSGVsbG8nKSImZ3Q7QUxFUlQmbHQ7L2J1dHRvbiZndDsmbHQ7YnImZ3Q7 CiAgICAmbHQ7YnV0dG9uIG9uY2xpY2s9ImRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCdyZXMnKS5p bm5lckhUTUw9J2NvbmZpcm0gcmVzdWx0OiAnK2NvbmZpcm0oJ0hlbGxvJykiJmd0O0NPTkZJUk0m bHQ7L2J1dHRvbiZndDsmbHQ7YnImZ3Q7CiAgICAmbHQ7YnV0dG9uIG9uY2xpY2s9ImRvY3VtZW50 LmdldEVsZW1lbnRCeUlkKCdyZXMnKS5pbm5lckhUTUw9J3Byb21wdCByZXN1bHQ6ICcrcHJvbXB0 KCdIZWxsbycpIiZndDtQUk9NUFQmbHQ7L2J1dHRvbiZndDsmbHQ7YnImZ3Q7Jmx0O2JyJmd0Owog ICAgJmx0O2RpdiBpZD0icmVzIiZndDsmbHQ7L2RpdiZndDsKJmx0Oy9ib2R5Jmd0OwombHQ7L2h0 bWwmZ3Q7CkhUTUw8L3N0cmluZz4KCTxrZXk+aW5wdXQ8L2tleT4KCTxzdHJpbmc+bm9uZTwvc3Ry aW5nPgoJPGtleT5uYW1lPC9rZXk+Cgk8c3RyaW5nPkpTQWxlcnRBbmRDb25maXJtPC9zdHJpbmc+ Cgk8a2V5Pm91dHB1dDwva2V5PgoJPHN0cmluZz5zaG93QXNIVE1MPC9zdHJpbmc+Cgk8a2V5PnV1 aWQ8L2tleT4KCTxzdHJpbmc+RDdCMjVBNDMtMTlBQi00ODZELTgwNDMtMTQ5RDhGMUFGQUQ5PC9z dHJpbmc+CjwvZGljdD4KPC9wbGlzdD4K --===============5854716710932818938==-- From bibiko@eva.mpg.de Thu Sep 25 10:29:28 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 12:29:20 +0200 Message-ID: <17C1A837-1D9E-483F-9395-2019C350EFFA@eva.mpg.de> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4680832021583838097==" --===============4680832021583838097== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit > I do not know if TM 2.0 supports this, but this could be sent by TM automatically if an user will show up something as HTMLoutput (?) --Hans --===============4680832021583838097==-- From tm-alex@rosiba.com Thu Sep 25 10:46:10 2008 From: Alex Ross To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 12:46:04 +0200 Message-ID: In-Reply-To: <17C1A837-1D9E-483F-9395-2019C350EFFA@eva.mpg.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1707965141923116652==" --===============1707965141923116652== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On Sep 25, 2008, at 12:29 PM, Hans-Jörg Bibiko wrote: >> > > I do not know if TM 2.0 supports this, but this could be sent by TM > automatically if an user will show up something as HTMLoutput (?) at the very least we can add it to the HTMLOutput.show command and web_preview. This would take care of 99% of the cases. For other commands, they can do without. —Alex --===============1707965141923116652==-- From bibiko@eva.mpg.de Thu Sep 25 11:07:26 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 13:07:21 +0200 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4941657954026354845==" --===============4941657954026354845== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On 25.09.2008, at 12:46, Alex Ross wrote: > > On Sep 25, 2008, at 12:29 PM, Hans-Jörg Bibiko wrote: > >>> >> >> I do not know if TM 2.0 supports this, but this could be sent by TM >> automatically if an user will show up something as HTMLoutput (?) > > at the very least we can add it to the HTMLOutput.show command and > web_preview. This would take care of 99% of the cases. For other > commands, they can do without. Well, I would say 97% because I use these functions rarely but it would be a step into the right direction ;) --Hans --===============4941657954026354845==-- From tm-alex@rosiba.com Thu Sep 25 11:17:50 2008 From: Alex Ross To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 13:17:47 +0200 Message-ID: <3DB52D80-F00E-4572-97F6-4AF139DDAD3F@rosiba.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1743150892257968450==" --===============1743150892257968450== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On Sep 25, 2008, at 1:07 PM, Hans-Jörg Bibiko wrote: > > On 25.09.2008, at 12:46, Alex Ross wrote: > >> >> On Sep 25, 2008, at 12:29 PM, Hans-Jörg Bibiko wrote: >> >>>> >>> >>> I do not know if TM 2.0 supports this, but this could be sent by TM >>> automatically if an user will show up something as HTMLoutput (?) >> >> at the very least we can add it to the HTMLOutput.show command and >> web_preview. This would take care of 99% of the cases. For other >> commands, they can do without. > Well, I would say 97% because I use these functions rarely but it > would be a step into the right direction ;) If you are dumping anything to the html output window, then you should be using HTMLOutput.show or at least web_preview… :) —Alex --===============1743150892257968450==-- From bibiko@eva.mpg.de Thu Sep 25 11:36:42 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 13:36:37 +0200 Message-ID: In-Reply-To: <3DB52D80-F00E-4572-97F6-4AF139DDAD3F@rosiba.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3321924960811873692==" --===============3321924960811873692== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On 25.09.2008, at 13:17, Alex Ross wrote: >>> at the very least we can add it to the HTMLOutput.show command and >>> web_preview. This would take care of 99% of the cases. For other >>> commands, they can do without. >> Well, I would say 97% because I use these functions rarely but it >> would be a step into the right direction ;) > > If you are dumping anything to the html output window, then you should > be using HTMLOutput.show or at least web_preview… :) Yes :) But sometimes I want to have a plain HTML window without the TextMate banner. Maybe one could provide an option in HTMLOutput.show à la HTMLOutput.show(:title => "My Title", :no_banner) --Hans --===============3321924960811873692==-- From tm-alex@rosiba.com Thu Sep 25 12:19:08 2008 From: Alex Ross To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 14:19:05 +0200 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3470042092187665093==" --===============3470042092187665093== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On Sep 25, 2008, at 1:36 PM, Hans-Jörg Bibiko wrote: >>>> at the very least we can add it to the HTMLOutput.show command and >>>> web_preview. This would take care of 99% of the cases. For other >>>> commands, they can do without. >>> Well, I would say 97% because I use these functions rarely but it >>> would be a step into the right direction ;) >> >> If you are dumping anything to the html output window, then you >> should >> be using HTMLOutput.show or at least web_preview… :) > > Yes :) But sometimes I want to have a plain HTML window without the > TextMate banner. Maybe one could provide an option in HTMLOutput.show > à la > HTMLOutput.show(:title => "My Title", :no_banner) Sure, this is a good idea. —Alex --===============3470042092187665093==-- From bibiko@eva.mpg.de Thu Sep 25 12:56:43 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 14:56:38 +0200 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1849246325318215085==" --===============1849246325318215085== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit I found a tiny bug in my JS script. How to escape ' and ". This should work: s.replace(/\x27/g,"’").replace(/\"/g,'\\\"') If someone could verify this I'd be appreciated ;) --Hans --===============1849246325318215085==-- From bibiko@eva.mpg.de Thu Sep 25 13:06:46 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 15:06:41 +0200 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2923274452200794178==" --===============2923274452200794178== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Arrgh, wait: I forgot to change " ' for confirm as well. It's really tricky ;} --Hans --===============2923274452200794178==-- From bibiko@eva.mpg.de Thu Sep 25 13:16:54 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 15:16:48 +0200 Message-ID: <86DF81B2-825F-4500-BA41-410219B18273@eva.mpg.de> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5777099238718982470==" --===============5777099238718982470== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit And, hoepfully, finally I fixed the issue if you do this try{...} catch(e) {alert(e)} and e is an object then this will work in a browser but for "$DIALOG" one has to write "e.toString()" that's why: Puuuh, --Hans --===============5777099238718982470==-- From oblivious@subtleGradient.com Thu Sep 25 16:42:47 2008 From: Thomas Aylott To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 12:42:45 -0400 Message-ID: In-Reply-To: <86DF81B2-825F-4500-BA41-410219B18273@eva.mpg.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2978946592096712893==" --===============2978946592096712893== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Thu, Sep 25, 2008 at 9:16 AM, Hans-J=C3=B6rg Bibiko = wrote: =E2=80=A6 awesome. Now implemented in Javascript Tools: http://github.com/subtleGradient/javascript-tools.tmbundle/tree/master/Comman= ds/Test%20Javascript.tmCommand The Javascript Runner now logs errors to the web inspector console as well as alerting with the filepath & corrected line number. I used try/throw/catch to find out the current line number and then offset the line number of your actual error. -- Thomas Aylott subtleGradient.com --===============2978946592096712893==-- From bibiko@eva.mpg.de Thu Sep 25 18:14:17 2008 From: =?utf-8?q?Hans-J=C3=B6rg?= Bibiko To: textmate@lists.macromates.com Subject: [TxMt] Re: HTML output window: JavaScrip alert() and confirm() Date: Thu, 25 Sep 2008 20:13:21 +0200 Message-ID: <62271861-5417-4F2E-9370-41F34CCF1392@eva.mpg.de> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1603165363408624437==" --===============1603165363408624437== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On 25.09.2008, at 18:42, Thomas Aylott wrote: > On Thu, Sep 25, 2008 at 9:16 AM, Hans-Jörg Bibiko > wrote: > … > > awesome. > Now implemented in Javascript Tools: > http://github.com/subtleGradient/javascript-tools.tmbundle/tree/ > master/Commands/Test%20Javascript.tmCommand > > The Javascript Runner now logs errors to the web inspector console as > well as alerting with the filepath & corrected line number. > > I used try/throw/catch to find out the current line number and then > offset the line number of your actual error. Excellent!! I will try whether I can adapt your code to the error handling of Objective-J (I know it's a stony way but maybe I can find a way). --Hans --===============1603165363408624437==--