<commit_before>/**
 * # ChannelList widget for nodeGame
 * Copyright(c) 2013 <NAME>
 * MIT Licensed
 *
 * Shows current, previous and next state.
 *
 * www.nodegame.org
 * ---
 */
(function(node) {

    "use strict";

    node.widgets.register('ChannelList', ChannelList);

    var JSUS = node.JSUS,
    Table = node.window.Table;

    // ## Defaults

    ChannelList.defaults = {};
    ChannelList.defaults.id = 'channellist';
    ChannelList.defaults.fieldset = {
        legend: 'Channels',
        id: 'channellist_fieldset'
    };

    // ## Meta-data

    ChannelList.version = '0.1.0';
    ChannelList.description = 'Visually display all channels on the server.';

    // ## Dependencies

    ChannelList.dependencies = {
        JSUS: {},
        Table: {}
    };

    function renderCell(o) {
        var content;
        var text, textElem;

        content = o.content;
        textElem = document.createElement('span');
        if ('object' === typeof content) {
            switch (o.x) {
            case 0:
                text = content.name;
                break;

            case 1:
                text = '' + content.nGameRooms;
                break;

            case 2:
                text = content.nConnClients +
                       ' (+' + content.nDisconnClients + ')';
                break;

            case 3:
                text = content.nConnPlayers +
                       ' (+' + content.nDisconnPlayers + ')';
                break;

            case 4:
                text = content.nConnAdmins +
                       ' (+' + content.nDisconnAdmins + ')';
                break;
            }

            textElem.appendChild(document.createTextNode(text));
            textElem.onclick = function() {
                alert(content.name);
            };
        }
        else {
            textElem = document.createTextNode(content);
        }

        return textElem;
    }

    function ChannelList(options) {
        this.id = options.id;

        this.root = null;
        this.table = new Table({
            render: {
                pipeline: renderCell,
                returnAt: 'first'
            }
        });

        // Create header:
        this.table.setHeader(['Name', '# Rooms',
                              '# Clients, Connected (+ Disconnected)',
                              '# Players', '# Admins']);
    }

    ChannelList.prototype.getRoot = function() {
        return this.root;
    };

    ChannelList.prototype.append = function(root, ids) {
        root.appendChild(this.table.table);

        // Ask server for channel list:
        node.socket.send(node.msg.create({
            target: 'SERVERCOMMAND',
            text:   'INFO',
            data: {
                type:      'CHANNELS',
                extraInfo: true
            }<commit_msg>Added tooltips to ChannelList<commit_after>/**
 * # ChannelList widget for nodeGame
 * Copyright(c) 2013 <NAME>
 * MIT Licensed
 *
 * Shows current, previous and next state.
 *
 * www.nodegame.org
 * ---
 */
(function(node) {

    "use strict";

    node.widgets.register('ChannelList', ChannelList);

    var JSUS = node.JSUS,
    Table = node.window.Table;

    // ## Defaults

    ChannelList.defaults = {};
    ChannelList.defaults.id = 'channellist';
    ChannelList.defaults.fieldset = {
        legend: 'Channels',
        id: 'channellist_fieldset'
    };

    // ## Meta-data

    ChannelList.version = '0.1.0';
    ChannelList.description = 'Visually display all channels on the server.';

    // ## Dependencies

    ChannelList.dependencies = {
        JSUS: {},
        Table: {}
    };

    function renderCell(o) {
        var content;
        var text, textElem;

        content = o.content;
        if ('object' === typeof content) {
            switch (o.x) {
            case 0:
                text = content.name;
                break;

            case 1:
                text = '' + content.nGameRooms;
                break;

            case 2:
                text = content.nConnClients +
                       ' (+' + content.nDisconnClients + ')';
                break;

            case 3:
                text = content.nConnPlayers +
                       ' (+' + content.nDisconnPlayers + ')';
                break;

            case 4:
                text = content.nConnAdmins +
                       ' (+' + content.nDisconnAdmins + ')';
                break;
            }

            textElem = document.createElement('span');
            textElem.appendChild(document.createTextNode(text));
            textElem.onclick = function() {
                alert(content.name);
            };

            if (o.x >= 2) {  // number of clients/players/admins
                textElem.title = 'Connected (+ Disconnected)';
            }
        }
        else {
            textElem = document.createTextNode(content);
        }

        return textElem;
    }

    function ChannelList(options) {
        this.id = options.id;

        this.root = null;
        this.table = new Table({
            render: {
                pipeline: renderCell,
                returnAt: 'first'
            }
        });

        // Create header:
        this.table.setHeader(['Name', '# Rooms',
                              '# Clients', '# Players', '# Admins']);
    }

    ChannelList.prototype.getRoot = function() {
        return this.root;
    };

    ChannelList.prototype.append = function(root, ids) {
        root.appendChild(this.table.table);

        // Ask server for channel list:
        node.socket.send(node.msg.create({
            target: 'SERVERCOMMAND',
            text:   'INFO',
            data: {
                type:      'CHANNELS',
                extraInfo: true
            }
{'fraction_non_alphanumeric': 0.1193073593073593, 'fraction_numerical': 0.004329004329004329, 'mean_word_length': 1.3730484798685292, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2255399', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1525, 'n_words': 312}