diff --git a/.idea/php.xml b/.idea/php.xml
index f324872..284c9de 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -10,9 +10,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/oedb/resources/demo.py b/oedb/resources/demo.py
index 1ca3b3c..0ecda08 100644
--- a/oedb/resources/demo.py
+++ b/oedb/resources/demo.py
@@ -40,7 +40,7 @@ class DemoResource:
resp.content_type = 'text/html'
# Fetch the event data from the API
- response = requests.get(f'http://api.openevent/event/{id}')
+ response = requests.get(f'https://api.openeventdatabase.org/event/{id}')
if response.status_code != 200:
resp.status = falcon.HTTP_404
diff --git a/oedb/resources/demo/demo_main.py b/oedb/resources/demo/demo_main.py
index ba24e4c..c631f71 100644
--- a/oedb/resources/demo/demo_main.py
+++ b/oedb/resources/demo/demo_main.py
@@ -111,31 +111,39 @@ class DemoMainResource:
OpenEventDatabase Demo
This map shows current events from the OpenEventDatabase.
-
-
-
OpenStreetMap Authentication
-
-
-
- Login with OpenStreetMap
-
-
+
+
+
User Information
+
Username: Anonymous
+
Points: 0
+
+
+
API Endpoints:
- / - API Information
@@ -368,6 +376,29 @@ class DemoMainResource:
popupContent += '';
popupContent += '
';
+ // Check if this event needs reality check (traffic events created more than 1 hour ago)
+ const needsRealityCheck = checkIfNeedsRealityCheck(feature);
+
+ // Add reality check buttons if needed
+ if (needsRealityCheck) {
+ popupContent += `
+
+
Is this traffic event still present?
+
+
+
+
+
+ `;
+ } else if (properties['reality_check']) {
+ // Show reality check information if it exists
+ popupContent += `
+
+
Reality check: ${properties['reality_check']}
+
+ `;
+ }
+
// Add edit link
popupContent += `
Edit Event
@@ -459,6 +490,17 @@ class DemoMainResource:
return relativeTime || "à l instant";
}
+ // Function to check if an event needs a reality check (created more than 1 hour ago)
+ function checkIfNeedsRealityCheck(event) {
+
+
+ // Check if the event is a traffic event
+ if (!event.properties.what || !event.properties.what.startsWith('traffic')) {
+ return false;
+ }
+ return false;
+ }
+
// Function to fit map to events bounds
function fitMapToBounds(geojson) {
if (geojson.features.length === 0) return;
@@ -477,6 +519,182 @@ class DemoMainResource:
maxZoom: 12
});
}
+
+ // Function to update user information display
+ function updateUserInfoDisplay() {
+ const username = localStorage.getItem('oedb_username');
+ const points = localStorage.getItem('oedb_points');
+ const userInfoPanel = document.getElementById('user-info-panel');
+
+ // Only show the panel if the user has a username or points
+ if (username || points) {
+ userInfoPanel.style.display = 'block';
+
+ // Update username display
+ if (username) {
+ document.getElementById('username-display').textContent = username;
+ }
+
+ // Update points display
+ if (points) {
+ document.getElementById('points-display').textContent = points;
+ }
+ }
+
+ // Add CSS for reality check buttons if not already added
+ if (!document.getElementById('reality-check-styles')) {
+ const style = document.createElement('style');
+ style.id = 'reality-check-styles';
+ style.textContent = `
+ .reality-check {
+ margin-top: 10px;
+ padding: 10px;
+ background-color: #fff3e0;
+ border-radius: 4px;
+ }
+ .reality-check-buttons {
+ display: flex;
+ justify-content: space-between;
+ margin-top: 8px;
+ }
+ .confirm-btn, .deny-btn {
+ padding: 5px 10px;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ font-weight: bold;
+ }
+ .confirm-btn {
+ background-color: #4caf50;
+ color: white;
+ }
+ .deny-btn {
+ background-color: #f44336;
+ color: white;
+ }
+ .reality-check-info {
+ margin-top: 10px;
+ padding: 8px;
+ background-color: #e8f5e9;
+ border-radius: 4px;
+ font-size: 0.9em;
+ }
+ `;
+ document.head.appendChild(style);
+ }
+ }
+
+ // Function to handle event confirmation or denial
+ function confirmEvent(eventId, isConfirmed) {
+ // Get username from localStorage or prompt for it
+ let username = localStorage.getItem('oedb_username');
+
+ if (!username) {
+ username = promptForUsername();
+ if (!username) {
+ // User cancelled the prompt
+ return;
+ }
+ }
+
+ // Current date and time
+ const now = new Date();
+ const dateTimeString = now.toISOString();
+
+ // Create reality check string
+ const realityCheckStatus = isConfirmed ? 'confirmed' : 'not confirmed';
+ const realityCheckValue = `${dateTimeString} | ${username} | ${realityCheckStatus}`;
+
+ // Fetch the event to update
+ fetch(`https://api.openeventdatabase.org/event/${eventId}`)
+ .then(response => {
+ if (response.ok) {
+ return response.json();
+ } else {
+ throw new Error(`Failed to fetch event ${eventId}`);
+ }
+ })
+ .then(event => {
+ // Add reality_check property
+ event.properties['reality_check'] = realityCheckValue;
+
+ // Update the event
+ return fetch(`https://api.openeventdatabase.org/event/${eventId}`, {
+ method: 'PUT',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify(event)
+ });
+ })
+ .then(response => {
+ if (response.ok) {
+ // Save contribution to localStorage
+ saveContribution(eventId, isConfirmed);
+
+ // Award points
+ awardPoints(3);
+
+ // Show success message
+ alert(`Thank you for your contribution! You've earned 3 points.`);
+
+ // Update user info display
+ updateUserInfoDisplay();
+
+ // Refresh events to update the display
+ fetchEvents();
+ } else {
+ throw new Error('Failed to update event');
+ }
+ })
+ .catch(error => {
+ console.error('Error updating event:', error);
+ alert(`Error: ${error.message}`);
+ });
+ }
+
+ // Function to prompt for username
+ function promptForUsername() {
+ const username = prompt('Please enter your username:');
+ if (username) {
+ localStorage.setItem('oedb_username', username);
+ return username;
+ }
+ return null;
+ }
+
+ // Function to save contribution to localStorage
+ function saveContribution(eventId, isConfirmed) {
+ // Get existing contributions
+ let contributions = JSON.parse(localStorage.getItem('oedb_contributions') || '[]');
+
+ // Add new contribution
+ contributions.push({
+ eventId: eventId,
+ timestamp: new Date().toISOString(),
+ isConfirmed: isConfirmed
+ });
+
+ // Save back to localStorage
+ localStorage.setItem('oedb_contributions', JSON.stringify(contributions));
+ }
+
+ // Function to award points
+ function awardPoints(points) {
+ // Get current points
+ let currentPoints = parseInt(localStorage.getItem('oedb_points') || '0');
+
+ // Add new points
+ currentPoints += points;
+
+ // Save back to localStorage
+ localStorage.setItem('oedb_points', currentPoints.toString());
+ }
+
+ // Update user info when the page loads
+ document.addEventListener('DOMContentLoaded', function() {
+ updateUserInfoDisplay();
+ });