pict 1.0.72 → 1.0.74

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pict",
3
- "version": "1.0.72",
3
+ "version": "1.0.74",
4
4
  "description": "Pict browser library.",
5
5
  "main": "source/Pict.js",
6
6
  "scripts": {
@@ -55,7 +55,7 @@ class PictApplication extends libFableServiceBase
55
55
  return true;
56
56
  }
57
57
 
58
- initialize(fCallback)
58
+ initialize()
59
59
  {
60
60
  this.log.info(`Pict Application ${this.options.Name}[${this.UUID}]::[${this.Hash}] beginning initialization...`);
61
61
  this.internalInitialize();
@@ -4,133 +4,158 @@ class PictContentAssignment extends libFableServiceBase
4
4
  {
5
5
  constructor(pFable, pOptions, pServiceHash)
6
6
  {
7
- super(pFable, pOptions, pServiceHash);
8
-
9
- this.serviceType = 'PictContentAssignment';
10
-
11
- // Check to see if we are running in a browser
12
- this.inBrowser = false;
13
- this.hasDocument = false;
14
- if (typeof(window) == 'object')
15
- {
16
- this.inBrowser = true;
17
- // Now check that the browser has a document object
18
- if ((typeof(window.document) != 'undefined') && (typeof(window.document.querySelectorAll) == 'function'))
19
- {
20
- this.hasDocument = true;
21
- }
22
- }
23
-
24
- // If we're in a browser, check to see if jQuery is available.
25
- this.hasJquery = false;
26
- this.jQuery = false;
27
- if (this.inBrowser && typeof(window.jQuery) !== 'undefined')
28
- {
29
- this.hasJquery = true;
30
- }
31
-
32
- // API Consumers can also craft their own assign function
33
- this.customAssignFunction = false;
34
-
35
- // API Consumers can also craft their own append function
36
- this.customAppendFunction = false;
37
-
38
- // API Consumers can also craft their own read function
39
- this.customReadFunction = false;
7
+ super(pFable, pOptions, pServiceHash);
8
+
9
+ this.serviceType = 'PictContentAssignment';
10
+
11
+ // Check to see if we are running in a browser
12
+ this.inBrowser = false;
13
+ this.hasDocument = false;
14
+ if (typeof (window) == 'object')
15
+ {
16
+ this.inBrowser = true;
17
+ // Now check that the browser has a document object
18
+ if ((typeof (window.document) != 'undefined') && (typeof (window.document.querySelectorAll) == 'function'))
19
+ {
20
+ this.hasDocument = true;
21
+ }
22
+ }
23
+
24
+ // If we're in a browser, check to see if jQuery is available.
25
+ this.hasJquery = false;
26
+ this.jQuery = false;
27
+ if (this.inBrowser && typeof (window.jQuery) !== 'undefined')
28
+ {
29
+ this.hasJquery = true;
30
+ }
31
+
32
+ // API Consumers can also craft their own assign function
33
+ this.customAssignFunction = false;
34
+
35
+ // API Consumers can also craft their own append function
36
+ this.customAppendFunction = false;
37
+
38
+ // API Consumers can also craft their own read function
39
+ this.customReadFunction = false;
40
+
41
+ // API Consumers can even craft their own get element function.
42
+ this.customGetElementFunction = false;
40
43
  }
41
44
 
42
- assignContent(pAddress, pContent)
43
- {
44
- if (this.customAssignFunction)
45
- {
46
- return this.customAssignFunction(pAddress, pContent);
47
- }
48
- else if (this.hasJquery)
49
- {
50
- // Get the element
51
- let tmpTargetElement = window.jQuery(pAddress);
52
-
53
- // Should we ensure we matched 1 and exactly 1 element?
54
- //if (tmpTargetElement && tmpTargetElement.length == 1)
55
- //{
56
- // Set the content
57
- tmpTargetElement.html(pContent);
58
- //}
59
- }
60
- else if (this.inBrowser && this.hasDocument)
61
- {
62
- let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
63
-
64
- for (let i = 0; i < tmpTargetElementSet.length; i++)
65
- {
66
- tmpTargetElementSet[i].innerHTML = pContent;
67
- }
68
- }
69
- else
70
- {
71
- // Just log it out for now
72
- this.log.trace(`PICT Content ASSIGN to [${pAddress}]:`, pContent);
73
- }
74
- }
75
-
76
- appendContent(pAddress, pContent)
77
- {
78
- if (this.customAppendFunction)
79
- {
80
- return this.customAppendFunction(pAddress, pContent);
81
- }
82
- else if (this.hasJquery)
83
- {
84
- let tmpTargetElement = window.jQuery(pAddress);
85
- tmpTargetElement.append(pContent);
86
- }
87
- else if (this.inBrowser && this.hasDocument)
88
- {
89
- let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
90
- for (let i = 0; i < tmpTargetElementSet.length; i++)
91
- {
92
- tmpTargetElementSet[i].insertAdjacentHTML("beforeend", pContent);
93
- }
94
- }
95
- else
96
- {
97
- // Just log it out for now -- nothing browser in our mix.
98
- this.log.trace(`PICT Content APPEND to [${pAddress}]:`, pContent);
99
- }
100
- }
101
-
102
- readContent(pAddress, pContentType)
103
- {
104
- let tmpContentType = (typeof(pContentType) == 'string') ? pContentType : 'value';
105
-
106
- if (this.customReadFunction)
107
- {
108
- return this.customReadFunction(pAddress, pContentType);
109
- }
110
- else if (this.hasJquery)
111
- {
112
- let tmpTargetElement = window.jQuery(pAddress);
113
- return tmpTargetElement.html();
114
- }
115
- else if (this.inBrowser && this.hasDocument)
116
- {
117
- let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
118
- if (tmpTargetElementSet.length < 1)
119
- {
120
- return '';
121
- }
122
- else if (tmpTargetElementSet.length == 1)
123
- {
124
- return tmpTargetElementSet[0].innerHTML;
125
- }
126
- }
127
- else
128
- {
129
- // Just log it out for now -- nothing browser in our mix.
130
- this.log.trace(`PICT Content READ from [${pAddress}] type [${tmpContentType}]...`);
131
- return '';
132
- }
133
- }
45
+ getElement(pAddress)
46
+ {
47
+ if (this.customGetElementFunction)
48
+ {
49
+ return this.customGetElementFunction(pAddress);
50
+ }
51
+ else if (this.hasJquery)
52
+ {
53
+ return window.jQuery(pAddress);
54
+ }
55
+ else if (this.inBrowser && this.hasDocument)
56
+ {
57
+ return window.document.querySelectorAll(pAddress);
58
+ }
59
+ else
60
+ {
61
+ // Just log it out for now
62
+ this.log.trace(`PICT Content GET ELEMENT for [${pAddress}]`);
63
+ return false;
64
+ }
65
+ }
66
+
67
+ assignContent(pAddress, pContent)
68
+ {
69
+ if (this.customAssignFunction)
70
+ {
71
+ return this.customAssignFunction(pAddress, pContent);
72
+ }
73
+ else if (this.hasJquery)
74
+ {
75
+ // Get the element
76
+ let tmpTargetElement = window.jQuery(pAddress);
77
+
78
+ // Should we ensure we matched 1 and exactly 1 element?
79
+ //if (tmpTargetElement && tmpTargetElement.length == 1)
80
+ //{
81
+ // Set the content
82
+ tmpTargetElement.html(pContent);
83
+ //}
84
+ }
85
+ else if (this.inBrowser && this.hasDocument)
86
+ {
87
+ let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
88
+
89
+ for (let i = 0; i < tmpTargetElementSet.length; i++)
90
+ {
91
+ tmpTargetElementSet[i].innerHTML = pContent;
92
+ }
93
+ }
94
+ else
95
+ {
96
+ // Just log it out for now
97
+ this.log.trace(`PICT Content ASSIGN to [${pAddress}]:`, pContent);
98
+ }
99
+ }
100
+
101
+ appendContent(pAddress, pContent)
102
+ {
103
+ if (this.customAppendFunction)
104
+ {
105
+ return this.customAppendFunction(pAddress, pContent);
106
+ }
107
+ else if (this.hasJquery)
108
+ {
109
+ let tmpTargetElement = window.jQuery(pAddress);
110
+ tmpTargetElement.append(pContent);
111
+ }
112
+ else if (this.inBrowser && this.hasDocument)
113
+ {
114
+ let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
115
+ for (let i = 0; i < tmpTargetElementSet.length; i++)
116
+ {
117
+ tmpTargetElementSet[i].insertAdjacentHTML("beforeend", pContent);
118
+ }
119
+ }
120
+ else
121
+ {
122
+ // Just log it out for now -- nothing browser in our mix.
123
+ this.log.trace(`PICT Content APPEND to [${pAddress}]:`, pContent);
124
+ }
125
+ }
126
+
127
+ readContent(pAddress, pContentType)
128
+ {
129
+ let tmpContentType = (typeof (pContentType) == 'string') ? pContentType : 'value';
130
+
131
+ if (this.customReadFunction)
132
+ {
133
+ return this.customReadFunction(pAddress, pContentType);
134
+ }
135
+ else if (this.hasJquery)
136
+ {
137
+ let tmpTargetElement = window.jQuery(pAddress);
138
+ return tmpTargetElement.html();
139
+ }
140
+ else if (this.inBrowser && this.hasDocument)
141
+ {
142
+ let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
143
+ if (tmpTargetElementSet.length < 1)
144
+ {
145
+ return '';
146
+ }
147
+ else if (tmpTargetElementSet.length == 1)
148
+ {
149
+ return tmpTargetElementSet[0].innerHTML;
150
+ }
151
+ }
152
+ else
153
+ {
154
+ // Just log it out for now -- nothing browser in our mix.
155
+ this.log.trace(`PICT Content READ from [${pAddress}] type [${tmpContentType}]...`);
156
+ return '';
157
+ }
158
+ }
134
159
  }
135
160
 
136
161
  module.exports = PictContentAssignment;
package/source/Pict.js CHANGED
@@ -106,6 +106,8 @@ class Pict extends libFable
106
106
  let fEntityRender = (pHash, pData, fCallback) =>
107
107
  {
108
108
  let tmpHash = pHash.trim();
109
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
110
+
109
111
 
110
112
  let tmpEntity = false;
111
113
  let tmpEntityID = false;
@@ -140,7 +142,7 @@ class Pict extends libFable
140
142
  else
141
143
  {
142
144
  // This is an address, so we need to get the value at the address
143
- tmpEntityID = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpEntityID);
145
+ tmpEntityID = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpEntityID);
144
146
  }
