Skip to content

Commit f43aa22

Browse files
authored
Oct, 19 Update (#45)
1 parent b039483 commit f43aa22

File tree

8 files changed

+338
-166
lines changed

8 files changed

+338
-166
lines changed

.devcontainer/requirements.prod.txt

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ numpy
99
Pillow
1010
gitpython
1111
babel
12+
waitress
13+
paste

docker-entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ fi
1515

1616
crond -L /var/log/crond -c $CRON_PATH
1717

18-
flask run --host=0.0.0.0 --port=5000
18+
python3 web.py
1919

2020
exec "$@"

html_templates/action.html

+53-56
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,59 @@
33

44
<head>
55
<meta charset="utf-8">
6-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
7-
<style>
8-
.block_container {
9-
text-align: right;
10-
}
11-
12-
.block1 {
13-
display: inline-flex;
14-
}
15-
16-
.block2 {
17-
width: 86px;
18-
}
19-
</style>
206
</head>
217

228
<body>
23-
{% if myval['action'] == 'delete' %}
24-
<h1>{{ myval['action'] | upper}}</h1>
25-
<div>
26-
<p><input type="submit" value="{{ myval['action'] | upper}}" /></p>
27-
</div>
28-
{% else %}
29-
<h1>{{ myval['action'] | upper}}</h1>
30-
<form action="/update" method="post" id="updateForm">
31-
<div class="block_container">
32-
<label class="block1 block2" for="home_team">קבוצת בית:</label>
33-
<input type="text" id="home_team" name="home_team" value="{{ myval['home_team'] }}" readonly>
34-
</div>
35-
<div class="block_container">
36-
<label class="block1 block2" for="guest_team">קבוצת חוץ:</label>
37-
<input type="text" id="guest_team" name="guest_team" value="{{ myval['guest_team'] }}" readonly>
38-
</div>
39-
<div class="block_container">
40-
<label class="block1 block2" for="specs_number">מס. אוהדים:</label>
41-
<input type="number" name="specs_number" value="{{ myval['specs_number'] }}" id="specNumber", max="30000">
42-
</div>
43-
<div class="block_container">
44-
<label class="block1 block2" for="specs_word">כמות:</label>
45-
<select id="specWord" name="specs_word">
46-
<option {% if myval['specs_word'] == "ללא" %}selected="selected" {% endif %} value="ללא">ללא</option>
47-
<option {% if myval['specs_word'] == "קטן" %}selected="selected" {% endif %} value="קטן">קטן</option>
48-
<option {% if myval['specs_word'] == "בינוני" %}selected="selected" {% endif %} value="בינוני">בינוני</option>
49-
<option {% if myval['specs_word'] == "גדול" %}selected="selected" {% endif %} value="גדול">גדול</option>
50-
<option {% if myval['specs_word'] == "גדול מאוד" %}selected="selected" {% endif %} value="גדול מאוד">גדול מאוד</option>
51-
</select>
9+
<div class="">
10+
{% if myval['action'] == 'delete' %}
11+
<h1>{{ myval['action'] | upper}}</h1>
12+
<div class="form-group">
13+
<input type="submit" value="{{ myval['action'] | upper}}" />
5214
</div>
53-
<div class="block_container">
54-
<label class="block1 block2" for="poll">סקר:</label>
55-
<div class="block1"><input type="checkbox" name="poll" {% if myval['poll'] == 'on' %}checked=true{% endif %}></div>
56-
</div>
57-
<div class="block_container">
58-
<label class="block1 block2" for="notes">הערות:</label>
59-
<textarea id="notes" name="notes" rows="2">{{ myval['notes'] }}</textarea>
60-
</div>
61-
<p><input type="submit" value="{{ myval['action'] | upper}}" /></p>
62-
</form>
63-
<p>
15+
{% else %}
16+
<h1>{{ myval['action'] | upper}}</h1>
17+
<form action="/update" method="post" id="updateForm" class="form-container">
18+
<div class="form-group">
19+
<label for="home_team">קבוצת בית:</label>
20+
<input type="text" id="home_team" name="home_team" value="{{ myval['home_team'] }}" readonly>
21+
</div>
22+
<div class="form-group">
23+
<label for="guest_team">קבוצת חוץ:</label>
24+
<input type="text" id="guest_team" name="guest_team" value="{{ myval['guest_team'] }}" readonly>
25+
</div>
26+
<div class="form-group">
27+
<label for="specs_number">מס. אוהדים:</label>
28+
<input type="number" name="specs_number" value="{{ myval['specs_number'] }}" id="specNumber"
29+
max="30000">
30+
</div>
31+
<div class="form-group">
32+
<label for="specs_word">כמות:</label>
33+
<select id="specWord" name="specs_word">
34+
<option {% if myval['specs_word']=="ללא" %}selected="selected" {% endif %} value="ללא">ללא</option>
35+
<option {% if myval['specs_word']=="קטן" %}selected="selected" {% endif %} value="קטן">קטן</option>
36+
<option {% if myval['specs_word']=="בינוני" %}selected="selected" {% endif %} value="בינוני">בינוני
37+
</option>
38+
<option {% if myval['specs_word']=="גדול" %}selected="selected" {% endif %} value="גדול">גדול
39+
</option>
40+
<option {% if myval['specs_word']=="גדול מאוד" %}selected="selected" {% endif %} value="גדול מאוד">
41+
גדול מאוד</option>
42+
</select>
43+
</div>
44+
<div class="form-group">
45+
<label for="poll">סקר:</label>
46+
<input type="checkbox" name="poll" {% if myval['poll']=='on' %}checked=true{% endif %}>
47+
</div>
48+
<div class="form-group">
49+
<label for="notes">הערות:</label>
50+
<textarea id="notes" name="notes" rows="2">{{ myval['notes'] }}</textarea>
51+
</div>
52+
<div class="form-group">
53+
<input type="submit" value="{{ myval['action'] | upper}}">
54+
</div>
55+
</form>
6456
<div id="result_update"></div>
65-
</p>
57+
{% endif %}
58+
</div>
6659
<script>
6760
$("#updateForm").submit(function (event) {
6861
event.preventDefault(); // Stop form from submitting normally
@@ -72,9 +65,13 @@ <h1>{{ myval['action'] | upper}}</h1>
7265
$.post(url, (form_data))
7366
.done(function (data) {
7467
$("#result_update").empty().append(data);
68+
setTimeout(function () {
69+
location.reload(); // Reload the page after 0 seconds
70+
}, 0);
71+
7572
});
7673
});
7774
</script>
78-
{% endif %}
7975
</body>
76+
8077
</html>

html_templates/next.html

+104-107
Original file line numberDiff line numberDiff line change
@@ -5,127 +5,124 @@
55
<meta charset="utf-8">
66
<title>המשחקים הקרובים</title>
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
8-
<style>
9-
div.unstyledTable {
10-
width: 1024px;
11-
border-collapse: collapse;
12-
}
13-
14-
.divTable.unstyledTable .divTableCell, .divTable.unstyledTable .divTableHead {}
15-
16-
.divTable.unstyledTable .divTableBody .divTableCell {
17-
font-size: 10px;
18-
}
19-
20-
.divTable.unstyledTable .divTableHeading {
21-
background: #DDDDDD;
22-
}
23-
24-
.divTable.unstyledTable .divTableHeading .divTableHead {
25-
font-size: 15px;
26-
font-weight: bold;
27-
text-align: right;
28-
}
29-
30-
/* DivTable.com */
31-
.divTable {
32-
display: table;
33-
}
34-
35-
.divTableRow {
36-
display: table-row;
37-
}
38-
39-
.divTableHeading {
40-
display: table-header-group;
41-
}
42-
43-
.divTableCell,
44-
.divTableHead {
45-
display: table-cell;
46-
font-size: 15px;
47-
}
48-
49-
.divTableHeading {
50-
display: table-header-group;
51-
}
52-
53-
.divTableBody {
54-
display: table-row-group;
55-
}
56-
</style>
8+
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
579
</head>
5810

5911
<body>
60-
<div class="divTable unstyledTable">
61-
<div class="divTableHeading">
62-
<div class="divTableRow">
63-
<div class="divTableHead">#</div>
64-
<div class="divTableHead">תאריך</div>
65-
<div class="divTableHead">יום</div>
66-
<div class="divTableHead">שעה</div>
67-
<div class="divTableHead">ליגה</div>
68-
<div class="divTableHead">בית</div>
69-
<div class="divTableHead">חוץ</div>
70-
<div class="divTableHead">אוהדים</div>
71-
<div class="divTableHead">מספר</div>
72-
<div class="divTableHead">פעולה</div>
73-
<div class="divTableHead">סקר</div>
74-
<div class="divTableHead">הערות</div>
12+
<div class="container">
13+
<div class="divTable unstyledTable">
14+
<div class="divTableHeading">
15+
<div class="divTableRow">
16+
<div class="divTableHead">#</div>
17+
<div class="divTableHead">תאריך</div>
18+
<div class="divTableHead">יום</div>
19+
<div class="divTableHead">שעה</div>
20+
<div class="divTableHead">ליגה</div>
21+
<div class="divTableHead">בית</div>
22+
<div class="divTableHead">חוץ</div>
23+
<div class="divTableHead">אוהדים</div>
24+
<div class="divTableHead">מספר</div>
25+
<div class="divTableHead">פעולה</div>
26+
<div class="divTableHead">סקר</div>
27+
<div class="divTableHead">הערות</div>
28+
<div class="divTableHead">שלח</div>
29+
</div>
7530
</div>
76-
</div>
77-
{% for key, value in mygames.items() %}
78-
{% set scraped_date_time, league, home_team, home_team_en, home_team_url, game_hour, guest_team, guest_team_en, guest_team_url, game_time_delta, road_block_time, specs_word, specs_number, poll, notes, custom_sepcs_number, custom_road_block_time = value %}
79-
{% if guest_team_url != '' %}
80-
{% set guest_team_alter = '<a href="' ~ guest_team_url ~ '" target="_blank">' ~ guest_team ~ '</a>' %}
81-
{% else %}
82-
{% set guest_team_alter = guest_team %}
83-
{% endif %}
84-
<div class="divTableRow">
85-
<div class="divTableCell">{{ loop.index }}</div>
86-
<div class="divTableCell">{{ scraped_date_time.strftime('%Y-%m-%d') }}</div>
87-
<div class="divTableCell">{{ scraped_date_time | babel_format_day_heb }}</div>
88-
<div class="divTableCell">{{ scraped_date_time.strftime('%H:%M') }}</div>
89-
<div class="divTableCell">{{ league }}</div>
90-
<div class="divTableCell"><img width="18" height="18" src="assets/teams/{{ home_team_en }}.png">&nbsp;<a href="{{ home_team_url }}" target="_blank">{{ home_team }}</a></div>
91-
<div class="divTableCell"><img width="18" height="18" src="assets/teams/{{ guest_team_en }}.png">&nbsp;{{ guest_team_alter | safe }}</div>
92-
<div class="divTableCell">{{ specs_word }}</div>
93-
<div class="divTableCell" {% if specs_number == 0 %}style="background: yellow;" {% endif %}>{{ specs_number }}</div>
94-
<div class="divTableCell">
95-
<form action="/action" method="post">
96-
<select id="action_{{ loop.index }}" name="action">
97-
<option option hidden selected>בחר</option>
98-
<option id="update" value='{
99-
"action":"update",
100-
"home_team":"{{ home_team | replace('"', '\\"') }}",
101-
"guest_team":"{{ guest_team | replace('"', '\\"') }}",
102-
"specs_word": "{{ specs_word }}",
103-
"specs_number": "{{ specs_number }}",
104-
"poll": "{{ poll }}",
105-
"notes": "{{ notes }}"}'>עדכן</option>
106-
<option id="delete" value='{
107-
"action":"delete",
108-
"home_team":"{{ home_team }}",
109-
"guest_team":"{{ guest_team }}"}'>מחק</option>
110-
</select>
111-
</form>
31+
{% for key, value in mygames.items() %}
32+
{% set scraped_date_time, league, home_team, home_team_en, home_team_url, game_hour, guest_team,
33+
guest_team_en, guest_team_url, game_time_delta, road_block_time, specs_word, specs_number, poll, notes,
34+
custom_sepcs_number, custom_road_block_time = value %}
35+
{% if guest_team_url != '' %}
36+
{% set guest_team_alter = '<a href="' ~ guest_team_url ~ '" target="_blank">' ~ guest_team ~ '</a>' %}
37+
{% else %}
38+
{% set guest_team_alter = guest_team %}
39+
{% endif %}
40+
<div class="divTableRow">
41+
<div class="divTableCell">{{ loop.index }}</div>
42+
<div class="divTableCell">{{ scraped_date_time.strftime('%Y-%m-%d') }}</div>
43+
<div class="divTableCell">{{ scraped_date_time | babel_format_day_heb }}</div>
44+
<div class="divTableCell">{{ scraped_date_time.strftime('%H:%M') }}</div>
45+
<div class="divTableCell">{{ league }}</div>
46+
<div class="divTableCell"><img width="18" height="18" src="assets/teams/{{ home_team_en }}.png">&nbsp;<a
47+
href="{{ home_team_url }}" target="_blank">{{ home_team }}</a></div>
48+
<div class="divTableCell"><img width="18" height="18"
49+
src="assets/teams/{{ guest_team_en }}.png">&nbsp;{{ guest_team_alter | safe }}</div>
50+
<div class="divTableCell">{{ specs_word }}</div>
51+
<div class="divTableCell" {% if specs_number==0 %}style="background: yellow;" {% endif %}>{{
52+
specs_number }}</div>
53+
<div class="divTableCell">
54+
<form action="/action" method="post">
55+
<select id="action_{{ loop.index }}" name="action">
56+
<option option hidden selected>בחר</option>
57+
<option id="update" value='{
58+
"action":"update",
59+
"home_team":"{{ home_team | replace('"', '\\"') }}",
60+
"guest_team":"{{ guest_team | replace('"', '\\"') }}",
61+
"specs_word": "{{ specs_word }}",
62+
"specs_number": "{{ specs_number }}",
63+
"poll": "{{ poll }}",
64+
"notes": "{{ notes }}"}'>עדכן</option>
65+
<option id="delete" value='{
66+
"action":"delete",
67+
"home_team":"{{ home_team }}",
68+
"guest_team":"{{ guest_team }}"}'>מחק</option>
69+
</select>
70+
</form>
71+
</div>
72+
<div class="divTableCell">
73+
<input type="checkbox" id="poll" disabled="disabled" {% if poll=='on' %}checked{% endif %}>
74+
</div>
75+
<div class="divTableCell">{{ notes }}</div>
76+
<div class="divTableCell">
77+
<button onclick="send(this)">שלח</button>
78+
</div>
11279
</div>
113-
<div class="divTableCell"><input type="checkbox" id="poll" disabled="disabled" {% if poll == 'on' %}checked{% endif %}></div>
114-
<div class="divTableCell">{{ notes }}</div>
80+
{% endfor %}
11581
</div>
116-
{% endfor %}
117-
</div>
118-
<p>
82+
<p>
11983
<div id="result_action"></div>
120-
</p>
84+
</p>
85+
</div>
12186
<script>
12287
$('select').on('change', function () {
12388
let select_id = $(this).children(":selected").attr("id");
89+
let row = $(this).closest('.divTableRow');
90+
91+
// Remove highlight from all rows
92+
$('.divTableRow').removeClass('highlight');
93+
94+
// Add highlight to the selected row
95+
row.addClass('highlight');
96+
12497
$.post("/action", { [select_id]: this.value })
12598
.done(function (data) {
12699
$("#result_action").empty().append(data);
127100
});
128101
});
102+
103+
function send(button) {
104+
const row = button.closest('.divTableRow');
105+
const cells = row.querySelectorAll('.divTableCell');
106+
const keys = [
107+
'index', 'date', 'day', 'time', 'league', 'home_team', 'guest_team',
108+
'fans', 'number', 'action', 'poll', 'notes', 'send'
109+
];
110+
const values = {};
111+
112+
cells.forEach((cell, index) => {
113+
values[keys[index]] = cell.innerText.trim();
114+
});
115+
116+
// Send the values using $.post
117+
$.post('/your-endpoint', values)
118+
.done(function (data) {
119+
console.log('Success:', data);
120+
})
121+
.fail(function (error) {
122+
console.error('Error:', error);
123+
});
124+
}
129125
</script>
130126
</body>
131-
</html>
127+
128+
</html>

screen.png

43.2 KB
Loading

0 commit comments

Comments
 (0)