<commit_before>
var Queue = { 
	manualList: [],
    autoList: [],
    manualPlayIndex: null,
    autoPlayIndex: null,
    init: function() {
    
    },
    addManual: function(video) {
        Queue.manualList.push(video);  
        Queue.updateView();
    },
    setAutoQueue: function(videoList) {
        Queue.autoPlayIndex = 0;
        Queue.autoList = videoList;
        Queue.updateView();
    },
    manualPlay: function(index) {
        console.log('manual ' + index);
        if (Queue.manualList.length === 0) {
            return false;
        }
        
        if (index < 0 || index > Queue.manualList.length -1) {
            return false;
        } else {
            Queue.manualPlayIndex = index;
        }
        Queue.manualList[Queue.manualPlayIndex].play();
        Queue.autoPlayIndex = null;
        Queue.updateView();
        return true;
    },
    autoPlay: function(index) {
        console.log('auto ' + index);
        if (Queue.autoList.length === 0) {
            return false;
        }
        
        if (index < 0 || index > Queue.autoList.length -1) {
            return false;
        } else {
            Queue.autoPlayIndex = index;
        }
        Queue.autoList[Queue.autoPlayIndex].play();
        Queue.updateView();
        return true;
    },
    playNext: function() {
        if ((Queue.manualList.length + Queue.autoList.length) === 0) {
            return false;
        }
        
        if (Queue.manualList.length > 0 && Queue.manualPlayIndex === null) {
            return Queue.manualPlay(0);
        } else if (Queue.manualList.length > 0 && Queue.manualPlayIndex + 1 < Queue.manualList.length) {
            return Queue.manualPlay(Queue.manualPlayIndex + 1);
        } else if (Queue.autoList.length > 0 && Queue.autoPlayIndex === null) {
            return Queue.autoPlay(0);
        } else if (Queue.autoList.length > 0 && Queue.autoPlayIndex + 1 < Queue.autoList.length) {
            return Queue.autoPlay(Queue.autoPlayIndex + 1);
        } else {
            return false;
        }
    },
    playPrev: function() {
        if ((Queue.manualList.length + Queue.autoList.length) === 0) {
            return false;
        }
        
        if (Queue.autoPlayIndex !== null && Queue.autoPlayIndex > 0) {
            return Queue.autoPlay(Queue.autoPlayIndex - 1);
        } else if (Queue.autoPlayIndex !== null && Queue.autoPlayIndex === 0) {
            return Queue.manualPlay(Queue.manualList.length - 1);
        } else if (Queue.manualPlayIndex !== null && Queue.manualPlayIndex > 0) {
            return Queue.manualPlay(Queue.manualPlayIndex - 1);
        } else {
            return false;
        }
    },
	updateView: function() {
        var view = Menu.find('queue').findTab('queue').paneView;
        
        view.html('');
        $.each(Queue.manualList, function(index, video) {
			var clone = video.listView.clone(),
                play = function() {
                    Queue.manualPlay(index);
                };
            
            /* Clean */
            clone.removeClass('selected').removeClass('playing');
            
            /* Is Playing? */
            if (index === Queue.manualPlayIndex && Queue.autoPlayIndex === null) {
                clone.addClass('playing');
            }
                        
            /* Bind actions */
            clone.dblclick(play);
            clone.find('.play').click(play);
            
            /* Only display the last 3 */
            if (Queue.manualPlayIndex !== null && index - Queue.manualPlayIndex < -2) {
                clone.hide();
            }
            clone.appendTo(view);
		});
        $.each(Queue.autoList, function(index, video) {
			var clone = video.listView.clone(),
                play = function() {
                    Queue.autoPlay(index);
                };
            
            /* Clean */
            clone.removeClass('selected').removeClass('playing');
            
            /* Is Playing? */
            if (index === Queue.autoPlayIndex) {
                clone.addClass('playing');
            }
                        
            /* Bind actions */
            clone.dblclick(play);
            clone.find('.play').click(play);
            
            clone.appendTo(view);
		});
	}
};<commit_msg>Made queue items draggable. Closes #76<commit_after>var Queue = { 
	manualList: [],
    autoList: [],
    manualPlayIndex: null,
    autoPlayIndex: null,
    init: function() {
    
    },
    addManual: function(video) {
        Queue.manualList.push(video);  
        Queue.updateView();
    },
    setAutoQueue: function(videoList) {
        Queue.autoPlayIndex = 0;
        Queue.autoList = videoList;
        Queue.updateView();
    },
    manualPlay: function(index) {
        console.log('manual ' + index);
        if (Queue.manualList.length === 0) {
            return false;
        }
        
        if (index < 0 || index > Queue.manualList.length -1) {
            return false;
        } else {
            Queue.manualPlayIndex = index;
        }
        Queue.manualList[Queue.manualPlayIndex].play();
        Queue.autoPlayIndex = null;
        Queue.updateView();
        return true;
    },
    autoPlay: function(index) {
        console.log('auto ' + index);
        if (Queue.autoList.length === 0) {
            return false;
        }
        
        if (index < 0 || index > Queue.autoList.length -1) {
            return false;
        } else {
            Queue.autoPlayIndex = index;
        }
        Queue.autoList[Queue.autoPlayIndex].play();
        Queue.updateView();
        return true;
    },
    playNext: function() {
        if ((Queue.manualList.length + Queue.autoList.length) === 0) {
            return false;
        }
        
        if (Queue.manualList.length > 0 && Queue.manualPlayIndex === null) {
            return Queue.manualPlay(0);
        } else if (Queue.manualList.length > 0 && Queue.manualPlayIndex + 1 < Queue.manualList.length) {
            return Queue.manualPlay(Queue.manualPlayIndex + 1);
        } else if (Queue.autoList.length > 0 && Queue.autoPlayIndex === null) {
            return Queue.autoPlay(0);
        } else if (Queue.autoList.length > 0 && Queue.autoPlayIndex + 1 < Queue.autoList.length) {
            return Queue.autoPlay(Queue.autoPlayIndex + 1);
        } else {
            return false;
        }
    },
    playPrev: function() {
        if ((Queue.manualList.length + Queue.autoList.length) === 0) {
            return false;
        }
        
        if (Queue.autoPlayIndex !== null && Queue.autoPlayIndex > 0) {
            return Queue.autoPlay(Queue.autoPlayIndex - 1);
        } else if (Queue.autoPlayIndex !== null && Queue.autoPlayIndex === 0) {
            return Queue.manualPlay(Queue.manualList.length - 1);
        } else if (Queue.manualPlayIndex !== null && Queue.manualPlayIndex > 0) {
            return Queue.manualPlay(Queue.manualPlayIndex - 1);
        } else {
            return false;
        }
    },
	updateView: function() {
        var view = Menu.find('queue').findTab('queue').paneView;
        
        view.html('');
        $.each(Queue.manualList, function(index, video) {
			var clone = video.listView.clone(),
                play = function() {
                    Queue.manualPlay(index);
                };
            
            /* Clean */
            clone.removeClass('selected').removeClass('playing');
            
            /* Is Playing? */
            if (index === Queue.manualPlayIndex && Queue.autoPlayIndex === null) {
                clone.addClass('playing');
            }
                        
            /* Bind actions */
            clone.dblclick(play);
            clone.find('.play').click(play);
            
            /* Only display the last 3 */
            if (Queue.manualPlayIndex !== null && index - Queue.manualPlayIndex < -2) {
                clone.hide();
            }
            clone.appendTo(view);
		});
        $.each(Queue.autoList, function(index, video) {
			var clone = video.listView.clone(),
                play = function() {
                    Queue.autoPlay(index);
                };
            
            /* Clean */
            clone.removeClass('selected').removeClass('playing');
            
            /* Is Playing? */
            if (index === Queue.autoPlayIndex) {
                clone.addClass('playing');
            }
                        
            /* Bind actions */
            clone.dblclick(play);
            clone.find('.play').click(play);
            
            /* Make movable */
            clone.data('model', video);
            clone.addClass('draggable');
            
            clone.appendTo(view);
		});
	}
};
{'fraction_non_alphanumeric': 0.13089124728974097, 'fraction_numerical': 0.006390505534634257, 'mean_word_length': 1.5227403569372482, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '7102439', 'n_tokens_mistral': 2557, 'n_tokens_neox': 2383, 'n_words': 447}