Last commit for src/scripts/messages.js: 2a3f969291d459609b2a61c1815f7d1a704aeb9f

Tweak to allowed in editable wiki extensions

Chris Pollett [2024-03-09 02:Mar:th]
Tweak to allowed in editable wiki extensions
/**
 * SeekQuarry/Yioop --
 * Open Source Pure PHP Search Engine, Crawler, and Indexer
 *
 * Copyright (C) 2009 - 2023  Chris Pollett chris@pollett.org
 *
 * LICENSE:
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * END LICENSE
 *
 * @author Chris Pollett chris@pollett.org
 * @license https://www.gnu.org/licenses/ GPL3
 * @link https://www.seekquarry.com/
 * @copyright 2009 - 2023
 * @filesource
 */
/*
 * Code for the user messages portion of Yioop
 */
document.addEventListener('DOMContentLoaded', function () {
    // Query the element
    const split_adjuster = document.getElementById('split-adjuster');
    if (!split_adjuster) {
        return;
    }
    const direction =
        document.getElementsByTagName('html')[0].getAttribute('dir');
    const direction_sign = (direction == 'rtl') ? -1 : 1;
    const left_elt = split_adjuster.previousElementSibling;
    const right_elt = split_adjuster.nextElementSibling;
    // The current position of mouse
    let x = 0;
    let y = 0;
    let left_width = 0;
    const mouseDownHandler = function (e) {
        x = e.clientX;
        y = e.clientY;
        left_width = left_elt.getBoundingClientRect().width;
        document.addEventListener('mousemove', mouseMoveHandler);
        document.addEventListener('mouseup', mouseUpHandler);
    };
    const mouseMoveHandler = function (e) {
        const dx = direction_sign*(e.clientX - x);
        const dy = e.clientY - y;
        const new_left_width = Math.max(((left_width + dx) * 100) /
            split_adjuster.parentNode.getBoundingClientRect().width, 10);
        left_elt.style.width = `${new_left_width}%`;
        split_adjuster.style.cursor = 'col-resize';
        document.body.style.cursor = 'col-resize';
        left_elt.style.userSelect = 'none';
        left_elt.style.pointerEvents = 'none';
        right_elt.style.userSelect = 'none';
        right_elt.style.pointerEvents = 'none';
    };
    const mouseUpHandler = function () {
        split_adjuster.style.removeProperty('cursor');
        document.body.style.removeProperty('cursor');
        left_elt.style.removeProperty('user-select');
        left_elt.style.removeProperty('pointer-events');
        right_elt.style.removeProperty('user-select');
        right_elt.style.removeProperty('pointer-events');
        document.removeEventListener('mousemove', mouseMoveHandler);
        document.removeEventListener('mouseup', mouseUpHandler);
    };
    split_adjuster.addEventListener('mousedown', mouseDownHandler);
});
function conversationUpdate()
{
    let conversation_obj = elt('conversation');
    let conversation_time =
        parseInt(conversation_obj.getAttribute('data-time'));
    getPage(null, start_url + conversation_time, function(text) {
        conversation_obj.style.backgroundColor = "#EEE";
        let tmp_container = document.createElement("div");
        tmp_container.innerHTML = text;
        let new_conversation_obj = tmp_container.getElementsByClassName(
            'conversation')[0];
        let update_time =
            new_conversation_obj.getAttribute('data-time');
        if (update_time) {
            conversation_obj.setAttribute('data-time', update_time);
        }
        conversation_obj.innerHTML = new_conversation_obj.innerHTML +
            conversation_obj.innerHTML;
        setTimeout("resetBackground()", 0.5 * sec);
    });
}
function clearUpdate()
{
     clearInterval(conversation_update_id);
     elt('conversation').innerHTML= "<h2 class='red'>" +
        tl['social_component_no_longer_update'] + '</h2>';
}
function resetBackground()
{
     elt('conversation').style.backgroundColor = "#FFF";
}
function doUpdate()
{
    var sec = 1000;
    var minute = 60 * sec;
    conversation_update_time = 15;
    conversation_update_id = setInterval("conversationUpdate()",
        conversation_update_time * sec);
    setTimeout("clearUpdate()", 20 * minute + sec);
}
ViewGit