From 6c7d66b2e0823a59ff1768da8c65715c92482416 Mon Sep 17 00:00:00 2001 From: Julian Labus <julian@labus-online.de> Date: Tue, 28 Apr 2020 19:33:26 +0200 Subject: [PATCH] app: allow device info links per revision --- app.js | 37 +++++++++++++++++++++++++------------ config_template.js | 16 ++++++++++------ devices.js | 5 +++++ 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/app.js b/app.js index 07282ec..5a761d1 100644 --- a/app.js +++ b/app.js @@ -839,23 +839,36 @@ var firmwarewizard = function() { scrollDown(); } - var deviceinfo = $('#deviceinfo'); + // find device info link + function findDeviceInfo(vendor, model, revision, links) { + if (links[vendor] !== undefined && links[vendor][model] !== undefined) { + revisions = links[vendor][model]; + } else { + return ''; + } + + if (typeof revisions == 'object' && revisions[revision] !== undefined) { + return revisions[revision]; + } else if (typeof revisions == 'string') { + return revisions; + } else { + return ''; + } + } + var url = ''; + var custom_url = ''; + var deviceinfo = $('#deviceinfo'); deviceinfo.innerHTML = ''; - if ( - devices_info[currentVendor] !== undefined && - devices_info[currentVendor][currentModel] !== undefined - ) { - url = devices_info[currentVendor][currentModel]; + url = findDeviceInfo(currentVendor, currentModel, currentRevision, devices_info); + + if ("devices_info" in config){ + custom_url = findDeviceInfo(currentVendor, currentModel, currentRevision, config.devices_info); } - if ( - config.devices_info !== undefined && - config.devices_info[currentVendor] !== undefined && - config.devices_info[currentVendor][currentModel] - ) { - url = config.devices_info[currentVendor][currentModel]; + if (custom_url !== '') { + url = custom_url; } if (url !== '') { diff --git a/config_template.js b/config_template.js index bbe0274..a54d778 100644 --- a/config_template.js +++ b/config_template.js @@ -54,10 +54,14 @@ var config = { // link to changelog changelog: 'CHANGELOG.html', // links for instructions like flashing of certain devices (optional) - // overwrites values from devices_info in devices.js - devices_info: { - 'AVM': { - "FRITZ!Box 4040": "https://fritz-tools.readthedocs.io" - } - } + // can be set for a whole model or individual revisions + // overwrites default values from devices_info in devices.js + // devices_info: { + // 'AVM': { + // "FRITZ!Box 4040": "https://fritz-tools.readthedocs.io" + // }, + // "TP-Link": { + // "TL-WR841N/ND": {"v13": "https://wiki.freifunk.net/TP-Link_WR841ND/Flash-Anleitung_v13"} + // } + // } }; diff --git a/devices.js b/devices.js index 1c85a4e..09a5816 100644 --- a/devices.js +++ b/devices.js @@ -428,5 +428,10 @@ var devices_info = { "UniFi AC Mesh Pro": "https://forum.darmstadt.freifunk.net/t/unifi-ap-erstinstallation/790", "UniFi AC Mesh": "https://forum.darmstadt.freifunk.net/t/unifi-ap-erstinstallation/790", "UniFi AC Pro": "https://forum.darmstadt.freifunk.net/t/unifi-ap-erstinstallation/790", + }, + "TP-Link": { + "TL-WR841N/ND" : { + "v13": "https://openwrt.org/toh/tp-link/tl-wr841nd#tftp_recovery_via_bootloader_for_v8_v9_v10_v11_v12_v13" + } } } -- GitLab