2019-07-19 22:35:33 +03:00
|
|
|
|
function toggleFullScreen() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (!document.fullscreenElement) {
|
|
|
|
|
document.documentElement.requestFullscreen()
|
2025-06-03 12:12:48 +02:00
|
|
|
|
} else if (document.exitFullscreen) {
|
|
|
|
|
document.exitFullscreen()
|
2019-07-19 22:35:33 +03:00
|
|
|
|
}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2019-07-19 22:35:33 +03:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
let cards = {}
|
|
|
|
|
let totalcolumns = 0
|
|
|
|
|
let columns = []
|
|
|
|
|
let currentTheme = 'bigcards'
|
|
|
|
|
let boardInitialized = false
|
|
|
|
|
let keyTrap = null
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const baseurl = location.pathname.substring(0, location.pathname.lastIndexOf('/'))
|
|
|
|
|
const socket = io.connect({ path: `${baseurl}/socket.io` })
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
moment.locale(navigator.language || navigator.languages[0])
|
2016-09-15 22:02:55 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
marked.setOptions({ sanitize: true })
|
2017-07-05 19:42:34 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// an action has happened, send it to the
|
|
|
|
|
// server
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function sendAction(a, d) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// console.log('--> ' + a);
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const message = {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
action: a,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
data: d
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
socket.json.send(message)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
socket.on('connect', () => {
|
|
|
|
|
// console.log('successful socket.io connect');
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// let the final part of the path be the room name
|
|
|
|
|
const room = location.pathname.substring(location.pathname.lastIndexOf('/'))
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// imediately join the room which will trigger the initializations
|
|
|
|
|
sendAction('joinRoom', room)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
socket.on('disconnect', () => {
|
|
|
|
|
blockUI('Serveur déconnecté. Veuillez rafraîchir la page pour essayer de vous reconnecter…')
|
|
|
|
|
// $('.blockOverlay').on('click', $.unblockUI);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
socket.on('message', (data) => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
getMessage(data)
|
|
|
|
|
})
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function unblockUI() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
$.unblockUI({ fadeOut: 50 })
|
2011-05-29 15:36:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function blockUI(message) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
message = message || 'En attente…'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
$.blockUI({
|
2025-06-03 12:12:48 +02:00
|
|
|
|
message,
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
css: {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
border: 'none',
|
|
|
|
|
padding: '15px',
|
|
|
|
|
backgroundColor: '#000',
|
|
|
|
|
'-webkit-border-radius': '10px',
|
|
|
|
|
'-moz-border-radius': '10px',
|
2021-11-29 19:14:50 +01:00
|
|
|
|
opacity: 0.5,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
color: '#fff',
|
|
|
|
|
fontSize: '20px'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fadeOut: 0,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
fadeIn: 10
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2011-05-29 15:36:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// respond to an action event
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function getMessage(m) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const message = m // JSON.parse(m);
|
|
|
|
|
const { action } = message
|
|
|
|
|
const { data } = message
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// console.log('<-- ' + action);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
switch (action) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'roomAccept':
|
|
|
|
|
// okay we're accepted, then request initialization
|
|
|
|
|
// (this is a bit of unnessary back and forth but that's okay for now)
|
|
|
|
|
sendAction('initializeMe', null)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'roomDeny':
|
|
|
|
|
// this doesn't happen yet
|
2021-11-29 19:14:50 +01:00
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'moveCard':
|
|
|
|
|
moveCard($(`#${data.id}`), data.position)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'initCards':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
initCards(data)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'createCard':
|
|
|
|
|
// console.log(data);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
drawNewCard(data.id, data.text, data.x, data.y, data.rot, data.colour, null)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'deleteCard':
|
|
|
|
|
$(`#${data.id}`).fadeOut(500, function() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
$(this).remove()
|
|
|
|
|
})
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'editCard':
|
|
|
|
|
$(`#${data.id}`)
|
|
|
|
|
.children('.content:first')
|
|
|
|
|
.attr('data-text', data.value)
|
|
|
|
|
$(`#${data.id}`)
|
|
|
|
|
.children('.content:first')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
.html(marked(data.value))
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'initColumns':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
initColumns(data)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'updateColumns':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
initColumns(data)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'changeTheme':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
changeThemeTo(data)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'join-announce':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
displayUserJoined(data.sid, data.user_name)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'leave-announce':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
displayUserLeft(data.sid)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'initialUsers':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
displayInitialUsers(data)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'nameChangeAnnounce':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
updateName(message.data.sid, message.data.user_name)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'addSticker':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
addSticker(message.data.cardId, message.data.stickerId)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'setBoardSize':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
resizeBoard(message.data)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'export':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
download(message.data.filename, message.data.text)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'addRevision':
|
2021-11-29 19:14:50 +01:00
|
|
|
|
addRevision(message.data)
|
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'deleteRevision':
|
|
|
|
|
$(`#revision-${message.data}`).remove()
|
2021-11-29 19:14:50 +01:00
|
|
|
|
break
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
case 'initRevisions':
|
|
|
|
|
$('#revisions-list').empty()
|
|
|
|
|
for (let i = 0; i < message.data.length; i++) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
addRevision(message.data[i])
|
|
|
|
|
}
|
|
|
|
|
break
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
default:
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// unknown message
|
|
|
|
|
alert(`action inconnue : ${JSON.stringify(message)}`)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
break
|
|
|
|
|
}
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(document).on('keyup', (event) => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
keyTrap = event.which
|
|
|
|
|
})
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed, mx = 0, my = 0) {
|
|
|
|
|
// cards[id] = {id: id, text: text, x: x, y: y, rot: rot, colour: colour};
|
|
|
|
|
|
|
|
|
|
const h = `<div id="${
|
|
|
|
|
id
|
|
|
|
|
}" class="card ${
|
|
|
|
|
colour
|
|
|
|
|
} draggable" style="-webkit-transform:rotate(${
|
|
|
|
|
rot
|
|
|
|
|
}deg);\
|
2014-09-01 12:29:32 -04:00
|
|
|
|
">\
|
2023-03-05 10:19:34 +03:00
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" class="card-icon delete-card-icon bi bi-x-lg"><path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"></path></svg>\
|
2025-06-03 12:12:48 +02:00
|
|
|
|
<div id="content:${
|
|
|
|
|
id
|
|
|
|
|
}" class="content stickertarget droppable" data-text="">${
|
|
|
|
|
marked(text)
|
|
|
|
|
}</div><span class="filler"></span>\
|
|
|
|
|
</div>`
|
|
|
|
|
|
|
|
|
|
const card = $(h)
|
|
|
|
|
card.appendTo('#board')
|
|
|
|
|
$(`#${id}`)
|
|
|
|
|
.children('.content:first')
|
|
|
|
|
.attr('data-text', text)
|
|
|
|
|
|
|
|
|
|
// @TODO
|
|
|
|
|
// Draggable has a bug which prevents blur event
|
|
|
|
|
// http://bugs.jqueryui.com/ticket/4261
|
|
|
|
|
// So we have to blur all the cards and editable areas when
|
|
|
|
|
// we click on a card
|
|
|
|
|
// The following doesn't work so we will do the bug
|
|
|
|
|
// fix recommended in the above bug report
|
2022-04-14 09:21:17 +03:00
|
|
|
|
// card.on('click', function() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
// $(this).focus();
|
|
|
|
|
// } );
|
|
|
|
|
|
|
|
|
|
card.draggable({
|
|
|
|
|
snap: false,
|
|
|
|
|
snapTolerance: 5,
|
|
|
|
|
containment: [0, 0, 2000, 2000],
|
2025-06-03 12:12:48 +02:00
|
|
|
|
stack: '.card',
|
|
|
|
|
start(event, ui) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
keyTrap = null
|
|
|
|
|
},
|
2025-06-03 12:12:48 +02:00
|
|
|
|
drag(event, ui) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (keyTrap == 27) {
|
|
|
|
|
ui.helper.css(ui.originalPosition)
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-06-03 12:12:48 +02:00
|
|
|
|
handle: 'div.content'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// After a drag:
|
|
|
|
|
card.on('dragstop', function(event, ui) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (keyTrap == 27) {
|
|
|
|
|
keyTrap = null
|
|
|
|
|
return
|
|
|
|
|
}
|
2014-09-13 02:04:27 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
id: this.id,
|
|
|
|
|
position: ui.position,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
oldposition: ui.originalPosition
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2014-09-13 02:04:27 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
sendAction('moveCard', data)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2014-09-13 02:04:27 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
card.children('.droppable').droppable({
|
|
|
|
|
accept: '.sticker',
|
|
|
|
|
drop(event, ui) {
|
|
|
|
|
const stickerId = ui.draggable.attr('id')
|
|
|
|
|
const cardId = $(this).parent().attr('id')
|
2014-09-13 02:04:27 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
addSticker(cardId, stickerId)
|
2014-09-13 02:04:27 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = {
|
|
|
|
|
cardId,
|
|
|
|
|
stickerId
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
sendAction('addSticker', data)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// remove hover state to everything on the board to prevent
|
|
|
|
|
// a jquery bug where it gets left around
|
|
|
|
|
$('.card-hover-draggable').removeClass('card-hover-draggable')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
},
|
2025-06-03 12:12:48 +02:00
|
|
|
|
hoverClass: 'card-hover-draggable'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
let speed = Math.floor(Math.random() * 1000)
|
|
|
|
|
if (typeof animationspeed != 'undefined') speed = animationspeed
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2023-03-05 10:19:34 +03:00
|
|
|
|
if (mx == 0 && my == 0) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const startPosition = $('#create-card').position()
|
|
|
|
|
mx = startPosition.left
|
|
|
|
|
my = startPosition.top
|
2023-03-05 10:19:34 +03:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
card.css('top', my)
|
|
|
|
|
card.css('left', mx)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
card.animate(
|
|
|
|
|
{
|
2025-06-03 12:12:48 +02:00
|
|
|
|
left: `${x}px`,
|
|
|
|
|
top: `${y}px`
|
2021-11-29 19:14:50 +01:00
|
|
|
|
},
|
|
|
|
|
speed
|
|
|
|
|
)
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
card.children('.delete-card-icon').on('click', () => {
|
|
|
|
|
$(`#${id}`).remove()
|
|
|
|
|
// notify server of delete
|
|
|
|
|
sendAction('deleteCard', { id })
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
card.children('.content').editable(
|
|
|
|
|
(value, settings) => {
|
|
|
|
|
$(`#${id}`)
|
|
|
|
|
.children('.content:first')
|
|
|
|
|
.attr('data-text', value)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
onCardChange(id, value)
|
|
|
|
|
return marked(value)
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-06-03 12:12:48 +02:00
|
|
|
|
type: 'textarea',
|
|
|
|
|
data() {
|
|
|
|
|
return $(`#${id}`)
|
|
|
|
|
.children('.content:first')
|
|
|
|
|
.attr('data-text')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
},
|
2025-06-03 12:12:48 +02:00
|
|
|
|
submit: 'OK',
|
|
|
|
|
style: 'inherit',
|
|
|
|
|
cssclass: 'card-edit-form',
|
|
|
|
|
placeholder: 'Double cliquez pour m’éditer',
|
|
|
|
|
onblur: 'submit',
|
|
|
|
|
event: 'dblclick' // event: 'mouseover'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
)
|
2014-09-13 02:04:27 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// add applicable sticker
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (sticker !== null) addSticker(id, sticker)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function onCardChange(id, text) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
sendAction('editCard', {
|
|
|
|
|
id,
|
|
|
|
|
value: text
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-14 07:42:04 +08:00
|
|
|
|
function moveCard(card, position) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
card.animate(
|
|
|
|
|
{
|
2025-06-03 12:12:48 +02:00
|
|
|
|
left: `${position.left}px`,
|
|
|
|
|
top: `${position.top}px`
|
2021-11-29 19:14:50 +01:00
|
|
|
|
},
|
|
|
|
|
500
|
|
|
|
|
)
|
2011-06-14 07:42:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function addSticker(cardId, stickerId) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
stickerContainer = $(`#${cardId} .filler`)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
if (stickerId === 'nosticker') {
|
|
|
|
|
stickerContainer.html('')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
return
|
|
|
|
|
}
|
2014-09-02 01:52:54 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (Array.isArray(stickerId)) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
for (const i in stickerId) {
|
|
|
|
|
stickerContainer.prepend(`<img src="images/stickers/${stickerId[i]}.png">`)
|
2014-09-13 02:04:27 -04:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
} else if (stickerContainer.html().indexOf(stickerId) < 0) { stickerContainer.prepend(`<img src="images/stickers/${stickerId}.png">`) }
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------
|
|
|
|
|
// cards
|
|
|
|
|
//----------------------------------
|
2025-06-03 12:12:48 +02:00
|
|
|
|
function createCard(id, text, x, y, rot, colour, mx = 0, my = 0) {
|
2023-03-05 10:19:34 +03:00
|
|
|
|
drawNewCard(id, text, x, y, rot, colour, null, null, mx, my)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const action = 'createCard'
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = {
|
|
|
|
|
id,
|
|
|
|
|
text,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
rot,
|
|
|
|
|
colour
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
sendAction(action, data)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function randomCardColour() {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const colours = ['yellow', 'green', 'blue', 'white']
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const i = Math.floor(Math.random() * colours.length)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
return colours[i]
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function initCards(cardArray) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// first delete any cards that exist
|
|
|
|
|
$('.card').remove()
|
2011-05-29 15:36:30 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
cards = cardArray
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
for (const i in cardArray) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
card = cardArray[i]
|
|
|
|
|
|
|
|
|
|
drawNewCard(card.id, card.text, card.x, card.y, card.rot, card.colour, card.sticker, 0)
|
|
|
|
|
}
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
boardInitialized = true
|
|
|
|
|
unblockUI()
|
|
|
|
|
}
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
|
|
|
|
//----------------------------------
|
|
|
|
|
// cols
|
|
|
|
|
//----------------------------------
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function drawNewColumn(columnName) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
let cls = 'col'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (totalcolumns === 0) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
cls = 'col first'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#icon-col').before(
|
|
|
|
|
`<td class="${
|
|
|
|
|
cls
|
|
|
|
|
}" width="10%" style="display:none"><h2 id="col-${
|
|
|
|
|
totalcolumns + 1
|
|
|
|
|
}" class="editable">${
|
|
|
|
|
columnName
|
|
|
|
|
}</h2></td>`
|
2021-11-29 19:14:50 +01:00
|
|
|
|
)
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.editable').editable(
|
|
|
|
|
function(value, settings) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
onColumnChange(this.id, value)
|
|
|
|
|
return value
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-06-03 12:12:48 +02:00
|
|
|
|
style: 'inherit',
|
|
|
|
|
cssclass: 'card-edit-form',
|
|
|
|
|
type: 'textarea',
|
|
|
|
|
placeholder: 'Nouveau',
|
|
|
|
|
onblur: 'submit',
|
|
|
|
|
width: '',
|
|
|
|
|
height: '',
|
2021-11-29 19:14:50 +01:00
|
|
|
|
xindicator: '<img src="images/ajax-loader.gif">',
|
2025-06-03 12:12:48 +02:00
|
|
|
|
event: 'dblclick' // event: 'mouseover'
|
2014-09-13 02:04:27 -04:00
|
|
|
|
}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
)
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.col:last').fadeIn(500)
|
2014-09-13 02:04:27 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
totalcolumns++
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function onColumnChange(id, text) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const names = []
|
2014-08-18 14:05:14 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// console.log(id + " " + text );
|
2014-08-18 14:05:14 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// Get the names of all the columns right from the DOM
|
|
|
|
|
$('.col').each(function() {
|
|
|
|
|
// get ID of current column we are traversing over
|
|
|
|
|
const thisID = $(this).children('h2').attr('id')
|
2014-08-18 14:05:14 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (id == thisID) {
|
|
|
|
|
names.push(text)
|
|
|
|
|
} else {
|
|
|
|
|
names.push($(this).text())
|
|
|
|
|
}
|
|
|
|
|
})
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
updateColumns(names)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function displayRemoveColumn() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (totalcolumns <= 0) return false
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.col:last').fadeOut(150, function() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
$(this).remove()
|
|
|
|
|
})
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
totalcolumns--
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function createColumn(name) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (totalcolumns >= 8) return false
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
drawNewColumn(name)
|
|
|
|
|
columns.push(name)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const action = 'updateColumns'
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = columns
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
sendAction(action, data)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function deleteColumn() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (totalcolumns <= 0) return false
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
displayRemoveColumn()
|
|
|
|
|
columns.pop()
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const action = 'updateColumns'
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = columns
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
sendAction(action, data)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function updateColumns(c) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
columns = c
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const action = 'updateColumns'
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = columns
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
sendAction(action, data)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function deleteColumns(next) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// delete all existing columns:
|
|
|
|
|
$('.col').fadeOut('slow', next())
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function initColumns(columnArray) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
totalcolumns = 0
|
|
|
|
|
columns = columnArray
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.col').remove()
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
for (const i in columnArray) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
column = columnArray[i]
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
drawNewColumn(column)
|
|
|
|
|
}
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function changeThemeTo(theme) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
currentTheme = theme
|
2023-03-05 10:19:34 +03:00
|
|
|
|
if (theme == 'bigcards') {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#board').removeClass('smallcards')
|
2023-03-05 10:19:34 +03:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#board').removeClass('bigcards')
|
2023-03-05 10:19:34 +03:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#board').addClass(theme)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/// ///////////////////////////////////////////////////////
|
|
|
|
|
/// /////// NAMES STUFF ///////////////////////////////////
|
|
|
|
|
/// ///////////////////////////////////////////////////////
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function setCookie(c_name, value, exdays) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const exdate = new Date()
|
2021-11-29 19:14:50 +01:00
|
|
|
|
exdate.setDate(exdate.getDate() + exdays)
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const c_value = `${escape(value) + (exdays === null ? '' : `; expires=${exdate.toUTCString()}`)};SameSite=Strict`
|
|
|
|
|
document.cookie = `${c_name}=${c_value}`
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function getCookie(c_name) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
let i
|
|
|
|
|
let x
|
|
|
|
|
let y
|
|
|
|
|
const ARRcookies = document.cookie.split(';')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
for (i = 0; i < ARRcookies.length; i++) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf('='))
|
|
|
|
|
y = ARRcookies[i].substr(ARRcookies[i].indexOf('=') + 1)
|
|
|
|
|
x = x.replace(/^\s+|\s+$/g, '')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (x == c_name) {
|
|
|
|
|
return unescape(y)
|
2014-09-13 02:04:27 -04:00
|
|
|
|
}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function setName(name) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
sendAction('setUserName', name)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
setCookie('scrumscrum-username', name, 365)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function displayInitialUsers(users) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
for (const i in users) {
|
|
|
|
|
// console.log(users);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
displayUserJoined(users[i].sid, users[i].user_name)
|
|
|
|
|
}
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function displayUserJoined(sid, user_name) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
name = ''
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (user_name) name = user_name
|
|
|
|
|
else name = sid.substring(0, 5)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#names-ul').append(`<li id="user-${sid}">${name}</li>`)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function displayUserLeft(sid) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
name = ''
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (name) name = user_name
|
|
|
|
|
else name = sid
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const id = `#user-${sid.toString()}`
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#names-ul')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
.children(id)
|
2025-06-03 12:12:48 +02:00
|
|
|
|
.fadeOut(1000, function() {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
$(this).remove()
|
|
|
|
|
})
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function updateName(sid, name) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const id = `#user-${sid.toString()}`
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#names-ul').children(id).text(name)
|
2011-03-10 08:20:27 -05:00
|
|
|
|
}
|
2011-05-27 01:08:25 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/// ///////////////////////////////////////////////////////
|
|
|
|
|
/// ///////////////////////////////////////////////////////
|
2011-05-27 01:08:25 -04:00
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function boardResizeHappened(event, ui) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const newsize = ui.size
|
2011-06-14 07:42:04 +08:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
sendAction('setBoardSize', newsize)
|
2011-05-27 01:08:25 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-13 02:04:27 -04:00
|
|
|
|
function resizeBoard(size) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.board-outline').animate({
|
2021-11-29 19:14:50 +01:00
|
|
|
|
height: size.height,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
width: size.width
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2011-05-27 01:08:25 -04:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/// ///////////////////////////////////////////////////////
|
|
|
|
|
/// ///////////////////////////////////////////////////////
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2011-06-14 07:42:04 +08:00
|
|
|
|
function calcCardOffset() {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const offsets = {}
|
|
|
|
|
$('.card').each(function() {
|
|
|
|
|
const card = $(this)
|
|
|
|
|
$('.col').each(function(i) {
|
|
|
|
|
const col = $(this)
|
|
|
|
|
if (col.offset().left + col.outerWidth() > card.offset().left + card.outerWidth() || i === $('.col').length - 1) {
|
|
|
|
|
offsets[card.attr('id')] = {
|
|
|
|
|
col,
|
|
|
|
|
x: (card.offset().left - col.offset().left) / col.outerWidth()
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
return offsets
|
2011-06-14 07:42:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// moves cards with a resize of the Board
|
|
|
|
|
// doSync is false if you don't want to synchronize
|
|
|
|
|
// with all the other users who are in this room
|
2011-06-23 19:12:53 -04:00
|
|
|
|
function adjustCard(offsets, doSync) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.card').each(function() {
|
|
|
|
|
const card = $(this)
|
|
|
|
|
const offset = offsets[this.id]
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (offset) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
id: this.id,
|
|
|
|
|
position: {
|
|
|
|
|
left: offset.col.position().left + offset.x * offset.col.outerWidth(),
|
2025-06-03 12:12:48 +02:00
|
|
|
|
top: parseInt(card.css('top').slice(0, -2))
|
2021-11-29 19:14:50 +01:00
|
|
|
|
},
|
|
|
|
|
oldposition: {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
left: parseInt(card.css('left').slice(0, -2)),
|
|
|
|
|
top: parseInt(card.css('top').slice(0, -2))
|
|
|
|
|
}
|
|
|
|
|
} // use .css() instead of .position() because css' rotate
|
|
|
|
|
// console.log(data);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (!doSync) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
card.css('left', data.position.left)
|
|
|
|
|
card.css('top', data.position.top)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// note that in this case, data.oldposition isn't accurate since
|
|
|
|
|
// many moves have happened since the last sync
|
|
|
|
|
// but that's okay becuase oldPosition isn't used right now
|
2021-11-29 19:14:50 +01:00
|
|
|
|
moveCard(card, data.position)
|
2025-06-03 12:12:48 +02:00
|
|
|
|
sendAction('moveCard', data)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
2011-06-14 07:42:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/// ///////////////////////////////////////////////////////
|
|
|
|
|
/// ///////////////////////////////////////////////////////
|
2011-06-14 07:42:04 +08:00
|
|
|
|
|
2016-09-13 09:06:15 +02:00
|
|
|
|
function download(filename, text) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const element = document.createElement('a')
|
|
|
|
|
let mime = 'text/plain'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (filename.match(/.csv$/)) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
mime = 'text/csv'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
element.setAttribute('href', `data:${mime};charset=utf-8,${encodeURIComponent(text)}`)
|
|
|
|
|
element.setAttribute('download', filename)
|
2016-09-13 09:06:15 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
element.style.display = 'none'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
document.body.appendChild(element)
|
|
|
|
|
element.click()
|
|
|
|
|
document.body.removeChild(element)
|
2016-09-13 09:06:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 22:02:55 +02:00
|
|
|
|
function addRevision(timestamp) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const li = $(`<li id="revision-${timestamp}"></li>`)
|
|
|
|
|
const s1 = $('<span></span>')
|
|
|
|
|
const s2 = $('<img src="/images/stickers/sticker-deletestar.png" alt="delete revision">')
|
|
|
|
|
if (typeof timestamp === 'string') {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
timestamp = parseInt(timestamp)
|
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
s1.text(moment(timestamp).format('LLLL'))
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
li.append(s1)
|
|
|
|
|
li.append(s2)
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#revisions-list').append(li)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2023-03-05 10:19:34 +03:00
|
|
|
|
// $('body').on("click", s1, function () {
|
|
|
|
|
// socket.json.send({
|
|
|
|
|
// action: "exportRevision",
|
|
|
|
|
// data: timestamp,
|
|
|
|
|
// })
|
|
|
|
|
// })
|
|
|
|
|
// $('body').on("click", s2, function () {
|
|
|
|
|
// socket.json.send({
|
|
|
|
|
// action: "deleteRevision",
|
|
|
|
|
// data: timestamp,
|
|
|
|
|
// })
|
|
|
|
|
// })
|
2016-09-15 22:02:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/// ///////////////////////////////////////////////////////
|
|
|
|
|
/// ///////////////////////////////////////////////////////
|
2016-09-13 09:06:15 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(() => {
|
|
|
|
|
// disable image dragging
|
|
|
|
|
// window.ondragstart = function() { return false; };
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
if (boardInitialized === false) blockUI('<img src="images/ajax-loader.gif" width=43 height=11/>')
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// setTimeout($.unblockUI, 2000);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.add-post-it').on('click', function(e) {
|
|
|
|
|
const rotation = Math.random() * 10 - 5 // add a bit of random rotation (+/- 10deg)
|
|
|
|
|
const cardLeft = 150 + Math.random() * 400
|
|
|
|
|
const cardTop = 20 + Math.random() * 50
|
|
|
|
|
const uniqueID = Math.round(Math.random() * 99999999) // is this big enough to assure uniqueness?
|
|
|
|
|
console.log(e.clientX, e.clientY)
|
|
|
|
|
createCard(`card${uniqueID}`, '', cardLeft, cardTop, rotation, $(this).data('color'), e.clientX, e.clientY)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Style changer
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#smallify').on('click', () => {
|
|
|
|
|
if (currentTheme == 'bigcards') {
|
|
|
|
|
changeThemeTo('smallcards')
|
|
|
|
|
} else if (currentTheme == 'smallcards') {
|
|
|
|
|
changeThemeTo('bigcards')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
sendAction('changeTheme', currentTheme)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
return false
|
|
|
|
|
})
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#icon-col').on(
|
|
|
|
|
'hover',
|
|
|
|
|
() => {
|
|
|
|
|
$('.col-icon').fadeIn(10)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
},
|
2025-06-03 12:12:48 +02:00
|
|
|
|
() => {
|
|
|
|
|
$('.col-icon').fadeOut(150)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
)
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#add-col').on('click', () => {
|
|
|
|
|
createColumn('Nouvelle colonne')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
return false
|
|
|
|
|
})
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#delete-col').on('click', () => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
deleteColumn()
|
|
|
|
|
return false
|
|
|
|
|
})
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const user_name = getCookie('scrumscrum-username')
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#yourname-input').on('focus', function() {
|
|
|
|
|
if ($(this).val() == 'anonyme') {
|
|
|
|
|
$(this).val('')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(this).addClass('focused')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#yourname-input').on('blur', function() {
|
|
|
|
|
if ($(this).val() === '') {
|
|
|
|
|
$(this).val('anonyme')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(this).removeClass('focused')
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
setName($(this).val())
|
|
|
|
|
})
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#yourname-input').val(user_name)
|
|
|
|
|
$('#yourname-input').trigger('blur')
|
2014-09-01 12:29:32 -04:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#yourname-li').hide()
|
2011-03-10 08:20:27 -05:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#yourname-input').on('keypress', function(e) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
code = e.keyCode ? e.keyCode : e.which
|
|
|
|
|
if (code == 10 || code == 13) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(this).trigger('blur')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.sticker').draggable({
|
2021-11-29 19:14:50 +01:00
|
|
|
|
revert: true,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
zIndex: 1000
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.board-outline').resizable({
|
2021-11-29 19:14:50 +01:00
|
|
|
|
ghost: false,
|
2023-03-05 10:19:34 +03:00
|
|
|
|
minWidth: 640,
|
|
|
|
|
minHeight: 480,
|
|
|
|
|
maxWidth: 1140,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
maxHeight: 855
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// A new scope for precalculating
|
|
|
|
|
;(function() {
|
|
|
|
|
let offsets
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.board-outline').on('resizestart', () => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
offsets = calcCardOffset()
|
2016-09-13 09:06:15 +02:00
|
|
|
|
})
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.board-outline').on('resize', (event, ui) => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
adjustCard(offsets, false)
|
2016-09-13 09:06:15 +02:00
|
|
|
|
})
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.board-outline').on('resizestop', (event, ui) => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
boardResizeHappened(event, ui)
|
|
|
|
|
adjustCard(offsets, true)
|
2016-09-13 09:06:15 +02:00
|
|
|
|
})
|
2025-06-03 12:12:48 +02:00
|
|
|
|
}())
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#marker').draggable({
|
|
|
|
|
axis: 'x',
|
|
|
|
|
containment: 'parent'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#eraser').draggable({
|
|
|
|
|
axis: 'x',
|
|
|
|
|
containment: 'parent'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#export-txt').on('click', () => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
socket.json.send({
|
2025-06-03 12:12:48 +02:00
|
|
|
|
action: 'exportTxt',
|
|
|
|
|
data: $('.col').length !== 0 ? $('.col').css('width').replace('px', '') : null
|
2016-09-13 09:06:15 +02:00
|
|
|
|
})
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2016-09-15 22:02:55 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#export-csv').on('click', () => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
socket.json.send({
|
2025-06-03 12:12:48 +02:00
|
|
|
|
action: 'exportCsv',
|
|
|
|
|
data: $('.col').length !== 0 ? $('.col').css('width').replace('px', '') : null
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#export-json').on('click', () => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
socket.json.send({
|
2025-06-03 12:12:48 +02:00
|
|
|
|
action: 'exportJson',
|
2021-11-29 19:14:50 +01:00
|
|
|
|
data: {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
width: $('.board-outline').css('width').replace('px', ''),
|
|
|
|
|
height: $('.board-outline').css('height').replace('px', '')
|
|
|
|
|
}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#import-file').on('click', (evt) => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
evt.stopPropagation()
|
|
|
|
|
evt.preventDefault()
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const f = $('#import-input').get(0).files[0]
|
|
|
|
|
const fr = new FileReader()
|
|
|
|
|
fr.onloadend = function() {
|
|
|
|
|
const text = fr.result
|
2021-11-29 19:14:50 +01:00
|
|
|
|
socket.json.send({
|
2025-06-03 12:12:48 +02:00
|
|
|
|
action: 'importJson',
|
|
|
|
|
data: JSON.parse(text)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
fr.readAsText(f)
|
|
|
|
|
})
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#create-revision').on('click', () => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
socket.json.send({
|
2025-06-03 12:12:48 +02:00
|
|
|
|
action: 'createRevision',
|
2021-11-29 19:14:50 +01:00
|
|
|
|
data: {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
width: $('.board-outline').css('width').replace('px', ''),
|
|
|
|
|
height: $('.board-outline').css('height').replace('px', '')
|
|
|
|
|
}
|
2016-09-15 22:02:55 +02:00
|
|
|
|
})
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
})
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/** Doubleclick on mobile + Layout Framemo with tabs * */
|
|
|
|
|
$(document).ready(() => {
|
|
|
|
|
if (window.location.href != `${window.location.protocol}//${window.location.host}/`) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
// Not on homepage
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/** Double click on mobile interface * */
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
let clickTimer = null
|
|
|
|
|
let clickTarget = null
|
|
|
|
|
let editTarget = null
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
function doubletapCards(selector) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(`${selector} .stickertarget`).addClass('doubletap') // Escape multi bound
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(`${selector} .doubletap`).on('click', () => {
|
|
|
|
|
clickTarget = selector.replace('#', '')
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (clickTimer == null) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
clickTimer = setTimeout(() => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
clickTimer = null
|
|
|
|
|
}, 1000)
|
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// console.log('doubleclick : '+clickTimer+':'+editTarget);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
clearTimeout(clickTimer)
|
|
|
|
|
clickTimer = null
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (editTarget == clickTarget && clickTarget !== undefined && clickTarget !== null) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(`#${clickTarget.replace('content:', '')} .doubletap`).trigger('dblclick')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2017-07-12 08:57:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
editTarget = clickTarget
|
|
|
|
|
})
|
|
|
|
|
}
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
function doubletapTitle(selector) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(selector).addClass('doubletap') // Escape multi bound
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(`${selector}.doubletap`).on('click', () => {
|
|
|
|
|
clickTarget = selector.replace('#', '')
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (clickTimer == null) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
clickTimer = setTimeout(() => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
clickTimer = null
|
|
|
|
|
}, 1000)
|
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
// console.log('doubleclick : '+clickTimer+':'+editTarget);
|
2021-11-29 19:14:50 +01:00
|
|
|
|
clearTimeout(clickTimer)
|
|
|
|
|
clickTimer = null
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (editTarget == clickTarget && clickTarget !== undefined && clickTarget !== null) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(`#${clickTarget}.doubletap`).trigger('dblclick')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
editTarget = clickTarget
|
|
|
|
|
})
|
|
|
|
|
}
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
setInterval(() => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
// Add periodically the doubletap event on new cards
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.stickertarget:not(.doubletap)').each(function() {
|
|
|
|
|
doubletapCards(`#${$(this).attr('id').replace('content:', '')}`)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#board-table .col h2:not(.doubletap)').each(function() {
|
|
|
|
|
doubletapTitle(`#${$(this).attr('id')}`)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
|
|
|
|
}, 500)
|
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/** Layout Framemo - Tabs * */
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
// Defaut board real size (not 'auto' or 'inherit') saved in database
|
|
|
|
|
// in order to be able to center it
|
2025-06-03 12:12:48 +02:00
|
|
|
|
var boardReady = setInterval(() => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (boardInitialized) {
|
|
|
|
|
// when board is ready
|
2025-06-03 12:12:48 +02:00
|
|
|
|
if ($('.board-outline').attr('style') === undefined) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
// check if size is imported from db
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.board-outline').css({
|
|
|
|
|
width: `${$('.board-outline.ui-resizable').width() + 16}px`,
|
|
|
|
|
height: '466px'
|
2021-11-29 19:14:50 +01:00
|
|
|
|
})
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const data = {}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
data.size = {
|
|
|
|
|
height: 466,
|
2025-06-03 12:12:48 +02:00
|
|
|
|
width: $('.board-outline.ui-resizable').width() + 16
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
boardResizeHappened('resizestop', data) // using scrumblr function that keep size in db after a resize
|
2017-07-12 08:57:22 +02:00
|
|
|
|
}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
clearInterval(boardReady)
|
|
|
|
|
}
|
|
|
|
|
}, 500)
|
|
|
|
|
|
2023-03-05 10:19:34 +03:00
|
|
|
|
// $("#scrumblr")
|
|
|
|
|
// .append($(".names, .stickers, .buttons"))
|
|
|
|
|
// .after(
|
|
|
|
|
// '<div role="tabpanel" class="tab-pane" id="export-import"></div>' +
|
|
|
|
|
// '<div role="tabpanel" class="tab-pane" id="share"></div>' +
|
|
|
|
|
// '<div role="tabpanel" class="tab-pane" id="revisions"></div>' +
|
|
|
|
|
// '<div role="tabpanel" class="tab-pane" id="about"></div>'
|
|
|
|
|
// )
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2023-03-05 10:19:34 +03:00
|
|
|
|
// $("#export-import").append($(".export, .import"))
|
|
|
|
|
// $("#share").append($(".share"))
|
|
|
|
|
// $("#revisions").append($(".revisions"))
|
|
|
|
|
// $("#about").append($("#tuto-faq, #le-logiciel, #jardin"))
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
|
|
|
|
// Style
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#smallify').on('click', function() {
|
|
|
|
|
if (currentTheme == 'bigcards') {
|
|
|
|
|
$(this).children('i').removeClass('fa-search-plus').addClass('fa-search-minus')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(this).children('i').removeClass('fa-search-minus').addClass('fa-search-plus')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#full-page').on('click', function() {
|
|
|
|
|
if ($(this).children('i').hasClass('fa-expand')) {
|
|
|
|
|
$(this).children('i').removeClass('fa-expand').addClass('fa-compress')
|
|
|
|
|
$('#header-bar').hide()
|
2021-11-29 19:14:50 +01:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(this).children('i').removeClass('fa-compress').addClass('fa-expand')
|
|
|
|
|
$('#header-bar').show()
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
toggleFullScreen()
|
|
|
|
|
})
|
2017-07-12 08:57:22 +02:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
/** Mode iframe * */
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (top.location != self.document.location) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#header-bar').hide()
|
2017-07-12 08:57:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
// put URL in share input
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const mainurl = location.toString().split('#')[0]
|
|
|
|
|
$('.replace-url').val(mainurl)
|
|
|
|
|
$('.share-iframe').text($('.share-iframe').text().replace('{{replace-url}}', mainurl))
|
2021-11-29 19:14:50 +01:00
|
|
|
|
// copy URL to clipboard
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#copyurl').on('click', (e) => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
e.preventDefault()
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const node = document.getElementById('taburl')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
node.disabled = null
|
|
|
|
|
node.select()
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const success = document.execCommand('copy')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (success) {
|
|
|
|
|
getSelection().removeAllRanges()
|
2025-06-03 12:12:48 +02:00
|
|
|
|
node.disabled = 'disabled'
|
|
|
|
|
alert('URL du tableau copiée dans votre presse-papier !')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
} else {
|
|
|
|
|
alert(
|
|
|
|
|
"Impossible de copier l'URL du tableau dans votre presse-papier. Veuillez copier son adresse manuellement (Ctrl+C)."
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2019-07-19 17:35:20 +03:00
|
|
|
|
|
2021-11-29 19:14:50 +01:00
|
|
|
|
function go() {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
let { value } = document.forms[0].elements.name
|
|
|
|
|
value = value.replace(/[\/\?&#]/g, '')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
window.location.href = value
|
|
|
|
|
return false
|
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(() => {
|
|
|
|
|
const headerBarUrl = $('#header-bar').data('url')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (headerBarUrl) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const getJSON = function(url, callback) {
|
|
|
|
|
const xhr = new XMLHttpRequest()
|
|
|
|
|
xhr.open('GET', url, true)
|
|
|
|
|
xhr.responseType = 'json'
|
|
|
|
|
xhr.onload = function() {
|
|
|
|
|
const { status } = xhr
|
2019-07-19 17:35:20 +03:00
|
|
|
|
if (status === 200) {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
callback(null, xhr.response)
|
2019-07-19 17:35:20 +03:00
|
|
|
|
} else {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
callback(status, xhr.response)
|
2019-07-19 17:35:20 +03:00
|
|
|
|
}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
xhr.send()
|
2019-07-19 22:35:33 +03:00
|
|
|
|
}
|
2021-11-29 19:14:50 +01:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
getJSON(headerBarUrl, (err, data) => {
|
2021-11-29 19:14:50 +01:00
|
|
|
|
if (err !== null) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
console.log(`Something went wrong: ${err}`)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
document.getElementById('header-bar').innerHTML = data.markup
|
|
|
|
|
const styleElement = document.createElement('style')
|
2021-11-29 19:14:50 +01:00
|
|
|
|
styleElement.innerHTML = data.style
|
2025-06-03 12:12:48 +02:00
|
|
|
|
document.getElementById('header-bar').appendChild(styleElement)
|
2021-11-29 19:14:50 +01:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-04-14 09:21:17 +03:00
|
|
|
|
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$(() => {
|
2023-03-05 10:19:34 +03:00
|
|
|
|
// check if hash used to show informations
|
|
|
|
|
if (window.location.hash == '#settings' || window.location.hash == '#share') {
|
|
|
|
|
toggleNav(window.location.hash)
|
|
|
|
|
}
|
2022-04-14 09:21:17 +03:00
|
|
|
|
// Toggle Nav on Click
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.toggle-nav').on('click', function() {
|
|
|
|
|
let target = $(this).attr('href')
|
|
|
|
|
|
2023-03-05 10:19:34 +03:00
|
|
|
|
if (target === '#' || ($('#site-wrapper').hasClass('show-nav') && target == window.location.hash)) {
|
2022-04-14 09:21:17 +03:00
|
|
|
|
target = false
|
2025-06-03 12:12:48 +02:00
|
|
|
|
history.replaceState('', '', '#')
|
2022-04-14 09:21:17 +03:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
history.replaceState('', '', target)
|
2022-04-14 09:21:17 +03:00
|
|
|
|
}
|
|
|
|
|
toggleNav(target)
|
|
|
|
|
return false
|
|
|
|
|
})
|
|
|
|
|
// When nav opened, a click on the canvas hides the menu
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('body').on('click', '.show-nav #site-canvas main, .show-nav .main-header', (e) => {
|
|
|
|
|
history.replaceState('', '', '#')
|
2022-04-14 09:21:17 +03:00
|
|
|
|
toggleNav(false)
|
|
|
|
|
return false
|
|
|
|
|
})
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.backgrounds .bg').on('click', function() {
|
|
|
|
|
if ($(this).hasClass('selected')) {
|
|
|
|
|
$('body').css('background-image', 'none')
|
|
|
|
|
$(this).removeClass('selected')
|
2022-04-14 09:21:17 +03:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.selected').removeClass('selected')
|
2022-04-14 09:21:17 +03:00
|
|
|
|
$('.bgurl').val('')
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('body').css('background-image', `url("/${$(this).attr('src')}")`)
|
|
|
|
|
$(this).addClass('selected')
|
2022-04-14 09:21:17 +03:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
$('.bgurl').on('change', function() {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
const url = $(this).val()
|
2022-04-14 09:21:17 +03:00
|
|
|
|
if (url) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('.selected').removeClass('selected')
|
|
|
|
|
$('body').css('background-image', `url("${url}")`)
|
2022-04-14 09:21:17 +03:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function toggleNav(target) {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
if ($('#site-wrapper').hasClass('show-nav') && target === false) {
|
|
|
|
|
$('#site-wrapper').removeClass('show-nav')
|
2022-04-14 09:21:17 +03:00
|
|
|
|
} else {
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#share, #settings').hide()
|
2022-04-14 09:21:17 +03:00
|
|
|
|
if (target !== false) {
|
|
|
|
|
$(target).show()
|
|
|
|
|
}
|
2025-06-03 12:12:48 +02:00
|
|
|
|
$('#site-wrapper').addClass('show-nav')
|
2022-04-14 09:21:17 +03:00
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|