poll xposting ui
This commit is contained in:
parent
2c735fef69
commit
ad40cc92b4
4
composer.lock
generated
4
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "d993b45e1a383647a4d2260a68ee1783",
|
"content-hash": "6fc1593cab1017ef65d6e12dc56c499c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "hutattedonmyarm/apnuti",
|
"name": "hutattedonmyarm/apnuti",
|
||||||
@ -12,7 +12,7 @@
|
|||||||
"dist": {
|
"dist": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "../APnutI",
|
"url": "../APnutI",
|
||||||
"reference": "2b45c9fdd0df6a6b6186c1afb1075ae5a0b69bbe"
|
"reference": "51a798ea3e39570e47eb3d55fc838d61cc0967f6"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
|
@ -5,7 +5,7 @@ require_once __DIR__ .'/bootstrap.php';
|
|||||||
use APnutI\Entities\Poll;
|
use APnutI\Entities\Poll;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
echo get_page_header('Post Poll', true, []);
|
echo get_page_header('Post Poll', true, ['post_poll']);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
quit('Something went wrong :( "'.$e->getMessage().'"');
|
quit('Something went wrong :( "'.$e->getMessage().'"');
|
||||||
}
|
}
|
||||||
@ -62,6 +62,15 @@ $url = $scheme
|
|||||||
. $dir_name
|
. $dir_name
|
||||||
. '/view_poll.php?id='
|
. '/view_poll.php?id='
|
||||||
. $poll_id;
|
. $poll_id;
|
||||||
|
|
||||||
|
$channels = [];
|
||||||
|
$channels_error_banner = '';
|
||||||
|
try {
|
||||||
|
$channels = $api->getSubscribedChannels(false);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$channels_error_banner = make_banner('error', 'Could not load channels: "'.$e->getMessage().'"');
|
||||||
|
}
|
||||||
|
echo $channels_error_banner;
|
||||||
?>
|
?>
|
||||||
Do you want to post about your poll?
|
Do you want to post about your poll?
|
||||||
<form method="POST" class="post-poll">
|
<form method="POST" class="post-poll">
|
||||||
@ -72,6 +81,19 @@ Do you want to post about your poll?
|
|||||||
</textarea><br>
|
</textarea><br>
|
||||||
<input type="hidden" name="poll_id" value="<?= $poll_id ?>">
|
<input type="hidden" name="poll_id" value="<?= $poll_id ?>">
|
||||||
<input type="hidden" name="poll_token" value="<?= $poll_token ?>">
|
<input type="hidden" name="poll_token" value="<?= $poll_token ?>">
|
||||||
|
<label>Post to channel
|
||||||
|
<select name="channelid">
|
||||||
|
<option value="-1">---</option>
|
||||||
|
<?php
|
||||||
|
foreach ($channels as $channel) { ?>
|
||||||
|
<option value="<?= $channel->id ?>"><?= $channel->name ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<label>Broadcast to global
|
||||||
|
<input type="checkbox" name="broadcast">
|
||||||
|
</label><br />
|
||||||
<button type="submit" name="submit" value="submit">Post to pnut</button>
|
<button type="submit" name="submit" value="submit">Post to pnut</button>
|
||||||
</form>
|
</form>
|
||||||
<a href="/view_poll.php?id=<?= $poll_id ?>">Take me straight to the poll</a>
|
<a href="/view_poll.php?id=<?= $poll_id ?>">Take me straight to the poll</a>
|
||||||
|
20
scripts/post_poll.js
Normal file
20
scripts/post_poll.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const channelSelector = document.querySelector('select[name="channelid"]');
|
||||||
|
document.querySelector('input[name="broadcast"]').disabled = channelSelector.value === '-1';
|
||||||
|
channelSelector.onchange = validateBroadcastStatus;
|
||||||
|
});
|
||||||
|
|
||||||
|
function validateBroadcastStatus() {
|
||||||
|
const postToChannel = parseInt(this.value) > 0;
|
||||||
|
const checkbox = document.querySelector('input[name="broadcast"]');
|
||||||
|
if (!postToChannel) {
|
||||||
|
checkbox.dataset.wasChecked = checkbox.checked;
|
||||||
|
checkbox.checked = false;
|
||||||
|
checkbox.disabled = true;
|
||||||
|
} else {
|
||||||
|
if (checkbox.disabled && checkbox.dataset.wasChecked !== undefined) {
|
||||||
|
checkbox.checked = checkbox.dataset.wasChecked === 'true';
|
||||||
|
}
|
||||||
|
checkbox.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user