Several bugfixes and finishing touches
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
*#
|
||||
<div id="header" class="horz flex">
|
||||
<div id="logo">
|
||||
<img src="/img/logov2.svg"/>
|
||||
<a href="/"><img src="/img/logov2.svg"/></a>
|
||||
</div>
|
||||
<div id="title">
|
||||
</div>
|
||||
|
@@ -71,6 +71,12 @@
|
||||
<load-on-startup>1</load-on-startup>
|
||||
<async-supported>true</async-supported>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>import</servlet-name>
|
||||
<servlet-class>org.jeudego.pairgoth.web.ImportServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
<async-supported>true</async-supported>
|
||||
</servlet>
|
||||
|
||||
<!-- servlet mappings -->
|
||||
<servlet-mapping>
|
||||
@@ -89,6 +95,10 @@
|
||||
<servlet-name>search</servlet-name>
|
||||
<url-pattern>/api/search/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>import</servlet-name>
|
||||
<url-pattern>/api/import/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- context params -->
|
||||
<context-param>
|
||||
|
@@ -1,15 +1,79 @@
|
||||
<div class="section">
|
||||
<div class="actions section">
|
||||
<a href="tour" class="ui blue icon floating button">
|
||||
<i class="fa fa-plus-square-o"></i>
|
||||
New tournament
|
||||
</a>
|
||||
</div>
|
||||
#foreach($tour in $api.get('tour').entrySet())
|
||||
<div class="section">
|
||||
$tour
|
||||
<a href="tour?id=${tour.key}" class="ui open basic secondary white icon floating button">
|
||||
<i class="fa fa-folder-open-o"></i>
|
||||
Open
|
||||
<a id="import-tournament" class="ui orange icon floating button">
|
||||
<i class="fa fa-upload"></i>
|
||||
Import tournament
|
||||
</a>
|
||||
</div>
|
||||
<div class="tournaments section">
|
||||
#foreach($tour in $api.get('tour').entrySet())
|
||||
<a href="tour?id=${tour.key}" class="ui open basic secondary white icon floating button">
|
||||
<i class="fa fa-folder-open-o"></i>
|
||||
$tour.value
|
||||
</a>
|
||||
#end
|
||||
</div>
|
||||
<div id="import-popup" class="popup">
|
||||
<div class="popup-body">
|
||||
<form id="import-form" class="ui form">
|
||||
<div class="popup-content">
|
||||
<div class="field">
|
||||
<label>OpenGotha file</label>
|
||||
<input type="file" name="file" accept=".xml"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="popup-footer">
|
||||
<button id="cancel-import" type="button" class="ui gray right labeled icon floating close button">
|
||||
<i class="times icon"></i>
|
||||
Cancel
|
||||
</button>
|
||||
<button id="import" type="button" class="ui green right labeled icon floating button">
|
||||
<i class="plus icon"></i>
|
||||
Import
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// #[[
|
||||
function doImport() {
|
||||
let form = $('#import-form')[0];
|
||||
let formData = new FormData(form);
|
||||
fetch('/api/import', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
}).then(resp => {
|
||||
if (resp.ok) return resp.json();
|
||||
else throw resp;
|
||||
}).then(json => {
|
||||
if (json.success) {
|
||||
console.log(`/tour?id=${json.id}`)
|
||||
document.location.href = `/tour?id=${json.id}`
|
||||
} else {
|
||||
showError(json.error || 'unknown error')
|
||||
}
|
||||
}).catch(err => {
|
||||
error(err);
|
||||
});
|
||||
}
|
||||
|
||||
onLoad(()=>{
|
||||
$('#import-tournament').on('click', e => {
|
||||
modal('import-popup');
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
$('#import').on('click', e => {
|
||||
let files = $('#import-form input')[0].files;
|
||||
if (files.length > 0) {
|
||||
doImport();
|
||||
} else showError('no file choosen');
|
||||
close_modal();
|
||||
});
|
||||
});
|
||||
// ]]#
|
||||
</script>
|
||||
|
@@ -163,6 +163,34 @@ function close_modal() {
|
||||
$(`.popup`).removeClass('shown');
|
||||
}
|
||||
|
||||
function screenshot() {
|
||||
const bodyContent = document.body.innerHTML;
|
||||
|
||||
// Create an SVG element
|
||||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
svg.setAttribute('width', window.innerWidth);
|
||||
svg.setAttribute('height', window.innerHeight);
|
||||
|
||||
// Create a foreignObject element
|
||||
const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
|
||||
foreignObject.setAttribute('width', '100%');
|
||||
foreignObject.setAttribute('height', '100%');
|
||||
|
||||
// Append the body content to foreignObject
|
||||
foreignObject.innerHTML = bodyContent;
|
||||
|
||||
// Append foreignObject to the SVG
|
||||
svg.appendChild(foreignObject);
|
||||
|
||||
// Create a data URL from the SVG
|
||||
const dataUrl = 'data:image/svg+xml,' + encodeURIComponent(new XMLSerializer().serializeToString(svg));
|
||||
|
||||
// Open the screenshot in a new window/tab (optional)
|
||||
const screenshotWindow = window.open();
|
||||
screenshotWindow.document.write('<img src="' + dataUrl + '" alt="Screenshot">');
|
||||
}
|
||||
|
||||
|
||||
onLoad(() => {
|
||||
$('button.close').on('click', e => {
|
||||
let modal = e.target.closest('.popup');
|
||||
@@ -223,5 +251,13 @@ onLoad(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// disable hash scrolling
|
||||
if (window.location.hash) {
|
||||
console.log("lkhjqlksjdhflkqsjhfd")
|
||||
setTimeout(function() {
|
||||
window.scrollTo(0, 0);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
@@ -44,7 +44,7 @@ function search(needle) {
|
||||
let html = resultTemplate.render(result);
|
||||
$('#search-result')[0].innerHTML = html;
|
||||
} else console.log(result);
|
||||
})
|
||||
});
|
||||
} else {
|
||||
$('#search-result').clear();
|
||||
searchTimer = undefined;
|
||||
|
@@ -51,7 +51,7 @@
|
||||
<th>Plc</th>
|
||||
<th>Name</th>
|
||||
<th>Rank</th>
|
||||
<th>Cntry</th>
|
||||
<th>Ctr</th>
|
||||
<th>Nbw</th>
|
||||
#foreach($r in [1..$round])
|
||||
<th>R$r</th>
|
||||
@@ -66,7 +66,7 @@
|
||||
<td>$part.num</td>
|
||||
<td>$part.place</td>
|
||||
<td>$part.name $part.firstname</td>
|
||||
<td>$part.rank</td>
|
||||
<td>#rank($part.rank)</td>
|
||||
<td>$part.country</td>
|
||||
<td>$part.NBW</td>
|
||||
#set($mx = $round - 1)
|
||||
|
@@ -149,31 +149,35 @@
|
||||
});
|
||||
|
||||
// prev/next round buttons
|
||||
if (activeRound === 1) {
|
||||
$('.prev-round').addClass('disabled');
|
||||
}
|
||||
if (activeRound === tour_rounds) {
|
||||
$('.next-round').addClass('disabled');
|
||||
}
|
||||
$('.prev-round').on('click', e => {
|
||||
let round = activeRound - 1;
|
||||
if (round > 0) {
|
||||
window.location.search = `id=${tour_id}&round=${round}`
|
||||
if (typeof(activeRound) !== 'undefined') {
|
||||
if (activeRound === 1) {
|
||||
$('.prev-round').addClass('disabled');
|
||||
}
|
||||
});
|
||||
$('.next-round').on('click', e => {
|
||||
let round = activeRound + 1;
|
||||
if (round <= tour_rounds) {
|
||||
window.location.search = `id=${tour_id}&round=${round}`
|
||||
if (activeRound === tour_rounds) {
|
||||
$('.next-round').addClass('disabled');
|
||||
}
|
||||
});
|
||||
$('.prev-round').on('click', e => {
|
||||
let round = activeRound - 1;
|
||||
if (round > 0) {
|
||||
window.location.search = `id=${tour_id}&round=${round}`
|
||||
}
|
||||
});
|
||||
$('.next-round').on('click', e => {
|
||||
let round = activeRound + 1;
|
||||
if (round <= tour_rounds) {
|
||||
window.location.search = `id=${tour_id}&round=${round}`
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// ]]#
|
||||
#include('/js/tour-information.inc.js')
|
||||
#include('/js/tour-registration.inc.js')
|
||||
#include('/js/tour-pairing.inc.js')
|
||||
#include('/js/tour-results.inc.js')
|
||||
#include('/js/tour-standings.inc.js')
|
||||
#if($tour)
|
||||
#include('/js/tour-registration.inc.js')
|
||||
#include('/js/tour-pairing.inc.js')
|
||||
#include('/js/tour-results.inc.js')
|
||||
#include('/js/tour-standings.inc.js')
|
||||
#end
|
||||
</script>
|
||||
<div id="invalid_character" class="hidden">Invalid character</div>
|
||||
<script type="text/javascript" src="/lib/datepicker-1.3.4/datepicker-full.min.js"></script>
|
||||
|
Reference in New Issue
Block a user