From d49aaf15364f4e875cafa2fcfe8dd1f327d87b72 Mon Sep 17 00:00:00 2001
From: spokik <61501832+spokik@users.noreply.github.com>
Date: Wed, 2 Dec 2020 16:21:56 +0300
Subject: [PATCH 1/2] =?UTF-8?q?=D0=9F=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD?=
=?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD?=
=?UTF-8?q?=D0=B8=D1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
После долгого ничего неделанья решил посмотреть в код на работе нашел свежий не рабочий и вроде поправил. Появилось желание допиливать это дело
---
README.md | 20 +++++++-------------
index.js | 2 ++
manifest.json | 3 +++
modules.js | 4 ++--
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 55147d3..afef5b4 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,11 @@
# Kad.arbitr
-Пользовательский скрипт, пока не имеющий названия. Создан для сканировщиков, загружающих на сайт необходимые дела.
+Для использования скрипта, необходимо [скачать](https://github.com/spokik/Kad.arbitr/archive/master.zip) файлы. распаковать в удобную папку.
+Далее следует в crome перейти в настройки ваших расширений => [browser://extensions/](browser://extensions/)
+В правом углу включить "режим разработчика", после чего у вас должно появится меню.
+Выбираем "загрузить распакованное расширение", выбираем папку в которую мы распокавали файлы.
-Функции
+**Возможности**
-МД по умолчанию:
-При добавлении иска на сайт, скрипт автоматически указывает тип документа.
-
-Горячие шаблоны:
-При отсудствии зарегестрированного документа в базе, сканеровщику необходимо создать собственную карточку. Скрипт позволяет как указать быстро сторону (истца, либо ответчика) Либо заполнить все поля ( Отзыв, заявление о праавоприемстве, ходатойство о приобщении дополнительных материалов дела и так далее.
-
-Проверка повторной загрузки:
-При попытке загрузить один и тот же фаил в разные дела, скрипт сообщит о потенциальной ошибке.
-
-Статистика:
-скрипт собирает статистику о загруженных документах. Имеет возможность построть таблицу по составам и дням.
\ No newline at end of file
+Теперь на каждо странице карточки дела появляется кнопка меню.
+Здесь можно выбрать необходимые вам модули, определить свои составы и вывести отчет по составам
\ No newline at end of file
diff --git a/index.js b/index.js
index 6586259..df17415 100644
--- a/index.js
+++ b/index.js
@@ -6,9 +6,11 @@ import { usersSettings } from './modules/usersSettings.js'
import { checkReload } from './modules/checkReload.js'
import { statisticsInterface } from './modules/statisticsInterface.js'
import { addStaticOnLocalStorage } from './modules/addStaticOnLocalStorage.js'
+// import { css } from './src/CSS/styles.css'
export {
+ // css,
windowForUserScript,
defaultMD,
addBattons,
diff --git a/manifest.json b/manifest.json
index e75bdb6..5a66782 100644
--- a/manifest.json
+++ b/manifest.json
@@ -16,6 +16,9 @@
"js": [
"modules.js"
],
+ "css": [
+ "src/CSS/styles.css"
+ ],
"matches": [
"https://*.kad.arbitr.ru/Card/*",
"https://*.kad.arbitr.ru/*"
diff --git a/modules.js b/modules.js
index 6ded196..ecc1191 100644
--- a/modules.js
+++ b/modules.js
@@ -11,9 +11,9 @@ createNewScript('./modules/statisticsInterface.js')
createNewScript('./modules/addStaticOnLocalStorage.js')
-function createNewScript(url) {
+function createNewScript(url, type = "module") {
const name = document.createElement('script')
- name.setAttribute("type", "module");
+ name.setAttribute("type", type);
name.setAttribute("src", chrome.extension.getURL(url))
head.insertBefore(name, head.lastChild);
}
From 478a39a5dc79e13014ef1e19a1967350af1481b5 Mon Sep 17 00:00:00 2001
From: spokik <61501832+spokik@users.noreply.github.com>
Date: Mon, 7 Dec 2020 16:48:57 +0300
Subject: [PATCH 2/2] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?=
=?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?=
=?UTF-8?q?=D1=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
modules/addBattons.js | 31 ++-----
modules/addStaticOnLocalStorage.js | 90 ++++++++++----------
modules/addTamplaties.js | 22 +++++
modules/checkReload.js | 29 ++++---
modules/selectYear.js | 35 ++------
modules/statisticsInterface.js | 132 ++++++++++++-----------------
modules/usersSettings.js | 2 +-
7 files changed, 156 insertions(+), 185 deletions(-)
diff --git a/modules/addBattons.js b/modules/addBattons.js
index e6e4e3c..8cdd5f0 100644
--- a/modules/addBattons.js
+++ b/modules/addBattons.js
@@ -1,29 +1,11 @@
import { usersSettings } from './usersSettings.js'
-// Добавляет кнопки пользовательского интерфейса
+// Добавляет меню
function addBattons() {
- let footer = document.createElement("div")
+ const footer = document.createElement("div")
footer.className = "b-feedback"
let xc = sostavPerDay(usersSettings.usersSS)
- footer.innerHTML = `${xc}
Статистика
`;
-
- let classBlok = document.createElement("style")
- classBlok.innerHTML = "div.tampleteButton{height: 30px;width: 130px;-webkit-appearance: button;-webkit-writing-mode: horizontal-tb !important;color: buttontext;text-shadow: none;display: inline-block;text-align: center;align-items: flex-start;background-color: buttonface;box-sizing: border-box;margin: 0em;font: 400 13.3333px Arial;padding: 1px 6px;border-width: 2px;border-style: outset;border-color: buttonface;border-image: initial;}}";
- let divBlok = document.createElement("div")
- divBlok.id = "UserTempale"
- divBlok.innerHTML = `
- Истец
- Ответчик
- По общим
- Уточнение.И
-
- Приобщении.И
- Отзыв.О
- Отказ.И
- Правоприемство
`;
-
- document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > div.b-popup-button.js-upload-submit").before(classBlok)
- document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > div.b-popup-button.js-upload-submit").before(divBlok)
+ footer.innerHTML = `${xc} Меню
`;
document.querySelector("#b-footer > div > div.b-copyright").after(footer)
}
@@ -44,12 +26,11 @@ function sostavPerDay(sostavs) {
}
}
//string stringify
+ // const stringReturn = counter.map((key, index) => (`${index} состав: ${key} штук | `));
let stringReturn = ''
- for (let key in counter) {
-
- stringReturn = stringReturn + `${key} состав: ${counter[key]} штук | `
- }
+ for (let key in counter) { stringReturn = stringReturn + `| ${key} состав: ${counter[key]} штук ` }
return stringReturn
+
}
export { addBattons }
\ No newline at end of file
diff --git a/modules/addStaticOnLocalStorage.js b/modules/addStaticOnLocalStorage.js
index 7321656..72e9e3c 100644
--- a/modules/addStaticOnLocalStorage.js
+++ b/modules/addStaticOnLocalStorage.js
@@ -2,24 +2,23 @@ import { usersSettings } from './usersSettings.js'
// Добавляет статистику по загрузкам в localStorage
function addStaticOnLocalStorage() {
- let elem = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload")
+ const elem = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload")
let promise = new Promise((resolve, reject) => {
let observer = new MutationObserver((mutationRecords) => {
if (mutationRecords.length > 1) {
- let saveScanStat = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > div.b-popup-button.js-upload-submit"); // кнопка по которой срабатывает скрипт
+ const saveScanStat = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > div.b-popup-button.js-upload-submit"); // кнопка по которой срабатывает скрипт
let q = document.querySelector("#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div").childElementCount //Кол-во элементов для фикла
let sostav = ' состав неопределен'
- let docId = document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > input[type=hidden]:nth-child(4)").value
-
- //it's selector for add new document without the card
- //document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > input[type=hidden]:nth-child(4)").value
- let a40 = document.querySelector("#b-case-header > ul.crumb.g-ec > li > span").textContent.split(" ")[20]
-
+ const docId = document.querySelector(" form > input[name=DocumentId]").value
+ //Если документ ид отсудствует, берем инстанст ид и добавляем к нему свой ид, предварительно проверяя есть ли подобные ид
+ // либо получать этот ид после добавления докумнта из дива и получив записывать в статистику
+ const a40 = document.querySelector("#b-case-header > ul.crumb.g-ec > li > span").textContent.split(" ")[20]
+ //Ищем и определем состав
for (let i = 1; i < q; i++) {
- if (document.querySelector(`#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div > div:nth-child(${i}) > div.r-col > h2 > a > span`) !== null) {
- let checker = document.querySelector(`#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div > div:nth-child(${i}) > div.r-col > h2 > a `)
+ if (document.querySelector(`#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div > div:nth-child(${i}) > div.r-col`) !== null) {
+ let checker = document.querySelector(`#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div > div:nth-child(${i}) > div.r-col`)
.textContent //полуучает текст
.trim() //Удаляет пробелы "с краёв"
.split(` `) //Правращает в масив по разделителю " "
@@ -44,17 +43,15 @@ function addStaticOnLocalStorage() {
else { sostav = ' состав неопределен' }
}
}
- if(document.querySelector(`#userSS`) === null){
+ if (document.querySelector(`#userSS`) === null) {
sostavAtPopup(sostav)
}
-
- let params = {
- saveScanStat: saveScanStat,
- sostav: sostav,
- docId: docId,
- a40: a40,
+ if (!document.querySelector(`#lastOnloadFile`) ) {
+ lastOnloadFile()
}
+
+ const params = { saveScanStat, sostav, docId, a40, }
resolve(params)
} else if (mutationRecords.length === 1) {
@@ -66,20 +63,19 @@ function addStaticOnLocalStorage() {
childList: true
})
})
- promise.catch((err) => { console.error(`Error: `, err) })
+ promise
+ .catch((err) => { console.error(`Error: `, err) })
.then((params) => {
//Срабатывает прии НАЖАТИИ на "Сохранить"
+ //Сохраняет в локал сторадж данные загруженного документа
params.saveScanStat.onclick = () => {
- let now = new Date()
- let dataForLS = {}
- dataForLS = JSON.parse(localStorage.getItem(`sostav${params.sostav}`))
- if (dataForLS == null) {
- dataForLS = {};
- }
+ let currentDate = new Date()
+ let dataForLS = JSON.parse(localStorage.getItem(`sostav${params.sostav}`)) || {}
+
dataForLS[params.docId] = {
- day: `${now.getDate()}`,
- month: `${1 + now.getMonth()}`,
+ day: `${currentDate.getDate()}`,
+ month: `${1 + currentDate.getMonth()}`,
a40: `${params.a40}`,
}
localStorage.setItem(`sostav${params.sostav}`, JSON.stringify(dataForLS)
@@ -90,30 +86,38 @@ function addStaticOnLocalStorage() {
function sostavAtPopup(sostav) {
const elem = document.createElement("div")
elem.className = "b-popup-info"
- elem.innerHTML = ``
- let isYourSostav = false
- function isCorrectSostav() {
- for (let i = 0; i < usersSettings.usersSS.length; i++) {
- if (usersSettings.usersSS[i] == sostav) {
- isYourSostav = true
- return
- } else {
- isYourSostav = false
+ elem.innerHTML = ``
+ if (sostav === ` состав неопределен` || !usersSettings.usersSS.includes(Number(sostav), 0)) {
+ const buttonsSelectionSS = usersSettings.usersSS.map((key) => { return `${key}
` })
+ elem.innerHTML = `` + buttonsSelectionSS
+ elem.style.color = "red"
+ if (!document.querySelector(`#SSOnPop`)) {
+ document.querySelector("div.js-popup-info_attributes").append(elem)
+ for (let i = 0; i < usersSettings.usersSS.length; i++) {
+ document.querySelector(`#SS${usersSettings.usersSS[i]}`).addEventListener("click", () => {
+ document.querySelector("#SSOnPop").innerText = usersSettings.usersSS[i]
+ document.querySelector("#SSOnPop").style.color = "black"
+ sostav = usersSettings.usersSS[i]
+ return sostav
+ })
}
}
}
- isCorrectSostav()
- if (sostav === ` состав неопределен` || !isYourSostav) {
- elem.innerHTML = ``
- elem.style.color = "red"
- }
- if (document.querySelector(`#SSOnPop`) !== null) { } else { document.querySelector("div.js-popup-info_attributes").append(elem) }
-
+ if (!document.querySelector(`#SSOnPop`)) { document.querySelector("div.js-popup-info_attributes").append(elem) }
+ }
+ function lastOnloadFile() {
+ const elem = document.createElement("div")
+ elem.id = `lastOnloadFile`
+ elem.innerHTML = ` - последний был ${JSON.parse(localStorage.getItem(`downLoadFilles`)).pop()}`
+ document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload.b-popup--edit.js-popup--edit > form > div.b-popup-file_upload-wrapper.js-popup-file_upload-wrapper.b-popup-file_upload-wrapper--titled > div.b-popup-file_upload.js-popup-sj-file_upload > a")
+ .after(elem)
}
}
-
+function changeSS(SS) {
+ sostav = SS
+}
export { addStaticOnLocalStorage }
\ No newline at end of file
diff --git a/modules/addTamplaties.js b/modules/addTamplaties.js
index 9bc3e9a..4e614aa 100644
--- a/modules/addTamplaties.js
+++ b/modules/addTamplaties.js
@@ -4,6 +4,27 @@ function addTamplaties() {
const applicantl1 = document.querySelector("#gr_case_partps > table > tbody > tr > td.plaintiffs.first > div > ul > li > span > a").innerText; //Истец
const applicantl2 = document.querySelector("#gr_case_partps > table > tbody > tr > td.defendants > div > ul > li > span > a").innerText; //Ответчик
+
+ const classBlok = document.createElement("style")
+ classBlok.innerHTML = "div.tampleteButton{height: 30px;width: 130px;-webkit-appearance: button;-webkit-writing-mode: horizontal-tb !important;color: buttontext;text-shadow: none;display: inline-block;text-align: center;align-items: flex-start;background-color: buttonface;box-sizing: border-box;margin: 0em;font: 400 13.3333px Arial;padding: 1px 6px;border-width: 2px;border-style: outset;border-color: buttonface;border-image: initial;}}";
+ const divBlok = document.createElement("div")
+ divBlok.id = "UserTempale"
+ divBlok.innerHTML = `
+ Истец
+ Ответчик
+ По общим
+ Уточнение.И
+
+ Приобщении.И
+ Отзыв.О
+ Отказ.И
+ Правоприемство
`;
+
+ document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > div.b-popup-button.js-upload-submit").before(classBlok)
+ document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > div.b-popup-button.js-upload-submit").before(divBlok)
+
+
+
//События меняют стороны
document.getElementById("istec").onclick = () => (document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > dl > dd > div > span > label > input").value = applicantl1);
document.getElementById("otvetchik").onclick = () => (document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > dl > dd > div > span > label > input").value = applicantl2);
@@ -19,6 +40,7 @@ function addTamplaties() {
document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > dl > dd > div > span > label > input").value = licantl;
document.querySelector("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div.b-popup.b-popup--blue.b-popup--upload.js-popup--upload > form > table > tbody > tr > td.b-popup-sj-table-item.b-popup-sj-table-item--name > dl > dd > a > span.selectBox-label").innerHTML = showText;
}
+
//Данные для заполнения шаблонов
const tamplatesValue = {
otziv: {
diff --git a/modules/checkReload.js b/modules/checkReload.js
index 8c47c13..044a43b 100644
--- a/modules/checkReload.js
+++ b/modules/checkReload.js
@@ -1,19 +1,19 @@
// Проверка задвоенной загрузки файлов
function checkReload() {
//Проверка повторной загрузки файлов
- let checkArray
+ let checkArray = []
let checkbatton = document.getElementById("UserTempale");
checkbatton.onmouseover = function () {
- checkArray = { isk: document.getElementsByClassName(`b-popup-sj-link js-popup-sj-link js-popup-sj-link--upload`)[0].innerText }
+ checkArray[0] = document.getElementsByClassName(`b-popup-sj-link js-popup-sj-link js-popup-sj-link--upload`)[0].innerText
- for (let i = 0; document.querySelectorAll("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div > form > div > div > ul > li > a.b-popup-loaded-attachments_list-item-link").length > i; i++) {
- checkArray[`md${i}`] = document.querySelectorAll("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div > form > div > div > ul > li > a.b-popup-loaded-attachments_list-item-link")[i].innerText;
+ for (let i = 1; document.querySelectorAll("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div > form > div > div > ul > li > a.b-popup-loaded-attachments_list-item-link").length + 1 > i; i++) {
+ checkArray[i] = document.querySelectorAll("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div > form > div > div > ul > li > a.b-popup-loaded-attachments_list-item-link")[i-1].innerText;
}
// значение прошлого иска
const lastFilles = JSON.parse(localStorage.getItem(`downLoadFilles`))
if (lastFilles === undefined) {
- lastFilles = {}
+ lastFilles = []
return lastFilles
}
@@ -22,17 +22,26 @@ function checkReload() {
for (let prop in lastFilles) {
if (checkArray[key] === "Прикрепить файл") { return }
if (checkArray[key] === lastFilles[prop]) {
- alert(`Ты уже загружал(а) > ${checkArray[key]} <, но загружаешь > ${checkArray[prop]} < повторно`);
+ alert(`Ты уже загружал(а) "${checkArray[key]}", но загружаешь "${checkArray[prop]}" повторно`);
}
}
}
return checkArray;
};
- //Установка новых значений файлов в куки
- document.getElementsByClassName(`b-popup-button js-upload-submit`)[0].addEventListener("click", () => { testForclick(checkArray) }) //onclick = testForclick(checkArray) //
- function testForclick(array) {
- localStorage.setItem(`downLoadFilles`, JSON.stringify(array))
+ //Установка новых значений файлов в local Storage
+ document.getElementsByClassName(`b-popup-button js-upload-submit`)[0].addEventListener("click", () => { testForclick() })
+ function testForclick() {
+ checkArray[0] = document.querySelector("span.qq-upload-file").innerText
+ if (document.querySelector("#b-container a.b-popup-loaded-attachments_list-item-link")) {
+ for (let i = 1; document.querySelectorAll("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div > form > div > div > ul > li > a.b-popup-loaded-attachments_list-item-link").length + 1 > i; i++) {
+ checkArray[i] = document.querySelectorAll("#b-container > div.b-popup-wrapper.js-popup-wrapper.js-popup-wrapper--upload > div > form > div > div > ul > li > a.b-popup-loaded-attachments_list-item-link")[i-1].innerText;
+ }
+ }
+
+
+
+ localStorage.setItem(`downLoadFilles`, JSON.stringify(checkArray))
}
}
diff --git a/modules/selectYear.js b/modules/selectYear.js
index e31954a..6b2e021 100644
--- a/modules/selectYear.js
+++ b/modules/selectYear.js
@@ -13,39 +13,14 @@ function windowForUserScript() {
`;
document.getElementById('b-form-submit').before(div);
- // getNumberInput.oninput = zamena();
- function zamena() {
-
- let a40 = document.getElementById(NumberWithoutA40).value;
- let year20 = document.getElementById(year20).checked;
- let year19 = document.getElementById(year19).checked;
- let year18 = document.getElementById(year18).checked;
- let year = 20;
-
- if (year20 == true) { year = 20; }
- else if (year19 == true) { year = 19; }
- else if (year18 == true) { year = 18; }
- else { alert(`ЕРОР! Чет какая - то шляпа введина в место года`) }
-
- let fullNumber = "А40-" + a40 + "-" + year;
- document.querySelector("#sug-cases > div > input").value = fullNumber;
- }
-
-
//Устанавливаем по умолчанию А40-88888-20
document.querySelector("#sug-cases > div > input").value = ` А40-88888-20`;
- //пересобирает строку, заменя 2 последний цифры
+ //пересобирает строку, заменяя 2 последний цифры
function setYear(year) {
- let newNumber = document.querySelector("#sug-cases > div > input").value
- let inString = document.querySelector("#sug-cases > div > input").value["length"]
- var getNewNumber = ``
- let i = 0
- while (inString - 2 > i) {
- getNewNumber = getNewNumber + newNumber[i]
- i++
- }
- getNewNumber = getNewNumber + year
- return getNewNumber
+ let oldNumber = document.querySelector("#sug-cases > div > input").value
+ let newNumber = ``
+ newNumber = oldNumber.slice(0,oldNumber.length-2) + year
+ return newNumber
}
//Красим фон и меняем год
diff --git a/modules/statisticsInterface.js b/modules/statisticsInterface.js
index 58b66ab..b5b44bc 100644
--- a/modules/statisticsInterface.js
+++ b/modules/statisticsInterface.js
@@ -1,6 +1,8 @@
import { usersSettings } from './usersSettings.js'
+// import { css } from '../index.js'
-// После и основным интерфейсом скрипта
+
+// Строка статистике в поле меню
function statisticsInterface() {
//Кнопка статистики
document.getElementById("activeStat").onclick = () => {
@@ -9,10 +11,9 @@ function statisticsInterface() {
reportTableBild()
resolve()
})
- promise.catch((err) => { console.error(`Error: `, err) })
- .then(() => { setSettings() })
-
-
+ promise
+ .catch((err) => { console.error(`Error: `, err) })
+ .then(() => { setSettings() })
}
//добавляет в открытое поле статистики необходимые кнопки
function showSettingButton() {
@@ -20,81 +21,18 @@ function statisticsInterface() {
let addStatInterface = document.createElement("div")
let addSettingsButton = document.createElement("div")
addStatInterface.innerHTML = `
-
-
-
+
+
+
+
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Посчитать
+ за день
`
let classBlok = document.createElement("style")
- classBlok.innerHTML = `
- body {
- margin: 0;
- padding: 0;
- background: #f3f3f3;
- }
- .settings {
- position: absolute;
- left: 82%;
- top: 40px;
- width: 250px;
- border: 1px solid rgb(205 205 224);
- padding: 5px;
- color: rgb(255 255 255);
- background: rgb(50 50 51);
- display: block;
- }
- #word_opts {
- position: relative;
- padding: 4px;
- width: 60px;
- height: 60px;
- background: #c6c6c6;
- outline: none;
- border-radius: 7px;
- box-shadow: inset 0 0 5px rgba(0,0,0, .2);
- transition: 0.5s;
- }
-
- label input[type="checkbox"]:checked + #word_opts {
- background: #02a9f4;
- }
-
- input[type="checkbox"] {
- width: 40px;
- height: 20px;
- -webkit-appearance: none;
- -moz-appearance: none;
- background: #c6c6c6;
- outline: none;
- border-radius: 50px;
- box-shadow: inset 0 0 5px rgba(0,0,0, .2);
- transition: 0.5s;
- position: absolute;
- right: 40px;
- }
- input:checked[type="checkbox"] {
- background: #02a9f4;
- }
- input[type="checkbox"]::before {
- content: '';
- position: absolute;
- width: 20px;
- height: 20px;
- border-radius: 50%;
- top: 0;
- left: 0;
- background: #fff;
- transform: scale(1.1);
- box-shadow: 0 2px 5px rgba(0,0,0, .2);
- transition: 0.5s;
- }
- input:checked[type="checkbox"]::before {
- left: 20px;
- }
- `
+ classBlok.innerHTML = `css`
addSettingsButton.id = `settings`
addSettingsButton.classList = `settings`
function changeSS(usersSS) {
@@ -154,13 +92,15 @@ function statisticsInterface() {
const usersButtons = document.getElementById(`statStart`)
usersButtons.addEventListener('click', () => { statTablegeneration() })
+ const dayStatistic = document.getElementById(`dayStatistic`)
+ dayStatistic.addEventListener('click', () => { dayReport(document.getElementById(`dayStat`).value) })
//Строит отчет по выбранному составу
function statTablegeneration() {
let dataForLS = {}
let sostavNumber = document.querySelector("#sostavNumber").value
const lastMonth = document.querySelector("#lastMonth").value
dataForLS = JSON.parse(localStorage.getItem(`sostav${sostavNumber}`))
- let counter = { "Прошлый месяц": lastMonth }
+ let counter = { "C прошлого месяца": lastMonth }
let needMonth = Number(document.querySelector("#month").value.substr(5, 7))
@@ -174,7 +114,6 @@ function statisticsInterface() {
}
let tableForStat = document.createElement(`div`);
-
let tableString = `
@@ -200,6 +139,47 @@ function statisticsInterface() {
document.querySelector("#b-footer > div > div.b-copyright").before(tableForStat)
}
+ //Строит отчет по дню
+ function dayReport(day ) {
+ let needMonth = Number(document.querySelector("#month").value.substr(5, 7))
+ const sostavNumber = document.querySelector("#sostavNumber").value
+ const dataFromLS = JSON.parse(localStorage.getItem(`sostav${sostavNumber}`))
+ let counter = { "что-то": lastMonth }
+ for (let key in dataFromLS) {
+ if (dataFromLS[key].month == needMonth && dataFromLS[key].day == day) {
+ counter[key] == dataFromLS[key].a40
+ }
+ }
+
+ let tableForStat = document.createElement(`div`);
+ let tableString = `
+
+
+ Номер
+ Время
+ опции
+
+ `;
+
+ for (const key in counter) {
+ tableString =
+ tableString +
+ `
+
+ ${key}
+ time
+ del
+ `
+ }
+ tableString = tableString + `
`
+ tableForStat.innerHTML = tableString
+ tableForStat.style.color = `#FFF`
+ tableForStat.style.position = `absolute`
+ tableForStat.style.margin = `30px 10px 10px 10px`
+ document.querySelector("#b-footer > div > div.b-copyright").before(tableForStat)
+
+
+ }
}
diff --git a/modules/usersSettings.js b/modules/usersSettings.js
index 79a930f..d1ce9e6 100644
--- a/modules/usersSettings.js
+++ b/modules/usersSettings.js
@@ -1,5 +1,5 @@
const usersSettings = JSON.parse(localStorage.getItem(`usersSettings`))
-if (usersSettings == undefined) {
+if (!usersSettings) {
usersSettings = {
autoMD: "checked",
tamplaties: "checked",