Add URL Versioning
This commit is contained in:
parent
aa555168e7
commit
ed189f8282
1 changed files with 18 additions and 11 deletions
29
dist/js/main.js
vendored
29
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,15 +411,20 @@ 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
|
||||||
renameKey(urlConfig, 'v', 'config_version')
|
let urlVersion = params['c'].substring(0, 1)
|
||||||
renameKey(urlConfig, 's', 'subnets')
|
let urlData = params['c'].substring(1)
|
||||||
expandKeys(urlConfig['subnets'])
|
if (urlVersion === '1') {
|
||||||
let subnet_split = Object.keys(urlConfig['subnets'])[0].split('/')
|
let urlConfig = JSON.parse(LZString.decompressFromEncodedURIComponent(params['c'].substring(1)))
|
||||||
$('#network').val(subnet_split[0])
|
renameKey(urlConfig, 'v', 'config_version')
|
||||||
$('#netsize').val(subnet_split[1])
|
renameKey(urlConfig, 's', 'subnets')
|
||||||
importConfig(urlConfig)
|
expandKeys(urlConfig['subnets'])
|
||||||
return true
|
let subnet_split = Object.keys(urlConfig['subnets'])[0].split('/')
|
||||||
|
$('#network').val(subnet_split[0])
|
||||||
|
$('#netsize').val(subnet_split[1])
|
||||||
|
importConfig(urlConfig)
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue