jqgrid_utils 1.2.6 → 1.2.9

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/README.md CHANGED
@@ -54,39 +54,39 @@ Discover All Functions:
54
54
  },
55
55
  ```
56
56
 
57
- <a name="module_Vanilla_website_utils"></a>
58
-
59
- ## Vanilla\_website\_utils
60
- A module for Vanilla_website_utils
61
-
62
-
63
- * [Vanilla_website_utils](#module_Vanilla_website_utils)
64
- * [module.exports#set_link()](#exp_module_Vanilla_website_utils--module.exports+set_link) ⏏
65
- * [module.exports#grid_set_captain()](#exp_module_Vanilla_website_utils--module.exports+grid_set_captain) ⏏
66
- * [module.exports#resize_saved_cell_width(col_model, page, grid)](#exp_module_Vanilla_website_utils--module.exports+resize_saved_cell_width) ⏏
67
- * [module.exports#upsert_row()](#exp_module_Vanilla_website_utils--module.exports+upsert_row) ⏏
68
- * [module.exports#insert_row()](#exp_module_Vanilla_website_utils--module.exports+insert_row) ⏏
69
- * [module.exports#update_row()](#exp_module_Vanilla_website_utils--module.exports+update_row) ⏏
70
- * [module.exports#delete_row()](#exp_module_Vanilla_website_utils--module.exports+delete_row) ⏏
71
- * [module.exports#adelete_api()](#exp_module_Vanilla_website_utils--module.exports+adelete_api) ⏏
72
- * [module.exports#post_json()](#exp_module_Vanilla_website_utils--module.exports+post_json) ⏏
73
- * [module.exports#put_json()](#exp_module_Vanilla_website_utils--module.exports+put_json) ⏏
74
- * [module.exports#hide_del_icon()](#exp_module_Vanilla_website_utils--module.exports+hide_del_icon) ⏏
75
- * [module.exports#add_link_details()](#exp_module_Vanilla_website_utils--module.exports+add_link_details) ⏏
76
- * [module.exports#add_link_details_separator()](#exp_module_Vanilla_website_utils--module.exports+add_link_details_separator) ⏏
77
- * [module.exports#__cell_format()](#exp_module_Vanilla_website_utils--module.exports+__cell_format) ⏏
78
- * [module.exports#subgrid(_id, id, data_url, col_model, caption)](#exp_module_Vanilla_website_utils--module.exports+subgrid) ⏏
79
- * [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Vanilla_website_utils--module.exports+add_image) ⏏
80
-
81
- <a name="exp_module_Vanilla_website_utils--module.exports+set_link"></a>
57
+ <a name="module_Jqgrid_utils"></a>
58
+
59
+ ## Jqgrid\_utils
60
+ A module for Jqgrid_utils
61
+
62
+
63
+ * [Jqgrid_utils](#module_Jqgrid_utils)
64
+ * [module.exports#set_link()](#exp_module_Jqgrid_utils--module.exports+set_link) ⏏
65
+ * [module.exports#grid_set_captain()](#exp_module_Jqgrid_utils--module.exports+grid_set_captain) ⏏
66
+ * [module.exports#resize_saved_cell_width(col_model, page, grid)](#exp_module_Jqgrid_utils--module.exports+resize_saved_cell_width) ⏏
67
+ * [module.exports#upsert_row()](#exp_module_Jqgrid_utils--module.exports+upsert_row) ⏏
68
+ * [module.exports#insert_row()](#exp_module_Jqgrid_utils--module.exports+insert_row) ⏏
69
+ * [module.exports#update_row()](#exp_module_Jqgrid_utils--module.exports+update_row) ⏏
70
+ * [module.exports#delete_row()](#exp_module_Jqgrid_utils--module.exports+delete_row) ⏏
71
+ * [module.exports#adelete_api()](#exp_module_Jqgrid_utils--module.exports+adelete_api) ⏏
72
+ * [module.exports#post_json()](#exp_module_Jqgrid_utils--module.exports+post_json) ⏏
73
+ * [module.exports#put_json()](#exp_module_Jqgrid_utils--module.exports+put_json) ⏏
74
+ * [module.exports#hide_del_icon()](#exp_module_Jqgrid_utils--module.exports+hide_del_icon) ⏏
75
+ * [module.exports#add_link_details()](#exp_module_Jqgrid_utils--module.exports+add_link_details) ⏏
76
+ * [module.exports#add_link_details_separator()](#exp_module_Jqgrid_utils--module.exports+add_link_details_separator) ⏏
77
+ * [module.exports#__cell_format()](#exp_module_Jqgrid_utils--module.exports+__cell_format) ⏏
78
+ * [module.exports#subgrid(_id, id, data_url, col_model, caption)](#exp_module_Jqgrid_utils--module.exports+subgrid) ⏏
79
+ * [module.exports#add_image(col_model, edit_field, size, link)](#exp_module_Jqgrid_utils--module.exports+add_image) ⏏
80
+
81
+ <a name="exp_module_Jqgrid_utils--module.exports+set_link"></a>
82
82
 
83
83
  ### module.exports#set\_link() ⏏
84
84
  **Kind**: Exported function
85
- <a name="exp_module_Vanilla_website_utils--module.exports+grid_set_captain"></a>
85
+ <a name="exp_module_Jqgrid_utils--module.exports+grid_set_captain"></a>
86
86
 
87
87
  ### module.exports#grid\_set\_captain() ⏏
88
88
  **Kind**: Exported function
89
- <a name="exp_module_Vanilla_website_utils--module.exports+resize_saved_cell_width"></a>
89
+ <a name="exp_module_Jqgrid_utils--module.exports+resize_saved_cell_width"></a>
90
90
 
91
91
  ### module.exports#resize\_saved\_cell\_width(col_model, page, grid) ⏏
92
92
  **Kind**: Exported function
@@ -101,39 +101,39 @@ A module for Vanilla_website_utils
101
101
  ```js
