|
| 1 | +// requires remote from electron to retrieve global var |
| 2 | +const { remote } = require('electron') |
| 3 | +const config = remote.getGlobal('config') |
| 4 | +// requires the dataExtractK10plus-module |
| 5 | +const DataExtractK10plus = require('./dataExtractK10plus.js') |
| 6 | +// requires the shelfmark class |
| 7 | +const Shelfmark = require('../shelfmark.js') |
| 8 | +const getLabelSize = require('../getLabelSize.js') |
| 9 | +const createMultipleLines = require('../createMultipleLines.js') |
| 10 | + |
| 11 | +module.exports = function (allLines) { |
| 12 | + let obj = { |
| 13 | + all: [] |
| 14 | + } |
| 15 | + let sig = new Shelfmark() |
| 16 | + let extract = new DataExtractK10plus() |
| 17 | + let ppnAktuell = '' |
| 18 | + let plainTxt = '' |
| 19 | + |
| 20 | + allLines.map((line) => { |
| 21 | + let first4 = extract.firstFour(line) |
| 22 | + if (first4 === '0100') { |
| 23 | + sig.ppn = ppnAktuell = extract.ppn(line) |
| 24 | + } else if (first4.substring(0, 1) === 'E' && first4.substring(1, 4) >= 1 && first4.substring(1, 4) <= 999) { |
| 25 | + sig.exNr = extract.exNr(line) |
| 26 | + } else if (first4 === '7100') { |
| 27 | + plainTxt = extract.txt(line) |
| 28 | + let big = getLabelSize(plainTxt) |
| 29 | + if (big === false) { |
| 30 | + sig.bigLabel = false |
| 31 | + } |
| 32 | + let txt = plainTxt.split(config.get('newLineAfter')) |
| 33 | + sig.txtLength = txt.length |
| 34 | + if (config.get('mode.useMode') && config.get('mode.defaultMode') === 'thulbMode') { |
| 35 | + if (txt.length === 6) { |
| 36 | + sig.txt = txt |
| 37 | + sig.txtOneLine = plainTxt |
| 38 | + } else { |
| 39 | + sig.txt = [plainTxt] |
| 40 | + sig.txtOneLine = plainTxt |
| 41 | + } |
| 42 | + } else { |
| 43 | + sig.txt = txt |
| 44 | + sig.txtOneLine = plainTxt |
| 45 | + } |
| 46 | + } else if (first4 === '7903') { |
| 47 | + sig.date = extract.date(line) |
| 48 | + } |
| 49 | + if (sig.allSet()) { |
| 50 | + if (config.get('mode.useMode') && config.get('mode.defaultMode') === 'thulbMode') { |
| 51 | + if (sig.txtLength < 3) { |
| 52 | + sig.txt = createMultipleLines(plainTxt) |
| 53 | + sig.txtLength = sig.txt.length |
| 54 | + } |
| 55 | + } |
| 56 | + obj.all.push(sig.shelfmark) |
| 57 | + sig = new Shelfmark() |
| 58 | + sig.ppn = ppnAktuell |
| 59 | + } |
| 60 | + }) |
| 61 | + return obj |
| 62 | +} |
0 commit comments