';
$(document).ready(function () {
$('#assets_button, .bookmarks_button, .toc_button').localScroll({
target: '#side_pane',
axis: 'x'
});
// import/export menu closes when click outside
$("*", document.body).click(function (e) {
if ((e.target.id != "bookmarks_actions") && !$(e.target).hasClass("menu-button") &&
($("#bookmarks_actions").css("display") != "none")) {
$("#bookmarks_actions").css("display", "none");
$(".settings.bookmarks a.menu-button").toggleClass('active')
} else if ((e.target.id != "tocs_actions") && !$(e.target).hasClass("menu-button") &&
($("#tocs_actions").css("display") != "none")) {
$("#tocs_actions").css("display", "none");
$(".settings.toc a.menu-button").toggleClass('active')
}
});
// settings checkboxes
if (!$("input[name='display_threads']").is(':checked')) {
$('#settings_notif_threads').removeAttr('checked');
$('#settings_notif_threads').attr("disabled", "disabled");
}
$("input[name='display_threads']").change(function () {
if ($(this).is(':checked')) {
$('#settings_notif_threads').removeAttr('disabled');
} else {
$('#settings_notif_threads').removeAttr('checked');
$('#settings_notif_threads').attr("disabled", "disabled");
}
});
// history handler for back/next buttons of the browser
window.onpopstate = function (event) {
if (event.state !== null) {
var state = jQuery.parseJSON(JSON.stringify(event.state)),
form,
form_value = "",
page,
url_split;
if(state.url.indexOf("?") >= 0) {
url_split = state.url.split("?");
page = url_split[0];
var url_param = url_split[1].split("&"),
name_value;
for (var i = 0; i < url_param.length; i++) {
name_value = url_param[i].split("=");
form_value += '';
}
} else {
page = state.url;
form_value = '';
}
form = '
';
var form_send = $(form);
$('body').append(form_send);
form_send.submit();
}
};
});
// ============== N A V I G A T I O N ================ //
/**
* Navigates to assets list
* @param {type} album
* @param {type} asset
* @param {type} timecode
* @param {type} type
* @returns {undefined}
*/
function show_album_assets(album, token) {
// the side pane changes to display the list of all assets contained in the selected album
current_album = album;
current_token = token;
// Getting the content from the server, and filling the div_album_header with it
document.getElementById('div_center').innerHTML = '
' +
'
';
tinymce.remove();
makeRequest('index.php', '?action=view_album_assets&album=' + album + '&token=' + token + '&click=true', 'div_center');
// history.pushState({"key": "show-album-assets", "function": "show_album_assets(" + album + "," + token + ")",
// "url": "index.php?action=view_album_assets&album=" + album + "&token=" + token}, 'album-details',
// 'index.php?action=view_album_assets');
}
/**
* Navigates to the given asset
* @param {type} album
* @param {type} asset
* @param {type} asset_token
* @returns {undefined}
*/
function show_asset_details(album, asset, asset_token, sesskey) {
current_album = album;
current_asset = asset;
display_thread_details = false;
makeRequest('index.php', '?action=view_asset_details&album=' + album + '&asset=' + asset + '&asset_token=' +
asset_token + '&click=true' + '&sesskey=' + sesskey, 'div_center');
// history.pushState({"key": "show-asset-details", "function": "show_asset_details(" + album + "," +
// asset + "," + asset_token + ")", "url": "index.php?action=view_asset_details&album=" + album +
// "&asset=" + asset + "&asset_token=" + asset_token}, 'asset-details', 'index.php?action=view_asset_details');
}
/**
* Navigates to the given asset
* @param {type} album
* @param {type} asset
* @param {type} asset_token
* @returns {undefined}
*/
function show_asset_streaming(album, asset, asset_token, sesskey) {
current_album = album;
current_asset = asset;
display_thread_details = false;
makeRequest('index.php', '?action=view_asset_streaming&album=' + album + '&asset=' + asset + '&asset_token=' +
asset_token + '&click=true' + '&sesskey=' + sesskey, 'div_center');
// history.pushState({"key": "show-asset-details", "function": "show_asset_details(" + album + "," +
// asset + "," + asset_token + ")", "url": "index.php?action=view_asset_details&album=" + album +
// "&asset=" + asset + "&asset_token=" + asset_token}, 'asset-details', 'index.php?action=view_asset_details');
}
/**
* Navigates to the given thread (from trending threads)
* @param {type} threadId
* @returns {Boolean}
*/
function show_thread(album, asset, timecode, threadId, commentId, sesskey) {
if (album != null && asset != null) {
current_album = album;
current_asset = asset;
}
if (typeof fullscreen != 'undefined' && fullscreen)
{
video_fullscreen(false);
}
if (ezplayer_mode == 'view_asset_streaming')
player_kill();
server_trace(new Array('2', 'thread_detail_from_trending', current_album, current_asset, timecode, threadId));
$.ajax({
type: 'POST',
url: 'index.php?action=view_asset_bookmark',
data: 'album=' + album + '&asset=' + asset + "&t=" + timecode + "&thread_id=" + threadId + "&click=true" + '&sesskey=' + sesskey,
success: function (response) {
$('#div_center').html(response);
if (commentId != '') {
$.scrollTo('#comment_' + commentId);
} else {
$.scrollTo('#threads');
}
}
});
close_popup();
}
/**
* Displays the detail of a thread (from threads list)
* @returns {Boolean}
*/
function show_thread_details(event, thread_id, sesskey) {
if ($(event.target).is('a') || $(event.target).is('span.timecode'))
return;
server_trace(new Array('3', 'thread_detail_show', current_album, current_asset, thread_id));
$.ajax({
type: 'POST',
url: 'index.php?action=view_thread_details&click=true',
data: {'thread_id': thread_id, 'sesskey': sesskey},
success: function (response) {
$('#threads').html(response);
tinymce.remove('textarea');
}
});
}
/**
* Navigates to the given bookmark
* @param {type} threadId
* @returns {Boolean}
*/
function show_asset_bookmark(album, asset, timecode, type, sesskey) {
current_album = album;
current_asset = asset;
if (ezplayer_mode == 'view_asset_streaming')
player_kill();
makeRequest('index.php', '?action=view_asset_bookmark&album=' + album + '&asset=' + asset + '&t=' +
timecode + '&type=' + type + '&click=true' + '&sesskey=' + sesskey, 'div_center');
close_popup();
}
// ================ S E A R C H ================== //
/**
* Modifies the display of the search form
* @returns {Boolean}
*/
function search_form_setup() {
if ($('#album_radio').is(':checked')) {
$('.search_current').hide();
$('.search_albums').show();
} else if ($('#current_radio').is(':checked')) {
$('.search_albums').hide();
$('.search_current').show();
} else {
$('.search_albums').hide();
$('.search_current').hide();
}
}
/**
* Verifies the search form before submitting it
* @returns {Boolean}
*/
function search_form_check() {
var search_words = $('#main_search').val();
if (typeof search_words != 'undefined') {
if (search_words.trim() == '') {
return false;
}
search_form_submit();
}
}
/**
* Adjusts the search options according to the selected fields
* (bookmarks | threads)
* @returns {Boolean}
*/
function search_options_adjust() {
if ($('#cb_toc').is(':checked') || $('#cb_bookmark').is(':checked')) {
$('#search_bookmarks').removeClass('hidden');
} else {
$('#search_bookmarks').addClass('hidden');
}
if ($('#cb_threads').is(':checked')) {
$('#search_threads').removeClass('hidden');
} else {
$('#search_threads').addClass('hidden');
}
}
/**
* Submits the search form to the server
* @param {type} index
* @param {type} tab
* @returns {Boolean}
*/
function search_form_submit() {
$('#div_popup').html('
');
$.ajax({
type: 'POST',
url: 'index.php?action=threads_bookmarks_search&click=true&origin=bookmarks',
data: $('#search_form').serialize(),
success: function (response) {
$('#div_popup').html(response);
}
});
// doesn't work in IE < 10
// ajaxSubmitForm('search_form', 'index.php', '?action=search_bookmark', 'div_popup');
$('#div_popup').reveal($(this).data());
}
/**
* Submits the keyword to be searched to the server
* @returns {Boolean}
*/
function keyword_search(keyword, sesskey) {
$('#div_popup').html('
');
$.ajax({
type: 'POST',
url: 'index.php?action=threads_bookmarks_search&click=true&origin=keyword',
data: 'search=' + keyword + '&target=global&albums%5B%5D=&fields%5B%5D=keywords&tab%5B%5D=official&tab%5B%5D=custom&level=0' + '&sesskey=' + sesskey,
success: function (response) {
$('#div_popup').html(response);
}
});
// doesn't work in IE < 10
// ajaxSubmitForm('search_form', 'index.php', '?action=search_bookmark', 'div_popup');
$('#div_popup').reveal($(this).data());
}
// ============== A L B U M S ============== //
/**
* Deletes an album from the home page
* @param {type} album
* @returns {undefined}
*/
function album_token_delete(album, sesskey) {
makeRequest('index.php', '?action=album_token_delete' +
'&album=' + album +
'&click=true' + '&sesskey=' + sesskey, 'div_center');
close_popup();
}
/**
* Sets the album position (up/down)
*/
function album_token_move(album, index, upDown, sesskey) {
makeRequest('index.php', '?action=album_token_move' +
'&album=' + album + '&index=' + index + '&up_down=' + upDown + "&click=true" + '&sesskey=' + sesskey, 'div_center');
}
// ============== F O R M V A L I D A T I O N ============= //
// -------------- B O O K M A R K S ------------- //
/**
* checks the bookmark creation form before submitting it
* @returns {Boolean}
*/
function bookmark_form_check() {
var timecode = document.getElementById('bookmark_timecode');
var level = document.getElementById('bookmark_level');
var bookmark_source = document.getElementById('bookmark_source');
if (isNaN(timecode.value)
|| timecode.value == ''
|| timecode.value < 0) {
window.alert('Le code temps est incorrect');
return false;
}
var liste = (bookmark_source.value === 'official') ? official_bookmarks_time_code : personal_bookmarks_time_code;
if($.inArray(parseInt(timecode.value), liste) >= 0) {
window.alert("Un signet existe déjà à ce moment");
return false;
}
if(level.value !== parseInt(level.value, 10))
{
level.value = parseInt(level.value, 10);
}
if (isNaN(level.value)
|| level.value < 1
|| level.value > 3) {
window.alert('Niveau incorrect. Le niveau doit être compris entre 1 et 3');
return false;
}
return true;
}
/**
* checks the bookmark edition form before submitting it
* @returns {Boolean}
*/
function bookmark_edit_form_check(index, tab) {
var timecode = document.getElementById(tab + '_timecode_' + index);
var level = document.getElementById(tab + '_level_' + index);
if (timecode.value == ''
|| timecode.value < 0) {
window.alert('Le code temps est incorrect');
return false;
}
if(level.value !== parseInt(level.value, 10))
{
level.value = parseInt(level.value, 10);
}
if (isNaN(level.value)
|| level.value < 1
|| level.value > 3) {
window.alert('Niveau incorrect. Le niveau doit être compris entre 1 et 3');
return false;
}
return true;
}
/**
* Checks the xml file containing bookmarks
* @returns {Boolean}
*/
function bookmarks_upload_form_check() {
var file = document.getElementById('loadingfile').value;
if (file == '') {
window.alert('Veuillez sélectionner un fichier');
return false;
} else {
var ext = file.split('.').pop();
var extensions = ["xml"];
// check if extension is accepted
var found = false;
for (var i = 0; i < extensions.length; i++) {
if (found = (extensions[i] == ext.toLowerCase()))
break;
}
if (!found) {
window.alert('Type de fichier non reconnu');
return false;
}
}
return true;
}
// -------------- T H R E A D S ------------- //
/**
* Checks the thread creation form
* @returns {undefined}
*/
function thread_form_check() {
document.getElementById('thread_desc_tinymce').value = tinymce.get('thread_desc_tinymce').getContent();
var timecode = document.getElementById('thread_timecode');
var message = document.getElementById('thread_desc_tinymce').value;
var title = document.getElementById('thread_title').value;
if (isNaN(timecode.value)
|| timecode.value == ''
|| timecode.value < 0) {
window.alert('Le code temps est incorrect');
return false;
}
if (message === '') {
window.alert('Le message est obligatoire.');
return false;
}
if (title === '') {
window.alert('Le titre est obligatoire.');
return false;
}
return true;
}
/**
* Checks the thread edition form
* @param {type} id
* @returns {undefined} */
function thread_edit_form_check(threadId) {
$("#edit_thread_message_" + threadId + "_tinyeditor").html(tinymce.get("edit_thread_message_" +
threadId + "_tinyeditor").getContent());
var message = document.getElementById("edit_thread_message_" + threadId + "_tinyeditor").value;
var title = document.getElementById('edit_thread_title_' + threadId).value;
if (message === '') {
window.alert('Le message est obligatoire.');
return false;
}
if (title === '') {
window.alert('Le titre est obligatoire.');
return false;
}
return true;
}
/**
* Checks the comment creation form
* @param {type} id
* @returns {undefined} */
function thread_comment_form_check() {
$('#comment_message_tinyeditor').html(tinymce.get('comment_message_tinyeditor').getContent());
var message = document.getElementById('comment_message_tinyeditor').value;
if (message == '') {
window.alert('Le message est obligatoire.');
return false;
}
return true;
}
/**
* Checks the comment reply form
* @param {type} event
* @param {type} thread_id
* @returns {undefined} */
function comment_answer_form_check(id) {
$('#answer_comment_message_' + id + '_tinyeditor').html(tinymce.get('answer_comment_message_' + id + '_tinyeditor').getContent());
var message = document.getElementById('answer_comment_message_' + id + '_tinyeditor').value;
if (message == '') {
window.alert('Le message est obligatoire.');
return false;
}
return true;
}
// =============== A D M I N M O D E , C O N T A C T & P R E F E R E N C E S ============== //
/**
* Enables/Disables admin mode
* @type
*/
function admin_mode_update() {
// creates a form
var form = document.createElement("form");
form.setAttribute("method", 'post');
form.setAttribute("action", 'index.php');
// adds a hidden field containing the action
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", 'action');
hiddenField.setAttribute("value", 'admin_mode_update');
// adds a hidden field containing session key
var hiddenField2 = document.createElement("input");
hiddenField2.setAttribute("type", "hidden");
hiddenField2.setAttribute("name", 'sesskey');
hiddenField2.setAttribute("value", 'f80ec130de65697a3e3f36ec4ad4abf5');
form.appendChild(hiddenField);
form.appendChild(hiddenField2);
// submits the form
document.body.appendChild(form);
form.submit();
}
// shows the settings / contact form
function header_form_show(src) {
switch (src) {
case 'settings':
$('#settings_form').slideDown();
$('#user-settings').addClass('active');
settings_form = true;
break;
case 'contact':
$('#contact_form').slideDown();
$('#contact').addClass('active');
contact_form = true;
break;
}
}
// hides the settings /contact form
function header_form_hide(src) {
switch (src) {
case 'settings':
$('#settings_form').slideUp();
$('#user-settings').removeClass('active');
settings_form = false;
break;
case 'contact':
$('#contact_form').slideUp();
$('#contact').removeClass('active');
contact_form = false;
break;
}
}
// shows/hides the settings / contact form
function header_form_toggle(src) {
var show_hide;
if ((settings_form && src == "settings") || (contact_form && src == "contact")) {
show_hide = '_hide';
header_form_hide(src);
} else {
show_hide = '_show';
header_form_show(src);
}
server_trace(new Array('4', src + show_hide, current_album, current_asset));
}
// =============== P O P - U P ================ //
/**
* Renders a modal window with a message related to an album
* @param {type} display the action to be shown in the modal window (delete | rss | ...)
* @returns {undefined}
*/
function popup_album(album, display, sesskey) {
$('#div_popup').html('
');
$.ajax({
type: 'POST',
url: 'index.php?action=album_popup&click=true',
data: 'album=' + album + '&display=' + display + '&sesskey=' + sesskey,
success: function (response) {
$('#div_popup').html(response);
}
});
$('#div_popup').reveal($(this).data());
}
/**
* Renders a modal window with a message related to an asset
* @param {type} display the action to be shown in the modal window (share_link | share_time | ...)
* @returns {undefined} */
function popup_asset(album, asset, currentTime, type, display, sesskey) {
$('#div_popup').html('
');
$.ajax({
type: 'POST',
url: 'index.php?action=asset_popup&click=true',
data: 'album=' + album + '&asset=' + asset + '&time=' + currentTime + '&type=' + type + '&display=' + display + '&sesskey=' + sesskey,
success: function (response) {
$('#div_popup').html(response);
}
});
$('#div_popup').reveal($(this).data());
}
// Closes the modal window being displayed
function close_popup() {
var e = jQuery.Event("click");
$(".reveal-modal-bg").trigger(e); // trigger it on document
}
// =============== V A R I O U S ================= //
function nl2br(str, is_xhtml) {
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? ' ' : ' ';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
function toggle(elem) {
$(elem).toggle(200);
}
// checks/unchecks all checkboxes
function toggle_checkboxes(source, target) {
var checkboxes = document.getElementsByName(target);
for (var i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = source.checked;
}
// scrolls to the given component
function scrollTo(component) {
if (typeof $('#' + component)[0] != 'undefined')
$('#' + component)[0].scrollIntoView(true);
}
// sends an array to the server containing the action trace to be saved
function server_trace(array) {
if (trace_on) { // from main.php
$.ajax({
type: 'POST',
url: 'index.php?action=client_trace',
data: {info: array}
});
}
return true;
}
// determines whether the action has been triggered from a button or a keyboard shortcut
function get_origin() {
if (from_shortcut) { // a key has been pressed to run the action
from_shortcut = false;
return "from_shortcut";
} else {
return "from_button";
}
}
// determines whether official or personal bookmarks tab is active
function setActivePane(elem) {
if (elem == '.bookmarks_button') {
$('.settings.bookmarks').show();
$('.settings.toc').hide();
current_tab = 'main';
} else {
$('.settings.bookmarks').hide();
$('.settings.toc').show();
current_tab = 'toc';
}
$('.bookmarks_button').removeClass("active");
$('.toc_button').removeClass("active");
$(elem).addClass("active");
}
// Render a styled file input in the submit form
function initFileUploads() {
var W3CDOM = (document.createElement && document.getElementsByTagName
&& navigator.appName != 'Microsoft Internet Explorer');
if (!W3CDOM)
return;
var fakeFileUpload = document.createElement('div');
fakeFileUpload.className = 'fakefile';
var input = document.createElement('input');
input.style.width = '140px';
fakeFileUpload.appendChild(input);
var span = document.createElement('span');
span.innerHTML = 'Choisir';
fakeFileUpload.appendChild(span);
var x = document.getElementsByTagName('input');
for (var i = 0; i < x.length; i++) {
if (x[i].type != 'file')
continue;
if (x[i].parentNode.className != 'fileinputs')
continue;
x[i].className = 'file hidden';
var clone = fakeFileUpload.cloneNode(true);
x[i].parentNode.appendChild(clone);
x[i].relatedElement = clone.getElementsByTagName('input')[0];
x[i].onchange = x[i].onmouseout = function () {
this.relatedElement.value = this.value;
}
}
}
×
Ce site n'est pas optimisé pour votre navigateur. Certaines fonctionnalités risquent de ne pas fonctionner.
Seuls les navigateurs suivants sont pleinement compatibles :
Safari 5+ |
Google Chrome |
Opera 26+
Notre site utilise des cookies pour améliorer votre expérience.
En continuant à naviguer sur notre site, vous acceptez leur utilisation.
Préférences
Un problème ? Une suggestion ?
Utilisez le formulaire suivant pour entrer en contact avec nous. Pensez à renseigner votre adresse email si vous souhaitez une réponse de notre part.