File size: 1,994 Bytes
49e476b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// API Configuration
const API_URL = 'http://localhost:3000/api';

// Utility Functions
function getToken() {
  return localStorage.getItem('viscan_token');
}

function getUser() {
  const user = localStorage.getItem('viscan_user');
  return user ? JSON.parse(user) : null;
}

function logout() {
  localStorage.removeItem('viscan_token');
  localStorage.removeItem('viscan_user');
  window.location.href = 'auth.html';
}

function showNotification(message, type = 'info') {
  const notification = document.createElement('div');
  notification.className = `alert alert-${type}`;
  notification.textContent = message;
  notification.style.position = 'fixed';
  notification.style.top = '2rem';
  notification.style.right = '2rem';
  notification.style.zIndex = '10000';
  notification.style.minWidth = '300px';
  notification.style.animation = 'fadeInUp 0.3s ease';
  
  document.body.appendChild(notification);
  
  setTimeout(() => {
    notification.style.animation = 'fadeOut 0.3s ease';
    setTimeout(() => notification.remove(), 300);
  }, 4000);
}

// Format date in Arabic
function formatDate(dateString) {
  const date = new Date(dateString);
  return date.toLocaleDateString('ar-EG', {
    year: 'numeric',
    month: 'long',
    day: 'numeric',
    hour: '2-digit',
    minute: '2-digit'
  });
}

// Get health status emoji
function getHealthEmoji(status) {
  const emojis = {
    'excellent': '๐ŸŒŸ',
    'good': '๐Ÿ’š',
    'fair': '๐Ÿ’›',
    'needs-attention': '๐Ÿ”ถ'
  };
  return emojis[status] || '๐Ÿ“Š';
}

// Get health status text in Arabic
function getHealthText(status) {
  const texts = {
    'excellent': 'ู…ู…ุชุงุฒ',
    'good': 'ุฌูŠุฏ',
    'fair': 'ู…ู‚ุจูˆู„',
    'needs-attention': 'ูŠุญุชุงุฌ ุงู†ุชุจุงู‡'
  };
  return texts[status] || status;
}

// Get zone health color
function getZoneColor(healthStatus) {
  const colors = {
    'normal': '#43e97b',
    'attention': '#feca57',
    'concern': '#ee5a6f'
  };
  return colors[healthStatus] || '#4facfe';
}