let details = { usb: ["Восстановление ПО", "Проблеммы с ПО"], backcase: ["Замена заднего корпуса", "Корпус МЕХ"], keyboard: ["Замена клавиатуры", "Залипает клавиатура"], printerroller: ["Замена ролика принтера", "Не печатает"], printerchange: ["Замена принтера", "Не печатает"], printerclean: ["Очистка принтера", "Не печатает"], printercoverused: ["Замена крышки принтера (б\y)", "Не печатает"], printercovernew: ["Замена крышка принтера и ролик (новая)", "Не печатает"], plonka: ["Снять пленку с экрана", "Экран"], screen: ["Замена дисплея", "Экран"], newdc: ["Замена разъема зарядки", "Не заряжается"], mag_change: ["Замена магнитный ридер", "Зависает"], Tarakan: ["Отказ. тараканы", "TAMPER"], water: ["Отказ. попадание жидкости", "TAMPER"], changesimreader: ["Перепайка картридера", "не читает карты"], cleansimreader: ["Очистка картридера", "не читает карты"], cpu: ["Отказ. системная плата", "TAMPER"], protection: ["Перепайка тамперного модуля", ""], dcjack: ["Перепайка разъема зарядки", "Не заряжается"], batteries: ["Замена батарейки CR2032", "TAMPER"], batteries2: ["Замена Батарейки CR2450", "TAMPER"], batteries1630: ["Замена Батарейки CR1630", "TAMPER"], buzzer: ["Замена пищалка", "пищалка"], conactlessboard: ["Замена платы ктлц", "Залипает клавиатура"], key: ["Очистка клавиатуры", "Залипает клавиатура"], keyC: ["Очистка платы ктлц", "Залипает клавиатура"], boardio: ["Замена нижней платы", "Не печатает"], ctls: ["Замена платы ктлц", "Залипает CTLS"], mag_clean: ["Очистка магнитный ридер", "Залит"], frontcasechange: ["Замена переднего корпуса", "Корпус МЕХ"], frontcase_clean: ["Очистка корпуса", "Залит"], bunker: ["Замена бункер", "Кнопки"], charging: ["Восстановление АКБ", "АКБ"], accumnew: ["Замена АКБ", "АКБ"], gprs: ["Замена модуль связи", "Связь"], lens: ["Замена линза", "Линза"], chip: ["обшая работа", "Не прошивается"], off: ["", "Не вкл"], powersupply: ["Ремонт цепей питания", "Разъем ЗУ"], miscroSD: ["Перепайка miscroSD", "miscroSD"], sim: ["Замена сим лоток", "Сим"], touch: ["touch", "Замена touch"], speaker: ["Замена динамика", "Динамика"], sensor: ["Замена сенсор", "Сенсорный экран"] } const models = { "S90": ["3K", "3k", "3Л", "3л", 8], "S80": ["2N", "2n", "2Т", "2т", 8], "S920": ["6N", "6n", "6т", "6Т", "6P", "6З", 8], "SP30": ["3A", "3a", "3Ф", "3ф", 8], "S200": ["5E", "5e", "5У", "5у", 8], "S300": ["5G", "5g", "5п", "5П", "53", 8], "S300": ["05G", "05g", "05п", "05П", 0], "V240m": ["450-", "390-", 11], "V520": ["331-4", "331-9", "262-", "285-", 11], "VX675": ["331-0", "331-3", "331-0", "333-", "332-", 11], "VX820": ["903-","327-" , 11], "D230": ["233", 10] } manualSelectModel = false; // manual select model let cityDetails = '' let lastThreeRecords = []; let tempDetails = [] let tempSerial = {} let tempModel = {} let isSerialHolderEmpty = true; let copiedTitle = ''; let polite = true; let enableBlinking = true; let modelFound = false; $(function () { $('.maparea').maphilight({ }); }); let intervalIds = {}; // Object to store interval IDs // External function to start blinking an element function startBlinking(id) { const element = $(`#${id}`); const data = element.data('maphilight') || {}; if (intervalIds[id]) { clearInterval(intervalIds[id]); } let isRed = true; // Track current color state intervalIds[id] = setInterval(() => { const currentColor = isRed ? 'ff0000' : '00ff00'; element.data('maphilight', { ...data, strokeColor: currentColor }).trigger('alwaysOn.maphilight'); isRed = !isRed; // Toggle color state }, 500); } // External function to stop blinking an element function stopBlinking(id) { if (intervalIds[id]) { clearInterval(intervalIds[id]); delete intervalIds[id]; // Remove the interval ID from the object } } // Click event handler for the map areas $("#map area").click(function () { const data = $(this).data('maphilight') || {}; data.alwaysOn = !data.alwaysOn; $(this).trigger('alwaysOn.maphilight'); const id = $(this).attr("id"); const gid = $(this).attr("gid"); if (isSerialHolderEmpty) { $('#searchText').text('Empty!') showNotification('random', 'Где серийный номер?!', 'danger') return; } if (data.alwaysOn) { tempDetails.push(details[gid]); console.log('tempDetails is: ', tempDetails); // Start blinking the selected element if (enableBlinking) { startBlinking(id); } } else { console.log('else temp: ', tempDetails[gid]); console.log('else details: ', details[gid]); tempDetails = tempDetails.filter(e => e !== details[gid]); console.log('filteredArray is: ', tempDetails); // Stop blinking the deselected element stopBlinking(id); } checkDetails(); console.log('my tempDetails are: ', tempDetails); }); $("#Tarakan").click(function () { const dancers = document.querySelector('.bg-tarakan'); dancers.classList.toggle("show-tarakan"); checkModel(($("#serial").val()), models) var problem = Object.keys(tempDetails)[0] $('#titleInput').val(tempModel + ' ' + tempSerial + ' ' + tempDetails[problem][1] + ' ' + "Отказ. тараканы") const otkaz = tempDetails[problem][1]; tempDetails = [] tempDetails[0] = ['Отказ. тараканы', otkaz] prepareTable('excelTable', [tempModel,tempSerial,otkaz,'Отказ. тараканы'], 'yellow') }); $("#water").click(function () { var problem = Object.keys(tempDetails)[0] checkModel(($("#serial").val()), models) $('#titleInput').val(tempModel + ' ' + tempSerial + ' ' + tempDetails[problem][1] + ' ' + "Отказ. попадание жидкости") const otkaz = tempDetails[problem][1]; tempDetails = [] tempDetails[0] = ['Отказ. попадание жидкости', otkaz] // console.log('my chnages are: ', tempDetails); prepareTable('excelTable', [tempModel,tempSerial,otkaz,'Отказ. попадание жидкости'], 'yellow') }); $("#removeFixes").click(function () { var problem = Object.keys(tempDetails)[0] checkModel(($("#serial").val()), models) $('#titleInput').val(tempModel + ' ' + tempSerial + ' ' + tempDetails[problem][1] + ' ' + "") const firstProblem = tempDetails[problem][1] const otkaz = tempDetails[problem][1]; tempDetails = [] tempDetails[0] = ['', otkaz] makePlusList(tempDetails) const pluslistMinus = makePlusList(tempDetails); prepareTable('excelTable', [tempModel,tempSerial,firstProblem,'']) }); $("#cpu").click(function () { var problem = Object.keys(tempDetails)[0] checkModel(($("#serial").val()), models) $('#titleInput').val(tempModel + ' ' + tempSerial + ' ' + tempDetails[problem][1] + ' ' + "Отказ. системная плата") const otkaz = tempDetails[problem][1]; tempDetails = [] tempDetails[0] = ['Отказ. системная плата', otkaz] prepareTable('excelTable', [tempModel,tempSerial,otkaz,'Отказ. системная плата'], 'yellow') }); $("#conactlessboard").click(function () { tempDetails.conactlessboard = ["Замена платы ктлц", "Залипает клавиатура"] checkDetails() }); checkDetails = () => { checkModel(($("#serial").val()), models) console.log('tempDetails is', tempDetails); for (var prop in tempDetails) { // object[prop] if (tempDetails[prop]) { var firstProblem = (tempDetails[prop][1]) break; } } if (!firstProblem) { firstProblem = ' ' } console.log(tempSerial); if (!tempSerial[0]) { tempSerial = $("#serial").val(); } // checkModel(); let serial = document.getElementById("serial"); tempSerial = keyboardLayoutSwitch(serial.value) $("#serial").val(tempSerial); checkModel(tempSerial, models) if (!tempModel[0]) { tempModel = 'Error'; } $('#titleInput').val(tempModel + ' ' + tempSerial + ' ' + firstProblem + ' ' + makePlusList(tempDetails)) const pluslist = makePlusList(tempDetails) prepareTable('excelTable', [tempModel,tempSerial,firstProblem,pluslist]) } $('#copyText').click(function () { if (isSerialHolderEmpty) { if (copiedTitle) { showNotification('Эх...', 'Уже скопировал последние записи:
' + copiedTitle, 'danger'); $("#serial").select(); } else { showNotification('random', 'Пусто же!!!', 'danger') } return; } if(!tempDetails[0]){ showNotification('random', 'Еще не выбрал неиспра́вность !', 'danger') return; } isSerialHolderEmpty = true; copiedTitle = $("#titleInput").val(); // if (!polite) { // showNotification('Заебись', '' , 'success') // }else{ // showNotification('Поздравляю', '' , 'success') // } // $("#titleInput").select(); // document.execCommand('copy'); var table = document.querySelector('#excelTable'); // Create a range for the table var range = document.createRange(); range.selectNode(table); // Select the table range window.getSelection().removeAllRanges(); window.getSelection().addRange(range); // Copy to clipboard document.execCommand('copy'); window.getSelection().removeAllRanges(); var problem = Object.keys(tempDetails)[0] checkModel(($("#serial").val()), models) const newData = { model: tempModel, serialNumber: tempSerial, problemList: tempDetails[problem][1], fixList: makePlusList(tempDetails), date: new Date().toLocaleTimeString() }; storeLastThreeResultsInVariable(newData); $('#lastThree').html(createTableFromLastThreeRecords()) saveToLocalStorage(); const userName = document.getElementById("userName").dataset.username; console.log("userName ", userName); const CityDetails = getCityDetails(); const newDataUpload = { 'Модель': tempModel, 'Сер.номер': tempSerial, 'Заявленная неисправность': tempDetails[problem][1], 'Произведенная работа': makePlusList(tempDetails).toString(), 'filename': CityDetails + ' ' + userName , 'timestamp': new Date().toLocaleTimeString() }; console.log(newDataUpload); // JavaScript code to send a POST request const url = 'http://' + serverEnv.ip + '/uploadText'; fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(newDataUpload) }) .then(response => response.json()) .then(data => { console.log('Success:', data); if (!polite) { showNotification('Заебись Скопирован в буфер обмена', '', 'success') } else { showNotification('Поздравляю Скопирован в буфер обмена', '', 'success') } }) .catch((error) => { console.error('Error:', error); if (!polite) { showNotification('нихуия upload не удалось', '', 'danger') } else { showNotification('ошибка upload не удалось', '', 'danger') } }); cleanAll(); // checkDetails(); $("#serial").val(''); $("#serial").select(); }); //testing upload button // $('#uploadText').click(function () { // var problem = Object.keys(tempDetails)[0] // checkModel(($("#serial").val()), models) // const newData = { // 'Модель': tempModel, // 'Сер.номер': tempSerial, // 'Заявленная неисправность': tempDetails[problem][1], // 'Произведенная работа': makePlusList(tempDetails).toString(), // 'filename': new Date().toLocaleTimeString() // }; // console.log(newData); // // JavaScript code to send a POST request // const url = 'http://' + serverEnv.ip + '/uploadText'; // fetch(url, { // method: 'POST', // headers: { // 'Content-Type': 'application/json' // }, // body: JSON.stringify(newData) // }) // .then(response => response.json()) // .then(data => { // console.log('Success:', data); // if (!polite) { // showNotification('Заебись upload', '', 'success') // } else { // showNotification('Поздравляю upload', '', 'success') // } // }) // .catch((error) => { // console.error('Error:', error); // if (!polite) { // showNotification('нихуия upload', '', 'danger') // } else { // showNotification('ошибка upload', '', 'danger') // } // }); // }); const makePlusList = (tempDetails) => { let list = [] for (const key in tempDetails) { if (Object.hasOwnProperty.call(tempDetails, key)) { const element = tempDetails[key]; if (element[0]) { // console.log(key + ' - ' + element[0]); list.push(element[0]) } } } // console.log("list: ", list); let newList = ' ' newList = list.join(',').replace(/,/g, ' + ').split(); // console.log("newList: ", newList); return newList } function storeLastThreeResultsInVariable(data) { // Add the new record to the beginning of the array lastThreeRecords.unshift(data); // If the array length exceeds 3, remove the oldest record(s) if (lastThreeRecords.length > lastThreeRecordslength) { lastThreeRecords.pop(); } } function createTableFromLastThreeRecords() { const table = document.createElement('table'); // const headerRow = table.insertRow(0); // const headers = ['Model', 'Serial Number', 'Problem List', 'Fix List', 'Date']; // Create header cells // headers.forEach((headerText, index) => { // const headerCell = document.createElement('th'); // headerCell.textContent = headerText; // headerRow.appendChild(headerCell); // }); // Populate the table with the last 3 records lastThreeRecords.forEach((record) => { const row = table.insertRow(-1); // row.className = 'clickable' Object.values(record).forEach(value => { const cell = row.insertCell(-1); cell.textContent = value; // cell.className = 'clickable'; }); }); return table; } function saveToLocalStorage() { const currentDate = new Date(); currentDate.setUTCHours(currentDate.getUTCHours() + 3); var problem = Object.keys(tempDetails)[0] checkModel(($("#serial").val()), models) const data = { model: tempModel, serialNumber: tempSerial, problemList: tempDetails[problem][1], fixList: makePlusList(tempDetails), date: currentDate.toISOString() }; const key = 'resultsData_' + tempSerial; // Use tempSerialNumber in the key localStorage.setItem(key, JSON.stringify(data)); console.log('Data saved with key:', key); } $('#reset').on('click', () => { cleanAll(); // checkDetails(); }); const cleanAll = () => { modelFound = false manualSelectModel = false; $("#selectmodel").removeClass("blinking"); cleanCoords(); // clean coords and shapes in area tag document.getElementById("serial").focus(); for (let id in intervalIds) { clearInterval(intervalIds[id]); } intervalIds = {}; // Reset the interval IDs object $("#serial").select(); tempSerial = {} var highlightedItems = document.querySelectorAll("#map area"); // console.log(highlightedItems); highlightedItems.forEach(function (item) { const dataX = $(item).data('maphilight') || {}; dataX.alwaysOn = false; // dataX.alwaysOn = !dataX.alwaysOn; // console.log(data); $(item).trigger('alwaysOn.maphilight'); }); tempDetails = []; $('#titleInput').val('Cleaned!') prepareTable('excelTable', ['Модель','Сер.номер','Заявленная неисправность','Произведенная работа']) $('#RepeatedTablePlace').text('') $('#SearchLiveTablePlace').text('') $('#SearchPriomTablePlace').text('') const dancers = document.querySelector('.bg-tarakan'); dancers.classList.remove("show-tarakan"); } $('#showStorage').on('click', () => { var textarea = $('