var mainFrameObj; $(function() { // Init mainFrameObj = $('body'); InitAjax(); InitBubble(); InitPopup(); InitScroll(); InitQueue(); InitPages(); InitUserSelect() }); var init_fct_list = new Array(); function addInit(fct) { init_fct_list.push(fct); } function InitQueue() { while (init_fct_list.length) { eval(init_fct_list.shift()); } } function goUrl(url) { if (url != '') window.location.href = url; } function reloadPage() { launchWarFog(); window.location.href=window.location.href; location.reload(); } /* Server Access */ /*****************************/ var ajxXHR = true; var ajxNameQueue = new Array(); var ajxDataQueue = new Array(); function InitAjax() { $.ajaxSetup({ type: "POST", dataType: 'script', timeout: 15000, error: function(jqXHR, textStatus, errorThrown) { abortServerAccess(); alert(textStatus+': '+errorThrown); }, success: function(jqXHR, textStatus, errorThrown) { ajxXHR = false; if (ajxDataQueue.length) { serverAccess(ajxNameQueue.shift(), ajxDataQueue.shift()); } } }); ajxXHR = false; if (ajxDataQueue.length) serverAccess(ajxNameQueue.shift(), ajxDataQueue.shift()); } function abortServerAccess() { if ((ajxXHR) && (ajxXHR.readyState != 4)) { ajxXHR.abort(); } ajxXHR = false; } function serverAccess(name, dataList) { if (! name.match(/^[0-9a-z_]+$/i)) return; if (ajxXHR) { ajxNameQueue.push(name); ajxDataQueue.push(dataList); return; } ajxXHR = $.ajax({ url: "https://mirandol.org/_inc/ajx/"+name+".ajx.php5", data:dataList }); } /*function string_protect(str) { return str.replace("'", "´").replace("&", "~38;"); } function string_unprotect(str) { return str.replace("~38;", "&"); }*/ function htmlEncode(value){ if (value) { return jQuery('
').text(value).html(); } else { return ''; } } function htmlDecode(value) { if (value) { return $('
').html(value).text(); } else { return ''; } } function utf8_encode (argString) { // http://kevin.vanzonneveld.net // + original by: Webtoolkit.info (http://www.webtoolkit.info/) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: sowberry // + tweaked by: Jack // + bugfixed by: Onno Marsman // + improved by: Yves Sucaet // + bugfixed by: Onno Marsman // + bugfixed by: Ulrich // + bugfixed by: Rafal Kukawski // + improved by: kirilloid // * example 1: utf8_encode('Kevin van Zonneveld'); // * returns 1: 'Kevin van Zonneveld' if (argString === null || typeof argString === "undefined") { return ""; } var string = (argString + ''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n"); var utftext = '', start, end, stringl = 0; start = end = 0; stringl = string.length; for (var n = 0; n < stringl; n++) { var c1 = string.charCodeAt(n); var enc = null; if (c1 < 128) { end++; } else if (c1 > 127 && c1 < 2048) { enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128); } else { enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128); } if (enc !== null) { if (end > start) { utftext += string.slice(start, end); } utftext += enc; start = end = n + 1; } } if (end > start) { utftext += string.slice(start, stringl); } return utftext; } /* Menu management */ /*****************************/ var LastMnuItemId = ''; var MnuItemOutTimeID = false; function MnuItemOver(ItemID) { if (MnuItemOutTimeID) { clearTimeout(MnuItemOutTimeID); MnuItemOutTimeID = false; } if (LastMnuItemId != '') { if (ItemID == LastMnuItemId) return; var MnuItmObj = $('#MnuItem_'+LastMnuItemId); if (MnuItmObj.length) MnuItmObj.stop(true, true).removeClass('over',0); var ImgItmObj = $('#AcceuilImg_'+LastMnuItemId); if (ImgItmObj.length) ImgItmObj.stop(true, true).hide('fade', 'slow'); LastMnuItemId = ''; } var MnuItmObj = $('#MnuItem_'+ItemID); if (MnuItmObj.length) MnuItmObj.addClass('over', 200); var ImgItmObj = $('#AcceuilImg_'+ItemID); if (ImgItmObj.length) ImgItmObj.show('fade', 'slow'); LastMnuItemId = ItemID; } function MnuItemOut() { if (LastMnuItemId == '') return; var MnuItmObj = $('#MnuItem_'+LastMnuItemId); if (MnuItmObj.length) { var ImgItmObj = $('#AcceuilImg_'+LastMnuItemId); MnuItemOutTimeID = setTimeout(function() { MnuItmObj.stop(true, true).removeClass('over', 200); if (ImgItmObj.length) ImgItmObj.stop(true, true).hide('fade', 'slow'); LastMnuItemId = ''; MnuItemOutTimeID = false; }, 50); } } function changeUser() { var UserSelectObj = $('#UserSelect'); if (!UserSelectObj.length) return; if (UserSelectObj.val() == 'CoUser') goUrl("https://mirandol.org?CoUser=Y"); else goUrl("https://mirandol.org?CoUser=N"); } function InitUserSelect() { var SelObj = $('#UserSelect'); if (!SelObj.length) return; loadSelect('UserSelect'); SelObj[0].boxHeadObj.removeClass('BoxSelect').addClass('UserSelect'); SelObj[0].boxHeadObj.html(' '); SelObj[0].boxHeadTextObj = $('').attr('id', 'UserSelect_boxtexthead').addClass('UserSelect').prependTo(SelObj[0].boxHeadObj); SelObj[0].boxHeadTextObj.removeClass('BoxSelect').addClass('UserSelect'); loadSelect('UserSelect'); } /* Bubble Help management */ /*****************************/ var BubbleObj; function InitBubble() { BubbleObj = $('
').attr('id', 'BubbleBox').appendTo('body'); if (BubbleObj.length) BubbleObj.hide(0).css({opacity:0.9}); } function BubbleMove(coordX, coordY) { if (!BubbleObj.length) return; var posX = coordX + 20; var screenWidth = $(document).innerWidth() - 5; var bubbleWidth = BubbleObj.outerWidth(true); if ((posX + bubbleWidth) >= screenWidth) posX = screenWidth - bubbleWidth; var posY = coordY + 20; var screenHeight = $(document).innerHeight() - 5; var bubbleHeight = BubbleObj.outerHeight(true); if ((posY + bubbleHeight) >= screenHeight) posY = coordY - (bubbleHeight + 20); BubbleObj.css({top: posY+'px',left: posX+'px'}); } function bubble(obj, content) { if ((!BubbleObj.length) || (content == '')) return; var JObj = $(obj); BubbleObj.html(content); if (!JObj[0].bubbleReady) { var pos = JObj.offset(); BubbleMove(pos.left, pos.top); JObj.mousemove(function (event) {BubbleMove(event.pageX, event.pageY);}); JObj.mouseout(BubbleOut); JObj[0].bubbleReady = true; } BubbleObj.slideDown('fast'); } function BubbleOut() { if (!BubbleObj.length) return; BubbleObj.hide(); } /* Popup window */ /*****************************/ var WarFogObj; var PopupObj; var PopupContentObj; var PopupCloseBtnObj; function InitPopup() { // PopupObj = $('
').attr('id', 'PopupWindow').appendTo('#mainFrame'); PopupObj = $('
').attr('id', 'PopupWindow').appendTo('body'); if (PopupObj.length) { PopupObj.hide(0); PopupCloseBtnObj = $('
').attr('id', 'CloseWinPopBtn').appendTo(PopupObj); PopupCloseBtnObj.hide(0); PopupContentObj = $('
').attr('id', 'PopupContent').appendTo(PopupObj); PopupObj[0].isOpen = false; } WarFogObj = $('
').attr('id', 'WarFog').appendTo('body'); if (WarFogObj.length) WarFogObj.hide(0); } function launchWarFog() { WarFogObj.stop(true, true).fadeTo(1000, 0.6); } function open_popup(content, xpos, ypos) { if (!PopupContentObj.length) return; BubbleOut(); PopupCloseBtnObj.hide(0); var tmpObj = $('
').css({position:'absolute', left:-9999}).appendTo('body').html(content); var Width = tmpObj.outerWidth(true)+30; var Height = tmpObj.outerHeight(true)+30; tmpObj.remove(); var screenWidth = mainFrameObj.innerWidth(); var screenHeight = mainFrameObj.innerHeight()-10; PopupContentObj[0].xpos = xpos; PopupContentObj[0].ypos = ypos; if ((!ypos) && (!xpos)) { xpos = (screenWidth - Width) / 2; ypos = (screenHeight - Height) / 2; } if ((ypos + Height) >= screenHeight) { ypos = screenHeight - Height; } PopupObj.stop(true, false); launchWarFog(); PopupContentObj.html(content).show(0); if (!PopupObj[0].isOpen) { PopupObj.css({ left : xpos+'px', width : Width+'px', top : ypos+'px', height: Height+'px' }).show('fold', 500);; } else { PopupObj.show(0).animate({ left : xpos+'px', width : Width+'px', top : ypos+'px', height: Height+'px' }, 500); } PopupObj[0].isOpen = true; } function resize_popup() { if (!PopupContentObj.length) return; if (PopupObj[0].isOpen) { var tmpObj = $('
').css({position:'absolute', left:-9999}).appendTo('body').html(PopupContentObj.html()); var Width = tmpObj.outerWidth(true)+30; var Height = tmpObj.outerHeight(true)+30; tmpObj.remove(); var xpos = PopupContentObj[0].xpos; var ypos = PopupContentObj[0].ypos; var screenWidth = mainFrameObj.innerWidth(); var screenHeight = mainFrameObj.innerHeight()-10; if ((!ypos) && (!xpos)) { xpos = (screenWidth - Width) / 2; ypos = (screenHeight - Height) / 2; } if ((ypos + Height) >= screenHeight) { ypos = screenHeight - Height; } PopupObj.show(0).animate({ left : xpos+'px', width : Width+'px', top : ypos+'px', height: Height+'px' }, 500); /* var closeBtn = PopupCloseBtnObj.is(':hidden'); open_popup(PopupContentObj.html(), PopupContentObj[0].xpos, PopupContentObj[0].ypos); if (!closeBtn) PopupCloseBtnObj.show(0);*/ } } function get_popup_content() { if (!PopupContentObj.length) return ''; return PopupContentObj.html(); } function window_popup(content, xpos, ypos, quitAction) { open_popup(content, xpos, ypos); PopupCloseBtnObj.show(0); PopupCloseBtnObj.click(function() {if (quitAction) eval(quitAction); else close_popup();}); WarFogObj.click(function() {if (quitAction) eval(quitAction); else close_popup();}); } function window_popup_at_pos(content, posObjID, quitAction) { var posObj = $('#'+posObjID); if (posObj.length) { var pos = posObj.offset(); window_popup(content, pos.left, pos.top, quitAction); } else { window_popup(content, 0, 0, quitAction); } } function close_popup() { PopupCloseBtnObj.off('click'); WarFogObj.off('click'); PopupObj.hide({effect:'fold', duration:'slow'}); PopupObj[0].isOpen = false; WarFogObj.stop(true, true).hide('fade', 1000); BubbleOut(); } /* Scroll box management */ /*****************************/ var ScrollObj; function InitScroll() { ScrollObj = $('#ScrolledBox'); if (ScrollObj.length) { var objPos = ScrollObj.position(); if ((navigator.userAgent.match(/msie/i)) || (objPos.top != 0)) { ScrollObj.css({height:ScrollObj.parent().innerHeight() - objPos.top}); $(window).resize(function() {ScrollObj.css({height:ScrollObj.parent().innerHeight() - objPos.top});}); } ScrollObj.mCustomScrollbar({ autoHideScrollbar:true, theme:"light-thin" }); /* ScrollObj.hover(function(){ $(document).data({"keyboard-input":"enabled"}); $(this).addClass("keyboard-input"); },function(){ $(document).data({"keyboard-input":"disabled"}); $(this).removeClass("keyboard-input"); }); $(document).keydown(function(e){ if($(this).data("keyboard-input")==="enabled"){ var activeElem=$(".keyboard-input"), activeElemPos=Math.abs($(".keyboard-input .mCSB_container").position().top), pixelsToScroll=60; if(e.which===38){ //scroll up e.preventDefault(); if(pixelsToScroll>activeElemPos){ activeElem.mCustomScrollbar("scrollTo","top"); }else{ activeElem.mCustomScrollbar("scrollTo",(activeElemPos-pixelsToScroll),{scrollInertia:400,scrollEasing:Power2.easeOut}); } } else if(e.which===40) { //scroll down e.preventDefault(); activeElem.mCustomScrollbar("scrollTo",(activeElemPos+pixelsToScroll),{scrollInertia:400,scrollEasing:Power2.easeOut}); } } });*/ } } function scrollTo(position) { if (ScrollObj.length) ScrollObj.mCustomScrollbar("scrollTo", position); } function ScrollingTo(position) { if (ScrollObj.length) ScrollObj.mCustomScrollbar("scrollTo", position); } /* Page content */ /*****************************/ function InitPages() { $('div#Article img').click(function(e) { serverAccess('upload_photo', 'SHOWIMAGEDATA='+$(this).attr('ID')); }); $('div#Article img').bind("contextmenu", function(e) { return false;}); } function initImageDisplay() { var ThumbScrollObj = $('div#imageThumb'); if (ThumbScrollObj.length) { ThumbScrollObj.mCustomScrollbar({ horizontalScroll:true, autoHideScrollbar:true, advanced:{autoExpandHorizontalScroll:true,updateOnContentResize:false}, theme:"light-thin" }); ThumbScrollObj.mCustomScrollbar("scrollTo", '.imgThumbSel'); } /* var imagePrevObj = $('div#imagePrev'); if (imagePrevObj.length) { $('div#imagePrev img').hide(0); imagePrevObj.hover( function() {$('div#imagePrev img').show('fade', 'slow');}, function() {$('div#imagePrev img').hide(0);}); } var imageNextObj = $('div#imageNext'); if (imageNextObj.length) { $('div#imageNext img').hide(0); imageNextObj.hover( function() {$('div#imageNext img').show('fade', 'slow');}, function() {$('div#imageNext img').hide(0);}); }*/ } /* Graphic extension */ /*****************************/ /* - Input text - */ function inputTextFocus(Obj, titleText, onenteraction, onbluraction, select = false) { var InputTxtObj = $(Obj); if (!InputTxtObj.length) return; if (!InputTxtObj[0].defaultTitle) InputTxtObj[0].defaultTitle = titleText; InputTxtObj.blur(function() { var currentValue = InputTxtObj.val(); if ((onbluraction) && (onbluraction != '') && (currentValue != InputTxtObj[0].defaultTitle) && (InputTxtObj[0].prevText != currentValue)) { eval(onbluraction); InputTxtObj[0].prevText = currentValue; } if (currentValue == "") { InputTxtObj.addClass("defaultTextActive"); InputTxtObj.removeClass("defaultText"); InputTxtObj.val(InputTxtObj[0].defaultTitle); } }); if ((onenteraction) && (onenteraction != '')) { InputTxtObj.keyup(function(event) { if (event.which == 13) eval(onenteraction); }); } if (InputTxtObj.val() == InputTxtObj[0].defaultTitle) { InputTxtObj.removeClass("defaultTextActive"); InputTxtObj.addClass("defaultText"); InputTxtObj.val(""); } InputTxtObj[0].prevText = InputTxtObj.val(); if (select) InputTxtObj.select(); } function inputTextUpdate(Obj, newtext) { var InputTxtObj = $(Obj); if (!InputTxtObj.length) return; var currentValue = InputTxtObj.val(); if (currentValue == newtext) return; if (newtext == "") { InputTxtObj.addClass("defaultTextActive"); InputTxtObj.removeClass("defaultText"); InputTxtObj.val(InputTxtObj[0].defaultTitle); } else { if ((currentValue == InputTxtObj[0].defaultTitle) || (InputTxtObj.hasClass('defaultTextActive'))) { if (!InputTxtObj[0].defaultTitle) InputTxtObj[0].defaultTitle = currentValue; InputTxtObj.removeClass("defaultTextActive"); InputTxtObj.addClass("defaultText"); } InputTxtObj.val(newtext); } InputTxtObj[0].prevText = newtext; } function inputTextIsEmpty(ObjName) { var InputTxtObj = $('#'+ObjName); if (!InputTxtObj.length) return true; var currentValue = InputTxtObj.val(); if (currentValue == '') return true; if ((InputTxtObj[0].defaultTitle) && (currentValue == InputTxtObj[0].defaultTitle)) return true; if (InputTxtObj.hasClass('defaultTextActive')) return true; return false; } /* - Updatable text - */ function UpdateText(ObjName) { var textInputObj = $('#'+ObjName); var textObj = $('#txt_'+ObjName); if ((textInputObj.length) || (textObj.length)) { textInputObj.val(textObj.text()); textObj.hide(); textInputObj.show(); textInputObj.focus(); } } function textUpdateFocus(ObjName, titleText, action) { var textInputObj = $('#'+ObjName); if (textInputObj.length) { if (!textInputObj[0].defaultTitle) textInputObj[0].defaultTitle = titleText; if (!textInputObj[0].validateContente) { textInputObj[0].validateContente = function() { var textObj = $('#txt_'+ObjName); if (textObj.length) { textInputObj.hide(); textObj.show(); if (textObj.text() != textInputObj.val()) { textObj.text(textInputObj.val()); if ((action) && (action != '')) eval(action); } } } } textInputObj.blur(function() { if (textInputObj.val() == "") { textInputObj.addClass("defaultTextActive"); textInputObj.removeClass("defaultText"); textInputObj.val(textInputObj[0].defaultTitle); } else { textInputObj[0].validateContente(); } }); textInputObj.keyup(function(event) { if ((event.which == 13) && (textInputObj.val() != '')) { textInputObj[0].validateContente(); } }); if (textInputObj.val() == textInputObj[0].defaultTitle) { textInputObj.removeClass("defaultTextActive"); textInputObj.addClass("defaultText"); textInputObj.val(""); } } } /* - Member search bar - */ function inputMemberFocus(ObjID, titleText, onFoundAction, acceptEmpty = false) { var InputTxtObj = $('#'+ObjID); if (InputTxtObj.length) { if (!InputTxtObj[0].defaultTitle) InputTxtObj[0].defaultTitle = titleText; if ((!InputTxtObj[0].onFoundMember) && (onFoundAction)) InputTxtObj[0].onFoundMember = onFoundAction; InputTxtObj[0].UsrID = 0; InputTxtObj[0].UsrConjoint = false; InputTxtObj[0].acceptEmpty = acceptEmpty; InputTxtObj.blur(function() { if (InputTxtObj[0].ChgTimer) clearTimeout(InputTxtObj[0].ChgTimer); if (InputTxtObj.val() == "") { InputTxtObj.addClass("defaultTextActive"); InputTxtObj.removeClass("defaultText"); InputTxtObj.val(InputTxtObj[0].defaultTitle); InputTxtObj[0].UsrID = 0; InputTxtObj[0].UsrConjoint = false; } }); InputTxtObj[0].prevValue = InputTxtObj.val(); if (InputTxtObj[0].ChgTimer) clearTimeout(InputTxtObj[0].ChgTimer); InputTxtObj[0].ChgTimer = setTimeout(function() {CheckInputMemberChg(ObjID);}, 200); InputTxtObj.keyup(function(event) { if (InputTxtObj[0].ChgTimer) clearTimeout(InputTxtObj[0].ChgTimer); setTimeout(function() {CheckInputMemberChg(ObjID);}, 20); }); if (InputTxtObj.val() == InputTxtObj[0].defaultTitle) { InputTxtObj.removeClass("defaultTextActive"); InputTxtObj.addClass("defaultText"); InputTxtObj.val(""); } var InputCancelObj = $('#'+ObjID+'_CANCEL'); if (InputCancelObj.length) { InputCancelObj.click(function() { InputTxtObj.val(""); InputTxtObj.focus(); InputCancelObj.hide(); if (acceptEmpty) FoundInputMemberFocus(ObjID, '', 0, false); }); if (InputTxtObj.val() != '') InputCancelObj.show(); else InputCancelObj.hide(); } } } function CheckInputMemberChg(ObjID) { var InputTxtObj = $('#'+ObjID); if (InputTxtObj.length) { InputTxtObj[0].ChgTimer = false; var currentValue = InputTxtObj.val(); if (InputTxtObj[0].prevValue != currentValue) { InputTxtObj[0].prevValue = currentValue; InputTxtObj[0].UsrID = 0; InputTxtObj[0].UsrConjoint = false; if ((currentValue != '') && (currentValue != InputTxtObj[0].defaultTitle)) { var InputCancelObj = $('#'+ObjID+'_CANCEL'); if (InputCancelObj.length) InputCancelObj.show(); if (currentValue.length >= 3) serverAccess('members', 'FOUND='+currentValue+'&OBJID='+ObjID); return; } else { var InputCancelObj = $('#'+ObjID+'_CANCEL'); if (InputCancelObj.length) InputCancelObj.hide(); if ( InputTxtObj[0].acceptEmpty ) FoundInputMemberFocus(ObjID, '', 0, false); } } InputTxtObj[0].ChgTimer = setTimeout(function() {CheckInputMemberChg(ObjID);}, 200); } } function FoundInputMemberFocus(ObjID, UsrName, UsrID, isConjoint) { var InputTxtObj = $('#'+ObjID); if (InputTxtObj.length) { InputTxtObj.val(UsrName); InputTxtObj[0].UsrID = UsrID; InputTxtObj[0].UsrConjoint = isConjoint; if (InputTxtObj[0].onFoundMember) { var cmd = InputTxtObj[0].onFoundMember+';'; eval(cmd); } } } function GetInputMemberID(ObjID) { var InputTxtObj = $('#'+ObjID); if ((InputTxtObj.length) && (InputTxtObj[0].UsrID)) return InputTxtObj[0].UsrID; return 0; } function GetInputMemberIsConjoint(ObjID) { var InputTxtObj = $('#'+ObjID); return ((InputTxtObj.length) && (InputTxtObj[0].UsrConjoint)); } /* - Button - */ function inputButtonHover(Obj) { var JObj = $(Obj); if (JObj.length) { JObj.addClass("inputButtonHover"); JObj.mouseout(function() {JObj.removeClass("inputButtonHover");JObj.removeClass("inputButtonClic");}); JObj.mousedown(function() {JObj.removeClass("inputButtonHover");JObj.addClass("inputButtonClic");}); } } /* - CheckBox - */ function checkboxSet(Obj, newVal) { var JObj = $(Obj); if (JObj.length) { if (newVal) JObj.attr('src', "https://mirandol.org/_inc/img/checkbx.png"); else JObj.attr('src', "https://mirandol.org/_inc/img/checkbx_empty.png"); } } /* - Selector - */ function loadSelect(ObjName) { var SelObj = $('#'+ObjName); if (!SelObj.length) return; SelObj.hide(0); SelObj[0].boxOutTimeID = false; if (!SelObj[0].boxOptObj) { SelObj[0].boxOptObj = $('#'+ObjName+'_boxsel'); if (!SelObj[0].boxOptObj.length) SelObj[0].boxOptObj = $('
').attr('id', ObjName+'_boxsel').addClass('BoxSelect').insertBefore(SelObj); SelObj[0].boxOptObj.mouseout(function() {outSelect(ObjName);}); } if (!SelObj[0].boxHeadObj) { SelObj[0].boxHeadObj = $('#'+ObjName+'_boxhead'); if (!SelObj[0].boxHeadObj.length) { SelObj[0].boxHeadObj = $('').attr('id', ObjName+'_boxhead').addClass('BoxSelect').insertBefore(SelObj); SelObj[0].boxHeadObj.html(' '); } SelObj[0].boxHeadObj.mouseover(function() { BubbleOut(); if (SelObj[0].boxOutTimeID) { clearTimeout(SelObj[0].boxOutTimeID); SelObj[0].boxOutTimeID = false; } }); SelObj[0].boxHeadObj.click(function() { if (!SelObj[0].boxOptObj.is(':hidden')) { outSelect(ObjName); return; } var content = ''; SelObj.children('option').each(function(){ if ($(this).is(':selected')) content += '
'+$(this).text()+'
'; else content += "
"+$(this).text()+'
'; }); SelObj[0].boxOptObj.html(content); var boxPos = SelObj[0].boxHeadObj.position(); SelObj[0].boxOptObj.css({top: boxPos.top+SelObj[0].boxHeadObj.outerHeight()+'px',left: boxPos.left+'px', opacity:0.9}); $('div.OptSelected').mouseover(function() {if (SelObj[0].boxOutTimeID) clearTimeout(SelObj[0].boxOutTimeID);}); $('div.OptSelect').mouseover(function() {$(this).addClass('OptSelectOver');if (SelObj[0].boxOutTimeID) clearTimeout(SelObj[0].boxOutTimeID);}); $('div.OptSelect').mouseout (function() {$(this).removeClass('OptSelectOver');}); SelObj[0].boxOptObj.stop(true, true).slideDown('fast'); }); SelObj[0].boxHeadObj.mouseout(function() {outSelect(ObjName);}); } if (!SelObj[0].boxHeadTextObj) { SelObj[0].boxHeadTextObj = $('#'+ObjName+'_boxtexthead'); if (!SelObj[0].boxHeadTextObj.length) { SelObj[0].boxHeadTextObj = $('').attr('id', ObjName+'_boxtexthead').addClass('BoxSelect').prependTo(SelObj[0].boxHeadObj); } } SelObj[0].boxHeadTextObj.html(SelObj.children('option:selected').text()); var boxPos = SelObj[0].boxHeadObj.offset(); SelObj[0].boxOptObj.hide(0); SelObj[0].boxOptObj.css({top: boxPos.top-5+SelObj[0].boxHeadObj.outerHeight()+'px',left: boxPos.left-5+'px', 'min-width': SelObj[0].boxHeadObj.outerWidth()+'px', opacity:0.9}); } function outSelect(ObjName) { var SelObj = $('#'+ObjName); if (!SelObj.length) return; if (SelObj[0].boxOutTimeID) clearTimeout(SelObj[0].boxOutTimeID); SelObj[0].boxOutTimeID = setTimeout(function() { SelObj[0].boxOptObj.stop(true, true).slideUp(); SelObj[0].boxOutTimeID = false; }, 100); } function optSel(ObjName, OptVal) { var SelObj = $('#'+ObjName); if (!SelObj.length) return; if (SelObj[0].boxOutTimeID) clearTimeout(SelObj[0].boxOutTimeID); if (SelObj[0].boxOptObj) SelObj[0].boxOptObj.stop(true, true).hide(0); if (SelObj.children('option:selected').val() == OptVal) return; SelObj.children('option['+OptVal+']').attr('selected', true); SelObj.val(OptVal); if (SelObj[0].onchange) SelObj[0].onchange(); loadSelect(ObjName); } function getSelection(ObjName) { var SelObj = $('#'+ObjName); if (!SelObj.length) return ''; return SelObj.children('option:selected').val(); } /* - Drop Zone - */ function createDropZone(dropZoneIDName, target, doneCommand) { var dropZone = $('#'+dropZoneIDName); if (dropZone[0].inputObj) return; dropZone[0].inputObj = $('').attr('type', 'file').attr('accept', "image/jpeg,image/png").addClass('inputDropZone').insertAfter(dropZone); dropZone.fileupload({ dataType: 'json', url: "https://mirandol.org/_inc/ajx/"+target+".ajx.php5", sequentialUploads: true, autoUpload:true, dropZone:dropZone, fileInput: dropZone[0].inputObj, formData: [{name:'option', value: dropZoneIDName}], done: function (e, data) { if (data.result.error) alert('ERROR: ' + data.result.error); else if ((data.result.filename) && (doneCommand)) eval(doneCommand); }, add: function (e, data) { dropZone.removeClass('in draghover'); var validFiles = true; $.each(data.files, function (index, file) { if (! (/\.(jpg|jpeg|png)$/i).test(file.name)) validFiles = false; }); if (validFiles) data.submit(); } }); $(document).bind('dragover', function (e) { var timeout = window.dropZoneTimeout; if (timeout) clearTimeout(timeout); if ((e.target === dropZone[0]) || (e.target.parentNode === dropZone[0])) { dropZone.addClass('draghover'); } else { dropZone.removeClass('draghover'); } window.dropZoneTimeout = setTimeout(function () { window.dropZoneTimeout = null; dropZone.removeClass('draghover'); }, 100); }); } function activateDropZone(dropZoneIDName) { var dropZone = $('#'+dropZoneIDName); if (!dropZone.length) return; if (dropZone[0].inputObj) dropZone[0].inputObj.trigger('click'); } /* Dynamic Calendar display */ /****************************/ function loadCalendar(entryName, Year, Month, Day, onUpdateCmd) { var entryObj = $('#'+entryName); if (!entryObj.length) return; entryObj.hide(0); if (entryObj[0].boxObj) return; entryObj[0].dateYear = Year; entryObj[0].dateMonth = Month; entryObj[0].dateDay = Day; entryObj[0].dateRefYear = Year; entryObj[0].dateRefMonth = Month; entryObj[0].onUpdateCmd = onUpdateCmd; if (!$('#'+entryName+'_box').length) { entryObj[0].boxObj = $('').attr('id', entryName+'_box').addClass('BoxSelect').insertBefore(entryObj); entryObj[0].boxObj.click(function() { if (!entryObj[0].calBoxObj) { entryObj[0].calBoxObj = $('
').attr('id', entryName+'_cal').addClass('BoxSelect').insertBefore(entryObj); } else if (!entryObj[0].calBoxObj.is(':hidden')) { closeCalBox(entryName); return; } entryObj[0].dateYear = entryObj[0].dateRefYear; entryObj[0].dateMonth = entryObj[0].dateRefMonth; updateCalendarBox(entryName); var boxPos = entryObj[0].boxObj.position(); entryObj[0].calBoxObj.css({top: boxPos.top+entryObj[0].boxObj.outerHeight()+'px',left: boxPos.left+'px', opacity:0.9}); entryObj[0].calBoxObj.stop(true, true).slideDown('fast'); }); } updateCalendarDate(entryName); } function updateCalendarDate(entryName) { var entryObj = $('#'+entryName); if (!entryObj.length) return; entryObj[0].dateStr = entryObj[0].dateDay+"-"+entryObj[0].dateMonth+"-"+entryObj[0].dateYear; entryObj.val(entryObj[0].dateStr); if (!entryObj[0].boxObj) return; var MonthStr = new Array('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Décembre'); var WDayStr = new Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'); var DispDate = new Date(entryObj[0].dateYear, entryObj[0].dateMonth-1, entryObj[0].dateDay); var DateTxt = WDayStr[DispDate.getDay()]+" "+entryObj[0].dateDay+" "+MonthStr[entryObj[0].dateMonth-1]+" "+entryObj[0].dateYear; entryObj[0].boxObj.html(DateTxt + ' '); } function getCalendarDate(entryName) { var entryObj = $('#'+entryName); if (!entryObj.length) return ''; if (entryObj[0].dateStr) return entryObj[0].dateStr; return ''; } function setCalendarDate(entryName, dateStr) { var entryObj = $('#'+entryName); if (!entryObj.length) return; if (typeof(dateStr) != 'string') return; var dateElt = dateStr.split("-"); if (dateElt.length != 3) return; entryObj[0].dateYear = dateElt[2]; entryObj[0].dateMonth = dateElt[1]; entryObj[0].dateDay = dateElt[0]; entryObj[0].dateRefYear = dateElt[2]; entryObj[0].dateRefMonth = dateElt[1]; updateCalendarDate(entryName); } function updateCalendarBox(entryName) { var entryObj = $('#'+entryName); if (!entryObj.length) return; if (!entryObj[0].boxObj) return; if (!entryObj[0].calBoxObj) return; var MonthStr = new Array('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Décembre'); var MonthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if (((entryObj[0].dateYear % 4 == 0) && (entryObj[0].dateYear % 100 != 0)) || (entryObj[0].dateYear % 400 == 0)) { MonthDays[1] = 29; } var FirstMonthDay = new Date(entryObj[0].dateYear, entryObj[0].dateMonth-1, 1); var startDay = FirstMonthDay.getDay(); var lastDay = MonthDays[entryObj[0].dateMonth-1]; var curMonth = ((entryObj[0].dateMonth == entryObj[0].dateRefMonth) && (entryObj[0].dateYear == entryObj[0].dateRefYear)); var content = ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; content += ""; var column = 0; content += ""; if (startDay) { content += ""; column += startDay; } for (day = 1; day <= lastDay; day++) { if (column == 7) { content += ""; column = 0; } var classStr = 'BoxCalCll'; if ((curMonth) && (day == entryObj[0].dateDay)) { classStr += ' BoxCalCll_sel'; } else if ((column == 0) || (column == 6)) { classStr += ' BoxCalCll_we'; } content += ""; column++; } if (column < 7) { content += ""; } content += ""; content += '
"+MonthStr[entryObj[0].dateMonth-1]+" "+entryObj[0].dateYear+"
DLMMJVS
 
"+day+" 
'; entryObj[0].calBoxObj.html(content); $('.BoxCalCll').hover(function() {$(this).addClass('BoxCalCll_hover');}, function() {$(this).removeClass('BoxCalCll_hover');}); entryObj[0].calBoxObj.mouseout(function(e){scheduleCloseCalBox(entryName);}); } function prevCalMonth(entryName) { var entryObj = $('#'+entryName); if (!entryObj.length) return; entryObj[0].dateMonth--; if (entryObj[0].dateMonth == 0) { entryObj[0].dateMonth = 12; entryObj[0].dateYear--; } updateCalendarBox(entryName); } function nextCalMonth(entryName) { var entryObj = $('#'+entryName); if (!entryObj.length) return; entryObj[0].dateMonth++; if (entryObj[0].dateMonth == 13) { entryObj[0].dateMonth = 1; entryObj[0].dateYear++; } updateCalendarBox(entryName); } function selCalDay(entryName, day) { var entryObj = $('#'+entryName); if (!entryObj.length) return; entryObj[0].dateDay = day; entryObj[0].dateRefMonth = entryObj[0].dateMonth; entryObj[0].dateRefYear = entryObj[0].dateYear; updateCalendarDate(entryName); if (entryObj[0].onUpdateCmd) eval(entryObj[0].onUpdateCmd+';'); closeCalBox(entryName); } function scheduleCloseCalBox(entryName) { var entryObj = $('#'+entryName); if (!entryObj.length) return; if (!isNaN(entryObj[0].closeTimeoutID)) clearTimeout(entryObj[0].closeTimeoutID); entryObj[0].closeTimeoutID = setTimeout(function() {closeCalBox(entryName);}, 500); } function unscheduleCloseCalBox(entryName) { var entryObj = $('#'+entryName); if ((entryObj.length) && (!isNaN(entryObj[0].closeTimeoutID))) clearTimeout(entryObj[0].closeTimeoutID); } function closeCalBox(entryName) { var entryObj = $('#'+entryName); if (!entryObj.length) return; if (!entryObj[0].calBoxObj) return; entryObj[0].calBoxObj.stop(true, true).slideUp(); }