This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
xephero.html
181 lines (154 loc) · 5.04 KB
/
xephero.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
html {
/*background-image: url(images/handle.png);*/
background-position: bottom right;
background-repeat: no-repeat;
box-sizing: border-box;
height: 100%;
}
#overlay {
font-family: Tahoma;
color: #ded7be;
background-color: rgba(0,0,0,0.3);
border-radius: 10px;
}
#source {
display: none;
}
ol {
list-style-type: none;
margin: 0;
padding: 5px;
}
li .dps {
display: inline-block;
color: #ded7be;
width: 28%;
max-width: 70px;
text-align: right;
font-size: 19px;
}
li .name {
display: inline-block;
width: 75%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
li .detail {
display: inline-block;
vertical-align: top;
color: #ded7be;
font-size: 12px;
width: 69%;
}
li .detail .number {
display: inline-block;
color: #ded7be;
float: right;
}
li .bar {
display: block;
height: 5px;
background-color: #9d9165;
}
.inactive li .bar {
background-color: #d8dadb;
}
li.you {
background-color: #5d5125;
}
</style>
<script type="text/javascript" src="lib/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(function() {
"use strict";
var rows = 10;
var rdps_max = 0;
function update(e) {
var encounter = e.detail.Encounter;
var combatants = e.detail.Combatant;
var template = $('#source li');
var container = $('#overlay').clone();
// todo: animate changes while combat is active?
// for now, always just fully replace the content
container.html('');
var rdps = parseFloat(encounter.encdps);
// sanity check
if (!isNaN(rdps) && rdps != Infinity) {
rdps_max = Math.max(rdps_max, rdps);
}
var header = template.clone();
if (encounter.encdps.length <= 7) {
header.find('.dps').text(encounter.encdps);
} else {
header.find('.dps').text(encounter.ENCDPS);
}
header.find('.name').text(encounter.title);
header.find('.number').text(encounter.duration);
header.find('.bar').css('width', ((rdps / rdps_max) * 100) + '%');
// set inactive
if (!e.detail.isActive) {
rdps_max = 0;
$('body').addClass('inactive');
} else {
$('body').removeClass('inactive');
}
container.append(header);
var limit = Math.max(combatants.length, rows);
var names = Object.keys(combatants).slice(0,rows-1);
var maxdps = false;
for (var i = 0; i < names.length; i++) {
var combatant = combatants[names[i]];
var row = template.clone();
if (!maxdps) {
maxdps = parseFloat(combatant.encdps);
}
if (combatant.name == 'YOU') {
row.addClass('you');
}
if (combatant.damage.length > 6) {
combatant.damage = combatant.damage.substring(0,combatant.damage.length-3) + 'K';
}
row.find('.dps').text(combatant.encdps);
row.find('.name').text(combatant.Job.toUpperCase() + ' ' + combatant.name);
row.find('.number').text(combatant.damage);
row.find('.bar').css('width', ((parseFloat(combatant.encdps) / maxdps) * 100) + '%');
container.append(row);
}
$('#overlay').replaceWith(container);
}
$(document).on('onOverlayDataUpdate', function(e) {
update(e.originalEvent);
});
window.addEventListener('message', function(e) {
if (e.data.type === 'onOverlayDataUpdate') {
update(e.data);
}
});
});
</script>
</head>
<body>
<ol id="source">
<li>
<span class="dps"></span>
<div class="detail">
<span class="title">
<span class="name"></span>
<span class="number"></span>
</span>
<span class="bar"></span>
</div>
</li>
</ol>
<ol id="overlay">
<li>Awaiting data.</li>
</ol>
</body>
</html>