145
147
 
146
148
  // No Entity or EntityID
@@ -178,11 +180,12 @@ class Pict extends libFable
178
180
  let fNotEmptyRender = (pHash, pData)=>
179
181
  {
180
182
  let tmpHash = pHash.trim();
183
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
181
184
  // Should switch this to indexOf so pipes can be in the content.
182
185
  let tmpHashParts = tmpHash.split('|');
183
186
 
184
187
  // For now just check truthiness
185
- if (this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpHashParts[0]))
188
+ if (this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHashParts[0]))
186
189
  {
187
190
  return tmpHashParts[1];
188
191
  }
@@ -198,6 +201,7 @@ class Pict extends libFable
198
201
  let fTemplateRender = (pHash, pData)=>
199
202
  {
200
203
  let tmpHash = pHash.trim();
204
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
201
205
 
202
206
  let tmpTemplateHash = false;
203
207
  let tmpAddressOfData = false;
@@ -228,7 +232,7 @@ class Pict extends libFable
228
232
  }
229
233
  else
230
234
  {
231
- return this.parseTemplateByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpAddressOfData));
235
+ return this.parseTemplateByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpAddressOfData));
232
236
  }
233
237
  };
234
238
  this.defaultServices.MetaTemplate.addPattern('{~T:', '~}', fTemplateRender);
