 
      
    JavaScript
    4
    Вклад в тег
    
      
      
    
  
  
$('#buttons-grid a').click(function () {  
   var index = $('#buttons-grid a').index($(this));
   $('#buttons-grid a').removeClass('active').eq(index).addClass('active');
   $('#contactAndMapBlock__wrapper .contactAndMapBlock__right').hide().eq(index).show();
});class MyObject {
  constructor(id, otherProperty) {
    this.id = id;
    this.otherProperty = otherProperty;
  }
}
function generateObjectsArray() {
  const objectsArray = [];
  for (let i = 1; i <= 25; i++) {
    const objectId = i; // Уникальный идентификатор объекта
    const otherProperty = "Другое свойство " + i; // Другое свойство объекта
    const newObj = new MyObject(objectId, otherProperty);
    objectsArray.push(newObj);
  }
  return objectsArray;
}
const myArray = generateObjectsArray();
console.log(myArray);const objectsArray = Array.from({ length: 25 })
  .map((_, index) => index + 1)
  .map(id => {
    const sum = [...Array(Math.floor(Math.random() * 10) + 1)].reduce((acc, _) => acc + Math.floor(Math.random() * 100) + 1, id);
    let emoji = '';
    if (sum % 2 === 0) {
      const emojis = ['', '', '', '', ''];
      emoji = emojis[Math.floor(Math.random() * emojis.length)];
    } else {
      const emojis = ['', '', '', '', ''];
      emoji = emojis[Math.floor(Math.random() * emojis.length)];
    }
    
    return { id, sum, emoji };
  });
console.log(objectsArray);function uploadPhotos() {
    var formData = new FormData();
    var photos = $('#fileInput')[0].files; // получение массива выбранных файлов
    for (var i = 0; i < photos.length; i++) {
        formData.append('photos[]', photos[i]); // добавление фотографий в FormData
    }
    $.ajax({
        url: 'upload.php',
        type: 'POST',
        data: formData,
        processData: false,
        contentType: false,
        success: function(response) {
            console.log(response);
            // Действия после успешной загрузки
        },
        error: function(xhr, status, error) {
            console.log(xhr.responseText);
            // Действия в случае ошибки
        }
    });
}<?php
if(isset($_FILES['photos'])) {
    $photos = $_FILES['photos'];
    $uploadedFiles = [];
    foreach($photos['tmp_name'] as $key => $tmp_name) {
        $file_name = $photos['name'][$key];
        $file_tmp = $photos['tmp_name'][$key];
        $file_type = $photos['type'][$key];
        $file_size = $photos['size'][$key];
        
        $new_file_name = md5(time() . $file_name) . '.' . pathinfo($file_name, PATHINFO_EXTENSION);
        $destination = 'uploads/' . $new_file_name;
        
        if(move_uploaded_file($file_tmp, $destination)) {
            $uploadedFiles[] = $destination;
        }
    }
    
    if(!empty($uploadedFiles)) {
        // Действия после успешной загрузки
        echo "Фотографии успешно загружены";
    } else {
        // Действия в случае ошибки
        echo "Ошибка загрузки фотографий";
    }
}
?>