Skip to content

Commit 82e7102

Browse files
committed
improved shelfmark layout
1 parent 99be160 commit 82e7102

5 files changed

Lines changed: 146 additions & 33 deletions

File tree

signaturenDruck/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</div>
4242
<div id="container">
4343
<div id="buttonBox">
44-
<button id="btn_create_manually" class="button">Manuelles Anlegen</button>
44+
<button id="btn_create_manually" class="button" hidden>Manuelles Anlegen</button>
4545
<br>
4646
<button id="btn_deleteFile" class="button">Lösche Download Datei</button>
4747
<br>

signaturenDruck/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SignaturenDruck",
3-
"version": "1.0.2",
3+
"version": "1.0.3a",
44
"description": "SignaturenDruck der ThULB",
55
"main": "main.js",
66
"scripts": {

signaturenDruck/preview.js

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,72 @@ module.exports = function (id) {
5656
if (document.getElementById('short_' + id)) {
5757
if (document.getElementById('short_' + id).checked && length == 1) {
5858
let text = sig.txt[0]
59-
let textSplit = text.split(' ')
60-
let countSpaces = textSplit.length
59+
let indxSlash = text.indexOf('/')
60+
let indxColon = text.indexOf(':')
61+
sig.txt = []
62+
sig.txt[0] = text
6163
let i = 0
62-
let j = 0
63-
while (countSpaces >= 2) {
64-
sig.txt = []
65-
sig.txt[j] = textSplit[i] + ' ' + textSplit[i + 1]
66-
countSpaces -= 2
67-
i += 2
68-
j++
64+
if (indxSlash !== -1) {
65+
sig.txt[0] = text.substring(0, indxSlash + 1)
66+
sig.txt[1] = text.substring(indxSlash + 1)
67+
i = 1
6968
}
70-
if (countSpaces == 1) {
71-
sig.txt[j] = textSplit[i]
69+
if (indxColon !== -1) {
70+
if (i === 0) {
71+
sig.txt[0] = text.substring(0, indxColon + 1)
72+
sig.txt[1] = text.substring(indxColon + 1)
73+
i = 1
74+
} else {
75+
let i = 0
76+
let txt = []
77+
let length = sig.txt.length
78+
sig.txt.forEach(element => {
79+
let indx = element.indexOf(':')
80+
if (indx !== -1) {
81+
let j = 0
82+
while (j < i) {
83+
txt[j] = sig.txt[j]
84+
j++
85+
}
86+
let k = i
87+
txt[k] = element.substring(0, indx)
88+
k++
89+
txt[k] = element.substring(indx)
90+
k++
91+
while (k <= length) {
92+
txt[k] = sig.txt[k - 1]
93+
k++
94+
}
95+
sig.txt = txt
96+
}
97+
i++
98+
})
99+
}
72100
}
101+
i = 0
102+
let txt = []
103+
let length = sig.txt.length
104+
sig.txt.forEach(element => {
105+
let elementParts = element.split(' ')
106+
if (elementParts.length >= 3) {
107+
let j = 0
108+
while (j < i) {
109+
txt[j] = sig.txt[j]
110+
j++
111+
}
112+
let k = i
113+
txt[k] = elementParts[0] + ' ' + elementParts[1]
114+
k++
115+
txt[k] = element.substring(txt[k - 1].length)
116+
k++
117+
while (k <= length) {
118+
txt[k] = sig.txt[k - 1]
119+
k++
120+
}
121+
sig.txt = txt
122+
}
123+
i++
124+
})
73125
}
74126
}
75127
sig.txt.forEach(element => {

signaturenDruck/printRenderer.js

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,76 @@ function main (ids) {
5959
div.className = 'shelfmark center small'
6060
}
6161
div.id = id
62-
let text = shelfmark.txt
6362
if (objct.short && length == 1) {
64-
text = shelfmark.txt[0]
65-
let textSplit = text.split(' ')
66-
let countSpaces = textSplit.length
63+
let text = shelfmark.txt[0]
64+
let indxSlash = text.indexOf('/')
65+
let indxColon = text.indexOf(':')
66+
shelfmark.txt = []
67+
shelfmark.txt[0] = text
6768
let i = 0
68-
let j = 0
69-
text = []
70-
while (countSpaces >= 2) {
71-
text[j] = textSplit[i] + ' ' + textSplit[i + 1]
72-
countSpaces -= 2
73-
i += 2
74-
j++
69+
if (indxSlash !== -1) {
70+
shelfmark.txt[0] = text.substring(0, indxSlash + 1)
71+
shelfmark.txt[1] = text.substring(indxSlash + 1)
72+
i = 1
7573
}
76-
if (countSpaces == 1) {
77-
text[j] = textSplit[i]
74+
if (indxColon !== -1) {
75+
if (i === 0) {
76+
shelfmark.txt[0] = text.substring(0, indxColon + 1)
77+
shelfmark.txt[1] = text.substring(indxColon + 1)
78+
i = 1
79+
} else {
80+
let i = 0
81+
let txt = []
82+
let length = shelfmark.txt.length
83+
shelfmark.txt.forEach(element => {
84+
let indx = element.indexOf(':')
85+
if (indx !== -1) {
86+
let j = 0
87+
while (j < i) {
88+
txt[j] = shelfmark.txt[j]
89+
j++
90+
}
91+
let k = i
92+
txt[k] = element.substring(0, indx)
93+
k++
94+
txt[k] = element.substring(indx)
95+
k++
96+
while (k <= length) {
97+
txt[k] = shelfmark.txt[k - 1]
98+
k++
99+
}
100+
shelfmark.txt = txt
101+
}
102+
i++
103+
})
104+
}
78105
}
106+
i = 0
107+
let txt = []
108+
let length = shelfmark.txt.length
109+
shelfmark.txt.forEach(element => {
110+
let elementParts = element.split(' ')
111+
if (elementParts.length >= 3) {
112+
let j = 0
113+
while (j < i) {
114+
txt[j] = shelfmark.txt[j]
115+
j++
116+
}
117+
let k = i
118+
txt[k] = elementParts[0] + ' ' + elementParts[1]
119+
k++
120+
txt[k] = element.substring(txt[k - 1].length)
121+
k++
122+
while (k <= length) {
123+
txt[k] = shelfmark.txt[k - 1]
124+
k++
125+
}
126+
shelfmark.txt = txt
127+
}
128+
i++
129+
})
79130
}
131+
let text = shelfmark.txt
80132
let lineCount = shelfmark.txt.length
81133
text.forEach(element => {
82134
if ((lineCount === 1) && (text.length === 1)) {

signaturenDruck/renderer.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,18 @@ function writeToFile (allLines) {
8484
} else if (first4 >= 7001 && first4 <= 7099) {
8585
sig.exNr = extract.exNr(line)
8686
} else if (first4 == 7100) {
87-
let txt = extract.txt(line)
88-
let big = labelSize(txt)
87+
let plainTxt = extract.txt(line)
88+
let big = labelSize(plainTxt)
8989
if (big === false) {
9090
sig.bigLabel = false
9191
}
92-
txt = txt.split(':')
93-
sig.txt = txt
92+
let txt = plainTxt.split(':')
93+
if (txt.length === 6) {
94+
sig.txt = txt
95+
} else {
96+
let txt = [plainTxt]
97+
sig.txt = txt
98+
}
9499
sig.txtLength = sig.txt.length
95100
} else if (first4 == 7901) {
96101
sig.date = extract.date(line)
@@ -228,9 +233,13 @@ function createPpnRow (row, value) {
228233
function createTxtCell (row, cellNr, objct) {
229234
let txtCell = row.insertCell(cellNr)
230235
txtCell.onclick = function () { pre(objct.id) }
231-
_.forEach(objct.txt, function (value) {
232-
txtCell.innerHTML += value + ' '
233-
})
236+
if (objct.txtLength === 1) {
237+
txtCell.innerHTML = objct.txt
238+
} else {
239+
_.forEach(objct.txt, function (value) {
240+
txtCell.innerHTML += value + ' '
241+
})
242+
}
234243
txtCell.className = 'txtCell'
235244
}
236245

0 commit comments

Comments
 (0)