@@ -238,6 +242,7 @@ class Pict extends libFable
238
242
  let fTemplateSetRender = (pHash, pData)=>
239
243
  {
240
244
  let tmpHash = pHash.trim();
245
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
241
246
 
242
247
  let tmpTemplateHash = false;
243
248
  let tmpAddressOfData = false;
@@ -268,7 +273,7 @@ class Pict extends libFable
268
273
  }
269
274
  else
270
275
  {
271
- return this.parseTemplateSetByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpAddressOfData));
276
+ return this.parseTemplateSetByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpAddressOfData));
272
277
  }
273
278
  };
274
279
  this.defaultServices.MetaTemplate.addPattern('{~TS:', '~}', fTemplateSetRender);
@@ -278,7 +283,8 @@ class Pict extends libFable
278
283
  let fDataRender = (pHash, pData)=>
279
284
  {
280
285
  let tmpHash = pHash.trim();
281
- let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpHash);
286
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
287
+ let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
282
288
  if ((tmpValue == null) || (tmpValue == 'undefined') || (typeof(tmpValue) == 'undefined'))
283
289
  {
284
290
  return '';
@@ -292,14 +298,16 @@ class Pict extends libFable
292
298
  (pHash, pData)=>
293
299
  {
294
300
  let tmpHash = pHash.trim();
295
- let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpHash);
301
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
302
+ let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
296
303
  return this.defaultServices.DataFormat.formatterDollars(tmpColumnData);
297
304
  });
298
305
  this.defaultServices.MetaTemplate.addPattern('{~Digits:', '~}',
299
306
  (pHash, pData)=>
300
307
  {
301
308
  let tmpHash = pHash.trim();
302
- let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpHash);
309
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
310
+ let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
303
311
  return this.defaultServices.DataFormat.formatterAddCommasToNumber(this.defaultServices.DataFormat.formatterRoundNumber(tmpColumnData, 2));
304
312
  });
305
313
 
@@ -332,7 +340,8 @@ class Pict extends libFable
332
340
  let fPascalCaseIdentifier = (pHash, pData)=>
333
341
  {
334
342
  let tmpHash = pHash.trim();
335
- let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:pData}, tmpHash);
343
+ let tmpData = (typeof(pData) === 'object') ? pData : {};
344
+ let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
336
345
  if ((tmpValue == null) || (tmpValue == 'undefined') || (typeof(tmpValue) == 'undefined'))
337
346
  {
338
347
  return '';