add_paper.js 3.7 KB
Newer Older
Myriam Guedey's avatar
Myriam Guedey committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var item_debug
var item_id = 0
function addpaper(item) {
  var new_row = document.getElementById("cont_paper")

  if (item === undefined) {

  } else {
    item_debug = item
    var authors = "";
    for (var i = 0; i < item.item.authors.length; i++) {
      authors += item.item.authors[i].lastName + ", " + item.item.authors[i].firstName.substring(0, 1) + "., "
      //Do something
    }
    var keywords = "";
    // check if there is keywords in item
    if (item.item.keywords !== undefined) {
      for (var i = 0; i < item.item.keywords.length; i++) {
        keywords += '<span class="badge badge-pill badge-light">' + item.item.keywords[i] + '</span>'
        //Do something
      }
    }

    authors = authors.substring(0, authors.length - 2);
    last_item = item
    var PDF_HTML = ''

    var PDF_HTML = item.links.pdf != "" ? `<a type="button" href="${item.links.pdf}" class="btn btn-outline-success btn-circle" target="_blank">  <i class="far fa-file-pdf"> </i></a>  PDF ` : ""
    var UrlHTML = ''
    if ('url' in item.links) { // to be replaced by if (item.YouTubelink) or so...
      var url = item.links.url // to be replaced by item.pdf or so...
      UrlHTML = `<a type="button" href="${url}" class="btn btn-outline-info btn-circle" target="_blank"> <i class="fas fa-globe"></i> </a> Link `
    }
    // Do Authors and Keywords
    var doi = ""
    if ('journal' in item.item) {
      doi += '<small class="text-muted"> '
      doi += item.item.conference.name && item.item.journal.name != "" ? item.item.journal.name + ' ' : ""
      doi += item.item.conference.volume && item.item.journal.volume != "" ? item.item.journal.volume + ' ' : ""
      doi += item.item.conference.pages && item.item.journal.pages != "" ? item.item.journal.pages + ' ' : ""
      doi += item.item.conference.DOI && item.item.DOI != "" && item.item.DOI != undefined ? item.item.journal.DOI + ' ' : ""
      doi += `</small>`
    }
    if ('conference' in item.item) {
      doi += '<small class="text-muted"> '
      doi += item.item.conference.name && item.item.conference.name != "" ? item.item.conference.name + ' ' : ""
      doi += item.item.conference.date && item.item.conference.date != "" ? item.item.conference.date + ' ' : ""
      doi += item.item.conference.DOI && item.item.conference.DOI != "" ? item.item.conference.DOI + ' ' : ""
      doi += `</small>`

    }
    item_id += 1
    var bibtex_content = item.bibtex ? `<button type="button" class="btn btn-outline-danger btn-circle" data-toggle="collapse" data-target="#bibtex-paper-vision-${item_id}" aria-expanded="false" aria-controls="bibtex-paper-vision-${item_id}"> <i class="fas fa-code"></i> </button> Bib <pre id="bibtex-paper-vision-${item_id}" class="pre-style collapse">${item.bibtex}</pre>` : ""
    new_row.innerHTML = new_row.innerHTML + '<div class="card" style="max-width: 1080px;">' +
      '<div class="row publication_card g-0">' +
      '<div class="col-md-3">' +
      '<img src="' + item.item.imageLink + '" alt="..." style="width:100%">' +
      '</div>' +
      '<div class="col-md-9">' +
      '<div class="card-body">' +
      '<h5 class="card-title" style="margin-bottom:0px">' +
      '<small>' + authors + '</small>' +
      '<br>' +
      item.item.title +
      '<br>' +
      '<small>' +
      keywords +
      '</small>' +
      '</h5>' +
      doi +
      '<br>' +
      PDF_HTML + ' ' +
      //BIBTEX BUTTON'<button type="button" class="btn btn-outline-danger btn-circle" data-toggle="collapse" data-target="#bibtex-paper-vision" aria-expanded="false" aria-controls="bibtex-paper-vision"> <i class="fas fa-code"></i> </button>BIB' +

      UrlHTML +
      '</small>' +

      // BIBTEX area
      bibtex_content +

      '</div>' +
      '</div>' +
      '</div>' +
      '</div>'

  }
}