<commit_before>/**
 *
 * @desc code to build HTML user interface for /{PNAME}/file endpoint
 * @author <NAME> <<EMAIL>>
 * @date 11 Feb. 2020
 *
 */
'use strict'

var toolbar = document.createElement('div');
toolbar.setAttribute('id', 'toolbar');
var pname = document.createElement('div');
pname.setAttribute('class', 'pname');
toolbar.appendChild(pname);

var pagetools = document.createElement('div');
pagetools.setAttribute('class', 'pagetools');
toolbar.appendChild(pagetools);

var pageinfo = document.createElement('div');
pageinfo.setAttribute('class', 'pageinfo');
toolbar.appendChild(pageinfo);

var content = document.createElement('div');
content.setAttribute('id', 'content');
var file_panel = document.createElement('div');
file_panel.setAttribute('class', 'file_panel');
var file_metadata = document.createElement('div');
file_metadata.setAttribute('class', 'file_metadata');
var file_content = document.createElement('div');
file_content.setAttribute('class', 'file_content');
var region_metadata = document.createElement('div');
region_metadata.setAttribute('class', 'region_metadata');

file_panel.appendChild(file_metadata);
file_panel.appendChild(file_content);
file_panel.appendChild(region_metadata);
content.appendChild(file_panel);

document.body.appendChild(toolbar);
document.body.appendChild(content);

var query_img;
var via_img_annotator;
var query_img_container = document.createElement('div');
query_img_container.setAttribute('id', 'query_img_container');

var query_img_container_height = 65;

// update the search result when browser is resized
// this is required as the image size changes and hence the bounding box needs update
window.addEventListener('resize', _vise_init_file_panel);

// check existence of everything we need
if( !_vise_self_check_is_ok()) {
  console.log('self check failed');
} else {
  var pname_link = document.createElement('a');
  pname_link.setAttribute('href', 'filelist');
  pname_link.setAttribute('title', 'Home of ' + _vise_data.PNAME + ' project');
  pname_link.innerHTML = _vise_data.PNAME;

  pname.innerHTML = '';
  pname.appendChild(pname_link);

  document.title = _vise_data.PNAME;
  _vise_init_file_panel();
}

function _vise_self_check_is_ok() {
  if( typeof(_vise_data) === 'object' ) {
    return true;
  }
  return false;
}

function _vise_init_file_panel() {
  _vise_set_project_pagetools(pagetools);
  _vise_init_query_toolbar();
  _vise_init_query_file_metadata();
  _vise_init_query_file_content();
  _vise_init_query_region_metadata();
}

