Skip to content

Commit 32f0a11

Browse files
authored
Merge pull request #53 from opowell/stable
Stable
2 parents 72b0170 + 720cd09 commit 32f0a11

File tree

169 files changed

+521
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+521
-398
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
## Getting started
22
Download for your system, unzip and run.
33

4-
Latest version (2019.12.12): **0.8.4**
4+
Latest version (2019.12.13): **0.8.5**
55

6-
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.4-win.zip'>jtree for Windows</a>
6+
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.5-win.zip'>jtree for Windows</a>
77

8-
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.4-macos.zip'>jtree for Mac</a>
8+
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.5-macos.zip'>jtree for Mac</a>
99

10-
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.4-linux.zip'>jtree for Linux</a>
10+
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.5-linux.zip'>jtree for Linux</a>
1111

12-
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.4-winxp.zip'>jtree for WindowsXP</a>
12+
<a href='https://github.com/opowell/jtree/releases/latest/download/jtree-0.8.5-winxp.zip'>jtree for WindowsXP</a>
1313

1414
![](double-auction.png)
1515

build-tools/win/buildJTree.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ REM 2. Update README.md.
1010
REM 3. Update docs/README.md.
1111
REM 4. Commit to Github.
1212

13-
set "vers=0.8.4"
13+
set "vers=0.8.5"
1414

1515
REM ------- Prepare output folder.
1616
call del ".\release" /Q /F

client/internal/clients/admin/multiuser/utilities.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,44 @@ fullPartLink = function(pId) {
1111
return jt.serverURL() + '/session/' + jt.data.session.id + '/' + pId;
1212
}
1313

14+
// http://www.davekoelle.com/files/alphanum.js
15+
// Sort alphanumerically in place.
16+
alphanumSort = function(ids) {
17+
let caseInsensitive = true;
18+
for (var z = 0, t; t = ids[z]; z++) {
19+
ids[z] = new Array();
20+
var x = 0, y = -1, n = 0, i, j;
21+
22+
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
23+
var m = (i == 46 || (i >=48 && i <= 57));
24+
if (m !== n) {
25+
ids[z][++y] = "";
26+
n = m;
27+
}
28+
ids[z][y] += j;
29+
}
30+
}
31+
32+
ids.sort(function(a, b) {
33+
for (var x = 0, aa, bb; (aa = a[x]) && (bb = b[x]); x++) {
34+
if (caseInsensitive) {
35+
aa = aa.toLowerCase();
36+
bb = bb.toLowerCase();
37+
}
38+
if (aa !== bb) {
39+
var c = Number(aa), d = Number(bb);
40+
if (c == aa && d == bb) {
41+
return c - d;
42+
} else return (aa > bb) ? 1 : -1;
43+
}
44+
}
45+
return a.length - b.length;
46+
});
47+
48+
for (var z = 0; z < ids.length; z++)
49+
ids[z] = ids[z].join("");
50+
}
51+
1452
roomLink = function(roomId) {
1553
return jt.serverURL() + '/room/' + roomId;
1654
}

