<commit_before>/* <NAME>
 * 
 * Javascript to manage what's going on with the playqueue
 *  --Largely based off browser class for now
 *
 *  Updated 11/6/07 (r43) to support ExtJS --JMT
 *
 *  FIXME:Major unresolved issue -- when removing tree rows, queuestore is not
 *  currently updated to reflect the fact that the song has been removed!
 */

function PlayQueue(domObj, dragGroup, fields)
{
    var fields = fields;
    var div = Ext.get(domObj);
    var queue = new Ext.dd.DropTarget(div);
    queue.addToGroup("GridDD"); //This is undocumented, but necessary!


    this.addEvents({
        "newsong" : true
    });

    var npt = new Ext.Template(
        '<div name="np">',
            '<span id="np-title">{title}</span>',
            '<span id="np-info">{info}</span>',
        '</div');


    var instructions = new Ext.Template(
            '<div id="instruction" class="instruction">',
                    'Drag here to add songs',
                    '<br>-OR-<br>',
                    'Hit the <img class="middle" src="/images/enqueue.png" /> button',
            '</div>');

	
    instructions.overwrite(div);
    clear = true;

    //This stores every song that's ever been put in the queue.
    //The tree manages the look, this manages the actual data
    queueStore = new Ext.data.SimpleStore({fields:fields});

    viewData = new Ext.util.MixedCollection();

    this.queue = queueStore;
    var nowplaying = -1;

    Tree = Ext.tree;
    var tree = new Tree.TreePanel(div, {
                animate:true,
                enableDD:true,
                fitToContainer:true,
                rootVisible:false,
				containerScroll:true
            });
    root = new Tree.AsyncTreeNode({
        text:'queue', 
        draggable:false, 
        id:'source'
    });
    tree.setRootNode(root);

    queue.notifyDrop = dropAction;

    function newNode(title, id, leaf)
    {
        nodeConfig = {
            text:title, 
            id:id,
            leaf: leaf,
            cls: "x-tree-noicon",
            allowDrop: false
        }
        var nn = new Tree.AsyncTreeNode(nodeConfig);
        return nn;
    }
        
    function dropAction(source, e, data)
    {
        for (var i =0; i<data.selections.length; i++) {
            addRecord(data.selections[i]);
        }
    }

    function makeViewId(records, insert)
    {
        newViewNode = {
            start: queueStore.getAt(queueStore.getCount()-records.length),
            end: queueStore.getAt(queueStore.getCount()-1)
        };

        id = Ext.id(); 
        if (insert)
            viewData.insert(0, id, newViewNode);
        else
            viewData.add(id, newViewNode);

        queueStore.add(records);

        return id;
    }


    this.getTree = getTree;
    function getTree()
    {
        return tree;
    }

    this.addRecord = addRecord;
    function addRecord(newRow)
    {<commit_msg>[svn] fixed a playqueue bug<commit_after>/* <NAME>
 * 
 * Javascript to manage what's going on with the playqueue
 *  --Largely based off browser class for now
 *
 *  Updated 11/6/07 (r43) to support ExtJS --JMT
 *
 *  FIXME:Major unresolved issue -- when removing tree rows, queuestore is not
 *  currently updated to reflect the fact that the song has been removed!
 */

function PlayQueue(domObj, dragGroup, fields)
{
    var fields = fields;
    var div = Ext.get(domObj);
    var queue = new Ext.dd.DropTarget(div);
    queue.addToGroup("GridDD"); //This is undocumented, but necessary!


    this.addEvents({
        "newsong" : true
    });

    var npt = new Ext.Template(
        '<div name="np">',
            '<span id="np-title">{title}</span>',
            '<span id="np-info">{info}</span>',
        '</div');


    var instructions = new Ext.Template(
            '<div id="instruction" class="instruction">',
                    'Drag here to add songs',
                    '<br>-OR-<br>',
                    'Hit the <img class="middle" src="/images/enqueue.png" /> button',
            '</div>');

	
    instructions.overwrite(div);
    clear = true;

    //This stores every song that's ever been put in the queue.
    //The tree manages the look, this manages the actual data
    queueStore = new Ext.data.SimpleStore({fields:fields});

    viewData = new Ext.util.MixedCollection();

    this.queue = queueStore;
    var nowplaying = -1;

    Tree = Ext.tree;
    var tree = new Tree.TreePanel(div, {
                animate:true,
                enableDD:true,
                fitToContainer:true,
                rootVisible:false,
				containerScroll:true
            });
    root = new Tree.AsyncTreeNode({
        text:'queue', 
        draggable:false, 
        id:'source'
    });
    tree.setRootNode(root);

    queue.notifyDrop = dropAction;

    function newNode(title, id, leaf)
    {
        nodeConfig = {
            text:title, 
            id:id,
            leaf: leaf,
            cls: "x-tree-noicon",
            allowDrop: false
        }
        var nn = new Tree.AsyncTreeNode(nodeConfig);
        return nn;
    }
        
    function dropAction(source, e, data)
    {
        for (var i =0; i<data.selections.length; i++) {
            addRecord(data.selections[i]);
        }
    }

    function makeViewId(records, insert)
    {
        if (insert)
            queueStore.insert(0,records);
        else
            queueStore.add(records);

        var newViewNode = {
            start: queueStore.getAt(queueStore.getCount()-records.length),
            end: queueStore.getAt(queueStore.getCount()-1)
        };

        id = Ext.id(); 
        if (insert)
            viewData.insert(0, id, newViewNode);
        else
            viewData.add(id, newViewNode);

        return id;
    }


    this.getTree = getTree;
    function getTree()
    {
        return tree;
    }

    this.addRecord = addRecord;
    function addRecord(newRow)
    {
{'fraction_non_alphanumeric': 0.12154602474995763, 'fraction_numerical': 0.0038989659264282083, 'mean_word_length': 1.8766455387615797, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6721051', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1724, 'n_words': 443}