@osimatic/helpers-js 1.0.11 → 1.0.12
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/bank.js
CHANGED
|
@@ -4,4 +4,19 @@ class IBAN {
|
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
class BankCard {
|
|
8
|
+
static formatCardNumber(cardNumber) {
|
|
9
|
+
if (cardNumber.length === 16) {
|
|
10
|
+
cardNumber = cardNumber.substring(0, 4)+'-'+cardNumber.substring(4, 8)+'-'+cardNumber.substring(8, 12)+'-'+cardNumber.substring(12, 16);
|
|
11
|
+
cardNumber = cardNumber.replace(/(\*)/gi, 'X');
|
|
12
|
+
}
|
|
13
|
+
return cardNumber;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static formatExpirationDate(expirationDate) {
|
|
17
|
+
let locale = typeof locale != 'undefined' ? locale : 'fr-FR';
|
|
18
|
+
return SqlDateTime.getMonthName(expirationDate, locale)+' '+SqlDateTime.getYear(expirationDate);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { IBAN, BankCard };
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@ require('./array');
|
|
|
7
7
|
|
|
8
8
|
// exports d'ojets non natif
|
|
9
9
|
const { HTTPRequest, Cookie, UrlAndQueryString } = require('./network');
|
|
10
|
-
const { IBAN } = require('./bank');
|
|
10
|
+
const { IBAN, BankCard } = require('./bank');
|
|
11
11
|
const { AudioMedia } = require('./media');
|
|
12
12
|
const { PersonName, Email, TelephoneNumber } = require('./contact_details');
|
|
13
13
|
const { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod } = require('./date_time');
|
|
@@ -22,9 +22,12 @@ const { chr, ord, trim, empty } = require('./php.min');
|
|
|
22
22
|
// exports plugins "maison"
|
|
23
23
|
const { DataTable } = require('./data_table');
|
|
24
24
|
const { Pagination, Navigation } = require('./paging');
|
|
25
|
+
const { DetailsSubArray } = require('./details_sub_array');
|
|
26
|
+
const { SelectAll } = require('./select_all');
|
|
27
|
+
const { MultipleActionInTable } = require('./multiple_action_in_table');
|
|
28
|
+
const { ShoppingCart } = require('./shopping_cart');
|
|
25
29
|
const { FlashMessage } = require('./flash_message');
|
|
26
30
|
const { CountDown } = require('./count_down');
|
|
27
|
-
const { DetailsSubArray } = require('./details_sub_array');
|
|
28
31
|
const { ImportFromCsv } = require('./import_from_csv');
|
|
29
32
|
const { JwtToken, JwtSession } = require('./jwt');
|
|
30
33
|
const { ListBox } = require('./list_box');
|
|
@@ -40,8 +43,8 @@ const { NumberValue } = require('./number');
|
|
|
40
43
|
|
|
41
44
|
module.exports = {
|
|
42
45
|
Array, Object, Number, String,
|
|
43
|
-
HTTPRequest, Cookie, UrlAndQueryString, IBAN, AudioMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, NumberValue,
|
|
44
|
-
DataTable, Pagination, Navigation, FlashMessage, CountDown,
|
|
46
|
+
HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, NumberValue,
|
|
47
|
+
DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
|
|
45
48
|
sleep, refresh, chr, ord, trim, empty,
|
|
46
49
|
GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
|
|
47
50
|
};
|
|
@@ -111,11 +111,7 @@ class MultipleActionInTable {
|
|
|
111
111
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
$('table.table-action_multiple').each(function(idx, table) {
|
|
116
|
-
MultipleActionInTable.init($(table));
|
|
117
|
-
});
|
|
118
|
-
});
|
|
114
|
+
module.exports = { MultipleActionInTable };
|
|
119
115
|
|
|
120
116
|
/*
|
|
121
117
|
// init checkbox
|
package/package.json
CHANGED
|
@@ -114,19 +114,4 @@ class SelectAll {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
// Dans un form-group
|
|
119
|
-
$('a.check_all').each(function(idx, link) {
|
|
120
|
-
SelectAll.initLinkInFormGroup($(link));
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Dans tableau
|
|
124
|
-
$('table tr input.check_all').each(function(idx, inputCheckAll) {
|
|
125
|
-
SelectAll.initInTable($(inputCheckAll).closest('table'));
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// Dans un div
|
|
129
|
-
$('div.checkbox_with_check_all').each(function(idx, div) {
|
|
130
|
-
SelectAll.initDiv($(div));
|
|
131
|
-
});
|
|
132
|
-
});
|
|
117
|
+
module.exports = { SelectAll };
|
package/shopping_cart.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class ShoppingCart {
|
|
2
|
+
static addProduct(productId, quantity, data) {
|
|
3
|
+
let cart = this.getCart();
|
|
4
|
+
let item = cart.find(element => element.product_id == productId);
|
|
5
|
+
if (typeof item != 'undefined') {
|
|
6
|
+
cart.unsetVal(item);
|
|
7
|
+
quantity += item.quantity;
|
|
8
|
+
}
|
|
9
|
+
cart.push({product_id: productId, quantity: quantity, data: data});
|
|
10
|
+
localStorage.setItem('cart', JSON.stringify(cart));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static deleteProduct(productId) {
|
|
14
|
+
let cart = this.getCart();
|
|
15
|
+
cart.unsetVal(cart.find(element => element.product_id == productId));
|
|
16
|
+
localStorage.setItem('cart', JSON.stringify(cart));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static removeAllItems() {
|
|
20
|
+
localStorage.removeItem('cart');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static getCart() {
|
|
24
|
+
let cart = [];
|
|
25
|
+
if (localStorage.getItem('cart') != null) {
|
|
26
|
+
cart = JSON.parse(localStorage.getItem('cart'));
|
|
27
|
+
}
|
|
28
|
+
return cart;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { ShoppingCart };
|