|
1 | 1 | <script> |
2 | | -var re = /^\/c\/site-feedback\/2$/i |
| 2 | +var re = /\/c\/course\/programming\/10/i |
3 | 3 | setInterval(function () { |
4 | 4 | var $ = function (sel) { return document.querySelector(sel) } |
5 | 5 | if (re.test(location.pathname)) setTimeout(function () { |
|
12 | 12 | $('#create-pm').onclick = function () { |
13 | 13 | require('discourse/mixins/open-composer').default.mixins[0].properties.openComposerWithMessageParams.call( |
14 | 14 | { controllerFor: function () { return Discourse.__container__.lookup('controller:composer') } }, |
15 | | - { recipients: 'moderators', hasGroups: true }, |
| 15 | + { recipients: 'Programming-TAs', hasGroups: true }, |
16 | 16 | ) |
17 | 17 | } |
18 | 18 | } |
19 | 19 | }, 100) |
20 | | - var msgLink = $('[href=\\/messages]') |
21 | | - if (msgLink) msgLink.href = '/u/' + Discourse.currentUser.username + '/messages/sent' |
| 20 | + if (!Discourse.currentUser.groups.some(function (x) { return x.name === 'Programming-TAs' })) return |
22 | 21 | if ($('#ta-convert-public')) return |
23 | 22 | var aRP = $('.add-remove-participant-btn') |
24 | 23 | if (aRP) { |
25 | 24 | var wrapper = document.createElement('div') |
26 | 25 | wrapper.innerHTML = '<button id="ta-convert-public" class="btn-default btn btn-icon-text ember-view" type="button"><span class="d-button-label">设为公开话题</span></button>' |
27 | 26 | aRP.parentElement.insertBefore(wrapper, aRP) |
28 | 27 | $('#ta-convert-public').onclick = function () { |
| 28 | + $('#ta-convert-public').disabled = true |
29 | 29 | var id = $('h1[data-topic-id]').getAttribute('data-topic-id') |
30 | | - fetch('http://localhost/t/' + id + '/convert-topic/public', { |
| 30 | + fetch('/t/' + id + '/convert-topic/public', { |
31 | 31 | credentials: "include", |
32 | 32 | headers: { |
33 | 33 | 'X-CSRF-Token': require('discourse/models/session').default.current().csrfToken, |
|
36 | 36 | "Discourse-Present": "true", |
37 | 37 | 'X-Requested-With': 'XMLHttpRequest', |
38 | 38 | }, |
39 | | - "body": "category_id=2", |
| 39 | + "body": "category_id=10", |
40 | 40 | "method": "PUT", |
41 | | - }); |
42 | | - location.reload() |
| 41 | + }).then(() => location.reload()) |
43 | 42 | } |
44 | 43 | } |
45 | 44 | }, 500) |
|
0 commit comments