isite 2022.2.5 → 2022.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1108,7 +1108,7 @@
1108
1108
  console.error('qrcode need {selector , text}');
1109
1109
  return;
1110
1110
  }
1111
- return JsBarcode(options.selector, options.selector);
1111
+ return JsBarcode(options.selector, options.selector , options.options);
1112
1112
  };
1113
1113
  site.qrcode = function (options) {
1114
1114
  if (!options || !options.selector || !options.text) {
@@ -1,40 +1,42 @@
1
1
  module.exports = function (site) {
2
- site.printList = [];
2
+ site.printList = [];
3
3
 
4
- site.post('/api/print', (req, res) => {
5
- let id = new Date().getTime();
4
+ site.post('/api/print', (req, res) => {
5
+ let id = new Date().getTime();
6
6
 
7
- site.printList.push({
8
- id: id,
9
- content: req.data.content,
10
- type: req.data.type ?? 'html',
11
- });
7
+ site.printList.push({
8
+ id: id,
9
+ content: req.data.content,
10
+ type: req.data.type ?? 'html',
11
+ });
12
12
 
13
- res.json({
14
- done: !0,
15
- url: '/view/print/' + id,
13
+ res.json({
14
+ done: !0,
15
+ url: '/view/print/' + id,
16
+ });
16
17
  });
17
- });
18
18
 
19
- site.get('/view/print/:id', (req, res) => {
20
- let content = '';
21
- let type = 'html';
22
- site.printList.forEach((item) => {
23
- if (item.id.toString() == req.params.id) {
24
- content = item.content;
25
- type = item.type ?? 'html';
26
- }
27
- });
19
+ site.get('/view/print/:id', (req, res) => {
20
+ let content = '';
21
+ let type = 'html';
22
+ site.printList.forEach((item) => {
23
+ if (item.id.toString() == req.params.id) {
24
+ content = item.content;
25
+ type = item.type ?? 'html';
26
+ }
27
+ });
28
28
 
29
- let html = '';
30
- if (type == 'image') {
31
- html = site.readFileSync(__dirname + '/site_files/html/image.html');
32
- } else if (type == 'svg') {
33
- html = site.readFileSync(__dirname + '/site_files/html/svg.html');
34
- } else {
35
- html = site.readFileSync(__dirname + '/site_files/html/index.html');
36
- }
37
- html = html.replace('##data.content##', content);
38
- res.htmlContent(html);
39
- });
29
+ let html = '';
30
+ if (type == 'image') {
31
+ html = site.readFileSync(__dirname + '/site_files/html/image.html');
32
+ } else if (type == 'svg') {
33
+ html = site.readFileSync(__dirname + '/site_files/html/svg.html');
34
+ } else if (type == 'content') {
35
+ html = site.readFileSync(__dirname + '/site_files/html/content.html');
36
+ } else {
37
+ html = site.readFileSync(__dirname + '/site_files/html/index.html');
38
+ }
39
+ html = html.replace('##data.content##', content);
40
+ res.htmlContent(html);
41
+ });
40
42
  };
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
7
+ <title>content Print</title>
8
+ </head>
9
+
10
+ <body>
11
+ ##data.content##
12
+
13
+ <script>
14
+ document.querySelectorAll('.not-print').forEach((el) => {
15
+ el.remove();
16
+ });
17
+ window.addEventListener('load', () => {
18
+ window.print({});
19
+ });
20
+ </script>
21
+ </body>
22
+ </html>
@@ -10,7 +10,6 @@
10
10
  <body class="print-mode">
11
11
  ##data.content##
12
12
 
13
- <style></style>
14
13
  <script>
15
14
  document.querySelectorAll('.not-print').forEach((el) => {
16
15
  el.remove();
@@ -18,10 +17,6 @@
18
17
  window.addEventListener('load', () => {
19
18
  window.print({});
20
19
  });
21
- /*
22
- Repeat table headers in every page if table too large
23
- use thead & tbody
24
- */
25
20
  </script>
26
21
  </body>
27
22
  </html>
@@ -1,74 +1,78 @@
1
1
  site.print = site.printHTML = function (options) {
2
2
  options = options || {};
3
+ let content = '';
3
4
 
4
5
  if (typeof options === 'string') {
5
6
  options = {
6
7
  selector: options,
7
8
  };
8
9
  }
10
+ if (!options.content) {
11
+ if (!options.selector) {
12
+ console.error('No Selector sets ...');
13
+ return false;
14
+ }
15
+ window.document.querySelectorAll('link[rel=stylesheet]').forEach((l) => {
16
+ l.href = site.handle_url(l.href);
17
+ content += l.outerHTML;
18
+ });
9
19
 
10
- if (!options.selector) {
11
- console.error('No Selector sets ...');
12
- return false;
13
- }
14
- if (!options.ip) {
15
- options.ip = '127.0.0.1';
16
- }
17
- if (!options.port) {
18
- options.port = '60080';
19
- }
20
+ window.document.querySelectorAll('style').forEach((s) => {
21
+ content += s.outerHTML;
22
+ });
20
23
 
21
- let content = '';
22
- window.document.querySelectorAll('link[rel=stylesheet]').forEach((l) => {
23
- l.href = site.handle_url(l.href);
24
- content += l.outerHTML;
25
- });
26
-
27
- window.document.querySelectorAll('style').forEach((s) => {
28
- content += s.outerHTML;
29
- });
30
-
31
- if (options.links) {
32
- options.links.forEach((link) => {
33
- content += '<link rel="stylesheet" href="' + link + '" type="text/css" >';
24
+ if (options.links) {
25
+ options.links.forEach((link) => {
26
+ content += '<link rel="stylesheet" href="' + link + '" type="text/css" >';
27
+ });
28
+ }
29
+
30
+ if (options.preappends) {
31
+ options.preappends.forEach((el) => {
32
+ el = window.document.querySelector(el);
33
+ if (el) {
34
+ content += el.outerHTML;
35
+ }
36
+ });
37
+ }
38
+
39
+ document.querySelectorAll(options.selector + ' input').forEach((el) => {
40
+ el.setAttribute('value', el.value);
34
41
  });
35
- }
36
42
 
37
- if (options.preappends) {
38
- options.preappends.forEach((el) => {
39
- el = window.document.querySelector(el);
40
- if (el) {
41
- content += el.outerHTML;
42
- }
43
+ document.querySelectorAll(options.selector + ' textarea').forEach((el) => {
44
+ el.innerText = el.value;
43
45
  });
44
- }
45
46
 
46
- document.querySelectorAll(options.selector + ' input').forEach((el) => {
47
- el.setAttribute('value', el.value);
48
- });
49
-
50
- document.querySelectorAll(options.selector + ' textarea').forEach((el) => {
51
- el.innerText = el.value;
52
- });
53
-
54
- document.querySelectorAll(options.selector).forEach((el) => {
55
- let display = el.style.display;
56
- el.style.display = 'block';
57
- content += el.outerHTML;
58
- el.style.display = display;
59
- });
60
-
61
- if (options.appends) {
62
- options.appends.forEach((el) => {
63
- el = window.document.querySelector(el);
64
- if (el) {
65
- content += el.outerHTML;
66
- }
47
+ document.querySelectorAll(options.selector).forEach((el) => {
48
+ let display = el.style.display;
49
+ el.style.display = 'block';
50
+ content += el.outerHTML;
51
+ el.style.display = display;
67
52
  });
53
+
54
+ if (options.appends) {
55
+ options.appends.forEach((el) => {
56
+ el = window.document.querySelector(el);
57
+ if (el) {
58
+ content += el.outerHTML;
59
+ }
60
+ });
61
+ }
62
+ } else {
63
+ options.type = 'content'
64
+ content = options.content;
65
+ }
66
+
67
+ if (!options.ip) {
68
+ options.ip = '127.0.0.1';
69
+ }
70
+ if (!options.port) {
71
+ options.port = '60080';
68
72
  }
69
73
 
70
74
  site.postData(
71
- { url: '/api/print', data: { content: content } },
75
+ { url: '/api/print', data: { content: content , type : options.type} },
72
76
  (response) => {
73
77
  if (response.done) {
74
78
  if (options.printer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isite",
3
- "version": "2022.02.05",
3
+ "version": "2022.03.01",
4
4
  "description": "Create Enterprise Multi-Language Web Site [Fast and Easy] ",
5
5
  "main": "index.js",
6
6
  "repository": {