Kategorien
![]() |
Bitte befüllt die Seite DarkfleetWiki:NoSpamUser in alphabetischer Reihenfolge mit den Namen von Wikibenutzern, welche keine Spam-Bots sind. | ![]() |
MediaWiki:CFoptions.js: Unterschied zwischen den Versionen
Aus DarkfleetWiki
Galak (Diskussion | Beiträge) (erstmal unveränderte version aus dem fwwiki....ist wichtig für den forschungsrechner und wird demnächst entsprechend angepasst) |
(addOnLoadHook war deprecated und ist in 1.27 scheinbar entfernt) |
||
(4 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt) | |||
Zeile 5: | Zeile 5: | ||
optcont = document.getElementById('CFoptions'); | optcont = document.getElementById('CFoptions'); | ||
caption = document.createElement('b'); | caption = document.createElement('b'); | ||
− | caption.appendChild(document.createTextNode(' | + | caption.appendChild(document.createTextNode('Forschungszeit anzeigen: ')); |
form = document.createElement('form'); | form = document.createElement('form'); | ||
form.action = '#'; | form.action = '#'; | ||
Zeile 11: | Zeile 11: | ||
option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); option.checked = 'checked'; | option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); option.checked = 'checked'; | ||
− | option.name = 'CF_switch'; option.value = 'level'; form.appendChild(option); form.appendChild(document.createTextNode(' | + | option.name = 'CF_switch'; option.value = 'level'; form.appendChild(option); form.appendChild(document.createTextNode('Forschungszeit pro Stufe')); |
option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); | option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); | ||
− | option.name = 'CF_switch'; option.value = 'total'; form.appendChild(option); form.appendChild(document.createTextNode(' | + | option.name = 'CF_switch'; option.value = 'total'; form.appendChild(option); form.appendChild(document.createTextNode('Gesamtforschungszeit')); |
option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); | option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); | ||
Zeile 36: | Zeile 36: | ||
tr = document.createElement('tr'); | tr = document.createElement('tr'); | ||
− | td = document.createElement('td'); td.appendChild(document.createTextNode('Stufe | + | td = document.createElement('td'); td.appendChild(document.createTextNode('Stufe Basiswissen:')); tr.appendChild(td); |
td = document.createElement('td'); input = document.createElement('input'); input.type = 'text'; | td = document.createElement('td'); input = document.createElement('input'); input.type = 'text'; | ||
input.style.width = '100px'; input.name = 'CFlerntech'; td.appendChild(input); tr.appendChild(td); | input.style.width = '100px'; input.name = 'CFlerntech'; td.appendChild(input); tr.appendChild(td); | ||
Zeile 62: | Zeile 62: | ||
function calc_CF() { | function calc_CF() { | ||
if (isNaN(form.CFlevel.value) || isNaN(form.CFlerntech.value)) return alert('Bitte nur Zahlen eingeben!'); | if (isNaN(form.CFlevel.value) || isNaN(form.CFlerntech.value)) return alert('Bitte nur Zahlen eingeben!'); | ||
− | if ((Number(form.CFlevel.value) > mx) || (Number(form.CFlerntech.value) > | + | if ((Number(form.CFlevel.value) > mx) || (Number(form.CFlerntech.value) > 60)) alert('Mindestens ein eingegebener Wert ist höher als die Maximalstufe der betreffenden Fähigkeit. Das Ergebnis ist hypothetisch und kann so nicht im Spiel vorkommen.'); |
− | duration = Math.pow(0. | + | duration = Math.pow(0.98, form.CFlerntech.value) * (form.CFlevel.value - 1) * gw; |
− | totalduration = Math.pow(0. | + | totalduration = Math.pow(0.98, form.CFlerntech.value) * (form.CFlevel.value - 1) * form.CFlevel.value / 2 * gw; |
lerntechsaving = (form.CFlevel.value - 1) * gw - duration; | lerntechsaving = (form.CFlevel.value - 1) * gw - duration; | ||
lerntechtotalsaving = (form.CFlevel.value - 1) * form.CFlevel.value / 2 * gw - totalduration; | lerntechtotalsaving = (form.CFlevel.value - 1) * form.CFlevel.value / 2 * gw - totalduration; | ||
if (form.nextSibling) calc.removeChild(form.nextSibling); | if (form.nextSibling) calc.removeChild(form.nextSibling); | ||
− | calc.appendChild(document.createTextNode(' | + | calc.appendChild(document.createTextNode('Die Forschung auf Stufe ' + form.CFlevel.value + ' dauert ' |
+ (duration >= 86400 ? String(Math.floor(duration / 86400)) + ' Tage, ' : '') + String(Math.floor((duration % 86400) / 3600)) | + (duration >= 86400 ? String(Math.floor(duration / 86400)) + ' Tage, ' : '') + String(Math.floor((duration % 86400) / 3600)) | ||
− | + ' Stunden und ' + String(Math.floor((duration % 3600) / 60)) + ' Minuten. Die | + | + ' Stunden und ' + String(Math.floor((duration % 3600) / 60)) + ' Minuten. Die Gesamtforschungszeit beträgt ' |
+ (totalduration >= 86400 ? String(Math.floor(totalduration / 86400)) + ' Tage, ' : '') + String(Math.floor((totalduration % 86400) / 3600)) | + (totalduration >= 86400 ? String(Math.floor(totalduration / 86400)) + ' Tage, ' : '') + String(Math.floor((totalduration % 86400) / 3600)) | ||
+ ' Stunden und ' + String(Math.floor((totalduration % 3600) / 60)) + ' Minuten.' + (form.CFlerntech.value > 0 | + ' Stunden und ' + String(Math.floor((totalduration % 3600) / 60)) + ' Minuten.' + (form.CFlerntech.value > 0 | ||
− | ? ' Gegenüber | + | ? ' Gegenüber der Forschung mit Basiswissen auf Stufe 0 wurden ' + (lerntechsaving >= 86400 |
? String(Math.floor(lerntechsaving / 86400)) + ' Tage, ' : '') + String(Math.floor((lerntechsaving % 86400) / 3600)) | ? String(Math.floor(lerntechsaving / 86400)) + ' Tage, ' : '') + String(Math.floor((lerntechsaving % 86400) / 3600)) | ||
− | + ' Stunden und ' + String(Math.floor((lerntechsaving % 3600) / 60)) + ' Minuten ( | + | + ' Stunden und ' + String(Math.floor((lerntechsaving % 3600) / 60)) + ' Minuten (Gesamtforschunszeit: ' + (lerntechtotalsaving >= 86400 |
? String(Math.floor(lerntechtotalsaving / 86400)) + ' Tage, ' : '') + String(Math.floor((lerntechtotalsaving % 86400) / 3600)) | ? String(Math.floor(lerntechtotalsaving / 86400)) + ' Tage, ' : '') + String(Math.floor((lerntechtotalsaving % 86400) / 3600)) | ||
+ ' Stunden und ' + String(Math.floor((lerntechtotalsaving % 3600) / 60)) + ' Minuten) eingespart.' : ''))); | + ' Stunden und ' + String(Math.floor((lerntechtotalsaving % 3600) / 60)) + ' Minuten) eingespart.' : ''))); | ||
} | } | ||
− | + | jQuery( document ).ready( function( $ ) { | |
+ | init_CF(); | ||
+ | } ); | ||
+ | //addOnloadHook(init_CF); |
Aktuelle Version vom 8. Februar 2017, 14:10 Uhr
var calc, form, gw, mx; function init_CF() { if (!document.getElementById('CFoptions')) return; optcont = document.getElementById('CFoptions'); caption = document.createElement('b'); caption.appendChild(document.createTextNode('Forschungszeit anzeigen: ')); form = document.createElement('form'); form.action = '#'; form.style.display = 'inline'; option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); option.checked = 'checked'; option.name = 'CF_switch'; option.value = 'level'; form.appendChild(option); form.appendChild(document.createTextNode('Forschungszeit pro Stufe')); option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); option.name = 'CF_switch'; option.value = 'total'; form.appendChild(option); form.appendChild(document.createTextNode('Gesamtforschungszeit')); option = document.createElement('input'); option.type = 'radio'; option.setAttribute('onclick', 'switch_CF(this);'); option.name = 'CF_switch'; option.value = 'calc'; form.appendChild(option); form.appendChild(document.createTextNode('Wartezeitenrechner')); optcont.appendChild(caption); optcont.appendChild(form); calc = document.getElementById('CFcalc'); gw = Number(calc.removeChild(calc.firstChild).nodeValue); mx = Number(document.getElementById('CFmax').firstChild.nodeValue); form = document.createElement('form'); form.action = '#'; table = document.createElement('table'); tr = document.createElement('tr'); td = document.createElement('td'); td.appendChild(document.createTextNode('Stufe:')); tr.appendChild(td); td = document.createElement('td'); input = document.createElement('input'); input.type = 'text'; input.style.width = '100px'; input.name = 'CFlevel'; td.appendChild(input); tr.appendChild(td); table.appendChild(tr); tr = document.createElement('tr'); td = document.createElement('td'); td.appendChild(document.createTextNode('Stufe Basiswissen:')); tr.appendChild(td); td = document.createElement('td'); input = document.createElement('input'); input.type = 'text'; input.style.width = '100px'; input.name = 'CFlerntech'; td.appendChild(input); tr.appendChild(td); table.appendChild(tr); tr = document.createElement('tr'); td = document.createElement('td'); td.colspan = '2'; td.style.textAlign = 'center'; input = document.createElement('input'); input.type = 'button'; input.value = 'Berechnen'; input.onclick = calc_CF; td.appendChild(input); tr.appendChild(td); table.appendChild(tr); form.appendChild(table); calc.appendChild(form); document.getElementById('CFtotal').style.display = 'none'; calc.style.display = 'none'; } function switch_CF(option) { document.getElementById('CFlevel').style.display = (option.value == 'level' ? 'block' : 'none'); document.getElementById('CFtotal').style.display = (option.value == 'total' ? 'block' : 'none'); document.getElementById('CFcalc').style.display = (option.value == 'calc' ? 'block' : 'none'); } function calc_CF() { if (isNaN(form.CFlevel.value) || isNaN(form.CFlerntech.value)) return alert('Bitte nur Zahlen eingeben!'); if ((Number(form.CFlevel.value) > mx) || (Number(form.CFlerntech.value) > 60)) alert('Mindestens ein eingegebener Wert ist höher als die Maximalstufe der betreffenden Fähigkeit. Das Ergebnis ist hypothetisch und kann so nicht im Spiel vorkommen.'); duration = Math.pow(0.98, form.CFlerntech.value) * (form.CFlevel.value - 1) * gw; totalduration = Math.pow(0.98, form.CFlerntech.value) * (form.CFlevel.value - 1) * form.CFlevel.value / 2 * gw; lerntechsaving = (form.CFlevel.value - 1) * gw - duration; lerntechtotalsaving = (form.CFlevel.value - 1) * form.CFlevel.value / 2 * gw - totalduration; if (form.nextSibling) calc.removeChild(form.nextSibling); calc.appendChild(document.createTextNode('Die Forschung auf Stufe ' + form.CFlevel.value + ' dauert ' + (duration >= 86400 ? String(Math.floor(duration / 86400)) + ' Tage, ' : '') + String(Math.floor((duration % 86400) / 3600)) + ' Stunden und ' + String(Math.floor((duration % 3600) / 60)) + ' Minuten. Die Gesamtforschungszeit beträgt ' + (totalduration >= 86400 ? String(Math.floor(totalduration / 86400)) + ' Tage, ' : '') + String(Math.floor((totalduration % 86400) / 3600)) + ' Stunden und ' + String(Math.floor((totalduration % 3600) / 60)) + ' Minuten.' + (form.CFlerntech.value > 0 ? ' Gegenüber der Forschung mit Basiswissen auf Stufe 0 wurden ' + (lerntechsaving >= 86400 ? String(Math.floor(lerntechsaving / 86400)) + ' Tage, ' : '') + String(Math.floor((lerntechsaving % 86400) / 3600)) + ' Stunden und ' + String(Math.floor((lerntechsaving % 3600) / 60)) + ' Minuten (Gesamtforschunszeit: ' + (lerntechtotalsaving >= 86400 ? String(Math.floor(lerntechtotalsaving / 86400)) + ' Tage, ' : '') + String(Math.floor((lerntechtotalsaving % 86400) / 3600)) + ' Stunden und ' + String(Math.floor((lerntechtotalsaving % 3600) / 60)) + ' Minuten) eingespart.' : ''))); } jQuery( document ).ready( function( $ ) { init_CF(); } ); //addOnloadHook(init_CF);