Jump to content

Save Group Power Inputs


Tunes

Recommended Posts

  • Members

I'm surprised this wasn't thought of originally but it's tedious to have to input values every single time you assign a group power. I should be able to save a list of values for use later, like as a default but with a list of them. This would be helpful because I have only one (lang) power, but it makes me not want to switch the power to another group because that means I have to re-list every value again but I also don't want to buy another (lang) power. There are ~269 values for (lang) power. No one wants to sit through and do a bunch of those for each time they re-assign it. The feature should work similarly to this:

 

The save button should be next to the 'OK' button. When you click it, you are prompted to title it for easy identification when you use it again.

The current 'Default' button should be replaced with a dropdown menu. When you click it, you are prompted to choose one of the saved values in addition to the default values that were created by xat. You should then receive another prompt saying: 'Are you sure you would like to load [...]?'

 

This should also apply to powers with a list of values, such as (gcontrol), (link), (bad), (gsound), and any other powers that I missed that work similarly to the ones listed. 

  • Award 2
Link to comment
Share on other sites

  • Wiki Editors

It's definitely not user-friendly to have to manually input values every time you want to move a group power into a new chat. xat should add an "Export/Import" button in order to allow users to reuse their old preferences. This would also allow chat owners to let guests/members/moderators/owners contribute to their group settings by simply importing a file rather than having to process each change manually or make them a main owner.

  • Award 3
Link to comment
Share on other sites

  • Members
2 hours ago, Arthur said:

It's definitely not user-friendly to have to manually input values every time you want to move a group power into a new chat. xat should add an "Export/Import" button in order to allow users to reuse their old preferences. This would also allow chat owners to let guests/members/moderators/owners contribute to their group settings by simply importing a file rather than having to process each change manually or make them a main owner.

An export/import button would be perfect actually. That would make things so much easier. 

Link to comment
Share on other sites

  • Advanced Members

I got bored and created a user script that does exactly this. Have fun I guess.

Spoiler

// ==UserScript==
// @name         xat Lang tools
// @version      1.0
// @description  xat Lang exporter and importer
// @author       Daniel
// @match        https://xat.com/web_gear/chat/GroupOptionEdit.php*
// @grant        none
// @require      http://code.jquery.com/jquery-3.3.1.slim.min.js
// ==/UserScript==

function main() {
    //Add buttons
    $('body').prepend('<h1>Export/Import</h1><p id="langmsg"></p><button type="button" onclick="exportLang()">Export</button> <input type="button" value="Import" onclick="document.getElementById(\'file\').click();" /><input type="file" style="display:none;" id="file" name="file" onchange="importLang();" accept=".xatlang"/><br/><h1>Lang settings</h1>');

    //Inject functions
    var script = document.createElement("script");
    script.textContent += exportLang.toString() + "\n";
    script.textContent += importLang.toString() + "\n";
    document.body.appendChild(script);
}

function exportLang() {
    exportObj = {};

    $("tr").each(function() {
        var input = $(this).find("input");
        var value = input.val();

        if(value == undefined) {
            return true;
        }

        var id = input.attr('id');

        if (value.trim()) {
            exportObj[id] = value;
        }
    });

    if(Object.keys(exportObj).length < 1){
        $('#langmsg').text("No options to export.");
    }
    else{
        data = encodeURI("data:text/json;charset=utf-8," + JSON.stringify(exportObj));

        url = new URL(window.location.href);
        searchParams = new URLSearchParams(url.search);
        roomid  = searchParams.get('roomid');

        link = document.createElement('a');
        link.setAttribute('href', data);
        link.setAttribute('download', roomid + '.xatlang');
        link.click();
        link.remove();
    }
}

function importLang() {
    var $i = $( '#file' ), input = $i[0];

    if (input.files && input.files[0]) {
        file = input.files[0];
        fr = new FileReader();
        fr.readAsText(file);
        fr.onload = function () {
            data = JSON.parse(fr.result);

            for (var key in data) {
                $("#" + key).val(data[key]);
            }
        };
    } else {
        alert( "File not selected or browser incompatible.");
    }
}

if (/\bid=206\b/.test (location.search) ) {
    main();
}

 

 

That one xat browser extension could add things like this.

Edited by Daniel
  • Award 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.