forked from Suchty112/Leitstellenspiel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortkeymissingvehicles.user.js
91 lines (86 loc) · 4.03 KB
/
shortkeymissingvehicles.user.js
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
// ==UserScript==
// @name shortkeyMissingVehicles
// @version 1.0.0
// @description add a new short-key for loading missing vehicles
// @author DrTraxx
// @include *://www.leitstellenspiel.de/missions/*
// @grant none
// ==/UserScript==
/* global $ */
(function() {
'use strict';
$(".missing_vehicles_load:first")
.before(`<button type="button" class="btn btn-success btn-xs" data-toggle="modal" data-target="#smvModal" style="height:24px">
Einstellungen Short-Key
</button>
<div class="modal fade" id="smvModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="smvModalLabel">Einstellungen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="smvModalBody">
Bitte den Short-Key eingeben. Groß- und Kleinschreibung muss beachtet werden!<br>
<div style="display:flex">
<input type="text" class="form-control form-control-sm" value="${localStorage.smv_key}" id="smvShortKey" style="height:22px;flex:0.25">
<label class="form-check-label" for="smvShortKey" style="flex:1">Short-Key</label>
</div><br>
Folgende Short-Keys sind vom Spiel schon belegt:<br>
<small>
<table>
<tr>
<th class="col-1">Key</th>
<th class="col">Funktion</th>
<th class="col-1">Key</th>
<th class="col">Funktion</th>
<th class="col-1">Key</th>
<th class="col">Funktion</th>
</tr>
<tr>
<td class="col-1">x</td>
<td class="col">Alarmieren</td>
<td class="col-1">s</td>
<td class="col">Alarmieren + nächster Einsatz
<td class="col-1">w</td>
<td class="col">Einsatz freigeben</td>
</tr>
<tr>
<td class="col-1">n</td>
<td class="col">fehlende Fahrzeuge nachladen</td>
<td class="col-1">e</td>
<td class="col">Alarmieren, freigeben + nächster Einsatz</td>
<td class="col-1">a</td>
<td class="col">Vorheriger Einsatz</td>
</tr>
<tr>
<td class="col-1">d</td>
<td class="col">Nächster Einsatz</td>
<td class="col-1">q</td>
<td class="col">Sprechwünsche</td>
<td class="col-1">1-9</td>
<td class="col">Fahrzeuge an Position 1 - 9 in Fahrzeugliste auswählen</td>
</tr>
</table>
</small>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Schließen</button>
<button type="button" class="btn btn-success" id="smvSavePreferences">Speichern</button>
</div>
</div>
</div>
</div>`);
$("body").on("keypress", function(e) {
if($("input:text").is(":focus") || $("textarea").is(":focus") || $("input[type='search']").is(":focus")) return true;
if(e.key === localStorage.smv_key) {
$(".missing_vehicles_load").first().click();
}
});
$("body").on("click", "#smvSavePreferences", function() {
localStorage.smv_key = $("#smvShortKey").val();
$("#smvSavePreferences").css({"display":"none"});
$("#smvModalBody").html("<h3><center>Die Einstellungen wurden gespeichert.</center></h5>");
});
})();