On Tue, Nov 17, 2015 at 9:00 PM, Craig L Russell <[email protected]> wrote: > Here’s my latest attempt. A couple of questions. > > 1. When I create the button, I set data_email to the email address. > > But when I add the event listener, I getAttribute on data-email. Is there > some magic that transforms data_email to data-email?
Yup. :-) Back story: HTML attributes (and element names) may have dashes in them, and rarely (if ever) have underscores in them. Variable names in Ruby can't have dashes in them, but can have underscores. So when I generate the HTML (view source on the page to see what is generated), I convert underscores to dashes. This implementation detail "bleeds through" when you call an underlying DOM function like getAttribute. > 2. I’m missing the lesson on creating new line characters in strings. \n > doesn’t seem to work. Switch from single quotes to double quotes. https://en.wikibooks.org/wiki/Ruby_Programming/Strings > 3. How do I tell email to use my clr at apache.org address? When you push the button, it launches your email client. Your email client knows who you are, and may even allow you to change between multiple addresses. It also will allow you to edit the subject and/or body before sending, or even chose to cancel sending entirely. > Thanks, > > Craig The diff below looks good, but longer term you might want to add if statements to vary the subject and/or body based on the type of issue? - Sam Ruby > clr% svn diff > Index: icla-lint.cgi > =================================================================== > --- icla-lint.cgi (revision 972670) > +++ icla-lint.cgi (working copy) > @@ -122,7 +122,8 @@ > end > > _td do > - _button 'email', data_id: id > + _button 'email', data_email: "#{name} <#{email}>", > + data_issue: note, data_name: name > _span note > end > > @@ -151,8 +152,24 @@ > buttons = document.querySelectorAll('button') > for i in 0...buttons.length > buttons[i].addEventListener('click') do |event| > - id = event.target.getAttribute('data-id') > - alert(id) > + email = event.target.getAttribute('data-email') > + issue = event.target.getAttribute('data-issue') > + name = event.target.getAttribute('data-name') > + > + destination = "mailto:#{email}[email protected]" > + subject = 'Your Apache ICLA' > + from = '[email protected]' > + body = 'Dear ' + name + '\n' + > + 'While reviewing our records, we have not been able to locate > your ICLA.\n' + > + 'Can you please resubmit to [email protected]? > http://apache.org/licenses/#submitting\n' + > + 'Best regards,\n\n' + > + 'Craig' > + > + window.location = destination + > + "&from=#{encodeURIComponent(from)}" + > + "&subject=#{encodeURIComponent(subject)}" + > + "&body=#{encodeURIComponent(body)}" > + > end > end > >> On Nov 16, 2015, at 10:24 PM, Sam Ruby <[email protected]> wrote: >> >> On Tue, Nov 17, 2015 at 12:31 AM, Craig L Russell >> <[email protected]> wrote: >>> Another thought on this, since it would be nice to have this feature work >>> both on a client and on the whimsy service. >>> >>> Maybe the “alert” could create an email message that can be edited to suit >>> (similar to the commit message in SA tool) and once it’s perfect, the >>> (send) button would send the completed, edited message to the email system >>> to be sent. >>> >>> I’ll experiment with the alert dialog box to see what is involved. >> >> I do suggest that you try the following patch before you explore a dialog >> box: >> >> Index: icla-lint.cgi >> =================================================================== >> --- icla-lint.cgi (revision 972667) >> +++ icla-lint.cgi (working copy) >> @@ -122,7 +122,8 @@ >> end >> >> _td do >> - _button 'email', data_id: id >> + _button 'email', data_email: "#{name} <#{email}>", >> + data_issue: note >> _span note >> end >> >> @@ -151,8 +152,16 @@ >> buttons = document.querySelectorAll('button') >> for i in 0...buttons.length >> buttons[i].addEventListener('click') do |event| >> - id = event.target.getAttribute('data-id') >> - alert(id) >> + email = event.target.getAttribute('data-email') >> + issue = event.target.getAttribute('data-issue') >> + >> + destination = "mailto:#{email}[email protected]" >> + subject = issue >> + body = 'blah, blah, blah' >> + >> + window.location = destination + >> + "&subject=#{encodeURIComponent(subject)}" + >> + "&body=#{encodeURIComponent(body)}" >> end >> end >> >> =================================================================== >> >> If you want to go the dialog box route, what the board agenda tool >> uses is Bootstrap modals: >> >> http://getbootstrap.com/javascript/#modals >> >> To pull in bootstrap, add the following to the top of your script: >> >> require 'wunderbar/bootstrap/theme' >> >> Have fun! >> >> - Sam Ruby > > Craig L Russell > Architect, Oracle > http://db.apache.org/jdo > 408 276-5638 mailto:[email protected] > P.S. A good JDO? O, Gasp! >
