This repository has been archived by the owner on May 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure_commands.html
134 lines (113 loc) · 3.84 KB
/
configure_commands.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{% extends 'configure_server.html' %}
{% block rightSidebarContents %}
<div class="category-name">
{{ WEBSITE_COMMANDS }}
</div>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-3-4">
<div id="communityTitle" class="toggleSubText">
{{ DASHBOARD_ManageCommands }}
</div>
</div>
<div class="pure-u-1 pure-u-md-1-4">
</div>
</div>
<hr>
<input type="text" id="filterBox" placeholder="{{ DASHBOARD_FilterByName }}">
<script>
$('#filterBox').on('input', function() {
var text = $(this).val()
console.log(text)
filter(text)
});
function getFilterText() {
return $("#filterBox").val()
}
function filter(text) {
$("#availableCommands").children().each(function() {
$(this).css('display', '')
});
$("#availableCommands").children().each(function() {
var commandName = $(this).text()
if (commandName.indexOf(text) == -1) {
$(this).css('display', 'none')
}
});
}
function moveSelectedAllRight() {
$("#availableCommands").children().each(function() {
$(this).prop("selected", false)
$(this).prependTo("#disabledCommands");
});
filter(getFilterText());
}
function moveSelectedOneRight() {
$("#availableCommands").children().each(function() {
if ($(this).is(':selected')) {
$(this).prop("selected", false)
$(this).prependTo("#disabledCommands");
}
});
filter(getFilterText());
}
function moveSelectedAllLeft() {
$("#disabledCommands").children().each(function() {
$(this).prop("selected", false)
$(this).prependTo("#availableCommands");
});
filter(getFilterText());
}
function moveSelectedOneLeft() {
$("#disabledCommands").children().each(function() {
if ($(this).is(':selected')) {
$(this).prop("selected", false)
$(this).prependTo("#availableCommands");
}
});
filter(getFilterText());
}
function transformBlockedCommandsToJson() {
var configAttr = {"type":"{{ saveType }}"}
var disabledCommands = []
$("#disabledCommands").children().each(function() {
var value = $(this).val();
disabledCommands.push(value)
});
configAttr["disabledCommands"] = disabledCommands
console.log(configAttr);
var json = JSON.stringify(configAttr);
sendJsonToServer(json);
}
</script>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-2">
<div class="flavourText">{{ DASHBOARD_EnabledCommands }}</div>
<div style="margin: 5px">
<select id="availableCommands" multiple style="width: 100%; height: 35vh;">
{% for command in enabledCommands %}
<option value="{{ command.getClass.getSimpleName }}">{{ serverConfig.commandPrefix }}{{ command.getLabel }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="pure-u-1 pure-u-md-1-2">
<div style="margin: 5px">
<div class="flavourText">{{ DASHBOARD_DisabledCommands }}</div>
<select id="disabledCommands" multiple style="width: 100%; height: 35vh;">
{% for command in disabledCommands %}
<option value="{{ command.getClass.getSimpleName }}">{{ serverConfig.commandPrefix }}{{ command.getLabel }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div style="text-align: center;">
<button onclick="moveSelectedAllRight()" class="button-discord button-discord-info pure-button"><i class="fas fa-angle-double-right"></i></button>
<button onclick="moveSelectedOneRight()" class="button-discord button-discord-info pure-button"><i class="fas fa-angle-right"></i></button>
<button onclick="moveSelectedOneLeft()" class="button-discord button-discord-info pure-button"><i class="fas fa-angle-left"></i></button>
<button onclick="moveSelectedAllLeft()" class="button-discord button-discord-info pure-button"><i class="fas fa-angle-double-left"></i></button>
</div>
<hr>
<button onclick="transformBlockedCommandsToJson()" style="float: right;" class="button-discord button-discord-success pure-button">{{ DASHBOARD_SAVE }}</button>
<br style="clear: both" /> <!-- So dirty! -->
{% endblock %}