@zykjcommon/questions 0.0.64 → 0.0.66
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 +47 -4
- package/packageClear.json +22 -0
- package/src/assets/js/json2html.js +446 -0
- package/src/components/questions/developmentEntry.js +4 -2
- package/package2.json +0 -65
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zykjcommon/questions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
4
4
|
"main": "src/components/questions/entry.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vue-cli-service serve",
|
|
@@ -11,10 +11,53 @@
|
|
|
11
11
|
"lint": "vue-cli-service lint",
|
|
12
12
|
"build:lib": "vue-cli-service build --target lib src/components/questions/buildEntry.js --name zykjcommon-questions",
|
|
13
13
|
"publishLib": "node tasks/setPublishPackageJson.js && npm publish && node tasks/setOriPackageJson.js",
|
|
14
|
-
"publishZykjLib": "npm publish --registry https://nexus.thedeer.cn/repository/npm-zykj
|
|
14
|
+
"publishZykjLib": "node tasks/setPublishPackageJson.js && npm publish --registry https://nexus.thedeer.cn/repository/npm-zykj/ && node tasks/setOriPackageJson.js"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"alife-logger": "^1.8.30",
|
|
18
|
+
"axios": "^0.26.0",
|
|
19
|
+
"cookie": "^0.4.1",
|
|
20
|
+
"core-js": "^3.6.5",
|
|
21
|
+
"crypto-js": "^3.1.9-1",
|
|
22
|
+
"md5": "^2.2.1",
|
|
23
|
+
"mitt": "^3.0.0",
|
|
24
|
+
"mobile-detect": "^1.4.5",
|
|
25
|
+
"video.js": "^7.6.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^18.11.9",
|
|
29
|
+
"@vue/cli-plugin-babel": "^5.0.1",
|
|
30
|
+
"@vue/cli-plugin-router": "~4.5.0",
|
|
31
|
+
"@vue/cli-plugin-typescript": "^5.0.1",
|
|
32
|
+
"@vue/cli-plugin-vuex": "~4.5.0",
|
|
33
|
+
"@vue/cli-service": "^5.0.1",
|
|
34
|
+
"@vue/compiler-sfc": "^3.0.0",
|
|
35
|
+
"@zykjcommon/questions": "^0.0.39",
|
|
36
|
+
"element-plus": "^2.0.2",
|
|
37
|
+
"file-loader": "^6.2.0",
|
|
38
|
+
"image-webpack-loader": "^8.1.0",
|
|
39
|
+
"postcss": "^8.4.6",
|
|
40
|
+
"postcss-cssnext": "^3.1.0",
|
|
41
|
+
"postcss-extend": "^1.0.5",
|
|
42
|
+
"postcss-import": "^14.0.2",
|
|
43
|
+
"postcss-mixins": "^6.2.1",
|
|
44
|
+
"postcss-nested": "^4.1.2",
|
|
45
|
+
"postcss-pxtorem": "^6.0.0",
|
|
46
|
+
"postcss-simple-vars": "^5.0.2",
|
|
47
|
+
"sass": "^1.26.5",
|
|
48
|
+
"sass-loader": "^8.0.2",
|
|
49
|
+
"typescript": "~4.1.5",
|
|
50
|
+
"unplugin-auto-import": "^0.6.0",
|
|
51
|
+
"unplugin-element-plus": "^0.3.1",
|
|
52
|
+
"unplugin-vue-components": "^0.17.18",
|
|
53
|
+
"url-loader": "^4.1.1",
|
|
54
|
+
"webpack": "^5.88.1",
|
|
55
|
+
"yargs": "^16.2.0",
|
|
56
|
+
"vue": "^3.0.0",
|
|
57
|
+
"vue-router": "^4.0.0-0",
|
|
58
|
+
"vuex": "^4.0.0-0",
|
|
59
|
+
"vuex-composition-helpers": "^2.0.1"
|
|
15
60
|
},
|
|
16
|
-
"dependencies": {},
|
|
17
|
-
"devDependencies": {},
|
|
18
61
|
"publishConfig": {
|
|
19
62
|
"access": "public",
|
|
20
63
|
"registry": "https://registry.npmjs.org"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zykjcommon/questions",
|
|
3
|
+
"version": "0.0.64",
|
|
4
|
+
"main": "src/components/questions/entry.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve",
|
|
7
|
+
"design": "node tasks/vueMapper.js && node tasks/vueMapperTree.js && npm run serve -- --design",
|
|
8
|
+
"build": "vue-cli-service build",
|
|
9
|
+
"pre": "vue-cli-service build --mode test",
|
|
10
|
+
"buildTest": "vue-cli-service build --mode buildTest",
|
|
11
|
+
"lint": "vue-cli-service lint",
|
|
12
|
+
"build:lib": "vue-cli-service build --target lib src/components/questions/buildEntry.js --name zykjcommon-questions",
|
|
13
|
+
"publishLib": "node tasks/setPublishPackageJson.js && npm run publishZykjLib && node tasks/setOriPackageJson.js",
|
|
14
|
+
"publishZykjLib": "npm publish --registry https://nexus.thedeer.cn/repository/npm-zykj/"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {},
|
|
17
|
+
"devDependencies": {},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
//Copyright (c) 2018 Crystalline Technologies
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'),
|
|
4
|
+
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
5
|
+
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
//
|
|
7
|
+
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
//
|
|
9
|
+
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
10
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
11
|
+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
12
|
+
export let json2html = {
|
|
13
|
+
|
|
14
|
+
/* ---------------------------------------- Public Methods ------------------------------------------------ */
|
|
15
|
+
'transform': function(json,transform,_options) {
|
|
16
|
+
|
|
17
|
+
//create the default output
|
|
18
|
+
var out = {'events':[],'html':''};
|
|
19
|
+
|
|
20
|
+
//default options (by default we don't allow events)
|
|
21
|
+
var options = {
|
|
22
|
+
'events':false
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//extend the options
|
|
26
|
+
options = json2html._extend(options,_options);
|
|
27
|
+
|
|
28
|
+
//Make sure we have a transform & json object
|
|
29
|
+
if( transform !== undefined || json !== undefined ) {
|
|
30
|
+
|
|
31
|
+
//Normalize strings to JSON objects if necessary
|
|
32
|
+
var obj = typeof json === 'string' ? JSON.parse(json) : json;
|
|
33
|
+
|
|
34
|
+
//Transform the object (using the options)
|
|
35
|
+
out = json2html._transform(obj, transform, options);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//determine if we need the events
|
|
39
|
+
// otherwise return just the html string
|
|
40
|
+
if(options.events) return(out);
|
|
41
|
+
else return( out.html );
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/* ---------------------------------------- Private Methods ------------------------------------------------ */
|
|
45
|
+
|
|
46
|
+
//Extend options
|
|
47
|
+
'_extend':function(obj1,obj2){
|
|
48
|
+
var obj3 = {};
|
|
49
|
+
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
|
|
50
|
+
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
|
|
51
|
+
return obj3;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
//Append results
|
|
55
|
+
'_append':function(obj1,obj2) {
|
|
56
|
+
var out = {'html':'','event':[]};
|
|
57
|
+
if(typeof obj1 !== 'undefined' && typeof obj2 !== 'undefined') {
|
|
58
|
+
out.html = obj1.html + obj2.html;
|
|
59
|
+
|
|
60
|
+
out.events = obj1.events.concat(obj2.events);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return(out);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
//isArray (fix for IE prior to 9)
|
|
67
|
+
'_isArray':function(obj) {
|
|
68
|
+
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
//Transform object
|
|
72
|
+
'_transform':function(json, transform, options) {
|
|
73
|
+
|
|
74
|
+
var elements = {'events':[],'html':''};
|
|
75
|
+
|
|
76
|
+
//Determine the type of this object
|
|
77
|
+
if(json2html._isArray(json)) {
|
|
78
|
+
|
|
79
|
+
//Itterrate through the array and add it to the elements array
|
|
80
|
+
var len=json.length;
|
|
81
|
+
for(var j=0;j<len;++j) {
|
|
82
|
+
//Apply the transform to this object and append it to the results
|
|
83
|
+
elements = json2html._append(elements,json2html._apply(json[j], transform, j, options));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
} else if(typeof json === 'object') {
|
|
87
|
+
|
|
88
|
+
//Apply the transform to this object and append it to the results
|
|
89
|
+
elements = json2html._append(elements,json2html._apply(json, transform, undefined, options));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//Return the resulting elements
|
|
93
|
+
return(elements);
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
//Apply the transform at the second level
|
|
97
|
+
'_apply':function(obj, transform, index, options) {
|
|
98
|
+
|
|
99
|
+
var element = {'events':[],'html':''};
|
|
100
|
+
|
|
101
|
+
//Itterate through the transform and create html as needed
|
|
102
|
+
if(json2html._isArray(transform)) {
|
|
103
|
+
|
|
104
|
+
var t_len = transform.length;
|
|
105
|
+
for(var t=0; t < t_len; ++t) {
|
|
106
|
+
//transform the object and append it to the output
|
|
107
|
+
element = json2html._append(element,json2html._apply(obj, transform[t], index, options));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
} else if(typeof transform === 'object') {
|
|
111
|
+
|
|
112
|
+
var _element = '<>';
|
|
113
|
+
|
|
114
|
+
//Add legacy support for tag
|
|
115
|
+
if(transform[_element] === undefined) _element = 'tag';
|
|
116
|
+
|
|
117
|
+
//Check to see if we have a valid element name
|
|
118
|
+
if( transform[_element] !== undefined ) {
|
|
119
|
+
|
|
120
|
+
//Get the element name (this can be tokenized)
|
|
121
|
+
var name = json2html._getValue(obj,transform,_element,index);
|
|
122
|
+
|
|
123
|
+
//Create a new element
|
|
124
|
+
element.html += '<' + name;
|
|
125
|
+
|
|
126
|
+
//Create a new object for the children
|
|
127
|
+
var children = {'events':[],'html':''};
|
|
128
|
+
|
|
129
|
+
//innerHTML
|
|
130
|
+
var html;
|
|
131
|
+
|
|
132
|
+
//Look into the properties of this transform
|
|
133
|
+
for (var key in transform) {
|
|
134
|
+
|
|
135
|
+
switch(key) {
|
|
136
|
+
|
|
137
|
+
//DEPRECATED (use <> instead)
|
|
138
|
+
case 'tag':
|
|
139
|
+
|
|
140
|
+
//HTML element to render
|
|
141
|
+
case '<>':
|
|
142
|
+
//Do nothing as we have already created the element
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
//Encode as text
|
|
146
|
+
case 'text':
|
|
147
|
+
//Get the transform value associated with this key
|
|
148
|
+
var _transform = transform[key];
|
|
149
|
+
|
|
150
|
+
//Determine what kind of object this is
|
|
151
|
+
// array => NOT SUPPORTED
|
|
152
|
+
// other => text
|
|
153
|
+
if(json2html._isArray(_transform)) {
|
|
154
|
+
//NOT Supported
|
|
155
|
+
} else if(typeof _transform === 'function') {
|
|
156
|
+
|
|
157
|
+
//Get the result from the function
|
|
158
|
+
var temp = _transform.call(obj, obj, index);
|
|
159
|
+
|
|
160
|
+
//Don't allow arrays as return objects from functions
|
|
161
|
+
if(!json2html._isArray(temp)) {
|
|
162
|
+
|
|
163
|
+
//Determine what type of object was returned
|
|
164
|
+
switch(typeof temp){
|
|
165
|
+
|
|
166
|
+
//Not supported for text
|
|
167
|
+
case 'function':
|
|
168
|
+
case 'undefined':
|
|
169
|
+
case 'object':
|
|
170
|
+
break;
|
|
171
|
+
|
|
172
|
+
//Append as text
|
|
173
|
+
// string, number, boolean
|
|
174
|
+
default:
|
|
175
|
+
//Insure we encode as text first
|
|
176
|
+
children.html += json2html.toText(temp);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
|
|
182
|
+
//Get the encoded text associated with this element
|
|
183
|
+
html = json2html.toText( json2html._getValue(obj,transform,key,index) );
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
//DEPRECATED (use HTML instead)
|
|
188
|
+
case 'children':
|
|
189
|
+
|
|
190
|
+
//Encode as HTML
|
|
191
|
+
// accepts Array of children, functions, string, number, boolean
|
|
192
|
+
case 'html':
|
|
193
|
+
|
|
194
|
+
//Get the transform value associated with this key
|
|
195
|
+
// added as key could be children or html
|
|
196
|
+
var _transform = transform[key];
|
|
197
|
+
|
|
198
|
+
//Determine what kind of object this is
|
|
199
|
+
// array & function => children
|
|
200
|
+
// other => html
|
|
201
|
+
if(json2html._isArray(_transform)) {
|
|
202
|
+
|
|
203
|
+
//Apply the transform to the children
|
|
204
|
+
children = json2html._append(children,json2html._apply(obj, _transform, index, options));
|
|
205
|
+
} else if(typeof _transform === 'function') {
|
|
206
|
+
|
|
207
|
+
//Get the result from the function
|
|
208
|
+
var temp = _transform.call(obj, obj, index);
|
|
209
|
+
|
|
210
|
+
//Don't allow arrays as return objects from functions
|
|
211
|
+
if(!json2html._isArray(temp)) {
|
|
212
|
+
|
|
213
|
+
//Determine what type of object was returned
|
|
214
|
+
switch(typeof temp){
|
|
215
|
+
|
|
216
|
+
//Only returned by json2html.transform or $.json2html calls
|
|
217
|
+
case 'object':
|
|
218
|
+
//make sure this object is a valid json2html response object
|
|
219
|
+
// we ignore all other objects (since we don't know how to represent them in html)
|
|
220
|
+
if(temp.html !== undefined && temp.events !== undefined) children = json2html._append(children,temp);
|
|
221
|
+
break;
|
|
222
|
+
|
|
223
|
+
//Not supported
|
|
224
|
+
case 'function':
|
|
225
|
+
case 'undefined':
|
|
226
|
+
break;
|
|
227
|
+
|
|
228
|
+
//Append to html
|
|
229
|
+
// string, number, boolean
|
|
230
|
+
default:
|
|
231
|
+
children.html += temp;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
|
|
237
|
+
//Get the HTML associated with this element
|
|
238
|
+
html = json2html._getValue(obj,transform,key,index);
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
|
|
242
|
+
default:
|
|
243
|
+
//Add the property as a attribute if it's not a key one
|
|
244
|
+
var isEvent = false;
|
|
245
|
+
|
|
246
|
+
//Check if the first two characters are 'on' then this is an event
|
|
247
|
+
if( key.length > 2 )
|
|
248
|
+
if(key.substring(0,2).toLowerCase() == 'on') {
|
|
249
|
+
|
|
250
|
+
//Determine if we should add events
|
|
251
|
+
if(options.events) {
|
|
252
|
+
|
|
253
|
+
//if so then setup the event data
|
|
254
|
+
var data = {
|
|
255
|
+
'action':transform[key],
|
|
256
|
+
'obj':obj,
|
|
257
|
+
'data':options.eventData,
|
|
258
|
+
'index':index
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
//create a new id for this event
|
|
262
|
+
var id = json2html._guid();
|
|
263
|
+
|
|
264
|
+
//append the new event to this elements events
|
|
265
|
+
element.events[element.events.length] = {'id':id,'type':key.substring(2),'data':data};
|
|
266
|
+
|
|
267
|
+
//Insert temporary event property (json2html-event-id) into the element
|
|
268
|
+
element.html += " json2html-event-id-"+key.substring(2)+"='" + id + "'";
|
|
269
|
+
}
|
|
270
|
+
//this is an event
|
|
271
|
+
isEvent = true;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
//If this wasn't an event AND we actually have a value then add it as a property
|
|
275
|
+
if( !isEvent){
|
|
276
|
+
//Get the value
|
|
277
|
+
var val = json2html._getValue(obj, transform, key, index);
|
|
278
|
+
|
|
279
|
+
//Make sure we have a value
|
|
280
|
+
if(val !== undefined) {
|
|
281
|
+
var out;
|
|
282
|
+
|
|
283
|
+
//Determine the output type of this value (wrap with quotes)
|
|
284
|
+
if(typeof val === 'string') out = '"' + val.replace(/"/g, '"') + '"';
|
|
285
|
+
else out = val;
|
|
286
|
+
|
|
287
|
+
//create the name value pair
|
|
288
|
+
element.html += ' ' + key + '=' + out;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//close the opening element
|
|
296
|
+
element.html += '>';
|
|
297
|
+
|
|
298
|
+
//add the innerHTML (if we have any)
|
|
299
|
+
if(html) element.html += html;
|
|
300
|
+
|
|
301
|
+
//add the children (if we have any)
|
|
302
|
+
element = json2html._append(element,children);
|
|
303
|
+
|
|
304
|
+
//add the closing element
|
|
305
|
+
element.html += '</' + name + '>';
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
//Return the output object
|
|
310
|
+
return(element);
|
|
311
|
+
},
|
|
312
|
+
|
|
313
|
+
//Get a new GUID (used by events)
|
|
314
|
+
'_guid':function() {
|
|
315
|
+
var S4 = function() {
|
|
316
|
+
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
|
317
|
+
};
|
|
318
|
+
return (S4()+S4()+"-"+S4()+S4()+"-"+S4()+S4());
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
//Get the html value of the object
|
|
322
|
+
'_getValue':function(obj, transform, key,index) {
|
|
323
|
+
|
|
324
|
+
var out = '';
|
|
325
|
+
|
|
326
|
+
var val = transform[key];
|
|
327
|
+
var type = typeof val;
|
|
328
|
+
|
|
329
|
+
if (type === 'function') {
|
|
330
|
+
return(val.call(obj,obj,index));
|
|
331
|
+
} else if (type === 'string') {
|
|
332
|
+
var _tokenizer = new json2html._tokenizer([
|
|
333
|
+
/\$\{([^\}\{]+)\}/
|
|
334
|
+
],function( src, real, re ){
|
|
335
|
+
return real ? src.replace(re,function(all,name){
|
|
336
|
+
|
|
337
|
+
//Split the string into it's seperate components
|
|
338
|
+
var components = name.split('.');
|
|
339
|
+
|
|
340
|
+
//Set the object we use to query for this name to be the original object
|
|
341
|
+
var useObj = obj;
|
|
342
|
+
|
|
343
|
+
//Output value
|
|
344
|
+
var outVal = '';
|
|
345
|
+
|
|
346
|
+
//Parse the object components
|
|
347
|
+
var c_len = components.length;
|
|
348
|
+
for (var i=0;i<c_len;++i) {
|
|
349
|
+
|
|
350
|
+
if( components[i].length > 0 ) {
|
|
351
|
+
|
|
352
|
+
var newObj = useObj[components[i]];
|
|
353
|
+
useObj = newObj;
|
|
354
|
+
if(useObj === null || useObj === undefined) break;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
//As long as we have an object to use then set the out
|
|
359
|
+
if(useObj !== null && useObj !== undefined) outVal = useObj;
|
|
360
|
+
|
|
361
|
+
return(outVal);
|
|
362
|
+
}) : src;
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
out = _tokenizer.parse(val).join('');
|
|
366
|
+
} else {
|
|
367
|
+
out = val;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return(out);
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
//Encode the html to text
|
|
374
|
+
'toText':function(html) {
|
|
375
|
+
return html
|
|
376
|
+
.replace(/&/g, '&')
|
|
377
|
+
.replace(/</g, '<')
|
|
378
|
+
.replace(/>/g, '>')
|
|
379
|
+
.replace(/\"/g, '"')
|
|
380
|
+
.replace(/\'/g, ''')
|
|
381
|
+
.replace(/\//g, '/');
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
//Tokenizer
|
|
385
|
+
'_tokenizer':function( tokenizers, doBuild ){
|
|
386
|
+
|
|
387
|
+
if( !(this instanceof json2html._tokenizer ) )
|
|
388
|
+
return new json2html._tokenizer( tokenizers, doBuild );
|
|
389
|
+
|
|
390
|
+
this.tokenizers = tokenizers.splice ? tokenizers : [tokenizers];
|
|
391
|
+
if( doBuild )
|
|
392
|
+
this.doBuild = doBuild;
|
|
393
|
+
|
|
394
|
+
this.parse = function( src ){
|
|
395
|
+
this.src = src;
|
|
396
|
+
this.ended = false;
|
|
397
|
+
this.tokens = [ ];
|
|
398
|
+
do {
|
|
399
|
+
this.next();
|
|
400
|
+
} while( !this.ended );
|
|
401
|
+
return this.tokens;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
this.build = function( src, real ){
|
|
405
|
+
if( src )
|
|
406
|
+
this.tokens.push(
|
|
407
|
+
!this.doBuild ? src :
|
|
408
|
+
this.doBuild(src,real,this.tkn)
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
this.next = function(){
|
|
413
|
+
var self = this,
|
|
414
|
+
plain;
|
|
415
|
+
|
|
416
|
+
self.findMin();
|
|
417
|
+
plain = self.src.slice(0, self.min);
|
|
418
|
+
|
|
419
|
+
self.build( plain, false );
|
|
420
|
+
|
|
421
|
+
self.src = self.src.slice(self.min).replace(self.tkn,function( all ){
|
|
422
|
+
self.build(all, true);
|
|
423
|
+
return '';
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
if( !self.src )
|
|
427
|
+
self.ended = true;
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
this.findMin = function(){
|
|
431
|
+
var self = this, i=0, tkn, idx;
|
|
432
|
+
self.min = -1;
|
|
433
|
+
self.tkn = '';
|
|
434
|
+
|
|
435
|
+
while(( tkn = self.tokenizers[i++]) !== undefined ){
|
|
436
|
+
idx = self.src[tkn.test?'search':'indexOf'](tkn);
|
|
437
|
+
if( idx != -1 && (self.min == -1 || idx < self.min )){
|
|
438
|
+
self.tkn = tkn;
|
|
439
|
+
self.min = idx;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if( self.min == -1 )
|
|
443
|
+
self.min = self.src.length;
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
}
|
|
@@ -11,6 +11,7 @@ import Question_Programming from './Question_Programming.vue'
|
|
|
11
11
|
import Question_Classify from './Question_Classify.vue'
|
|
12
12
|
import {questionMapper} from "./const";
|
|
13
13
|
import fun from "../../assets/js/fun";
|
|
14
|
+
import {json2html} from "../../assets/js/json2html";
|
|
14
15
|
import storeOptions from './store'
|
|
15
16
|
let parseQuestionListItem = function(mode,question_list,answer_map,parentIndex = undefined){
|
|
16
17
|
function parseContent(arr,contentWidth){
|
|
@@ -89,14 +90,15 @@ let parseQuestionListItem = function(mode,question_list,answer_map,parentIndex =
|
|
|
89
90
|
let contentWidth = jQuery('.question-list').width() - 30
|
|
90
91
|
//图片宽度超出框架的时候把宽度设置成框架大小
|
|
91
92
|
parseContent(contentArr,contentWidth)
|
|
92
|
-
item.htmlContent = $.json2html({}, contentArr);
|
|
93
|
+
// item.htmlContent = $.json2html({}, contentArr);
|
|
94
|
+
item.htmlContent = json2html.transform({}, contentArr);
|
|
93
95
|
}catch(e){
|
|
94
96
|
item.htmlContent = item.content
|
|
95
97
|
}
|
|
96
98
|
//转化analysis富文本
|
|
97
99
|
try{
|
|
98
100
|
if(item.analysis){
|
|
99
|
-
item.analysisHtmlContent =
|
|
101
|
+
item.analysisHtmlContent = json2html.transform({}, JSON.parse(item.analysis));
|
|
100
102
|
}else{
|
|
101
103
|
item.analysisHtmlContent = ''
|
|
102
104
|
}
|
package/package2.json
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@zykjcommon/questions",
|
|
3
|
-
"version": "0.0.62",
|
|
4
|
-
"main": "src/components/questions/entry.js",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"serve": "vue-cli-service serve",
|
|
7
|
-
"design": "node tasks/vueMapper.js && node tasks/vueMapperTree.js && npm run serve -- --design",
|
|
8
|
-
"build": "vue-cli-service build",
|
|
9
|
-
"pre": "vue-cli-service build --mode test",
|
|
10
|
-
"buildTest": "vue-cli-service build --mode buildTest",
|
|
11
|
-
"lint": "vue-cli-service lint",
|
|
12
|
-
"build:lib": "vue-cli-service build --target lib src/components/questions/buildEntry.js --name zykjcommon-questions",
|
|
13
|
-
"publishLib": "node tasks/setPublishPackageJson.js && npm publish && node tasks/setOriPackageJson.js",
|
|
14
|
-
"publishZykjLib": "node tasks/setPublishPackageJson.js && npm publish --registry https://nexus.thedeer.cn/repository/npm-zykj-hosted/ && node tasks/setOriPackageJson.js"
|
|
15
|
-
},
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"alife-logger": "^1.8.30",
|
|
18
|
-
"axios": "^0.26.0",
|
|
19
|
-
"cookie": "^0.4.1",
|
|
20
|
-
"core-js": "^3.6.5",
|
|
21
|
-
"crypto-js": "^3.1.9-1",
|
|
22
|
-
"md5": "^2.2.1",
|
|
23
|
-
"mitt": "^3.0.0",
|
|
24
|
-
"mobile-detect": "^1.4.5",
|
|
25
|
-
"video.js": "^7.6.0",
|
|
26
|
-
"vue": "^3.0.0",
|
|
27
|
-
"vue-router": "^4.0.0-0",
|
|
28
|
-
"vuex": "^4.0.0-0",
|
|
29
|
-
"vuex-composition-helpers": "^2.0.1"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/node": "^18.11.9",
|
|
33
|
-
"@vue/cli-plugin-babel": "^5.0.1",
|
|
34
|
-
"@vue/cli-plugin-router": "~4.5.0",
|
|
35
|
-
"@vue/cli-plugin-typescript": "^5.0.1",
|
|
36
|
-
"@vue/cli-plugin-vuex": "~4.5.0",
|
|
37
|
-
"@vue/cli-service": "^5.0.1",
|
|
38
|
-
"@vue/compiler-sfc": "^3.0.0",
|
|
39
|
-
"@zykjcommon/questions": "^0.0.39",
|
|
40
|
-
"element-plus": "^2.0.2",
|
|
41
|
-
"file-loader": "^6.2.0",
|
|
42
|
-
"image-webpack-loader": "^8.1.0",
|
|
43
|
-
"postcss": "^8.4.6",
|
|
44
|
-
"postcss-cssnext": "^3.1.0",
|
|
45
|
-
"postcss-extend": "^1.0.5",
|
|
46
|
-
"postcss-import": "^14.0.2",
|
|
47
|
-
"postcss-mixins": "^6.2.1",
|
|
48
|
-
"postcss-nested": "^4.1.2",
|
|
49
|
-
"postcss-pxtorem": "^6.0.0",
|
|
50
|
-
"postcss-simple-vars": "^5.0.2",
|
|
51
|
-
"sass": "^1.26.5",
|
|
52
|
-
"sass-loader": "^8.0.2",
|
|
53
|
-
"typescript": "~4.1.5",
|
|
54
|
-
"unplugin-auto-import": "^0.6.0",
|
|
55
|
-
"unplugin-element-plus": "^0.3.1",
|
|
56
|
-
"unplugin-vue-components": "^0.17.18",
|
|
57
|
-
"url-loader": "^4.1.1",
|
|
58
|
-
"webpack": "^5.88.1",
|
|
59
|
-
"yargs": "^16.2.0"
|
|
60
|
-
},
|
|
61
|
-
"publishConfig": {
|
|
62
|
-
"access": "public",
|
|
63
|
-
"registry": "https://registry.npmjs.org"
|
|
64
|
-
}
|
|
65
|
-
}
|