-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.html
More file actions
230 lines (206 loc) · 6.96 KB
/
index.html
File metadata and controls
230 lines (206 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Calendar to search at GitHub</title>
<!-- Fontawesome CSS -->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.css"
rel="stylesheet"
type="text/css"
/>
<link
href="https://fonts.googleapis.com/css?family=Montserrat"
rel="stylesheet"
/>
<link rel="stylesheet" href="src/css/style.css" />
<link rel="stylesheet" href="src/css/utils.css" />
</head>
<body>
<main id="app">
<div class="header">
<div class="logo">
<img src="./src/assets/logo.png" alt="Azordev logo" />
</div>
<div class="language">
<div class="world">
<img src="./src/assets/world.png" alt="world icon" />
</div>
<div class="content-select">
<select class="arrow-bottom">
<option selected>English</option>
<option>Spanish</option>
</select>
</div>
</div>
</div>
<div class="center-block p-relative">
<div class="logo-github">
<img src="src/assets/GitHub-plus.png" />
</div>
<div>
<form id="calendary_filter" class="calendary_filter">
<div id="tab_1" class="box d-inline">
<div>
<select
id="type_of_search"
name="typeOfSearch"
class="input arrow-bottom"
>
<option value="issue">Issues</option>
<option value="pr">Pull Request</option>
</select>
<span id="error_type_of_search"></span>
</div>
<div>
<input
type="text"
placeholder="User / Organization"
list="users_history"
id="input_user"
name="user"
class="input calendary_filter__repository_name"
/>
<span id="error_input_user"></span>
</div>
<div>
<input
type="text"
placeholder="Repository Name"
list="repositories_history"
id="input_repository"
name="repository"
class="input calendary_filter__repository_name"
/>
<span id="error_input_repository"></span>
</div>
<div class="align-r mt-4">
<button id="btn_next" class="btn btn-sm">Next</button>
</div>
</div>
<div id="tab_2" class="box">
<div>
<select id="input_condition" name="condition" class="input">
<option value="after">After of</option>
<option value="before">Before of</option>
<option value="equals">Equals to</option>
</select>
<span id="error_input_condition"></span>
</div>
<div>
<input
type="date"
name="date"
id="input_date"
style="text-transform: uppercase"
class="calendary_filter__date_search input"
/>
<span id="error_input_date"></span>
</div>
<div class="p-relative">
<button id="goback" class="btn--back p-absolute mt-6">
<img
src="./src/assets/arrow.png"
style="margin-top: 3px"
width="15px"
height="15px"
alt=""
/>
</button>
</div>
<div class="div mt-3">
<button id="redirectToSearch" class="btn btn-sm">GO</button>
<button id="copySearch" class="btn btn--secondary btn-sm">
Copy
</button>
</div>
</div>
<datalist id="repositories_history">
<!-- TODO: ADD repositories history on this datalist -->
</datalist>
<datalist id="users_history">
<!-- TODO: ADD users history on this datalist -->
</datalist>
</form>
</div>
</div>
</main>
<div class="footer-line"></div>
<script type="module">
import {
getFromLSOrDefaultValue,
validateForm,
createSearchFilter,
getFormValues,
} from './src/js/utils.js';
/*
* STEPS FORM
*/
const btnNext = document.getElementById('btn_next');
const goBack = document.getElementById('goback');
const switchTab = (evt) => {
evt.preventDefault();
const tab1 = document.getElementById('tab_1');
const tab2 = document.getElementById('tab_2');
tab1.classList.toggle('d-inline');
tab2.classList.toggle('d-inline');
};
btnNext.addEventListener('click', function (evt) {
evt.preventDefault();
if (validateForm()) {
switchTab(evt);
}
});
goBack.addEventListener('click', switchTab);
const form = document.forms['calendary_filter'];
const formData = getFromLSOrDefaultValue('formData', getFormValues(form));
const linkRedirect = document.getElementById('redirectToSearch');
const buttonCopy = form['copySearch'];
const fillFormWithFormData = (formData, form) => {
if (!form) return;
for (const [key, data] of Object.entries(formData)) {
try {
form[key].value = data;
} catch (error) {
debugger;
console.error(error);
}
}
};
window.onload = () => {
const date = new Date();
const fullDate = `${date.getFullYear()}-${date.getMonth()}-${
date.getDay() >= 10 ? date.getDate() : '0' + date.getDate()
}`;
form.date.value = fullDate;
linkRedirect.classList.add('btn--disabled');
fillFormWithFormData(formData, form);
validateForm();
};
form.addEventListener(
'change',
(evt) => {
formData[evt.target.name] = evt.target.value;
localStorage.setItem('formData', JSON.stringify(formData));
validateForm();
},
true
);
buttonCopy.addEventListener('click', (evt) => {
evt.preventDefault();
if (validateForm()) {
const { typeOfSearch, date } = createSearchFilter(formData);
navigator.clipboard.writeText(`${typeOfSearch} ${date}`);
}
});
linkRedirect.addEventListener('click', (evt) => {
evt.preventDefault();
if (validateForm()) {
//action
}
});
</script>
</body>
</html>