102
102
  col_model = await jqu.resize_saved_cell_width(col_model);
103
103
  ```
104
- <a name="exp_module_Vanilla_website_utils--module.exports+upsert_row"></a>
104
+ <a name="exp_module_Jqgrid_utils--module.exports+upsert_row"></a>
105
105
 
106
106
  ### module.exports#upsert\_row() ⏏
107
107
  **Kind**: Exported function
108
- <a name="exp_module_Vanilla_website_utils--module.exports+insert_row"></a>
108
+ <a name="exp_module_Jqgrid_utils--module.exports+insert_row"></a>
109
109
 
110
110
  ### module.exports#insert\_row() ⏏
111
111
  **Kind**: Exported function
112
- <a name="exp_module_Vanilla_website_utils--module.exports+update_row"></a>
112
+ <a name="exp_module_Jqgrid_utils--module.exports+update_row"></a>
113
113
 
114
114
  ### module.exports#update\_row() ⏏
115
115
  **Kind**: Exported function
116
- <a name="exp_module_Vanilla_website_utils--module.exports+delete_row"></a>
116
+ <a name="exp_module_Jqgrid_utils--module.exports+delete_row"></a>
117
117
 
118
118
  ### module.exports#delete\_row() ⏏
119
119
  **Kind**: Exported function
120
- <a name="exp_module_Vanilla_website_utils--module.exports+adelete_api"></a>
120
+ <a name="exp_module_Jqgrid_utils--module.exports+adelete_api"></a>
121
121
 
122
122
  ### module.exports#adelete\_api() ⏏
123
123
  **Kind**: Exported function
124
- <a name="exp_module_Vanilla_website_utils--module.exports+post_json"></a>
124
+ <a name="exp_module_Jqgrid_utils--module.exports+post_json"></a>
125
125
 
126
126
  ### module.exports#post\_json() ⏏
127
127
  **Kind**: Exported function
128
- <a name="exp_module_Vanilla_website_utils--module.exports+put_json"></a>
128
+ <a name="exp_module_Jqgrid_utils--module.exports+put_json"></a>
129
129
 
130
130
  ### module.exports#put\_json() ⏏
131
131
  **Kind**: Exported function
132
- <a name="exp_module_Vanilla_website_utils--module.exports+hide_del_icon"></a>
132
+ <a name="exp_module_Jqgrid_utils--module.exports+hide_del_icon"></a>
133
133
 
134
134
  ### module.exports#hide\_del\_icon() ⏏
135
135
  **Kind**: Exported function
136
- <a name="exp_module_Vanilla_website_utils--module.exports+add_link_details"></a>
136
+ <a name="exp_module_Jqgrid_utils--module.exports+add_link_details"></a>
137
137
 
138
138
  ### module.exports#add\_link\_details() ⏏
139
139
  **Kind**: Exported function
@@ -141,7 +141,7 @@ col_model = await jqu.resize_saved_cell_width(col_model);
141
141
  ```js