client/internal/clients/admin/multiuser/webcomponents/ViewHome.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class ViewHome extends HTMLElement {
33
this.innerHTML = `
44
<div id='view-home' class='view'>
55
Welcome to jtree.
6-
<div style='padding-top: 1rem; color: #888'>0.8.4</div>
6+
<div style='padding-top: 1rem; color: #888'>0.8.5</div>
77
<br><a href='/admin/vue' target='__blank'>Try new interface (BETA)</a>
88
</div>
99
`;

client/internal/clients/admin/multiuser/webcomponents/ViewSessionActivity.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ class ViewSessionActivity extends HTMLElement {
3232
document.write('<script src="/admin/multiuser/webcomponents/SetAutoplayFreqModal.js"></script>');
3333

3434
function viewAllParticipants() {
35-
for (var pId in jt.data.session.participants) {
35+
let ids = Object.keys(jt.data.session.participants);
36+
alphanumSort(ids);
37+
38+
for (var i in ids) {
39+
let pId = ids[i];
3640
var participant = jt.data.session.participants[pId];
3741
viewParticipant(participant.id);
3842
}

client/internal/clients/admin/multiuser/webcomponents/ViewSessionParticipants.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ function showParticipants(participants) {
236236
},
237237
partsArray() {
238238
let parts = [];
239-
for (let p in this.data.session.participants) {
240-
parts.push(this.data.session.participants[p]);
239+
let ids = Object.keys(this.data.session.participants);
240+
alphanumSort(ids);
241+
for (let p in ids) {
242+
parts.push(this.data.session.participants[ids[p]]);
241243
}
242244
return parts;
243245
},

client/internal/clients/admin/shared/utilities.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,44 @@ partLink = function(pId) {
1111
}
1212
}
1313

14+
// http://www.davekoelle.com/files/alphanum.js
15+
// Sort alphanumerically in place.
16+
alphanumSort = function(ids) {
17+
let caseInsensitive = true;
18+
for (var z = 0, t; t = ids[z]; z++) {
19+
ids[z] = new Array();
20+
var x = 0, y = -1, n = 0, i, j;
21+
22+
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
23+
var m = (i == 46 || (i >=48 && i <= 57));
24+
if (m !== n) {
25+
ids[z][++y] = "";
26+
n = m;
27+
}
28+
ids[z][y] += j;
29+
}
30+
}
31+
32+
ids.sort(function(a, b) {
33+
for (var x = 0, aa, bb; (aa = a[x]) && (bb = b[x]); x++) {
34+
if (caseInsensitive) {
35+
aa = aa.toLowerCase();
36+
bb = bb.toLowerCase();
37+
}
38+
if (aa !== bb) {
39+
var c = Number(aa), d = Number(bb);
40+
if (c == aa && d == bb) {
41+
return c - d;
42+
} else return (aa > bb) ? 1 : -1;
43+
}
44+
}
45+
return a.length - b.length;
46+
});
47+
48+
for (var z = 0; z < ids.length; z++)
49+
ids[z] = ids[z].join("");
50+
}
51+
1452
roomLink = function(roomId) {
1553
return jt.serverURL() + '/room/' + roomId;
1654
}

client/internal/clients/participant/defaultClient.js

Lines changed: 68 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -97,52 +97,19 @@ jt.setFormDefaults = function() {
9797
}
9898

9999
if (
100-
$(this).attr('action')===undefined &&
100+
form.attr('action')===undefined &&
101101
(
102102
this.$listeners == null ||
103103
this.$listeners.click == null
104104
)
105105
) {
106106
try {
107-
$(this).off('submit');
108-
$(this).submit(function(event) {
107+
form.off('submit');
108+
form.submit(function(event) {
109109
event.preventDefault();
110110
event.stopPropagation();
111-
var values = {};
112-
var stageName = jt.data.player.stage.id;
113-
values.fnName = stageName;
114-
values.playerRoomId = jt.data.player.roomId;
115-
116-
// INPUTS (includes input, select and checkboxes, but not buttons)
117-
// https://stackoverflow.com/questions/11855781/jquery-getting-data-from-form
118-
var $inputs = $(this).find(':input:not(:button)');
119-
$inputs.each(function() {
120-
// Skip blank inputs.
121-
var fieldName = $(this).attr('name');
122-
if (fieldName !== '' && fieldName !== undefined) {
123-
if (this.type === 'checkbox') {
124-
if (this.checked === true) {
125-
if (values[fieldName] === undefined) {
126-
values[fieldName] = [];
127-
}
128-
values[fieldName].push(this.value);
129-
}
130-
} else if (this.type === 'radio') {
131-
if (this.checked) {
132-
values[fieldName] = this.value;
133-
}
134-
} else {
135-
values[fieldName] = this.value;
136-
}
137-
}
138-
});
139-
140-
console.log('submitting form with values ' + JSON.stringify(values));
141-
142-
jt.sendMessage(stageName, values);
143-
144-
$(form).find('[jtautogenerated=true]').remove();
145-
111+
jt.submitForm(form);
112+
form.find('[jtautogenerated=true]').remove();
146113
});
147114
} catch (err) {
148115
console.log('error assigning submit button action');
@@ -153,6 +120,49 @@ jt.setFormDefaults = function() {
153120

154121
}
155122

123+
jt.submitForm = function(formEl) {
124+
var values = {};
125+
126+
// INPUTS (includes input, select and checkboxes, but not buttons)
127+
// https://stackoverflow.com/questions/11855781/jquery-getting-data-from-form
128+
var $inputs = $(formEl).find(':input:not(:button)');
129+
$inputs.each(function() {
130+
// Skip blank inputs.
131+
var fieldName = $(this).attr('name');
132+
if (fieldName !== '' && fieldName !== undefined) {
133+
if (this.type === 'checkbox') {
134+
if (this.checked === true) {
135+
if (values[fieldName] === undefined) {
136+
values[fieldName] = [];
137+
}
138+
values[fieldName].push(this.value);
139+
}
140+
} else if (this.type === 'radio') {
141+
if (this.checked) {
142+
values[fieldName] = this.value;
143+
}
144+
} else {
145+
values[fieldName] = this.value;
146+
}
147+
}
148+
});
149+
jt.submitFormData(values);
150+
}
151+
152+
jt.submitFormData = function(values) {
153+
var stageName = jt.data.player.stage.id;
154+
values.fnName = stageName;
155+
values.playerRoomId = jt.data.player.roomId;
156+
console.log('submitting form with values ' + JSON.stringify(values));
157+
try {
158+
eval(jt.vue.app.onSubmit);
159+
} catch (err) {
160+
161+
}
162+
$('#jtree').addClass('hidden');
163+
jt.sendMessage(stageName, values);
164+
}
165+
156166
jt.vueMounted = false;
157167
jt.vueMethods = {};
158168

@@ -253,6 +263,21 @@ jt.getVueModels = function(player) {
253263
timeElapsed: 0,
254264
timeElapsedClient: 0,
255265
}
266+
267+
let app = vueModel.app;
268+
let funcPrefix = '__func_';
269+
for (let i in app) {
270+
let isFunc = false;
271+
let name = i;
272+
if (name.startsWith(funcPrefix)) {
273+
name = name.substring(funcPrefix.length);
274+
isFunc = true;
275+
}
276+
if (isFunc) {
277+
eval('app[name] = ' + app[i]);
278+
}
279+
}
280+
256281
if (vueModel.group.players == null) {
257282
vueModel.group.players = [];
258283
}
@@ -353,6 +378,9 @@ jt.updatePlayer = function(player, updateVue) {
353378
return;
354379
}
355380

381+
$('#jtree').removeClass('hidden');
382+
$('.alert-box').remove();
383+
356384
if (!jt.vueMounted) {
357385
jt.mountVue(player);
358386
$('body').addClass('show');
@@ -632,13 +660,11 @@ jt.endStage = function(player) {
632660
let forms = $('form').filter(':visible');
633661
if (forms != null && forms.length > 0) {
634662
forms.each(function() {
635-
$(this).submit();
663+
jt.submitForm(this);
636664
});
637665
} else {
638666
var values = {};
639-
var stageName = jt.data.player.stage.id;
640-
values.fnName = stageName;
641-
jt.sendMessage(stageName, values);
667+
jt.submitFormData(values);
642668
}
643669
}
644670
}

0 commit comments

Comments
 (0)