Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email tab does not come up on Windows with Chrome or Edge #87

Open
chrisxkeith opened this issue Oct 22, 2021 · 3 comments
Open

Email tab does not come up on Windows with Chrome or Edge #87

chrisxkeith opened this issue Oct 22, 2021 · 3 comments
Assignees

Comments

@chrisxkeith
Copy link
Contributor

chrisxkeith commented Oct 22, 2021

Try turning it back into a full link?
Install Selenium IDE into Edge and Firefox and run automated tests.
Does not work: Maybe add a junk "To:" email address?

@chrisxkeith
Copy link
Contributor Author

chrisxkeith commented Oct 22, 2021

https://stackoverflow.com/questions/2906582/how-to-create-an-html-button-that-acts-like-a-link

Breaks Firefox!

PS C:\Users\chris\Documents\Github\shelby-co-employment-screener> git diff
diff --git a/www/formflow.js b/www/formflow.js
index 3979c65..b4ed1b7 100644
--- a/www/formflow.js
+++ b/www/formflow.js
@@ -108,7 +108,6 @@ $(document).ready(function() {
           }
           break;
         case 'email_self_form':
-          selection_handler.send_self_email();
           alert_message = '';
           break;
       }
@@ -923,8 +922,10 @@ class SelectionHandler {
     return s;
   }
   email_to_user() {
-    let button_html = '<input  style="color: #518846;"type="submit" ' + 
-                  'value="Email the organization list to yourself"/><br/><br/>';
+    let button_html = '<form id="email_self_form" action="' + 
+        this.get_email_self_url() + '" target="_blank">' + 
+        '<input  style="color: #518846;"type="submit" ' + 
+        'value="Email the organization list to yourself"/></form><br/><br/>';
     return '<div class="usa-prose" style="max-width:68ex;"><p>Click on a phone number to call an organization. ' +
       'Some organizations have a contact form on their website.</p><br/>' +
       'To send these emails, you must enter your email address in "To:" and click "Send".<br/>' +
@@ -1057,7 +1058,7 @@ class SelectionHandler {
     title.empty();
     let matches = this.get_matches();
     title.append(matches.length + " matches");
-    this.load_form('email_self_form', this.email_to_user());
+    this.load_form('email_self_div', this.email_to_user());
     let el = $(".matches_div");
     el.empty();
     for (let m of matches) {
diff --git a/www/index.html b/www/index.html
index 5dc62a9..63af816 100644
--- a/www/index.html
+++ b/www/index.html
@@ -202,7 +202,7 @@

   <div class="matches" hidden>
     <h3 id="matches_title"></h3>
-    <form id="email_self_form"></form>
+    <div id="email_self_div"></div>
     <form id="send_emails_form"></form>

@chrisxkeith
Copy link
Contributor Author

Does not work.

diff --git a/www/formflow.js b/www/formflow.js
index 3e8449a..8d40daf 100644
--- a/www/formflow.js
+++ b/www/formflow.js
@@ -107,14 +107,10 @@ $(document).ready(function() {
             alert_message = '';
           }
           break;
-        case 'email_self_form':
-          selection_handler.send_self_email();
-          alert_message = '';
-          break; 
       }
       if (alert_message) {
         alert(alert_message);
-      } else if (!['email_self_form', 'personal_info'].includes(id)) {
+      } else if (!['personal_info'].includes(id)) {
         selection_handler.handle();
       }
       event.preventDefault();
@@ -138,8 +134,7 @@ class SelectionHandler {
                                'client_age', 'criminal_history',
                                'zip_code', 'race',
                                'gender', 'legal_resident', 'disabilities', 'work_status',
-                               'english_lang', 'send_emails_form', 'personal_info',
-                               'email_self_form' ];
+                               'english_lang', 'send_emails_form', 'personal_info' ];
     this.client_data = {
       needs : null,
       zip_code : null,
@@ -871,9 +866,6 @@ class SelectionHandler {
             '&body=' + encodeURIComponent(body);
     window.open(url, '_blank');
   }
-  send_self_email() {
-    window.open(this.get_email_self_url(), '_blank');
-  }
   send_provider_emails() {
     let provider_array = [];
     let matches = this.get_matches();
@@ -956,9 +948,20 @@ class SelectionHandler {
       }
       s += '\r\n';
     }
-    return 'mailto:?subject=' +
-      encodeURIComponent('Organizations with employment services') +
-      '&body=' + encodeURIComponent(s);
+    return this.make_mailto('', '', 'Organizations with employment services',
+            s, 'Email this information to yourself');
+
+  }
+  make_mailto(to, bcc, subject, body, link_text) {
+    let html = '<p>' + '<a href="mailto:' + to + '?';
+    if (bcc) {
+      html += 'bcc=' + encodeURIComponent(bcc) + '&';
+    }
+    html += 'subject=' + encodeURIComponent(subject) +
+          '&body=' + encodeURIComponent('test') +
+          '" target="_blank">' + link_text + '</a>' +
+          '</p>';
+    return html;
   }
   get_small_separator() {
     return '<hr align="left" style="height:2px;border:none;color:#518846;background-color:#518846;max-width:68ex;"/>';
@@ -1041,22 +1044,22 @@ class SelectionHandler {
     this.add_language_orgs(orgs);
     return Object.keys(orgs).sort();
   }
-  load_form(form_name, html) {
-    let the_form = $('#' + form_name);
-    the_form.empty();
-    the_form.append(html);
+  load_element(elem_id, html) {
+    let the_elem = $('#' + elem_id);
+    the_elem.empty();
+    the_elem.append(html);
   }
   load_send_email_form() {
     let html = '<input style="color: #518846;" type="submit" ' + 
               'value="Email my information to the organizations"/>'
-    this.load_form('send_emails_form', html);
+    this.load_element('send_emails_form', html);
   }
   show_matches() {
     let title = $("#matches_title");
     title.empty();
     let matches = this.get_matches();
     title.append(matches.length + " matches");
-    this.load_form('email_self_form', this.email_to_user());
+    this.load_element('email_self_div', this.get_email_self_url());
     let el = $(".matches_div");
     el.empty();
     for (let m of matches) {
diff --git a/www/index.html b/www/index.html
index 5dc62a9..63af816 100644
--- a/www/index.html
+++ b/www/index.html
@@ -202,7 +202,7 @@
 
   <div class="matches" hidden>
     <h3 id="matches_title"></h3>
-    <form id="email_self_form"></form>
+    <div id="email_self_div"></div>
     <form id="send_emails_form"></form>
     <div class="matches_div"></div>
   </div>

@chrisxkeith
Copy link
Contributor Author

When Kevin tried, the mail-to-self didn't work from Chrome, but the send-to-orgs brought up his Outlook email client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant