@yz-social/civildefense.io 4.4.4 → 4.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
1
  const { localStorage } = globalThis; // For linters.
2
2
  import { stripLeadingEmoji, canonicalTag } from './versions.js';
3
3
  import { Int } from './translations.js';
4
- import { updateSubscriptions, Marker, showMessage } from './map.js';
4
+ import { showMessage } from './map.js';
5
+ import { Alert } from './alert.js';
5
6
  import { resetInactivityTimer, clickTip } from './main.js';
6
7
 
7
8
  // We subscribe to the cartesian product of the list of non-overlapping cells and all hashes.
@@ -26,7 +27,7 @@ export const Hashtags = {
26
27
  // were using the same emoji as each other.
27
28
  hashtags: {},
28
29
  canonical2extended: {},
29
- add(label, active = true, updateMarkers = true) { // Ensure label is a hashtag, initialized to active, and if existing, forcing it active.
30
+ add(label, active = true, updateAlerts = true) { // Ensure label is a hashtag, initialized to active, and if existing, forcing it active.
30
31
  // Return our (possibly new) understanding of the extended hashtag.
31
32
  // Note that only startup-population of tags from persistence would ever specify active=false.
32
33
  // Here we accept a canonical or extended label, updating our records keyed by the canonical part,
@@ -44,7 +45,7 @@ export const Hashtags = {
44
45
  this.canonical2extended[canonical] = extended;
45
46
  if (!oursHasEmoji) {
46
47
  this.onchange({resetSubscriptions: false});
47
- if (updateMarkers) Marker.updateMarkers(canonical, extended);
48
+ if (updateAlerts) Alert.updateAlerts(canonical, extended);
48
49
  }
49
50
  return extended;
50
51
  },
@@ -70,7 +71,7 @@ export const Hashtags = {
70
71
  // Unneeded and not necessarilly meaningful if tag has emoji.
71
72
  return `<minidenticon-svg ${slot ? `slot="${slot}"` : ''} username="${tag}"></minidenticon-svg>`;
72
73
  },
73
- formatMarker(tag) { // HTML (possibly text) to represent tag as a marker on map.
74
+ formatAlert(tag) { // HTML (possibly text) to represent tag as a marker on map.
74
75
  return this.firstEmoji(tag) || this.identicon(tag);
75
76
  },
76
77
  formatPubtag(tag) { // HTML (possibly text) to represent tag with defaulted icon.
@@ -82,8 +83,8 @@ export const Hashtags = {
82
83
  if (redisplaySubscribers) this.resetSubscriberDisplay();
83
84
  localStorage.setItem('hashtags', JSON.stringify(this.hashtags));
84
85
  if (resetSubscriptions) {
85
- updateSubscriptions();
86
- Object.values(Marker.markers).forEach(wrapper => this.hashtags[wrapper.hashtag] || wrapper.destroy());
86
+ Alert.updateSubscriptions();
87
+ Alert.items.forEach(wrapper => this.hashtags[wrapper.hashtag] || wrapper.destroy());
87
88
  }
88
89
  },
89
90
  chipset: document.body.querySelector('.watching-hashtags'), // Element containing the user's chips.
@@ -132,7 +133,7 @@ export const Hashtags = {
132
133
  if (chip.selected) showMessage(Int`Turning "${chip.label}" alerts back on in the map.`, 'instructions');
133
134
  else showMessage(Int`Turning off "${chip.label}" alerts in the map. You can delete the topic altogether with the X.`, 'instructions');
134
135
  this.toggleChip(chip);
135
- Marker.closePopup();
136
+ Alert.closePopup();
136
137
  if (chip.selected) this.setPublish(chip.label);
137
138
  this.onchange({redisplaySubscribers: false});
138
139
  });
@@ -141,7 +142,7 @@ export const Hashtags = {
141
142
  `<md-filled-text-field class="newtag" placeholder="➕${Int`add topic`}"></md-filled-text-field>`);
142
143
  clickTip(this.chipset.firstChild, Int`Add a new topic for which the map should show any alerts.`, event => { // Focusing "add topic".
143
144
  event.stopPropagation();
144
- Marker.closePopup();
145
+ Alert.closePopup();
145
146
  showMessage(Int`Type a new topic name to see any alerts on the map with this topic.`, 'instructions');
146
147
  });
147
148
  this.chipset.firstChild.onchange = event => { // Add the new hashtag.
@@ -151,7 +152,7 @@ export const Hashtags = {
151
152
  .replace(/\s+/g, ' ') // Replace multiple spaces with a single space
152
153
  .normalize('NFD'); // Standardize different ways of making accents into decomposed form - but do not remove them.
153
154
  if (!tag) return;
154
- Marker.closePopup();
155
+ Alert.closePopup();
155
156
  tag = this.add(tag); // Might exist, in which case tag might now be extended.
156
157
  this.setPublish(tag);
157
158
  this.onchange({highlightPublish: true});
@@ -5,7 +5,8 @@ import { openDisplay } from './display.js';
5
5
  import { Agent} from './agent.js';
6
6
  import { P2PWebNetwork } from './p2pWebNetwork.js';
7
7
  import { getPointInCell } from './s2.js';
8
- import { Marker, map, getShareableURL, showMessage, updateLocation, updateSubscriptions, recenterMap, share } from './map.js';
8
+ import { Alert, getShareableURL, share } from './alert.js';
9
+ import { map, showMessage, updateLocation, recenterMap } from './map.js';
9
10
  import './service-manager.js'; // Comment this out and kill service-workers for reload-to-get-latest behavior during development.
10
11
 
11
12
  document.getElementById('appVersion').textContent = appVersion;
@@ -41,7 +42,6 @@ export function tooltip(elementOrQuerySelector, text) { // Add plain tooltip tex
41
42
  }
42
43
  export function clickTip(elementOrQuerySelector, text, clickHandler) { // tooltip and onclick in one step.
43
44
  const element = asElement(elementOrQuerySelector);
44
- if (element.id === 'downloadUpdates2') console.log('assigning title', text, 'and', clickHandler, 'to', element);
45
45
  tooltip(element, text);
46
46
  element.onclick = clickHandler;
47
47
  }
@@ -124,7 +124,7 @@ export function openAbout(event) {
124
124
  noteNotificationPermission(window.Notification?.permission);
125
125
  }
126
126
  clickTip('#aboutButton', Int`Information about this app, and options to change how you appear to others.`, event => { // open about
127
- Marker.closePopup();
127
+ Alert.closePopup();
128
128
  openAbout(event);
129
129
  });
130
130
  clickTip('#wipe', Int`Wipe from ${osName()} all personal data and source files for this app.`, async event => {
@@ -243,7 +243,7 @@ function initializeGeolocation(subscribe = false) { // Arrange to constantly upd
243
243
  if (!subscribeOneShot) return;
244
244
  subscribeOneShot = false;
245
245
  resetInactivityTimer(false);
246
- updateSubscriptions([]); // This was for a new node, so supply an empty oldSubscriptions.
246
+ Alert.updateSubscriptions([]); // This was for a new node, so supply an empty oldSubscriptions.
247
247
  };
248
248
  if (!geolocation) {
249
249
  showMessage(Int`Geolocation not supported. Using default location.`, 'error', 'fail');
@@ -364,7 +364,6 @@ document.querySelector('head > title').innerHTML = titleElement.textContent;
364
364
  function initText(selector, content = selector) {
365
365
  const element = document.querySelector(selector);
366
366
  const text = Int([content]);
367
- if (element.id === 'downloadUpdates2') console.log('assigning', text, 'to', element);
368
367
  element.textContent = text;
369
368
  }
370
369
  initText('#aboutReport');