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'; 'use strict';
/* global debug: false */
/* global page_generic: false */
// function to get all files in on click // function to get all files in on click
// event comes from HTML // event comes from HTML
function download_all(div_id) { function download_all(div_id) {
...@@ -66,6 +69,7 @@ function Page_Distrubion(socket) { ...@@ -66,6 +69,7 @@ function Page_Distrubion(socket) {
var view = Utils.from_hash_to_view(); var view = Utils.from_hash_to_view();
var sidebarOffset = 0; var sidebarOffset = 0;
var new_lines = []; var new_lines = [];
var current_file_in_preview = false;
function __check_hash_makes_sense() { function __check_hash_makes_sense() {
if (window.location.hash.indexOf('..') >= 0) { if (window.location.hash.indexOf('..') >= 0) {
...@@ -100,6 +104,7 @@ function Page_Distrubion(socket) { ...@@ -100,6 +104,7 @@ function Page_Distrubion(socket) {
label += ' <a class="btn btn-link btn-lg" title="Download" href="' + view.file.path + '"> ' + label += ' <a class="btn btn-link btn-lg" title="Download" href="' + view.file.path + '"> ' +
'<span class="glyphicon glyphicon-download-alt"></span></a>'; '<span class="glyphicon glyphicon-download-alt"></span></a>';
if (config.file.preview.indexOf(view.file.name) >= 0) { 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>'); 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>'); view_all.html('<span class="glyphicon glyphicon-eye-open"></span>');
label += view_all.get(0).outerHTML; label += view_all.get(0).outerHTML;
...@@ -230,7 +235,7 @@ function Page_Distrubion(socket) { ...@@ -230,7 +235,7 @@ function Page_Distrubion(socket) {
// update html // update html
socket_data.package.sources.forEach(function (f) { socket_data.package.sources.forEach(function (f) {
$('#sources ul').append('<li><a title="' + f.orig_name + '" href="' + f.path + '">' + f.name + '</a></li>'); $('#sources ul').append('<li><a title="' + f.orig_name + '" href="' + f.path + '">' + f.name + '</a></li>');
}) });
$('#sources').show(); $('#sources').show();
} }
files.show(); files.show();
...@@ -284,7 +289,15 @@ function Page_Distrubion(socket) { ...@@ -284,7 +289,15 @@ function Page_Distrubion(socket) {
}, },
append: function (new_content) { append: function (new_content) {
var content = $('#file pre'); var content = $('#file pre');
if (!current_file_in_preview) {
content.append(new_content); 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) { if (config.preferences.autoscroll) {
// scroll down if file is covering footer // 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