add functions to get acks json off website and overwrite file

merge-requests/150/merge
Matthew Chambers 2021-12-16 14:42:44 -06:00
rodzic 268459833b
commit 0518d6e40c
1 zmienionych plików z 18 dodań i 43 usunięć

Wyświetl plik

@ -116,7 +116,14 @@ function loadAllSettings()
def_adifLogSettings def_adifLogSettings
); );
g_msgSettings = loadDefaultsAndMerge("msgSettings", def_msgSettings); g_msgSettings = loadDefaultsAndMerge("msgSettings", def_msgSettings);
// one-time override of oams pop-up messages: if pop-ups disabled
// and new version, reset msgActionSelect to 1 (pop up)
if (g_msgSettings.msgActionSelect == 0 &&
String(gtVersion) != String(g_startVersion))
{
g_msgSettings.msgActionSelect = 1;
localStorage.msgSettings = JSON.stringify(g_msgSettings);
}
g_receptionSettings = loadDefaultsAndMerge( g_receptionSettings = loadDefaultsAndMerge(
"receptionSettings", "receptionSettings",
def_receptionSettings def_receptionSettings
@ -11156,25 +11163,15 @@ function checkForNewVersion(showUptoDate)
} }
} }
function downloadAcknowledgements() function checkForNewAcks()
{ {
if (g_mapSettings.offlineMode == false) getBuffer(
{ "http://app.gridtracker.org/acknowledgements.json?lang=" + g_localeString,
getBuffer( updateAcks,
"http://app.gridtracker.org/acknowledgements.json", null,
updateAcks, http,
null, 80
"http", );
80
);
}
}
function checkForNewAcknowledgements()
{
downloadAcknowledgements();
setTimeout(checkForNewAcknowledgements, 8640000);
readAcksFromDisk();
} }
function renderBandActivity() function renderBandActivity()
@ -12728,30 +12725,8 @@ function versionCheck(buffer, flag)
function updateAcks(buffer) function updateAcks(buffer)
{ {
try g_acks = JSON.parse(buffer);
{ fs.writeFileSync("./data/acknowledgements.json", JSON.stringify(g_acks));
g_acks = JSON.parse(buffer);
fs.writeFileSync(g_NWappData + "acknowledgements.json", JSON.stringify(g_acks));
}
catch (e)
{
// can't write, somethings broke
}
}
function readAcksFromDisk()
{
try
{
var fileBuf = fs.readFileSync(g_NWappData + "acknowledgements.json");
var loadedData = JSON.parse(fileBuf);
// some validation here?
g_acknowledgedCalls = loadedData;
}
catch (e)
{
// file failed to load, probably not downloaded
}
} }
function onExitAppToGoWebsite() function onExitAppToGoWebsite()