142
142
  example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
143
143
  ```
144
- <a name="exp_module_Vanilla_website_utils--module.exports+add_link_details_separator"></a>
144
+ <a name="exp_module_Jqgrid_utils--module.exports+add_link_details_separator"></a>
145
145
 
146
146
  ### module.exports#add\_link\_details\_separator() ⏏
147
147
  **Kind**: Exported function
@@ -149,11 +149,11 @@ example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 't
149
149
  ```js
150
150
  col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
151
151
  ```
152
- <a name="exp_module_Vanilla_website_utils--module.exports+__cell_format"></a>
152
+ <a name="exp_module_Jqgrid_utils--module.exports+__cell_format"></a>
153
153
 
154
154
  ### module.exports#\_\_cell\_format() ⏏
155
155
  **Kind**: Exported function
156
- <a name="exp_module_Vanilla_website_utils--module.exports+subgrid"></a>
156
+ <a name="exp_module_Jqgrid_utils--module.exports+subgrid"></a>
157
157
 
158
158
  ### module.exports#subgrid(_id, id, data_url, col_model, caption) ⏏
159
159
  **Kind**: Exported function
@@ -172,7 +172,7 @@ let data_url = api + '/phone_detail?f=data&_id=';
172
172
  let col_model_url = api + '/phone_detail?f=col_model';
173
173
  let col_model = JSON.parse(await vwu.aget_api(col_model_url))
174
174
  ```
175
- <a name="exp_module_Vanilla_website_utils--module.exports+add_image"></a>
175
+ <a name="exp_module_Jqgrid_utils--module.exports+add_image"></a>
176
176
 
177
177
  ### module.exports#add\_image(col_model, edit_field, size, link) ⏏
178
178
  **Kind**: Exported function
@@ -1,7 +1,7 @@
1
1
  (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Jqgrid_utils = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
2
  /**
3
- * A module for Vanilla_website_utils
4
- * @module Vanilla_website_utils
3
+ * A module for Jqgrid_utils
4
+ * @module Jqgrid_utils
5
5
  */
6
6
 
7
7
  'use strict';
@@ -28,7 +28,7 @@ module.exports = class Vanilla_website_utils
28
28
  }
29
29
 
30
30
  /**
31
- @alias module:Vanilla_website_utils
31
+ @alias module:Jqgrid_utils
32
32
  */
33
33
  async set_link(col_model, edit_field, url ,attr='')
34
34
  {
@@ -52,7 +52,7 @@ module.exports = class Vanilla_website_utils
52
52
  }
53
53
 
54
54
  /**
55
- @alias module:Vanilla_website_utils
55
+ @alias module:Jqgrid_utils
56
56
  */
57
57
  async grid_set_captain(_grid, data=[])
