Improving things.

This commit is contained in:
Marat Fayzullin 2023-07-19 22:06:05 -04:00
parent 2eb3c0aac3
commit 7604a8e385
3 changed files with 31 additions and 20 deletions

View File

@ -523,9 +523,8 @@ $(function(){
}
var makeListItem = function(name, value) {
return '<div style="border-bottom:1px dotted;">'
+ '<span>' + name.replace(/[ \r\n]+/gm, '&nbsp;')
+ '</span>&nbsp;&nbsp;&nbsp;&nbsp;'
return '<div style="border-bottom:1px dotted;white-space:nowrap;">'
+ '<span>' + name + '&nbsp;&nbsp;&nbsp;&nbsp;</span>'
+ '<span style="float:right;">' + value + '</span>'
+ '</div>';
}
@ -707,7 +706,7 @@ $(function(){
: freq;
var name = ("0000" + marker.schedule[j].time1).slice(-4)
+ "-" + ("0000" + marker.schedule[j].time2).slice(-4)
+ "&#8209;" + ("0000" + marker.schedule[j].time2).slice(-4)
+ "&nbsp;&nbsp;" + marker.schedule[j].name;
freq = '<a target="openwebrx-rx" href="/#freq=' + tune

View File

@ -64,6 +64,16 @@ class EIBI(object):
if not self.schedule:
self.schedule = self.loadSchedule(file)
# Save schedule to a given JSON file
def saveSchedule(self, file: str, schedule):
logger.debug("Saving {0} schedule entries to '{1}'...".format(len(schedule), file))
try:
with open(file, "w") as f:
json.dump(schedule, f, indent=2)
f.close()
except Exception as e:
logger.debug("saveSchedule() exception: {0}".format(e))
# Load schedule from a given JSON file
def loadSchedule(self, file: str):
logger.debug("Loading schedule from '{0}'...".format(file))
@ -85,13 +95,7 @@ class EIBI(object):
schedule = self.scrape()
# Save parsed data into a file
if schedule:
logger.debug("Saving {0} schedule entries to '{1}'...".format(len(schedule), file))
try:
with open(file, "w") as f:
json.dump(schedule, f, indent=2)
f.close()
except Exception as e:
logger.debug("updateSchedule() exception: {0}".format(e))
self.saveSchedule(file, schedule)
# Done
return schedule
@ -167,6 +171,7 @@ class EIBI(object):
result[name]["schedule"] = []
# Add schedule entry to the location
result[name]["schedule"].append(entry)
# Done
return result
@ -237,6 +242,7 @@ class EIBI(object):
# When we encounter a location...
m = self.patternCSV.match(line)
if m is not None:
freq = int(float(m.group(1)) * 1000)
days = m.group(4)
name = m.group(6).lower()
lang = m.group(7)
@ -250,6 +256,7 @@ class EIBI(object):
"lsb" if days == "LSB" else
"hfdl" if "hfdl" in name else # HFDL
"fax" if " fax" in name else # Weather FAX
"rtty450" if "rtty" in name else # Weather RTTY
"usb" if "volmet" in name else # Weather
"usb" if "cross " in name else # Weather
"usb" if " ldoc" in name else # Aircraft
@ -257,18 +264,19 @@ class EIBI(object):
"usb" if " nat-" in name else # Aircraft
"usb" if " usb" in name else
"usb" if "fsk" in name else
"usb" if freq < 7000000 else # Services
"am")
# Append a new entry to the result
result.append({
"freq" : int(float(m.group(1)) * 1000),
"freq" : freq,
"mode" : mode,
"time1" : int(m.group(2)),
"time2" : int(m.group(3)),
"days" : self.convertDays(days),
"itu" : m.group(5),
"name" : m.group(6),
"lang" : m.group(7),
"lang" : lang,
"tgt" : m.group(8),
"src" : m.group(9),
"pers" : int(m.group(10)),

View File

@ -196,6 +196,16 @@ class Markers(object):
logger.debug("Stopped marker database thread.")
self.thread = None
# Save markers to a given file
def saveMarkers(self, file: str, markers):
logger.debug("Saving {0} markers to '{1}'...".format(len(markers), file))
try:
with open(file, "w") as f:
json.dump(markers, f, cls=MyJSONEncoder, indent=2)
f.close()
except Exception as e:
logger.debug("saveMarkers() exception: {0}".format(e))
# Load markers from a given file
def loadMarkers(self, file: str):
logger.debug("Loading markers from '{0}'...".format(file))
@ -237,13 +247,7 @@ class Markers(object):
# Save parsed data into a file, if there is anything to save
if cache:
logger.debug("Saving {0} markers to '{1}'...".format(len(cache), file))
try:
with open(file, "w") as f:
json.dump(cache, f, cls=MyJSONEncoder, indent=2)
f.close()
except Exception as e:
logger.debug("updateCache() exception: {0}".format(e))
self.saveMarkers(file, cache)
# Done
return cache