Aleksmorshen commited on
Commit
156af44
·
verified ·
1 Parent(s): 93455ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -245,10 +245,10 @@ html_template = '''
245
 
246
  const inputTelegram = document.createElement('input');
247
  inputTelegram.type = 'text';
248
- inputTelegram.placeholder = 'Имя пользователя Telegram (без https://t.me/)';
249
 
250
  const button = document.createElement('button');
251
- button.textContent = 'Добавить метку';
252
  button.onclick = function() {
253
  if (inputName.value && inputDescription.value && inputTelegram.value) {
254
  addMarker(inputName.value, inputDescription.value, inputTelegram.value, e.latlng);
@@ -280,7 +280,7 @@ html_template = '''
280
 
281
  // Функция для поиска меток
282
  function searchMarkers(query) {
283
- fetch(`/search_markers?query=${query}`)
284
  .then(response => response.json())
285
  .then(data => {
286
  const resultsDiv = document.getElementById('search-results');
@@ -301,7 +301,7 @@ html_template = '''
301
  // Обработчик события для кнопки поиска
302
  document.getElementById('search-button').onclick = function() {
303
  const query = document.getElementById('search-input').value;
304
- searchMarkers(query.toLowerCase()); // Приведение к нижнему регистру для поиска
305
  };
306
 
307
  // Функция для показа метки на карте
@@ -366,7 +366,7 @@ def search_markers():
366
  conn = sqlite3.connect('markers.db')
367
  cursor = conn.cursor()
368
  cursor.execute('''SELECT id, name, description, telegram_link, latitude, longitude FROM markers
369
- WHERE LOWER(name) LIKE ? COLLATE NOCASE OR LOWER(description) LIKE ? COLLATE NOCASE''',
370
  (f'%{query}%', f'%{query}%'))
371
  markers = cursor.fetchall()
372
  conn.close()
 
245
 
246
  const inputTelegram = document.createElement('input');
247
  inputTelegram.type = 'text';
248
+ inputTelegram.placeholder = 'Telegram ссылка (без @)';
249
 
250
  const button = document.createElement('button');
251
+ button.innerText = 'Добавить метку';
252
  button.onclick = function() {
253
  if (inputName.value && inputDescription.value && inputTelegram.value) {
254
  addMarker(inputName.value, inputDescription.value, inputTelegram.value, e.latlng);
 
280
 
281
  // Функция для поиска меток
282
  function searchMarkers(query) {
283
+ fetch(`/search_markers?query=${encodeURIComponent(query)}`)
284
  .then(response => response.json())
285
  .then(data => {
286
  const resultsDiv = document.getElementById('search-results');
 
301
  // Обработчик события для кнопки поиска
302
  document.getElementById('search-button').onclick = function() {
303
  const query = document.getElementById('search-input').value;
304
+ searchMarkers(query); // Убираем приведение к нижнему регистру
305
  };
306
 
307
  // Функция для показа метки на карте
 
366
  conn = sqlite3.connect('markers.db')
367
  cursor = conn.cursor()
368
  cursor.execute('''SELECT id, name, description, telegram_link, latitude, longitude FROM markers
369
+ WHERE name LIKE ? OR description LIKE ?''',
370
  (f'%{query}%', f'%{query}%'))
371
  markers = cursor.fetchall()
372
  conn.close()