58
58
  {
@@ -81,7 +81,7 @@ module.exports = class Vanilla_website_utils
81
81
 
82
82
 
83
83
  /**
84
- @alias module:Vanilla_website_utils
84
+ @alias module:Jqgrid_utils
85
85
  @param {object} - the col_model of the grid
86
86
  @param {string} - the name of the page(optional)
87
87
  @param {object} - the grid objec(optional)
@@ -111,9 +111,7 @@ module.exports = class Vanilla_website_utils
111
111
  }
112
112
 
113
113
  /**
114
- @alias module:Vanilla_website_utils
115
- * resize_cell
116
- * call after resize a column
114
+ @alias module:Jqgrid_utils
117
115
  @param {string} the width of the resized column
118
116
  @param {string} column number what get resized
119
117
  @param {string} not in use yet
@@ -141,7 +139,7 @@ module.exports = class Vanilla_website_utils
141
139
 
142
140
 
143
141
  /**
144
- @alias module:Vanilla_website_utils
142
+ @alias module:Jqgrid_utils
145
143
  */
146
144
  async upsert_row(row, url, req = {})
147
145
  {
@@ -158,7 +156,7 @@ async upsert_row(row, url, req = {})
158
156
  }
159
157
 
160
158
  /**
161
- @alias module:Vanilla_website_utils
159
+ @alias module:Jqgrid_utils
162
160
  */
163
161
  async insert_row(row, url)
164
162
  {
@@ -182,7 +180,7 @@ async insert_row(row, url)
182
180
 
183
181
 
184
182
  /**
185
- @alias module:Vanilla_website_utils
183
+ @alias module:Jqgrid_utils
186
184
  */
187
185
  async update_row(row, url, req = {})
188
186
  {
@@ -205,7 +203,7 @@ async update_row(row, url, req = {})
205
203
  }
206
204
 
207
205
  /**
208
- @alias module:Vanilla_website_utils
206
+ @alias module:Jqgrid_utils
209
207
  */
210
208
  async delete_row(_id, url)
211
209
  {
@@ -225,7 +223,7 @@ async delete_row(_id, url)
225
223
 
226
224
 
227
225
  /**
228
- @alias module:Vanilla_website_utils
226
+ @alias module:Jqgrid_utils
229
227
  */
230
228
  async adelete_api(url, json = false)
231
229
  {
@@ -243,7 +241,7 @@ async adelete_api(url, json = false)
243
241
 
244
242
 
245
243
  /**
246
- @alias module:Vanilla_website_utils
244
+ @alias module:Jqgrid_utils
247
245
  */
248
246
  async post_json(url, data)
249
247
  {
@@ -259,7 +257,7 @@ async post_json(url, data)
259
257
  }
260
258
 
261
259
  /**
262
- @alias module:Vanilla_website_utils
260
+ @alias module:Jqgrid_utils
263
261
  */
264
262
  async put_json(url, data)
265
263
  {
@@ -281,7 +279,7 @@ s_hide_del_icon()
281
279
  }
282
280
 
283
281
  /**
284
- @alias module:Vanilla_website_utils
282
+ @alias module:Jqgrid_utils
285
283
  */
286
284
  async hide_del_icon()
287
285
  {
@@ -291,7 +289,7 @@ async hide_del_icon()
291
289
 
292
290
 
293
291
  /**
294
- @alias module:Vanilla_website_utils
292
+ @alias module:Jqgrid_utils
295
293
  @example
296
294
  * example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
297
295
  */
@@ -363,7 +361,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
363
361
 
364
362
 
365
363
  /**
366
- @alias module:Vanilla_website_utils
364
+ @alias module:Jqgrid_utils
367
365
  @example
368
366
  * col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
369
367
  */
@@ -430,7 +428,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
430
428
 
431
429
 
432
430
  /**
433
- @alias module:Vanilla_website_utils
431
+ @alias module:Jqgrid_utils
434
432
  */
435
433
  __cell_format(cell_value, format)
436
434
  {
@@ -451,7 +449,7 @@ __cell_format(cell_value, format)
451
449
 
452
450
 
453
451
  /**
454
- @alias module:Vanilla_website_utils
452
+ @alias module:Jqgrid_utils
455
453
  @param {string} - row_id
456
454
  @param {string} - data id
457
455
  @param {string} - url to request
@@ -483,7 +481,7 @@ async subgrid(_id, id, data_url, col_model, caption='' )
483
481
 
484
482
 
485
483
  /**
486
- @alias module:Vanilla_website_utils
484
+ @alias module:Jqgrid_utils
487
485
  @param {object} - col_model for the grid
488
486
  @param {string} - field what include the image/picture href path like http://mypicture.png
489
487
  @param {int} - size of the picture
@@ -506,14 +504,28 @@ async add_image(col_model, edit_field, size, link=false)
506
504
  col_model[i]['height'] = size;
507
505
  col_model[i]['formatter'] = function(cell_val)
508
506
  {
509
- if(link)
507
+ const cell_val2 = cell_val.toLowerCase();
508
+ if(cell_val2.startsWith('https://', 0) || cell_val2.startsWith('http://', 0) )
510
509
  {
511
- return '<a target="blank" href="' + cell_val + '"><img src="' + cell_val + '" alt="my image" width="' + size + '" /></a>';
510
+ if(cell_val2.endsWith(".png") ||
511
+ cell_val2.endsWith(".jpg") ||
512
+ cell_val2.endsWith(".jpeg") ||
513
+ cell_val2.endsWith(".gif") ||
514
+ cell_val2.endsWith(".svg") ||
515
+ cell_val2.endsWith(".svgz") ||
516
+ cell_val2.endsWith(".webp"))
517
+ {
518
+ if(link)
519
+ {
520
+ return '<a target="blank" href="' + cell_val + '"><img src="' + cell_val + '" alt="my image" width="' + size + '" /></a>';
521
+ }
522
+ else
523
+ {
524
+ return '<img src="' + cell_val + '" alt="my image" width="' + size + '" />';
525
+ }
526
+ }
512
527
  }
513
- else
514
- {
515
- return '<img src="' + cell_val + '" alt="my image" width="' + size + '" />';
516
- }
528
+ return cell_val;
517
529
  };
518
530
  }
519
531
  }
@@ -522,6 +534,9 @@ async add_image(col_model, edit_field, size, link=false)
522
534
 
523
535
 
524
536
 
537
+
538
+
539
+
525
540
  };
526
541
 
527
542
 
package/jqgrid_utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * A module for Vanilla_website_utils
3
- * @module Vanilla_website_utils
2
+ * A module for Jqgrid_utils
3
+ * @module Jqgrid_utils
4
4
  */
5
5
 
6
6
  'use strict';
@@ -27,7 +27,7 @@ module.exports = class Vanilla_website_utils
27
27
  }
28
28
 
29
29
  /**
30
- @alias module:Vanilla_website_utils
30
+ @alias module:Jqgrid_utils
31
31
  */
32
32
  async set_link(col_model, edit_field, url ,attr='')
33
33
  {
@@ -51,7 +51,7 @@ module.exports = class Vanilla_website_utils
51
51
  }
52
52
 
53
53
  /**
54
- @alias module:Vanilla_website_utils
54
+ @alias module:Jqgrid_utils
55
55
  */
56
56
  async grid_set_captain(_grid, data=[])
57
57
  {
@@ -80,7 +80,7 @@ module.exports = class Vanilla_website_utils
80
80
 
81
81
 
82
82
  /**
83
- @alias module:Vanilla_website_utils
83
+ @alias module:Jqgrid_utils
84
84
  @param {object} - the col_model of the grid
85
85
  @param {string} - the name of the page(optional)
86
86
  @param {object} - the grid objec(optional)
@@ -110,9 +110,7 @@ module.exports = class Vanilla_website_utils
110
110
  }
111
111
 
112
112
  /**
113
- @alias module:Vanilla_website_utils
114
- * resize_cell
115
- * call after resize a column
113
+ @alias module:Jqgrid_utils
116
114
  @param {string} the width of the resized column
117
115
  @param {string} column number what get resized
118
116
  @param {string} not in use yet
@@ -140,7 +138,7 @@ module.exports = class Vanilla_website_utils
140
138
 
141
139
 
142
140
  /**
143
- @alias module:Vanilla_website_utils
141
+ @alias module:Jqgrid_utils
144
142
  */
145
143
  async upsert_row(row, url, req = {})
146
144
  {
@@ -157,7 +155,7 @@ async upsert_row(row, url, req = {})
157
155
  }
158
156
 
159
157
  /**
160
- @alias module:Vanilla_website_utils
158
+ @alias module:Jqgrid_utils
161
159
  */
162
160
  async insert_row(row, url)
163
161
  {
@@ -181,7 +179,7 @@ async insert_row(row, url)
181
179
 
182
180
 
183
181
  /**
184
- @alias module:Vanilla_website_utils
182
+ @alias module:Jqgrid_utils
185
183
  */
186
184
  async update_row(row, url, req = {})
187
185
  {
@@ -204,7 +202,7 @@ async update_row(row, url, req = {})
204
202
  }
205
203
 
206
204
  /**
207
- @alias module:Vanilla_website_utils
205
+ @alias module:Jqgrid_utils
208
206
  */
209
207
  async delete_row(_id, url)
210
208
  {
@@ -224,7 +222,7 @@ async delete_row(_id, url)
224
222
 
225
223
 
226
224
  /**
227
- @alias module:Vanilla_website_utils
225
+ @alias module:Jqgrid_utils
228
226
  */
229
227
  async adelete_api(url, json = false)
230
228
  {
@@ -242,7 +240,7 @@ async adelete_api(url, json = false)
242
240
 
243
241
 
244
242
  /**
245
- @alias module:Vanilla_website_utils
243
+ @alias module:Jqgrid_utils
246
244
  */
247
245
  async post_json(url, data)
248
246
  {
@@ -258,7 +256,7 @@ async post_json(url, data)
258
256
  }
259
257
 
260
258
  /**
261
- @alias module:Vanilla_website_utils
259
+ @alias module:Jqgrid_utils
262
260
  */
263
261
  async put_json(url, data)
264
262
  {
@@ -280,7 +278,7 @@ s_hide_del_icon()
280
278
  }
281
279
 
282
280
  /**
283
- @alias module:Vanilla_website_utils
281
+ @alias module:Jqgrid_utils
284
282
  */
285
283
  async hide_del_icon()
286
284
  {
@@ -290,7 +288,7 @@ async hide_del_icon()
290
288
 
291
289
 
292
290
  /**
293
- @alias module:Vanilla_website_utils
291
+ @alias module:Jqgrid_utils
294
292
  @example
295
293
  * example: col_model = await jqu.add_link_details(col_model,'http://foo.bar'' , 'target_field','target="_blank"',{"key":"field1","key":"field2"});
296
294
  */
@@ -362,7 +360,7 @@ async add_link_details(col_model, url, edit_field, attr = '', keys, format)
362
360
 
363
361
 
364
362
  /**
365
- @alias module:Vanilla_website_utils
363
+ @alias module:Jqgrid_utils
366
364
  @example
367
365
  * col_model = await jqu.add_link_details_separator(col_model, 'https://foo.com' , 'couchdb','target="_blank"',{"mykey":"myval"});
368
366
  */
@@ -429,7 +427,7 @@ async add_link_details_separator(col_model, url, edit_field, attr = '', keys, fo
429
427
 
430
428
 
431
429
  /**
432
- @alias module:Vanilla_website_utils
430
+ @alias module:Jqgrid_utils
433
431
  */
434
432
  __cell_format(cell_value, format)
435
433
  {
@@ -450,7 +448,7 @@ __cell_format(cell_value, format)
450
448
 
451
449
 
452
450
  /**
453
- @alias module:Vanilla_website_utils
451
+ @alias module:Jqgrid_utils
454
452
  @param {string} - row_id
455
453
  @param {string} - data id
456
454
  @param {string} - url to request
@@ -482,7 +480,7 @@ async subgrid(_id, id, data_url, col_model, caption='' )
482
480
 
483
481
 
484
482
  /**
485
- @alias module:Vanilla_website_utils
483
+ @alias module:Jqgrid_utils
486
484
  @param {object} - col_model for the grid
487
485
  @param {string} - field what include the image/picture href path like http://mypicture.png
488
486
  @param {int} - size of the picture
@@ -505,14 +503,28 @@ async add_image(col_model, edit_field, size, link=false)
505
503
  col_model[i]['height'] = size;
506
504
  col_model[i]['formatter'] = function(cell_val)
507
505
  {
508
- if(link)
506
+ const cell_val2 = cell_val.toLowerCase();
507
+ if(cell_val2.startsWith('https://', 0) || cell_val2.startsWith('http://', 0) )
509
508
  {
510
- return '<a target="blank" href="' + cell_val + '"><img src="' + cell_val + '" alt="my image" width="' + size + '" /></a>';
509
+ if(cell_val2.endsWith(".png") ||
510
+ cell_val2.endsWith(".jpg") ||
511
+ cell_val2.endsWith(".jpeg") ||
512
+ cell_val2.endsWith(".gif") ||
513
+ cell_val2.endsWith(".svg") ||
514
+ cell_val2.endsWith(".svgz") ||
515
+ cell_val2.endsWith(".webp"))
516
+ {
517
+ if(link)
518
+ {
519
+ return '<a target="blank" href="' + cell_val + '"><img src="' + cell_val + '" alt="my image" width="' + size + '" /></a>';
520
+ }
521
+ else
522
+ {
523
+ return '<img src="' + cell_val + '" alt="my image" width="' + size + '" />';
524
+ }
525
+ }
511
526
  }
512
- else
513
- {
514
- return '<img src="' + cell_val + '" alt="my image" width="' + size + '" />';
515
- }
527
+ return cell_val;
516
528
  };
517
529
  }
518
530
  }
@@ -521,6 +533,9 @@ async add_image(col_model, edit_field, size, link=false)
521
533
 
522
534
 
523
535
 
536
+
537
+
538
+
524
539
  };
525
540
 
526
541
 
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  {
30
30
  "test": "echo \"Error: no test specified\" && exit 1"
31
31
  },
32
- "version": "1.2.6"
32
+ "version": "1.2.9"
33
33
  }