mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
revamp request voting on detail page
This commit is contained in:
@@ -313,7 +313,7 @@
|
||||
document.getElementById('unit').addEventListener('input', () => {
|
||||
recalculate_bounty();
|
||||
});
|
||||
document.getElementById('button').addEventListener('click', () => {
|
||||
document.getElementById('button').addEventListener('click', (e) => {
|
||||
const requestId = document.getElementById('requestid');
|
||||
if (requestId != null) {
|
||||
add_bounty(
|
||||
@@ -325,6 +325,11 @@
|
||||
parseInt(document.getElementById('current_downloaded').value),
|
||||
parseFloat(document.getElementById('current_rr').value),
|
||||
);
|
||||
// disable to require a reload before voting again
|
||||
e.target.classList.add("hidden");
|
||||
document.getElementById('vote-help').innerHTML =
|
||||
"Reload the page if you wish to vote again";
|
||||
recalculate_bounty();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -368,20 +373,19 @@
|
||||
init_request_page(page[1]);
|
||||
} else if (window.location.pathname == '/requests.php') {
|
||||
init_index_page();
|
||||
} else {
|
||||
Array.from(document.querySelectorAll('.request-vote')).forEach((span) => {
|
||||
span.addEventListener('click', (e) => {
|
||||
add_bounty(
|
||||
VOTE_PAGE,
|
||||
parseInt(e.target.dataset.id),
|
||||
parseFloat(e.target.dataset.bounty),
|
||||
parseInt(e.target.dataset.n),
|
||||
parseInt(document.getElementById('current_uploaded').value),
|
||||
parseInt(document.getElementById('current_downloaded').value),
|
||||
parseFloat(document.getElementById('current_rr').value),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Array.from(document.querySelectorAll('.request-vote')).forEach((span) => {
|
||||
span.addEventListener('click', (e) => {
|
||||
add_bounty(
|
||||
VOTE_PAGE,
|
||||
parseInt(e.target.dataset.id),
|
||||
parseFloat(e.target.dataset.bounty),
|
||||
parseInt(e.target.dataset.n),
|
||||
parseInt(document.getElementById('current_uploaded').value),
|
||||
parseInt(document.getElementById('current_downloaded').value),
|
||||
parseFloat(document.getElementById('current_rr').value),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
@@ -821,7 +821,7 @@ tr.torrent .bookmark > a::after {
|
||||
}
|
||||
|
||||
.request-vote:hover {
|
||||
font-weight: 800;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#inbox #preview img,
|
||||
|
||||
@@ -18,7 +18,7 @@ $paginator = new Util\Paginator(TORRENT_COMMENTS_PER_PAGE, $commentPage->pageNum
|
||||
$paginator->setAnchor('comments')->setTotal($commentPage->total())->removeParam('postid');
|
||||
$userMan = new Manager\User();
|
||||
|
||||
$bounty = $Viewer->ordinal()->value('request-bounty-create');
|
||||
$bounty = $Viewer->ordinal()->value('request-bounty-vote');
|
||||
[$amount, $unit] = array_values(byte_format_array((float)$bounty));
|
||||
if (in_array($unit, ['GiB', 'TiB'])) {
|
||||
$unitGiB = true;
|
||||
|
||||
@@ -221,12 +221,6 @@
|
||||
<td class="label">Votes</td>
|
||||
<td>
|
||||
<span id="votecount">{{ request.userVotedTotal|number_format }} </span>
|
||||
{% if request.canVote(viewer) -%}
|
||||
<span class="brackets request-vote tooltip" data-id="{{
|
||||
request.id }}" data-bounty="{{ bounty }} " data-n="{{
|
||||
request.userVotedTotal }}">Vote</span>
|
||||
<strong>Costs {{ bounty|octet_size }}</strong> (you can change this default in your user settings).
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if request.hasNewVote %}
|
||||
@@ -237,21 +231,7 @@
|
||||
{% endif %}
|
||||
{% if request.canVote(viewer) %}
|
||||
<tr id="voting">
|
||||
<td class="label tooltip" title="These units are in base 2, not base 10. For example, there are 1,024 MiB in 1 GiB.">Custom vote</td>
|
||||
<td>
|
||||
<input type="text" id="amount_box" size="8" value="{{ amount_box }}"/>
|
||||
<select id="unit" name="unit">
|
||||
<option value="mb"{{ selected(not unit_GiB) }}>MiB</option>
|
||||
<option value="gb"{{ selected(unit_GiB) }}>GiB</option>
|
||||
</select>
|
||||
{% if constant('REQUEST_TAX') > 0 -%}
|
||||
<strong>{{ constant('REQUEST_TAX') * 100 }}% of this is deducted as tax by the system.</strong>
|
||||
{% endif %}
|
||||
<p>Bounty must be greater than or equal to {{ constant('REQUEST_MIN') }} MiB.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Bounty information</td>
|
||||
<td class="label tooltip" title="These units are in base 2, not base 10. For example, there are 1,024 MiB in 1 GiB.">Vote for this request</td>
|
||||
<td>
|
||||
<form class="add_form" name="request" action="requests.php" method="get" id="request_form">
|
||||
<input type="hidden" name="action" value="vote" />
|
||||
@@ -268,16 +248,25 @@
|
||||
{% else %}
|
||||
<span id="bounty_after_tax" style="display: none;">{{ tax_rate }} MiB</span>
|
||||
{% endif %}
|
||||
If you add the entered <strong><span id="new_bounty">0 MiB</span></strong> of bounty, your new stats will be: <br />
|
||||
Uploaded: <span id="new_uploaded">{{ viewer.uploadedSize|octet_size }}</span><br />
|
||||
Ratio: <span id="new_ratio">{{ ratio(viewer.uploadedSize, viewer.downloadedSize) }}</span>
|
||||
<input type="button" id="button" value="Vote!" disabled="disabled" />
|
||||
<input type="text" id="amount_box" size="8" value="{{ amount_box }}"/>
|
||||
<select id="unit" name="unit">
|
||||
<option value="mb"{{ selected(not unit_GiB) }}>MiB</option>
|
||||
<option value="gb"{{ selected(unit_GiB) }}>GiB</option>
|
||||
</select>
|
||||
<input type="button" id="button" value="Vote!" disabled />
|
||||
</form>
|
||||
<div id="vote-help">If you add the entered <strong><span id="new_bounty">0 MiB</span></strong> of bounty, your new stats will be:</div>
|
||||
<div>Uploaded: <span id="new_uploaded">{{ viewer.uploadedSize|octet_size }}</span><br />
|
||||
Ratio: <span id="new_ratio">{{ ratio(viewer.uploadedSize, viewer.downloadedSize) }}</span><br />
|
||||
Bounty must be greater than or equal to {{ constant('REQUEST_MIN') }} MiB.</div>
|
||||
{% if constant('REQUEST_TAX') > 0 -%}
|
||||
<strong>{{ constant('REQUEST_TAX') * 100 }}% of this is deducted as tax by the system.</strong>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr id="bounty">
|
||||
<td class="label">Bounty</td>
|
||||
<td class="label">Current Bounty</td>
|
||||
<td id="formatted_bounty">{{ request.bountyTotal|octet_size }}</td>
|
||||
</tr>
|
||||
{% if request.isFilled %}
|
||||
|
||||
Reference in New Issue
Block a user