{"id":2644,"date":"2024-04-08T01:52:03","date_gmt":"2024-04-07T17:52:03","guid":{"rendered":"https:\/\/www.sdcharging.com.hk\/?page_id=2644"},"modified":"2024-12-11T23:21:54","modified_gmt":"2024-12-11T15:21:54","slug":"opt-in-out","status":"publish","type":"page","link":"https:\/\/www.kinetacharge.com\/hk\/opt-in-out\/","title":{"rendered":"Unsubscribe to our Newsletter and Exclusive Privileges"},"content":{"rendered":"\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column opt-form is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"217\" src=\"http:\/\/www.kinetacharge.com.hk\/wp-content\/uploads\/2024\/12\/logo1-1024x217.png\" alt=\"\" class=\"wp-image-3077\" style=\"width:200px\" srcset=\"https:\/\/www.kinetacharge.com\/hk\/wp-content\/uploads\/2024\/12\/logo1-1024x217.png 1024w, https:\/\/www.kinetacharge.com\/hk\/wp-content\/uploads\/2024\/12\/logo1-300x64.png 300w, https:\/\/www.kinetacharge.com\/hk\/wp-content\/uploads\/2024\/12\/logo1-768x163.png 768w, https:\/\/www.kinetacharge.com\/hk\/wp-content\/uploads\/2024\/12\/logo1-1536x325.png 1536w, https:\/\/www.kinetacharge.com\/hk\/wp-content\/uploads\/2024\/12\/logo1-2048x434.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Unsubscribe to our Newsletter and Exclusive Privileges<\/h2>\n\n\n\n<p class=\"success-message has-vivid-cyan-blue-color has-text-color\"><strong>Successfully updated!<\/strong><\/p>\n\n\n\n<p class=\"fail-message has-vivid-red-color has-text-color\"><strong>Please visit this page from the SD Charging Mobile app<\/strong><\/p>\n\n\n\n<form id=\"opt-in-out-form\" class=\"opt-in-out-form\">\n  <div style=\"flex: 1; display: flex; align-items: start;\">\n    <input type=\"checkbox\" id=\"parent\" \/>\n    <label for=\"parent\" style=\"padding-left: 4px;\">I do not wish Bow Ma Motors (South China) Limited, BMW Concessionaires (HK) Limited, BMW AG, and Sime Darby Group to use my personal data to deliver latest events, updates, offers, and promotions.<\/label>\n  <\/div>\n  <div class=\"children\">\n    <div>\n      <input type=\"checkbox\" class=\"child\" id=\"opt_in_email\" \/>\n      <label for=\"opt_in_email\">via Email<\/label>\n    <\/div>\n    <div>\n      <input type=\"checkbox\" class=\"child\" id=\"opt_in_sms\" \/>\n      <label for=\"opt_in_sms\">via SMS<\/label>\n    <\/div>\n    <div>\n      <input type=\"checkbox\" class=\"child\" id=\"opt_in_phone\" \/>\n      <label for=\"opt_in_phone\">via Phone<\/label>\n    <\/div>\n    <div>\n      <input type=\"checkbox\" class=\"child\" id=\"opt_in_letter\" \/>\n      <label for=\"opt_in_letter\">via Letter<\/label>\n    <\/div>\n  <\/div>\n  <p class=\"disclaimer\" style=\"margin-top: 18px !important;\">By submitting this form, I agree to receive information on invitations to exclusive offers and events, latest news, and other relevant information from Bow Ma Motors (South China) Limited, BMW AG, and Sime Darby Group as set out in the <a href=\"http:\/\/sdcharging.com.hk\/privacy-policy\" data-type=\"link\" data-id=\"sdcharging.com.hk\/privacy\">Privacy Policy<\/a>. I understand this selection will prevail my previous preferences. I may unsubscribe at any time.<\/p>\n  <input class=\"submit\" type=\"submit\" value=\"Submit\" \/>\n<\/form>\n\n<script>\n  document.querySelector('.fail-message').style.display = 'none';\n  document.querySelector('.success-message').style.display = 'none';\n  document.querySelector('.opt-in-out-form').style.display = 'block';\n  document.querySelector('.disclaimer').style.display = 'none';\n\n  \/\/ Parse the query parameters\n  const urlParams = new URLSearchParams(window.location.search);\n  const uid = urlParams.get('uid');\n  if (!uid) {\n    document.querySelector('.fail-message').style.display = 'block';\n    document.querySelector('.success-message').style.display = 'none';\n    document.querySelector('.opt-in-out-form').style.display = 'none';\n    document.querySelector('.disclaimer').style.display = 'none';\n  }\n  const parentCheckbox = document.querySelector('#parent');\n  const childCheckboxes = document.querySelectorAll('.child');\n\n  \/\/ Function to update the state of the parent checkbox\n  function updateParentCheckbox() {\n    const allChecked = [...childCheckboxes].every((c) => c.checked);\n    const someChecked = [...childCheckboxes].some((c) => c.checked);\n\n    if (allChecked) {\n      parentCheckbox.checked = true;\n      parentCheckbox.indeterminate = false;\n      document.querySelector('.disclaimer').style.display = 'none';\n    } else if (someChecked) {\n      parentCheckbox.checked = false;\n      parentCheckbox.indeterminate = true;\n      document.querySelector('.disclaimer').style.display = 'block';\n    } else {\n      parentCheckbox.checked = false;\n      parentCheckbox.indeterminate = false;\n      document.querySelector('.disclaimer').style.display = 'block';\n    }\n  }\n\n  \/\/ Fill the checkboxes based on the query parameters\n  childCheckboxes.forEach((checkbox) => {\n    const optIn = urlParams.get(checkbox.id);\n    checkbox.checked = optIn === 'false';\n  });\n\n  \/\/ Update the state of the parent checkbox\n  updateParentCheckbox();\n\n  parentCheckbox.addEventListener('change', () => {\n    childCheckboxes.forEach((checkbox) => {\n      checkbox.checked = parentCheckbox.checked;\n    });\n    updateParentCheckbox();\n  });\n\n  childCheckboxes.forEach((checkbox) => {\n    checkbox.addEventListener('change', updateParentCheckbox);\n  });\n\n  \/\/ Handle the form submission\n  document.querySelector('#opt-in-out-form').addEventListener('submit', (event) => {\n    event.preventDefault();\n\n    const options = Array.from(document.querySelectorAll('.child'))\n      .reduce((acc, checkbox) => {\n        acc[checkbox.id] = !checkbox.checked;\n        return acc;\n      }, {});\n\n    fetch(`https:\/\/api.sdcharging.com.hk\/api\/v1\/user\/${uid}\/opt-in-out`, {\n      method: 'PUT',\n      headers: {\n        'Content-Type': 'application\/json',\n      },\n      body: JSON.stringify(options),\n    })\n    .then(response => response.json())\n    .then(data => {\n      \/\/ Show a success message\n      document.querySelector('.fail-message').style.display = 'none';\n      document.querySelector('.success-message').style.display = 'block';\n      document.querySelector('.opt-in-out-form').style.display = 'none';\n      document.querySelector('.disclaimer').style.display = 'none';\n    })\n    .catch((error) => {\n      console.error('Error:', error);\n      document.querySelector('.fail-message').style.display = 'block';\n      document.querySelector('.success-message').style.display = 'none';\n      document.querySelector('.opt-in-out-form').style.display = 'none';\n      document.querySelector('.disclaimer').style.display = 'none';\n    });\n  });\n<\/script>\n\n\n\n<p class=\"disclaimer\"><\/p>\n<\/div>\n<\/div>\n\n\n\n<style type=\"text\/css\">\n  .opt-form {\n    padding: 30px;\n  }\n\n  .opt-in-out-form {\n      margin-top: 24px;\n  }\n\n  img {\n    margin-bottom: 32px;\n  }\n\n  .children {\n    padding-left: 24px;\n  }\n\n  .submit {\n    padding: 10px 24px 8px !important;\n    margin-top: 24px;\n    border: none;\n    border-radius: 8px;\n    color: #fff;\n    background: #1c69d4;\n  }\n\n  .success-message {\n    margin-top: 24px;\n  }\n\n  .fail-message {\n    margin-top: 24px;\n  }\n<\/style>\n","protected":false},"excerpt":{"rendered":"<p>Unsubscribe to our Newsletter and Exclusive Privileges Successfully updated! Please visit this page from the SD Charging Mobile app I do not wish Bow Ma Motors (South China) Limited, BMW Concessionaires (HK) Limited, BMW AG, and Sime Darby Group to use my personal data to deliver latest events, updates, offers, and promotions. via Email via &hellip; <a href=\"https:\/\/www.kinetacharge.com\/hk\/opt-in-out\/\">Continued<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"views\/template-blank.blade.php","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"class_list":["post-2644","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/pages\/2644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/comments?post=2644"}],"version-history":[{"count":65,"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/pages\/2644\/revisions"}],"predecessor-version":[{"id":3145,"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/pages\/2644\/revisions\/3145"}],"wp:attachment":[{"href":"https:\/\/www.kinetacharge.com\/hk\/wp-json\/wp\/v2\/media?parent=2644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}