function _vise_init_query_toolbar() {
  var sep = document.createElement('div');
  sep.innerHTML = '&nbsp;|&nbsp;';

  var fileinfo = document.createElement('div');
  fileinfo.innerHTML = 'Showing file ' + _vise_data.FILE_ID + ' of ' + _vise_data.FLIST_SIZE + ' | <a target="_blank" href="' + _vise_data.FILENAME + '">' + _vise_data.FILENAME + '</a>';

  var list = document.createElement('a');
  list.setAttribute('href', 'filelist?start=' + _vise_data.FILE_ID);
  list.innerHTML = 'List';

  var prev;
  if(_vise_data.FILE_ID === 0) {
    prev = document.createElement('span');
  } else {
    prev = document.createElement('a');
    prev.setAttribute('href', 'file?file_id=' + (_vise_data.FILE_ID-1));
  }
  prev.innerHTML = 'Prev';

  var next;
  if(_vise_data.FILE_ID === (_vise_data.FLIST_SIZE-1)) {
    next = document.createElement('span');
  } else {
    next = document.createElement('a');
    next.setAttribute('href', 'file?file_id=' + (_vise_data.FILE_ID+1));
  }
  next.innerHTML = 'Next';

  var nav = document.createElement('div');
  nav.appendChild(list);
  nav.appendChild(sep.cloneNode(true));<commit_msg>fixed broken link to image in /file?file_id=XX endpoint<commit_after>/**
 *
 * @desc code to build HTML user interface for /{PNAME}/file endpoint
 * @author <NAME> <<EMAIL>>
 * @date 11 Feb. 2020
 *
 */
'use strict'

var toolbar = document.createElement('div');
toolbar.setAttribute('id', 'toolbar');
var pname = document.createElement('div');
pname.setAttribute('class', 'pname');
toolbar.appendChild(pname);

var pagetools = document.createElement('div');
pagetools.setAttribute('class', 'pagetools');
toolbar.appendChild(pagetools);

var pageinfo = document.createElement('div');
pageinfo.setAttribute('class', 'pageinfo');
toolbar.appendChild(pageinfo);

var content = document.createElement('div');
content.setAttribute('id', 'content');
var file_panel = document.createElement('div');
file_panel.setAttribute('class', 'file_panel');
var file_metadata = document.createElement('div');
file_metadata.setAttribute('class', 'file_metadata');
var file_content = document.createElement('div');
file_content.setAttribute('class', 'file_content');
var region_metadata = document.createElement('div');
region_metadata.setAttribute('class', 'region_metadata');

file_panel.appendChild(file_metadata);
file_panel.appendChild(file_content);
file_panel.appendChild(region_metadata);
content.appendChild(file_panel);

document.body.appendChild(toolbar);
document.body.appendChild(content);

var query_img;
var via_img_annotator;
var query_img_container = document.createElement('div');
query_img_container.setAttribute('id', 'query_img_container');

var query_img_container_height = 65;

// update the search result when browser is resized
// this is required as the image size changes and hence the bounding box needs update
window.addEventListener('resize', _vise_init_file_panel);

// check existence of everything we need
if( !_vise_self_check_is_ok()) {
  console.log('self check failed');
} else {
  var pname_link = document.createElement('a');
  pname_link.setAttribute('href', 'filelist');
  pname_link.setAttribute('title', 'Home of ' + _vise_data.PNAME + ' project');
  pname_link.innerHTML = _vise_data.PNAME;

  pname.innerHTML = '';
  pname.appendChild(pname_link);

  document.title = _vise_data.PNAME;
  _vise_init_file_panel();
}

function _vise_self_check_is_ok() {
  if( typeof(_vise_data) === 'object' ) {
    return true;
  }
  return false;
}

function _vise_init_file_panel() {
  _vise_set_project_pagetools(pagetools);
  _vise_init_query_toolbar();
  _vise_init_query_file_metadata();
  _vise_init_query_file_content();
  _vise_init_query_region_metadata();
}

function _vise_init_query_toolbar() {
  var sep = document.createElement('div');
  sep.innerHTML = '&nbsp;|&nbsp;';

  var fileinfo = document.createElement('div');
  fileinfo.innerHTML = 'Showing file ' + _vise_data.FILE_ID + ' of ' + _vise_data.FLIST_SIZE + ' | <a target="_blank" href="image/' + _vise_data.FILENAME + '">' + _vise_data.FILENAME + '</a>';

  var list = document.createElement('a');
  list.setAttribute('href', 'filelist?start=' + _vise_data.FILE_ID);
  list.innerHTML = 'List';

  var prev;
  if(_vise_data.FILE_ID === 0) {
    prev = document.createElement('span');
  } else {
    prev = document.createElement('a');
    prev.setAttribute('href', 'file?file_id=' + (_vise_data.FILE_ID-1));
  }
  prev.innerHTML = 'Prev';

  var next;
  if(_vise_data.FILE_ID === (_vise_data.FLIST_SIZE-1)) {
    next = document.createElement('span');
  } else {
    next = document.createElement('a');
    next.setAttribute('href', 'file?file_id=' + (_vise_data.FILE_ID+1));
  }
  next.innerHTML = 'Next';

  var nav = document.createElement('div');
  nav.appendChild(list);
  nav.appendChild(sep.cloneNode(true));
{'fraction_non_alphanumeric': 0.14986376021798364, 'fraction_numerical': 0.0032697547683923707, 'mean_word_length': 6.072254335260116, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '886968', 'n_tokens_mistral': 2372, 'n_tokens_neox': 2358, 'n_words': 444}