|
17 | 17 | <tbody>
|
18 | 18 | <tr>
|
19 | 19 | <td align="center" colspan="3">
|
20 |
| - <div id="photo_box"></div> |
| 20 | + <div id="del_photo" style="margin-bottom: 20px;"><a href="javascript:void();">Delete Photo</a></div> |
| 21 | + <div id="photo_box"> |
| 22 | + <img src="assets/default_profile.png" id="photo_obj"> |
| 23 | + </div> |
21 | 24 | </td>
|
22 | 25 | </tr>
|
23 | 26 | <tr>
|
24 |
| - <td>Upload Photo</td> |
| 27 | + <td>Upload New Photo</td> |
25 | 28 | <td>:</td>
|
26 | 29 | <td><input type="file" name="photo" id="uform_photo"/></td>
|
27 | 30 | </tr>
|
|
95 | 98 | width: 200px;
|
96 | 99 | height: 200px;
|
97 | 100 | border: 1px solid #000;
|
| 101 | + border-radius: 100%; |
| 102 | + margin-bottom: 50px; |
| 103 | +} |
| 104 | +#photo_obj { |
| 105 | + width: 100%; |
| 106 | + height: 100%; |
| 107 | + border-radius: 100%; |
98 | 108 | }
|
99 | 109 | #frcg {
|
100 | 110 | margin: 0 auto;
|
|
114 | 124 | }
|
115 | 125 | </style>
|
116 | 126 | <script>
|
| 127 | +function delete_photo_click_callback() |
| 128 | +{ |
| 129 | + gwm_fn_delete_user_photo(function (j) { |
| 130 | + gwm_auth_renew_session(function () { |
| 131 | + form_uinfo_set_inputs(gwm_auth_get_user()); |
| 132 | + }); |
| 133 | + |
| 134 | + if (j.code === 200) { |
| 135 | + gid("photo_obj").src = "assets/default_profile.png"; |
| 136 | + dp.style.display = "none"; |
| 137 | + } |
| 138 | + }); |
| 139 | +} |
| 140 | + |
117 | 141 | function form_uinfo_set_inputs(u)
|
118 | 142 | {
|
119 | 143 | gid("uform_full_name").value = u.full_name;
|
|
124 | 148 | gid("uform_telegram_username").value = u.socials.telegram_username;
|
125 | 149 | gid("uform_twitter_username").value = u.socials.twitter_username;
|
126 | 150 | gid("uform_discord_username").value = u.socials.discord_username;
|
| 151 | + |
| 152 | + if (u.photo) |
| 153 | + gid("photo_obj").src = u.photo; |
| 154 | + |
| 155 | + let dp = gid("del_photo"); |
| 156 | + if (u.photo) { |
| 157 | + dp.style.display = "block"; |
| 158 | + dp.onclick = function() { |
| 159 | + delete_photo_click_callback(); |
| 160 | + }; |
| 161 | + } else { |
| 162 | + dp.style.display = "none"; |
| 163 | + } |
127 | 164 | }
|
128 | 165 |
|
129 | 166 | function main()
|
|
144 | 181 | e.preventDefault();
|
145 | 182 | let fd = new FormData(uform);
|
146 | 183 | gwm_fn_set_user_info(function (j) {
|
| 184 | + toggle_disable_inputs(uform, false); |
147 | 185 | gwm_auth_renew_session(function () {
|
148 |
| - toggle_disable_inputs(uform, false); |
149 |
| - let u = gwm_auth_get_user(); |
150 |
| - form_uinfo_set_inputs(u); |
| 186 | + form_uinfo_set_inputs(gwm_auth_get_user()); |
151 | 187 | });
|
| 188 | + if (j.code === 200) |
| 189 | + photo.value = ""; |
152 | 190 | }, fd);
|
153 | 191 | toggle_disable_inputs(uform, true);
|
154 | 192 | });
|
|
0 commit comments