Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

me first a pull request #7

Open
wants to merge 18 commits into
base: spokik-dev-events
Choose a base branch
from
Open

me first a pull request #7

wants to merge 18 commits into from

Conversation

spokik
Copy link
Owner

@spokik spokik commented Sep 11, 2020

No description provided.

@@ -5,9 +5,6 @@ import { windowForUserScript } from './modules/alert.js';
import { defaultMD } from './modules/autoMD.js';

if (document.location.href === `https://kad.arbitr.ru/`) { windowForUserScript() }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings that contain url are better to be stored into const

kad.js Outdated
@@ -5,9 +5,6 @@ import { windowForUserScript } from './modules/alert.js';
import { defaultMD } from './modules/autoMD.js';

if (document.location.href === `https://kad.arbitr.ru/`) { windowForUserScript() }
injectFunction();



if (document.location.href != `https://kad.arbitr.ru/`) {
let usersSettings = JSON.parse(localStorage.getItem(`usersSettings`))
Copy link

@CristinaVolk CristinaVolk Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to keep one pattern of quotes, single or double or backward. Usually, if you have just a string use the single quotes ''

footer.innerHTML = `${xc} <div id="activeStat" class="tampleteButton" style="height:23px">Статистика</div>`;

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;}}";
Copy link

@CristinaVolk CristinaVolk Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can separate html from css. Create a module css and [ut all the styling there ;) when you use everything together it is not possible to change in future when the project grows and it looks dirty, not readable.

for (let index = 0; index < sostavs.length; index++) {
let starArray = JSON.parse(localStorage.getItem(`sostav${sostavs[index]}`))
for (let key in starArray) {
if (starArray[key].month == month) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try not to compare with ==, use triple one ;)

let today = new Date().getDate()
let month = new Date().getMonth() + 1
let counter = {}
for (let index = 0; index < sostavs.length; index++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can replace this loop with the map method :)

}
}
//string stringify
let stringReturn = ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to use more descriptive and meaningful names. It's not clear what you mean by stringReturn, which string? what return? why xd?

let stringReturn = ''
for (let key in counter) {

stringReturn = stringReturn + `${key} состав: ${counter[key]} штук | `
Copy link

@CristinaVolk CristinaVolk Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check if you can replace this loop just by that line:
const stringReturn = counter.map((key, index) => (${index} состав: ${key} штук | ));

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Угу, вот только counter = {}

return stringReturn
}

export { addBattons }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check please the spelling of the filename ;)

let xc = sostavPerDay(usersSettings.usersSS)
footer.innerHTML = `${xc} <div id="activeStat" class="tampleteButton" style="height:23px">Статистика</div>`;

let classBlok = document.createElement("style")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classBlok looks weird tbh , doesn't it?

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"); // кнопка по которой срабатывает скрипт

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please try mot to shorten the names, not to be afraid of using long names. They are descriptive and takes less time to understand what's going on :)

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")

