Skip to content

Commit 4d8e6b3

Browse files
committed
working manual shelfmark creation
1 parent 2cb4096 commit 4d8e6b3

5 files changed

Lines changed: 302 additions & 176 deletions

File tree

signaturenDruck/html/manual.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<body>
1313
<div id="container">
1414
<div id="inputBox">
15+
<div id="counter">
16+
Signatur Nr. <span id="countCurrent"></span> von <span id="countMax"></span>
17+
</div>
1518
<div id="editorBox">
1619
<input type="text" id="line_1"><br>
1720
<input type="text" id="line_2"><br>

signaturenDruck/main.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ app.on('activate', function () {
133133
})
134134

135135
// starts the printing process
136-
ipc.on('print', function (event, data) {
136+
ipc.on('print', function (event, data, dataMan) {
137137
savedData = data
138138
if (savedData.big || savedData.small) {
139139
try {
140140
if (savedData.big) {
141-
printBig(savedData.big)
141+
printBig(savedData.big, dataMan)
142142
}
143143
if (savedData.small) {
144-
printSmall(savedData.small)
144+
printSmall(savedData.small, dataMan)
145145
}
146146
// mainWindow.webContents.send('printed', true)
147147
} catch (error) {
@@ -162,7 +162,7 @@ ipc.on('printed', function (event) {
162162
})
163163

164164
// invokes the generating and printing of printBig.pdf
165-
function printBig (data) {
165+
function printBig (data, dataMan) {
166166
let winBig = null
167167
winBig = new BrowserWindow({ heihgt: 350, width: 500, show: false })
168168
winBig.loadURL(url.format({
@@ -171,7 +171,7 @@ function printBig (data) {
171171
slashes: true
172172
}))
173173
winBig.once('ready-to-show', () => {
174-
winBig.webContents.send('toPrint', data)
174+
winBig.webContents.send('toPrint', data, dataMan)
175175

176176
// generates a pdf file which is then printed silently via Foxit Reader v6.2.3.0815
177177
winBig.webContents.printToPDF({marginsType: 2, landscape: true, pageSize: { width: config.store.big.label.height, height: config.store.big.label.width }}, (error, data) => {
@@ -198,7 +198,7 @@ function printBig (data) {
198198
}
199199

200200
// invokes the generating and printing of printSmall.pdf
201-
function printSmall (data) {
201+
function printSmall (data, dataMan) {
202202
let winSmall = null
203203
winSmall = new BrowserWindow({width: 350, height: 500, show: false})
204204
winSmall.loadURL(url.format({
@@ -207,7 +207,7 @@ function printSmall (data) {
207207
slashes: true
208208
}))
209209
winSmall.once('ready-to-show', () => {
210-
winSmall.webContents.send('toPrint', data)
210+
winSmall.webContents.send('toPrint', data, dataMan)
211211
winSmall.webContents.printToPDF({marginsType: 2, landscape: true, pageSize: { width: config.store.small.label.height, height: config.store.small.label.width }}, (error, data) => {
212212
if (error) throw error
213213
fs.writeFile('./tmp/' + config.store.small.pdfName, data, (error) => {
@@ -231,11 +231,11 @@ function printSmall (data) {
231231
})
232232
}
233233

234-
ipc.on('openManually', function (event) {
235-
createManualWindow()
234+
ipc.on('openManually', function (event, objMan) {
235+
createManualWindow(objMan)
236236
})
237237

238-
function createManualWindow () {
238+
function createManualWindow (objMan) {
239239
winManual = new BrowserWindow({width: 600, height: 300, show: false})
240240
winManual.loadURL(url.format({
241241
pathname: path.join(__dirname, 'html/manual.html'),
@@ -244,19 +244,20 @@ function createManualWindow () {
244244
}))
245245
winManual.once('ready-to-show', () => {
246246
winManual.show()
247+
winManual.webContents.send('objMan', objMan)
247248
})
248249
}
249250

250251
ipc.on('closeManual', function (event) {
251252
winManual.close()
252253
winManual = null
254+
mainWindow.webContents.send('removeManual')
253255
})
254256

255257
ipc.on('saveManual', function (event, data) {
256258
winManual.close()
257259
winManual = null
258260
mainWindow.webContents.send('manual', data)
259-
console.log(data, data.length)
260261
})
261262

262263
// In this file you can include the rest of your app's specific main process

signaturenDruck/manualRenderer.js

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
}
1515
})
1616
}
17+
18+
document.getElementById('countCurrent').innerHTML = 1
19+
document.getElementById('countMax').innerHTML = 1
20+
focusFirst()
1721
})()
1822

1923
// required for ipc calls to the main process
@@ -24,28 +28,40 @@ let objct = {
2428
}
2529

2630
let id = 0
31+
let max = 1
32+
33+
ipc.on('objMan', function (event, objMan) {
34+
if (objMan !== null) {
35+
objct.manual = objMan
36+
id = objMan.length
37+
max = objMan.length + 1
38+
setCounters()
39+
document.getElementById('btn_previous').disabled = false
40+
}
41+
})
2742

2843
function f () {
2944
let radioButtons = document.getElementsByName('numberOfLines')
3045
for (let i = 0, length = radioButtons.length; i < length; i++) {
3146
if (radioButtons[i].checked) {
3247
showInputs(radioButtons[i].value)
33-
console.log(radioButtons[i].value)
3448
document.getElementById('previewBox').classList = ''
3549
if (radioButtons[i].value == 1) {
36-
console.log('small center')
3750
document.getElementById('previewBox').className = 'small center'
3851
} else if (radioButtons[i].value == 3) {
39-
console.log('small indent')
4052
document.getElementById('previewBox').className = 'small indent'
4153
} else {
42-
console.log('big indent')
4354
document.getElementById('previewBox').className = 'big indent'
4455
}
56+
break
4557
}
4658
}
4759
}
4860

61+
function focusFirst () {
62+
document.getElementById('line_1').focus()
63+
}
64+
4965
function showInputs (i) {
5066
removeLines()
5167
clearInput()
@@ -92,18 +108,36 @@ function removeLines () {
92108
}
93109
}
94110

111+
function setCounters () {
112+
document.getElementById('countCurrent').innerHTML = id + 1
113+
document.getElementById('countMax').innerHTML = max
114+
}
115+
95116
function next () {
96-
saveCurrent()
97-
id++
98-
if (id === 1) {
99-
document.getElementById('btn_previous').disabled = false
117+
let i = 0
118+
let isEmpty = true
119+
while (i < getNumberOfLines()) {
120+
if (document.getElementById('line_' + (i + 1)).value !== '') {
121+
isEmpty = false
122+
}
123+
i++
100124
}
101-
if (objct.manual[id] !== undefined) {
102-
getData()
103-
} else {
104-
removeLines()
105-
show(getNumberOfLines())
106-
clearInput()
125+
if (!isEmpty) {
126+
saveCurrent()
127+
id++
128+
if (id === 1) {
129+
document.getElementById('btn_previous').disabled = false
130+
}
131+
if (objct.manual[id] !== undefined) {
132+
getData()
133+
} else {
134+
removeLines()
135+
show(getNumberOfLines())
136+
clearInput()
137+
max++
138+
focusFirst()
139+
}
140+
setCounters()
107141
}
108142
}
109143

@@ -114,14 +148,12 @@ function previous () {
114148
}
115149
id--
116150
getData()
117-
console.log('prev', objct.manual)
151+
setCounters()
118152
}
119153

120154
function deleteData () {
121-
console.log('before', objct.manual)
122155
reset()
123156
changeOrder()
124-
console.log('after', objct.manual)
125157

126158
function reset () {
127159
objct.manual[id] = {}
@@ -139,7 +171,9 @@ function deleteData () {
139171
delete objct.manual[i - 1]
140172
if (id > 0) {
141173
id--
174+
max--
142175
}
176+
setCounters()
143177
if (id === 0) {
144178
document.getElementById('btn_previous').disabled = true
145179
}
@@ -161,11 +195,17 @@ function deleteAndExit () {
161195
function saveAndExit () {
162196
saveCurrent()
163197
let indx = objct.manual.length - 1
164-
let lastLength = objct.manual[indx].lineTxts.length
198+
let lastLength
165199
let isEmpty = true
166200
let i = 0
201+
if (objct.manual[indx] === undefined) {
202+
while ((objct.manual[indx] === undefined) && (indx > 0)) {
203+
indx--
204+
}
205+
}
206+
lastLength = objct.manual[indx].lineTxts.length
167207
while (i < lastLength) {
168-
if (objct.manual[indx].lineTxts[i] !== '') {
208+
if ((objct.manual[indx].lineTxts[i] !== '') && (objct.manual[indx].lineTxts !== undefined)) {
169209
isEmpty = false
170210
}
171211
i++

0 commit comments

Comments
 (0)