Skip to content

Commit 2b71f73

Browse files
Remove jQuery dependencies
1 parent 45b5803 commit 2b71f73

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"eslint-config-prettier": "2.9.0",
5151
"eslint-plugin-import": "2.8.0",
5252
"eslint-plugin-react": "7.5.1",
53+
"extend": "3.0.1",
5354
"gettext-parser": "1.3.0",
5455
"grunt": "1.0.1",
5556
"grunt-babel": "7.0.0",

src/javascript/_common/base/client_base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const ClientBase = (() => {
9292

9393
const getAccountOfType = (type, only_enabled) => {
9494
const id = getAllLoginids().find(loginid => isAccountOfType(type, loginid, only_enabled));
95-
return id ? $.extend({ loginid: id }, get(null, id)) : {};
95+
return id ? Object.assign({ loginid: id }, get(null, id)) : {};
9696
};
9797

9898
const hasAccountType = (type, only_enabled) => !isEmptyObject(getAccountOfType(type, only_enabled));

src/javascript/_common/base/socket_base.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const ClientBase = require('./client_base');
22
const SocketCache = require('../base/socket_cache');
33
const getLanguage = require('../language').get;
44
const State = require('../storage').State;
5+
const cloneObject = require('../utility').cloneObject;
56
const getPropertyValue = require('../utility').getPropertyValue;
67
const isEmptyObject = require('../utility').isEmptyObject;
78
const getAppId = require('../../config').getAppId;
@@ -69,7 +70,7 @@ const BinarySocketBase = (() => {
6970
Object.keys(waiting_list.items)
7071
.some(type => (
7172
type !== msg_type &&
72-
$.inArray(pr, waiting_list.items[type]) >= 0
73+
waiting_list.items[type].indexOf(pr) !== -1
7374
))
7475
),
7576
};
@@ -132,7 +133,7 @@ const BinarySocketBase = (() => {
132133
if (!options.forced) {
133134
const response = SocketCache.get(data, msg_type);
134135
if (response) {
135-
State.set(['response', msg_type], $.extend({}, response));
136+
State.set(['response', msg_type], cloneObject(response));
136137
if (isReady() && is_available) { // make the request to keep the cache updated
137138
binary_socket.send(JSON.stringify(data));
138139
}
@@ -181,7 +182,7 @@ const BinarySocketBase = (() => {
181182
sent_requests.add(msg_type);
182183
}
183184
} else if (+data.time !== 1) { // Do not buffer all time requests
184-
buffered_sends.push({ request: data, options: $.extend(options, { promise: promise_obj }) });
185+
buffered_sends.push({ request: data, options: Object.assign(options, { promise: promise_obj }) });
185186
}
186187

187188
return promise_obj.promise;
@@ -225,7 +226,7 @@ const BinarySocketBase = (() => {
225226

226227
// store in State
227228
if (!getPropertyValue(response, ['echo_req', 'subscribe']) || /balance|website_status/.test(msg_type)) {
228-
State.set(['response', msg_type], $.extend({}, response));
229+
State.set(['response', msg_type], cloneObject(response));
229230
}
230231
// resolve the send promise
231232
const this_req_id = response.req_id;

src/javascript/_common/url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const Url = (() => {
7878
*/
7979
const updateParamsWithoutReload = (new_params, should_preserve_old) => {
8080
const updated_params = should_preserve_old
81-
? $.extend(paramsHash(), new_params)
81+
? Object.assign(paramsHash(), new_params)
8282
: new_params;
8383
Object.keys(new_params).forEach(key => {
8484
if (new_params[key] === null) {

src/javascript/_common/utility.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const extend = require('extend');
12
require('./lib/polyfills/element.matches');
23

34
/**
@@ -13,11 +14,11 @@ const showLoadingImage = (container, theme = 'dark') => {
1314

1415
/**
1516
* Returns the highest z-index in the page.
16-
* Accepts a jquery style selector to only check those elements,
17+
* Accepts a selector to only check those elements,
1718
* uses all container tags by default
1819
* If no element found, returns null.
1920
*
20-
* @param selector: a jquery style selector for target elements
21+
* @param selector: a selector for target elements
2122
* @return int|null
2223
*/
2324
const getHighestZIndex = (selector = 'div,p,area,nav,section,header,canvas,aside,span') => {
@@ -66,7 +67,7 @@ const isEmptyObject = (obj) => {
6667
return is_empty;
6768
};
6869

69-
const cloneObject = obj => (!isEmptyObject(obj) ? $.extend(true, Array.isArray(obj) ? [] : {}, obj) : obj);
70+
const cloneObject = obj => (!isEmptyObject(obj) ? extend(true, Array.isArray(obj) ? [] : {}, obj) : obj);
7071

7172
const getPropertyValue = (obj, k) => {
7273
let keys = k;
@@ -174,7 +175,7 @@ const findParent = (el, selector) => {
174175

175176
let static_hash;
176177
const getStaticHash = () => {
177-
static_hash = static_hash || ($('script[src*="binary.min.js"],script[src*="binary.js"]').attr('src') || '').split('?')[1];
178+
static_hash = static_hash || (document.querySelector('script[src*="vendor.min.js"]').getAttribute('src') || '').split('?')[1];
178179
return static_hash;
179180
};
180181

@@ -183,8 +184,8 @@ module.exports = {
183184
getHighestZIndex,
184185
downloadCSV,
185186
template,
186-
cloneObject,
187187
isEmptyObject,
188+
cloneObject,
188189
getPropertyValue,
189190
handleHash,
190191
clearable,

0 commit comments

Comments
 (0)