Add URL Versioning
This commit is contained in:
parent
aa555168e7
commit
ed189f8282
1 changed files with 18 additions and 11 deletions
13
dist/js/main.js
vendored
13
dist/js/main.js
vendored
|
@ -19,6 +19,8 @@ let operatingMode = 'NORMAL'
|
||||||
let noteTimeout;
|
let noteTimeout;
|
||||||
let minSubnetSize = 30
|
let minSubnetSize = 30
|
||||||
let inflightColor = 'NONE'
|
let inflightColor = 'NONE'
|
||||||
|
let urlVersion = '1'
|
||||||
|
let configVersion = '1'
|
||||||
|
|
||||||
$('input#network,input#netsize').on('input', function() {
|
$('input#network,input#netsize').on('input', function() {
|
||||||
$('#input_form')[0].classList.add('was-validated');
|
$('#input_form')[0].classList.add('was-validated');
|
||||||
|
@ -391,7 +393,7 @@ $( document ).ready(function() {
|
||||||
|
|
||||||
function exportConfig() {
|
function exportConfig() {
|
||||||
return {
|
return {
|
||||||
'config_version': '1',
|
'config_version': configVersion,
|
||||||
'subnets': subnetMap,
|
'subnets': subnetMap,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,7 +403,7 @@ function getConfigUrl() {
|
||||||
renameKey(defaultExport, 'config_version', 'v')
|
renameKey(defaultExport, 'config_version', 'v')
|
||||||
renameKey(defaultExport, 'subnets', 's')
|
renameKey(defaultExport, 'subnets', 's')
|
||||||
shortenKeys(defaultExport['s'])
|
shortenKeys(defaultExport['s'])
|
||||||
return '/index.html?c=' + LZString.compressToEncodedURIComponent(JSON.stringify(defaultExport))
|
return '/index.html?c=' + urlVersion + LZString.compressToEncodedURIComponent(JSON.stringify(defaultExport))
|
||||||
}
|
}
|
||||||
|
|
||||||
function processConfigUrl() {
|
function processConfigUrl() {
|
||||||
|
@ -409,7 +411,11 @@ function processConfigUrl() {
|
||||||
get: (searchParams, prop) => searchParams.get(prop),
|
get: (searchParams, prop) => searchParams.get(prop),
|
||||||
});
|
});
|
||||||
if (params['c'] !== null) {
|
if (params['c'] !== null) {
|
||||||
let urlConfig = JSON.parse(LZString.decompressFromEncodedURIComponent(params['c']))
|
// First character is the version of the URL string, in case the mechanism of encoding changes
|
||||||
|
let urlVersion = params['c'].substring(0, 1)
|
||||||
|
let urlData = params['c'].substring(1)
|
||||||
|
if (urlVersion === '1') {
|
||||||
|
let urlConfig = JSON.parse(LZString.decompressFromEncodedURIComponent(params['c'].substring(1)))
|
||||||
renameKey(urlConfig, 'v', 'config_version')
|
renameKey(urlConfig, 'v', 'config_version')
|
||||||
renameKey(urlConfig, 's', 'subnets')
|
renameKey(urlConfig, 's', 'subnets')
|
||||||
expandKeys(urlConfig['subnets'])
|
expandKeys(urlConfig['subnets'])
|
||||||
|
@ -420,6 +426,7 @@ function processConfigUrl() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function shortenKeys(subnetTree) {
|
function shortenKeys(subnetTree) {
|
||||||
for (let mapKey in subnetTree) {
|
for (let mapKey in subnetTree) {
|
||||||
|
|
Loading…
Reference in a new issue