From 2f3059abee4e6d42254ecebe7a5e75860a8b3bd4 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Thu, 16 Aug 2018 22:55:04 -0400 Subject: [PATCH] temp changes --- view/template/mail/_settingsForm.php | 21 +++++++++-- view/template/mail/settings.php | 3 +- web/js/emailSettings.js | 52 ++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 web/js/emailSettings.js diff --git a/view/template/mail/_settingsForm.php b/view/template/mail/_settingsForm.php index c51ed48a..c892d33e 100644 --- a/view/template/mail/_settingsForm.php +++ b/view/template/mail/_settingsForm.php @@ -1,12 +1,27 @@ + +lbry.emailSettingsForm( ''); + -
+
-
-
+

Emails

+

Choose which emails you want to receive LBRY news

+
+
+
+
+
+
+

Tags

+

Any particular interests?

+
+
+
+
\ No newline at end of file diff --git a/view/template/mail/settings.php b/view/template/mail/settings.php index c65909e9..31d1b0be 100644 --- a/view/template/mail/settings.php +++ b/view/template/mail/settings.php @@ -1,6 +1,7 @@ false]) ?> +
@@ -9,7 +10,7 @@
- $nextUrl ?? '/']) ?> + $data ?? '/']) ?>

{{social.also}}

diff --git a/web/js/emailSettings.js b/web/js/emailSettings.js new file mode 100644 index 00000000..af9adcff --- /dev/null +++ b/web/js/emailSettings.js @@ -0,0 +1,52 @@ +lbry.emailSettingsForm = function (emailState) { + var + state = JSON.parse(emailState), + emails = state.emails, + tags = state.tags, + emailTable = $('#email_table'), + tagTable = $('#tag_table'); + + $.each(emails, function(email, enabled = false){ + console.log('email: ',email, ' enabled: ',enabled) + $labelCell = $(''); + $checkbox = $('').prop('checked',enabled ? true : false); + $checkBoxCell = $('').append($checkbox); + $rowEmail = $('
').append($labelCell).append($checkBoxCell); + emailTable.append($rowEmail) + }); + $.each(tags, function(tag, enabled){ + console.log('tagName: ',tag,' enabled: ',enabled) + $labelCell = $('') + $checkbox = $('').prop('checked',enabled ? true : false); + $checkBoxCell = $('').append($checkbox); + $rowTag = $('
') + tagTable.append($rowTag).append($labelCell).append($checkBoxCell); + }); + + $('#email_form').submit(function(e) { + e.preventDefault(); + }); + $('#tag_form').submit(function(e) { + e.preventDefault(); + }); + + +} + +lbry.applyEmailEdit = function () { + console.log("applied email settings") + + //How do I call PHP api with the proper arguments from here? + //Then how do I go to the page again triggering a refresh or show an error? + //Need to get the token here as well to call the API + + /*let url = 'http://localhost:8080/user/email/edit?auth_token='+token+'&' + fetch('http://localhost:8080/user/email/edit?').then(value => { + console.log(value.json()) + + });*/ +} + +lbry.applyTagEdit = function () { + console.log("applied tag settings") +} \ No newline at end of file