מדיה ויקי:סקריפטים/16.js – הבדלי גרסאות
תוכן שנמחק תוכן שנוסף
מ נראה לי יותר נכון בעברית |
ביטול קפיצה לראש הדף |
||
שורה 1: | שורה 1: | ||
// סקריפט ספירת הצבעות. נכתב על ידי [[משתמש:Yonidebest]], שוכתב על ידי קיפודנחש. |
// סקריפט ספירת הצבעות. נכתב על ידי [[משתמש:Yonidebest]], שוכתב על ידי קיפודנחש. |
||
if (mw.config.get('wgNamespaceNumber') == 4) |
if (mw.config.get('wgNamespaceNumber') == 4) |
||
mw.util.addPortletLink('p-tb', '#', 'ספירת הצבעות').onclick = function() { |
mw.util.addPortletLink('p-tb', '#', 'ספירת הצבעות').onclick = function(event) { |
||
event.preventDefault(); |
|||
function recalculate() { |
function recalculate() { |
||
var total = 0; |
var total = 0; |
גרסה מ־19:48, 22 בנובמבר 2018
// סקריפט ספירת הצבעות. נכתב על ידי [[משתמש:Yonidebest]], שוכתב על ידי קיפודנחש.
if (mw.config.get('wgNamespaceNumber') == 4)
mw.util.addPortletLink('p-tb', '#', 'ספירת הצבעות').onclick = function(event) {
event.preventDefault();
function recalculate() {
var total = 0;
$('div.voteCounterSpan span.voteResults').text(''); // clear all.
$('div.voteCounterSpan').each(function() { // count totlas
var $this = $(this);
if ($this.find('input').prop('checked'))
total += $this.next('ol').find('li').length;
});
if (total > 0)
$('div.voteCounterSpan').each(function() {
var $this = $(this);
if ($this.find('input').prop('checked')) {
var votes = $this.next('ol').find('li').length;
$this.find('span.voteResults').text(votes + '/' + total + ' (' + (100 * votes/total).toFixed(1) + '%)');
}
});
}
mw.util.$content.find('ol:has(li)').before(
$('<div>', {'class': 'voteCounterSpan'})
.css({'font-size': '140%', border: '2px solid red', 'margin-bottom': '20px', padding: '8px', width: 'auto'})
.text('חישוב אפשרות זו')
.append(
$('<input>', {'type': 'checkbox'})
.change(recalculate)
)
.append($('<span>', {'class': 'voteResults'}))
);
};