• Java script

    From Theviper@VERT/VIPERBBS to All on Tuesday, February 04, 2025 14:31:11
    // Filename: sysop_chat_with_splitscreen_and_colors.js

    load('sbbsdefs.js'); // Load the standard definitions
    load('userdefs.js'); // Load user definitions if needed

    // Helper function to add ANSI color codes
    function color(text, foreColor, backColor = null) {
    var ansiCode = '\x1b[';
    if (foreColor) ansiCode += foreColor + 'm';
    if (backColor) ansiCode += backColor + 'm';
    return ansiCode + text + '\x1b[0m'; // Reset color after text
    }

    // ANSI color codes for foreground
    const RED = '31';
    const GREEN = '32';
    const YELLOW = '33';
    const BLUE = '34';
    const MAGENTA = '35';
    const CYAN = '36';
    const WHITE = '37';

    // Main function to handle sysop chat and paging
    function sysopChat() {
    console.clear();
    console.putmsg(color("\1h\1cSysop Chat and Message System\1n\r\n", BLUE));
    console.putmsg(color("1. Page Sysop\r\n", GREEN));
    console.putmsg(color("2. Chat with Sysop\r\n", GREEN));
    console.putmsg(color("3. Send Message to Sysop\r\n", GREEN));
    console.putmsg(color("4. Node-to-Node Chat\r\n", GREEN));
    console.putmsg(color("5. Multi-Node Chat\r\n", GREEN));
    console.putmsg(color("6. Multi-User Chat Room\r\n", GREEN));
    console.putmsg(color("7. Split Screen Chat\r\n", GREEN));
    console.putmsg(color("8. Check User Status\r\n", GREEN));
    console.putmsg(color("9. Exit\r\n", RED));
    console.putmsg(color("Choose an option: ", YELLOW));

    var choice = console.getnum(1, 9);
    switch(choice) {
    case 1: // Page Sysop
    pageSysop();
    break;
    case 2: // Chat with Sysop
    startChat();
    break;
    case 3: // Send Message to Sysop
    sendMessage();
    break;
    case 4: // Node-to-Node Chat
    nodeChat();
    break;
    case 5: // Multi-Node Chat
    multiNodeChat();
    break;
    case 6: // Multi-User Chat Room
    multiUserChatRoom();
    break;
    case 7: // Split Screen Chat
    splitScreenChat();
    break;
    case 8: // Check User Status
    checkUserStatus();
    break;
    case 9: // Exit
    console.putmsg(color("\r\nGoodbye!\r\n", RED));
    return;
    }
    }

    function pageSysop() {
    console.putmsg(color("Paging the Sysop...\r\n", CYAN));
    }

    function startChat() {
    console.putmsg(color("Starting chat with Sysop...\r\n", MAGENTA));
    }

    function sendMessage() {
    console.putmsg(color("Sending message to Sysop...\r\n", YELLOW));
    }

    function nodeChat() {
    console.putmsg(color("Starting node-to-node chat...\r\n", WHITE));
    }

    function multiNodeChat() {
    console.putmsg(color("Starting multi-node chat...\r\n", BLUE));
    }

    function multiUserChatRoom() {
    console.putmsg(color("Entering multi-user chat room...\r\n", CYAN));
    }

    function splitScreenChat() {
    console.clear();
    console.putmsg(color("\1h\1cSplit Screen Chat\1n\r\n", MAGENTA));

    // Basic setup for split screen chat with colors
    console.putmsg(color("This would be the top half of the screen for one user.\r\n", RED));
    console.putmsg(color("-------------------------------------------\r\n", WHITE));
    console.putmsg(color("This would be the bottom half for another user.\r\n", GREEN));

    // Simulate some interaction
    console.putmsg(color("Press any key to exit split screen chat...\r\n", YELLOW));
    console.getkey();
    }

    function checkUserStatus() {
    console.clear();
    console.putmsg(color("\1h\1cUser Status Check\1n\r\n", BLUE));

    // List all users currently online
    var onlineUsers = [];
    for(var i = 0; i < system.node_list.length; i++) {
    if(system.node_list[i].status == NODE_INUSE) {
    var nodeUser = system.node_list[i].user;
    var nodeStatus = system.node_list[i].action;
    onlineUsers.push({
    user: nodeUser,
    status: nodeStatus,
    node: i + 1
    });
    }
    }

    if(onlineUsers.length === 0) {
    console.putmsg(color("No users are currently online.\r\n", RED));
    return;
    }

    console.putmsg(color("Users Online:\r\n", GREEN));
    for(var i = 0; i < onlineUsers.length; i++) {
    console.putmsg(color("Node " + onlineUsers[i].node + " - User: " + onlineUsers[i].user + ", Status: " + onlineUsers[i].status + "\r\n", CYAN));
    }

    console.putmsg(color("\r\nPress any key to continue...\r\n", YELLOW));
    console.getkey();
    }

    while(true) {
    sysopChat();
    if (!console.noyes(color("Do you want to perform another operation?", YELLOW))) {
    break;
    }
    }
    This is the new Chat system screen for the BBS Java script a new sysop page!

    ---
    þ Synchronet þ THEVIPERBBS - theviperbbs.mywire.org
  • From Digital Man@VERT to Theviper on Wednesday, February 05, 2025 22:10:55
    Re: Java script
    By: Theviper to All on Tue Feb 04 2025 02:31 pm

    // Filename: sysop_chat_with_splitscreen_and_colors.js

    load('sbbsdefs.js'); // Load the standard definitions
    load('userdefs.js'); // Load user definitions if needed

    Use require() instead of load() to prevent redundant/unnecessary reloads of the script.

    // Helper function to add ANSI color codes
    function color(text, foreColor, backColor = null) {
    var ansiCode = '\x1b[';
    if (foreColor) ansiCode += foreColor + 'm';
    if (backColor) ansiCode += backColor + 'm';
    return ansiCode + text + '\x1b[0m'; // Reset color after text
    }

    // ANSI color codes for foreground
    const RED = '31';
    const GREEN = '32';
    const YELLOW = '33';
    const BLUE = '34';
    const MAGENTA = '35';
    const CYAN = '36';
    const WHITE = '37';

    You seem to be reinventing the wheel here:

    1. This code only works with ANSI terminals and will not produce anything useful for other terminals.

    2. We already have console.attributes and a ton of other ways (in Synchronet-JS) to set the attributes in a terminal-neutral manner that will "just work" with other non-ANSI terminals.
    https://www.synchro.net/docs/jsobjs.html#console_object_properties

    This is the new Chat system screen for the BBS Java script a new sysop page!

    Cool! Keep it up. And it's "JavaScript". :-)
    --
    digital man (rob)

    This Is Spinal Tap quote #20:
    Well, I'm sure I'd feel much worse if I weren't under such heavy sedation. Norco, CA WX: 55.7øF, 90.0% humidity, 0 mph W wind, 0.01 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net