Commit ad5866e1 authored by Leo Iannacone's avatar Leo Iannacone

show only num_lines when file is in preview - also when receive new data

parent 4c36d7fd
'use strict';
/* global debug: false */
/* global page_generic: false */
// function to get all files in on click
// event comes from HTML
function download_all(div_id) {
......@@ -66,6 +69,7 @@ function Page_Distrubion(socket) {
var view = Utils.from_hash_to_view();
var sidebarOffset = 0;
var new_lines = [];
var current_file_in_preview = false;
function __check_hash_makes_sense() {
if (window.location.hash.indexOf('..') >= 0) {
......@@ -100,6 +104,7 @@ function Page_Distrubion(socket) {
label += ' <a class="btn btn-link btn-lg" title="Download" href="' + view.file.path + '"> ' +
'<span class="glyphicon glyphicon-download-alt"></span></a>';
if (config.file.preview.indexOf(view.file.name) >= 0) {
current_file_in_preview = true;
var view_all = $('<a id="get-whole-file" class="btn btn-link btn-lg" title="View the whole file"></a>');
view_all.html('<span class="glyphicon glyphicon-eye-open"></span>');
label += view_all.get(0).outerHTML;
......@@ -230,7 +235,7 @@ function Page_Distrubion(socket) {
// update html
socket_data.package.sources.forEach(function (f) {
$('#sources ul').append('<li><a title="' + f.orig_name + '" href="' + f.path + '">' + f.name + '</a></li>');
})
});
$('#sources').show();
}
files.show();
......@@ -284,7 +289,15 @@ function Page_Distrubion(socket) {
},
append: function (new_content) {
var content = $('#file pre');
content.append(new_content);
if (!current_file_in_preview) {
content.append(new_content);
} else {
// always show only config.file.num_lines lines in preview
content = content.html().replace(/\n$/, '').split('\n');
content = content.concat(new_content.replace(/\n$/, '').split('\n'));
content = content.slice(-config.file.num_lines).join('\n');
$('#file pre').html(content);
}
if (config.preferences.autoscroll) {
// scroll down if file is covering footer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment