sr-npm 1.7.273 → 1.7.275

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": "sr-npm",
3
- "version": "1.7.273",
3
+ "version": "1.7.275",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,7 +7,7 @@ const {
7
7
  debounce,
8
8
  getFilter,
9
9
  } = require('../public/filterUtils');
10
-
10
+ const { filterBrokenMarkers } = require('../public/utils');
11
11
  let currentLoadedItems =100;
12
12
  const itemsPerPage = 100;
13
13
  let allJobs=[]
@@ -18,6 +18,7 @@ const {
18
18
  let queryKeyWordVar;
19
19
  let queryDepartmentVar;
20
20
  let queryLocationVar;
21
+ let searchInputIsUsed=false;
21
22
  async function careersPageOnReady(_$w,thisObject,queryParams) {
22
23
  console.log("queryParams: ", queryParams);
23
24
  const { page, keyWord, department, location } = queryParams;
@@ -160,9 +161,9 @@ async function bind(_$w) {
160
161
  }
161
162
 
162
163
  function init(_$w) {
163
- const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
164
164
 
165
- _$w('#searchInput').onInput(debouncedSearch);
165
+ _$w('#searchInput').onInput(onchangeSearchInput);
166
+ _$w('#searchInput').onBlur(()=>searchInputIsUsed=false);
166
167
  _$w('#dropdownDepartment, #dropdownLocation, #dropdownJobType').onChange(()=>applyFilters(_$w));
167
168
  _$w('#resetFiltersButton, #clearSearch').onClick(()=>resetFilters(_$w));
168
169
 
@@ -176,6 +177,16 @@ function init(_$w) {
176
177
 
177
178
  }
178
179
 
180
+ function onchangeSearchInput(_$w){
181
+ const debouncedSearch = debounce(()=>applyFilters(_$w), 400,thisObjectVar);
182
+ debouncedSearch();
183
+ _$w('#searchInput').focus();
184
+
185
+
186
+ console.log("onchangeSearchInput");
187
+ searchInputIsUsed=true;
188
+ }
189
+
179
190
  async function applyFilters(_$w, skipUrlUpdate = false) {
180
191
  console.log("applying filters");
181
192
  const dropdownFiltersMapping = [
@@ -250,6 +261,11 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
250
261
  // Update reset button state
251
262
  const hasActiveFilters = filters.length > 0;
252
263
  hasActiveFilters? _$w('#resetFiltersButton').enable() : _$w('#resetFiltersButton').disable();
264
+ if(searchInputIsUsed){
265
+ _$w('#searchInput').focus();
266
+ }
267
+
268
+
253
269
  }
254
270
 
255
271
  async function resetFilters(_$w) {
@@ -349,20 +365,7 @@ async function handleLocationParam(_$w,location) {
349
365
  async function updateMapMarkers(_$w){
350
366
  const numOfItems = await _$w('#jobsDataset').getTotalCount();
351
367
  const items = await _$w('#jobsDataset').getItems(0, numOfItems);
352
- const markers = items.items
353
- .filter(item => {
354
- const locationAddress = item.locationAddress;
355
- const location = locationAddress && locationAddress.location;
356
- return (
357
- location !== undefined &&
358
- location !== null &&
359
- location.latitude !== undefined &&
360
- location.latitude !== null &&
361
- location.longitude !== undefined &&
362
- location.longitude !== null
363
- );
364
- })
365
- .map(item => {
368
+ const markers = filterBrokenMarkers(items.items).map(item => {
366
369
  const location = item.locationAddress.location;
367
370
  return {
368
371
  location: {
package/pages/homePage.js CHANGED
@@ -3,6 +3,7 @@ const {
3
3
  getFilter,
4
4
  } = require('../public/filterUtils');
5
5
  const { handleOnLocationClick } = require('../public/mapUtils');
6
+ const { filterBrokenMarkers } = require('../public/utils');
6
7
  const { location } = require('@wix/site-location');
7
8
  let thisObjectVar;
8
9
  async function homePageOnReady(_$w,thisObject) {
@@ -25,7 +26,7 @@ async function homePageOnReady(_$w,thisObject) {
25
26
  const numOfItems = await _$w('#citiesDataset').getTotalCount();
26
27
  const items = await _$w('#citiesDataset').getItems(0, numOfItems);
27
28
  let baseUrl = await location.baseUrl();
28
- const markers = items.items.map(item => {
29
+ const markers = filterBrokenMarkers(items.items).map(item => {
29
30
  const location = item.locationAddress.location;
30
31
  const cityName = encodeURIComponent(item.title); // Use the city name from the item
31
32
  const cityLinkUrl = `${baseUrl}/positions?location=${cityName}`; // Add city as search parameter
package/public/utils.js CHANGED
@@ -22,7 +22,24 @@ function htmlToText(html) {
22
22
  return text.replace(/\n\s*\n+/g, '\n\n').replace(/[ \t]+\n/g, '\n').trim();
23
23
  }
24
24
 
25
+ function filterBrokenMarkers(items) {
26
+ return items
27
+ .filter(item => {
28
+ const locationAddress = item.locationAddress;
29
+ const location = locationAddress && locationAddress.location;
30
+ return (
31
+ location !== undefined &&
32
+ location !== null &&
33
+ location.latitude !== undefined &&
34
+ location.latitude !== null &&
35
+ location.longitude !== undefined &&
36
+ location.longitude !== null
37
+ );
38
+ })
39
+ }
40
+
25
41
 
26
42
  module.exports = {
27
- htmlToText
43
+ htmlToText,
44
+ filterBrokenMarkers
28
45
  };