ffrs-fw-dl/js/firmware.js

199 lines
8.4 KiB
JavaScript
Raw Permalink Normal View History

2017-06-04 10:26:25 +00:00
function change (origin, select) {
if (origin === 'hersteller') {
$('#img_router_front').attr("src", "router_images/keinbild.jpg")
$('#img_router_back').attr("src", "router_images/keinbild.jpg")
$('#version')
.attr('disabled', '')
.material_select()
$('#erstinstallation')
.attr('disabled', '')
.material_select()
$('#entwicklungsstadium')
.attr('disabled', '')
.material_select()
var modelle = []
for (var i = 0; i < anzahl_hersteller; i++) {
2018-01-30 11:49:32 +00:00
if ($(select).find('option:selected').html() === herstellername[i]) {
2017-06-04 10:26:25 +00:00
var j = 0
while (j < router_json.length) {
2018-01-30 11:49:32 +00:00
if (router_json[j].hersteller === herstellername[i]) {
2017-06-04 10:26:25 +00:00
modelle[j] = router_json[j].modell
if (j < router_json.length - 1) {
2018-01-30 11:49:32 +00:00
while (router_json[j].modell === router_json[j + 1].modell) {
2017-06-04 10:26:25 +00:00
if (j < router_json.length - 1) {
j++
} else {
break
}
}
}
}
j++
}
}
}
$('#modell').html("<option disabled selected value=''>Modell auswählen</option>")
for (var modell in modelle) {
var newOption = document.createElement('option')
newOption.value = modelle[modell]
newOption.innerHTML = modelle[modell]
$('#modell').append(newOption)
}
$('#modell')
.removeAttr('disabled')
.material_select()
}
else if (origin === "modell") {
$('#img_router_front').attr("src", "router_images/keinbild.jpg")
$('#img_router_back').attr("src", "router_images/keinbild.jpg")
$('#erstinstallation')
.attr('disabled', '')
.material_select()
$('#entwicklungsstadium')
.attr('disabled', '')
.material_select()
var versionen = []
var i = 0
while (i < router_json.length) {
if (router_json[i].modell == $(select).val()) {
versionen[i] = i + '|' + router_json[i].version
if (i < router_json.length - 1) {
while (router_json[i].modell == router_json[i + 1].modell) {
if (i < router_json.length - 1) {
i++
versionen[i] = i + '|' + router_json[i].version
} else {
break
}
}
}
}
i++
}
$('#version').html("<option disabled selected value=''>Modell auswählen</option>")
for (var version in versionen) {
var pair = versionen[version].split('|')
var newOption = document.createElement('option')
newOption.value = pair[0]
newOption.innerHTML = pair[1]
$('#version').append(newOption)
}
$('#version')
.removeAttr('disabled')
.material_select();
}
else if(origin === 'version') {
2017-09-23 18:40:47 +00:00
var id = $('#version').val()
2017-06-04 10:26:25 +00:00
$('#entwicklungsstadium')
.attr('disabled', '')
.material_select()
2017-09-23 18:40:47 +00:00
$('#erstinstallation').html("<option disabled selected value=''>Firmware Erstinstallation?</option>")
if(router_json[id].stablefactory === 1) {
2017-09-23 19:35:04 +00:00
$('#erstinstallation').append('<option value="' + $(select).val() + 'J">Ja</option>');
2017-09-23 18:40:47 +00:00
}
if(router_json[id].stablesysupgrade === 1) {
2017-09-23 19:35:04 +00:00
$('#erstinstallation').append('<option value="' + $(select).val() + 'N">Nein</option>');
2017-09-23 18:40:47 +00:00
}
2017-06-04 10:26:25 +00:00
$('#erstinstallation').removeAttr('disabled')
$('#erstinstallation').material_select()
$('#img_router_front').attr("src", router_json[$(select).val()].imagefront)
$('#img_router_back').attr("src", router_json[$(select).val()].imageback)
}
else if (origin === 'erstinstallation') {
2017-09-23 19:35:04 +00:00
var erstinstallation;
if($('#erstinstallation').val().lastIndexOf('N') < 0) {
erstinstallation = true;
} else if($('#erstinstallation').val().lastIndexOf('Y') < 0) {
erstinstallation = false;
}
2017-06-04 10:26:25 +00:00
var stadium = $('#entwicklungsstadium')
2017-09-23 16:46:38 +00:00
stadium.html("<option disabled value=''>Firmware Entwicklungsstadium?</option>")
2017-06-04 10:26:25 +00:00
var id = $('#version').val()
2017-09-23 19:35:04 +00:00
if(erstinstallation) {
if (router_json[id].stablefactory === 1) {
stadium.append("<option selected value='" + $(select).val() +"stable'>Stabil &#040;empfohlen&#041;</option>")
}
if (router_json[id].betafactory === 1) {
stadium.append("<option value='" + $(select).val() +"beta'>Beta</option>")
}
if (router_json[id].experimentalfactory === 1) {
stadium.append("<option value='" + $(select).val() +"exp'>Experimental</option>")
}
if (router_json[id].brokenfactory === 1) {
stadium.append("<option value='" + $(select).val() +"broken'>Fehlerhaft</option>")
}
} else if (!erstinstallation) {
if (router_json[id].stablesysupgrade === 1) {
stadium.append("<option selected value='" + $(select).val() +"stable'>Stabil &#040;empfohlen&#041;</option>")
}
if (router_json[id].betasysupgrade === 1) {
stadium.append("<option value='" + $(select).val() +"beta'>Beta</option>")
}
if (router_json[id].experimentalsysupgrade === 1) {
stadium.append("<option value='" + $(select).val() +"exp'>Experimental</option>")
}
if (router_json[id].brokensysupgrade === 1) {
stadium.append("<option value='" + $(select).val() +"broken'>Fehlerhaft</option>")
}
2017-06-04 10:26:25 +00:00
}
stadium.removeAttr('disabled')
stadium.material_select()
}
else if (origin === 'entwicklungsstadium') {
var id = 0
var link = '#'
var linkclass = ''
if ($(select).val().lastIndexOf('Jbeta') != -1) {
console.log('xxx')
id = parseInt($(select).val().slice(0, $(select).val().length - 4))
link = router_json[id].betafactorylink
linkclass = 'btn-warning'
}
if ($(select).val().lastIndexOf('Jbroken') != -1) {
id = parseInt($(select).val().slice(0, $(select).val().length - 6))
link = router_json[id].brokenfactorylink
linkclass = 'btn-danger'
}
if ($(select).val().lastIndexOf('Jexp') != -1) {
id = parseInt($(select).val().slice(0, $(select).val().length - 3))
link = router_json[id].experimentalfactorylink
linkclass = 'btn-warning'
}
if ($(select).val().lastIndexOf('Jstable') != -1) {
console.log("xxxx")
id = parseInt($(select).val().slice(0, $(select).val().length - 6))
link = router_json[id].stablefactorylink
linkclass = 'btn-success'
}
if ($(select).val().lastIndexOf('Nbeta') != -1) {
id = parseInt($(select).val().slice(0, $(select).val().length - 4))
link = router_json[id].betasysupgradelink
linkclass = 'btn-warning'
}
if ($(select).val().lastIndexOf('Nbroken') != -1) {
id = parseInt($(select).val().slice(0, $(select).val().length - 6))
link = router_json[id].brokensysupgradelink
linkclass = 'btn-danger'
}
if ($(select).val().lastIndexOf('Nexp') != -1) {
id = parseInt($(select).val().slice(0, $(select).val().length - 3))
link = router_json[id].experimentalsysupgradelink
linkclass = 'btn-warning'
}
if ($(select).val().lastIndexOf('Nstable') != -1) {
id = parseInt($(select).val().slice(0, $(select).val().length - 6))
link = router_json[id].stablesysupgradelink
linkclass = 'btn-success'
}
$('#download').attr("href", link)
$('#download').removeAttr('disabled')
}
2017-06-26 13:42:51 +00:00
else if (origin === "stadtteil") {
location.href = "firmware.php?id=" + $(select).val()
}
2017-06-04 10:26:25 +00:00
}
$(function () {
$('select').material_select();
})