diff --git a/app.py b/app.py index c7000dc..ced3268 100644 --- a/app.py +++ b/app.py @@ -2569,5 +2569,50 @@ def set_language(language): 'message': f'Unsupported language: {language}' }), 400 +# ── Calculator leaderboard & display settings ──────────────────────────────── + +CALC_LEADERBOARD_FILE = os.path.join('data', 'calculator_leaderboard.json') + +@app.route('/api/calculator/leaderboard', methods=['GET']) +def get_calculator_leaderboard(): + try: + if os.path.exists(CALC_LEADERBOARD_FILE): + with open(CALC_LEADERBOARD_FILE, 'r', encoding='utf-8') as f: + return jsonify(json.load(f)) + return jsonify([]) + except Exception as e: + return jsonify({'status': 'error', 'message': str(e)}), 500 + +@app.route('/api/calculator/leaderboard', methods=['POST']) +def save_calculator_leaderboard(): + try: + data = request.get_json() + os.makedirs('data', exist_ok=True) + with open(CALC_LEADERBOARD_FILE, 'w', encoding='utf-8') as f: + json.dump(data, f, indent=2, ensure_ascii=False) + return jsonify({'status': 'success'}) + except Exception as e: + return jsonify({'status': 'error', 'message': str(e)}), 500 + +@app.route('/api/calculator/display', methods=['GET']) +def get_calculator_display(): + try: + settings = load_settings() + return jsonify(settings.get('calc_display', {'enabled': False, 'camera': 1})) + except Exception as e: + return jsonify({'status': 'error', 'message': str(e)}), 500 + +@app.route('/api/calculator/display', methods=['POST']) +def save_calculator_display(): + try: + data = request.get_json() + settings = load_settings() + settings['calc_display'] = {'enabled': bool(data.get('enabled')), 'camera': int(data.get('camera', 1))} + save_settings(settings) + return jsonify({'status': 'success'}) + except Exception as e: + return jsonify({'status': 'error', 'message': str(e)}), 500 + + if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=True) \ No newline at end of file diff --git a/app/storage.py b/app/storage.py index 318db97..ee5f0b8 100644 --- a/app/storage.py +++ b/app/storage.py @@ -35,7 +35,11 @@ DEFAULT_SETTINGS = { 'show_titles': True, 'title_size': 1.1 }, - 'disabled_cameras': [] + 'disabled_cameras': [], + 'calc_display': { + 'enabled': False, + 'camera': 1 + } } diff --git a/data/calculator_leaderboard.json b/data/calculator_leaderboard.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/data/calculator_leaderboard.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/data/camera_settings.json b/data/camera_settings.json index 9a97d9c..aebf485 100644 --- a/data/camera_settings.json +++ b/data/camera_settings.json @@ -13,5 +13,9 @@ "target_number_size": 1.7 }, "tv_view": "cameras", - "disabled_cameras": [] + "disabled_cameras": [], + "calc_display": { + "enabled": true, + "camera": 4 + } } \ No newline at end of file diff --git a/templates/calculator.html b/templates/calculator.html index 287a3a4..db087ae 100644 --- a/templates/calculator.html +++ b/templates/calculator.html @@ -1,5 +1,5 @@ - + Kalkulator @@ -8,39 +8,24 @@ @@ -308,12 +442,11 @@
- +
-

🎯 Konfiguracija

+

⚙️ Nastavitve

-
@@ -327,45 +460,156 @@
-
-
- Točke - 0 -
-
- 10-ke - 0 -
-
-
-
- +
+ +
-
- - +
+ 📺 Prikaz na zaslonu +
+ Omogoči prikaz + +
+
+ + +
- -
-
+ +
+ +
+ 👤 + +
+ +
🎯 Nastavi konfiguracijo in klikni Generiraj
+ +
+
+ 0 + 0 × 10 +
+
+
+
+
+
+
+ +
+ +
+ + +
+
+

🏆 Lestvica

+ 0 +
+ +
+ 🏅 + Dodaj tekmovalce z gumbom
Dodaj na lestvico
+
+ + + + +
+ + + diff --git a/templates/index.html b/templates/index.html index 7f08470..ec8e2f8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -130,6 +130,81 @@ align-content: stretch; } + /* ── Leaderboard display mode ── */ + .main-wrapper { + display: flex; + height: calc(100vh - 50px); + } + .main-wrapper .grid { + flex: 1; + height: 100%; + grid-template-columns: 1fr; + grid-template-rows: 1fr; + min-width: 0; + } + .lb-sidebar { + width: 320px; + flex-shrink: 0; + display: flex; + flex-direction: column; + background: #141414; + border-left: 2px solid #222; + overflow: hidden; + } + .lb-header { + height: 60px; + display: flex; + align-items: center; + justify-content: space-between; + padding: 0 20px; + border-bottom: 1px solid #222; + flex-shrink: 0; + } + .lb-title { font-size: 1.1rem; font-weight: 800; color: #fff; } + .lb-count { + background: #28a745; color: white; + font-size: 0.72rem; font-weight: 700; + padding: 2px 9px; border-radius: 12px; + } + .lb-empty { + flex: 1; display: flex; flex-direction: column; + align-items: center; justify-content: center; + color: #444; gap: 10px; font-size: 0.9rem; + } + .lb-empty .icon { font-size: 2.5rem; } + .lb-list { + flex: 1; overflow-y: auto; + padding: 10px 12px; + display: flex; flex-direction: column; gap: 7px; + } + .lb-list::-webkit-scrollbar { width: 4px; } + .lb-list::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; } + .lb-row { + display: flex; align-items: center; gap: 9px; + padding: 9px 12px; + border-radius: 10px; + background: #1e1e1e; border: 2px solid #2a2a2a; + } + .lb-row.r1 { border-color: #ffc107; background: #1c1900; } + .lb-row.r2 { border-color: #888; background: #181818; } + .lb-row.r3 { border-color: #a0522d; background: #1a1210; } + .lb-badge { + width: 30px; height: 30px; border-radius: 50%; + display: flex; align-items: center; justify-content: center; + font-size: 0.78rem; font-weight: 800; flex-shrink: 0; + background: #2a2a2a; color: #aaa; + } + .lb-row.r1 .lb-badge { background: #ffc107; color: #7a5800; font-size: 1rem; } + .lb-row.r2 .lb-badge { background: #888; color: #fff; font-size: 1rem; } + .lb-row.r3 .lb-badge { background: #a0522d; color: #fff; font-size: 1rem; } + .lb-name { + flex: 1; min-width: 0; + font-size: 0.95rem; font-weight: 700; color: #eee; + white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + } + .lb-tens { font-size: 0.7rem; font-weight: 700; color: #ffc107; flex-shrink: 0; } + .lb-pts { font-size: 1.2rem; font-weight: 900; color: #28a745; flex-shrink: 0; min-width: 36px; text-align: right; } + .camera-card { overflow: hidden; display: flex; @@ -884,7 +959,8 @@
-
+
+
{% for i in range(1, 7) %}
@@ -916,6 +992,17 @@ {% endfor %}
+ + +
+ \ No newline at end of file