let promise = new Promise((resolve, reject) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't use the parameter reject , then you can add underscore before in order to avoid eslint error/warn .
And if you do not change the variable in code use const instead

@@ -1,17 +1,17 @@
# Kad.arbitr

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here should be instructions how to run your application in Readme

Scan Outdated
document.getElementsByClassName(`b-popup-sj-link js-popup-sj-link js-popup-sj-link--upload`)[0].onclick = () =>{document.getElementsByClassName('js-input js-input--combobox js-input--deselect_with_save_val')[1].value = `Материалы по делу`;}
(function () {
"use strict";
let usersSettings = JSON.parse(localStorage.getItem(`usersSettings`))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use const if you don't assign a new value ;)

@@ -88,7 +90,7 @@ function addStaticOnLocalStorage() {
function sostavAtPopup(sostav) {
const elem = document.createElement("div")
elem.className = "b-popup-info"
elem.innerHTML = `<div class="b-popup-info-title">Состав</div><span class="b-popup-info-text js-popup-info-text" title="${sostav}">${sostav}</span>`
elem.innerHTML = `<div class="b-popup-info-title" id="userSS">Состав</div><span class="b-popup-info-text js-popup-info-text" title="${sostav}">${sostav}</span>`
let isYourSostav = false
function isCorrectSostav() {
for (let i = 0; i < usersSettings.usersSS.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the content of this loop can be written just in one line with the help of the ternary operation:
for (let i = 0; i < usersSettings.usersSS.length; i++) { return (isYourSostav = usersSettings.usersSS[i] == sostav ? true : false); }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also below состав неопределен is it should be necessary the phrase with space before??


//Срабатывает прии НАЖАТИИ на "Сохранить"
params.saveScanStat.onclick = () => {
let now = new Date()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change the name to currentDate for example :)

let now = new Date()
let dataForLS = {}
dataForLS = JSON.parse(localStorage.getItem(`sostav${params.sostav}`))
if (dataForLS == null) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can reverse this logic of checking :)
check for existence ;)
const dataForLS = JSON.parse(localStorage.getItem(sostav${params.sostav}));
and then if (dataForLS !==null)

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"); // кнопка по которой срабатывает скрипт
let q = document.querySelector("#chrono_list_content > div.b-chrono-items-container.js-chrono-items-container > div").childElementCount //Кол-во элементов для фикла

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use such short names for large functions or classes, where another context gives you the entire impression, but here it's tricky to understand

Comment on lines 50 to 54
let params = {
saveScanStat: saveScanStat,
sostav: sostav,
docId: docId,
a40: a40,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use the same names of the props and values , then you don't need to write it twice ;)
let params = { saveScanStat, sostav, docId, a40,

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я собственно так и сделал недавно, правда в другой ветке

.trim() //Удаляет пробелы "с краёв"
.split(` `) //Правращает в масив по разделителю " "
let stringValueCounter = 0
if (stringValueCounter < 2) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and what if stringValueCounter is equal to 2 ?
I recommend you to change if-else implementation here, it's confusing and long

@@ -1,57 +1,57 @@
// Добавляет обработчики интерфейса
function addTamplaties() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name :)

@@ -0,0 +1,57 @@
// Добавляет обработчики интерфейса

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should apply VS formatter here. It's unreadable at all

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uploading image.png…

Comment on lines 15 to 18
if (lastFilles === undefined) {
lastFilles = {}
return lastFilles
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you assign an empty object?
you can check the value to exist and proceed

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я уже не помню, оно без этого не работало XD

Comment on lines 31 to 97
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;
}
`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to extract all the css to the css module :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I will be try

modules/alert.js Outdated
Comment on lines 30 to 33
if (year20 == true) { year = 20; }
else if (year19 == true) { year = 19; }
else if (year18 == true) { year = 18; }
else { alert(`ЕРОР! Чет какая - то шляпа введина в место года`) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use ternary operators here

modules/alert.js Outdated
//пересобирает строку, заменя 2 последний цифры
function setYear(year) {
let newNumber = document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value
let inString = document.querySelector(`#sug - cases.tag input[type = "text"]: valid`).value["length"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't like the name XD

modules/alert.js Outdated
}


//Красим фон и меняем год

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you use comments, it means you use bad names ;)

Comment on lines 211 to 220
for (let i = 0; i < document.querySelectorAll("#settings > input[type=checkbox]").length; i++) {
let x = document.querySelectorAll("#settings > input[type=checkbox]")[i]
if (x.checked) {
preSet[x.name] = "checked"
} else {
preSet[x.name] = ""
}

localStorage.setItem(`usersSettings`, JSON.stringify(preSet))
})
}
preSet.usersSS = []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too long, i believe you can reduce it with the help of methods of js and ternary operators ;)

@@ -1,13 +1,13 @@
const usersSettings = JSON.parse(localStorage.getItem(`usersSettings`))
if (usersSettings == undefined) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!usersSettings)

spokik and others added 6 commits September 27, 2020 12:01
Давно не занимался проектом, не помню где ошибки. Не хочу разбираться. Кажется более простым вариантом вернуться к рабочей версии и плясать от нее
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants