sr-npm 1.7.1281 → 1.7.1283

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.1281",
3
+ "version": "1.7.1283",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,6 +42,8 @@ let considerAllJobs=false; // whether to consider all jobs or not
42
42
  let urlOnchangeIsActive=false
43
43
  let numbersofParamChanges=0;
44
44
  let pageIsRemoved=false
45
+ let selectedParamsList=[]
46
+ let urlParamsIndex=0;
45
47
  const pagination = {
46
48
  pageSize: 10,
47
49
  currentPage: 1,
@@ -49,7 +51,67 @@ const pagination = {
49
51
 
50
52
  async function careersMultiBoxesPageOnReady(_$w,urlParams) {
51
53
  //to handle back and forth , url changes
54
+ selectedParamsList.push(urlParams);
52
55
  onChange(async ()=>{
56
+
57
+
58
+ // INSERT_YOUR_CODE
59
+
60
+ // Yes, you can try to identify if it was a browser backward or forward navigation by using the window 'popstate' event and maintaining a stack/history index.
61
+ // Here's a simple approach using a navigation index:
62
+ if (typeof window !== "undefined") {
63
+ if (!window._careersNavIndex) {
64
+ window._careersNavIndex = 0;
65
+ }
66
+ }
67
+ let navDirection = null;
68
+
69
+ window.addEventListener('popstate', function (event) {
70
+ // Get new history state index, fallback to custom counter if unavailable
71
+ let newIndex = (history.state && history.state._careersNavIndex != null)
72
+ ? history.state._careersNavIndex
73
+ : (window._careersNavIndex || 0);
74
+
75
+ if (window._careersNavIndex != null) {
76
+ if (newIndex < window._careersNavIndex) {
77
+ navDirection = 'backward';
78
+ } else if (newIndex > window._careersNavIndex) {
79
+ navDirection = 'forward';
80
+ } else {
81
+ navDirection = null;
82
+ }
83
+ window._careersNavIndex = newIndex;
84
+ }
85
+ // You can use navDirection in your logic as needed
86
+ // Example: console.log('Navigation direction:', navDirection);
87
+ });
88
+
89
+ // On each navigation (including programmatic changes), increment the index, and push the state:
90
+ if (typeof history !== "undefined" && typeof window !== "undefined") {
91
+ window._careersNavIndex = window._careersNavIndex || 0;
92
+ if (!history.state || history.state._careersNavIndex == null) {
93
+ // Only set if not already set by another navigation
94
+ history.replaceState(
95
+ Object.assign({}, history.state, { _careersNavIndex: window._careersNavIndex }),
96
+ ''
97
+ );
98
+ }
99
+ // Whenever you push a new URL (not popstate), increment:
100
+ // window._careersNavIndex++;
101
+ // history.pushState(
102
+ // Object.assign({}, history.state, { _careersNavIndex: window._careersNavIndex }),
103
+ // ''
104
+ // );
105
+ }
106
+ // INSERT_YOUR_CODE
107
+ if (navDirection) {
108
+ console.log('Navigation direction:', navDirection);
109
+ }
110
+
111
+
112
+
113
+
114
+
53
115
  urlOnchangeIsActive=true;
54
116
  await handleBackAndForth(_$w);
55
117
  urlOnchangeIsActive=false;
@@ -74,6 +136,14 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
74
136
  }
75
137
 
76
138
  async function handleBackAndForth(_$w){
139
+ //check the case when i click on a category then i click on
140
+
141
+
142
+ const newQueryParams=await location.query();
143
+ selectedParamsStack.push(newQueryParams);
144
+
145
+
146
+
77
147
  if(ActivateURLOnchange) {
78
148
  const newQueryParams=await location.query();
79
149
  await clearAll(_$w,true);
@@ -86,6 +156,8 @@ async function handleBackAndForth(_$w){
86
156
  ActivateURLOnchange=true;
87
157
  }
88
158
  }
159
+
160
+
89
161
  // if(ActivateURLOnchange) {
90
162
  // const newQueryParams=await location.query();
91
163
  // console.log("newQueryParams: ", newQueryParams);
@@ -334,13 +406,17 @@ async function handleParams(_$w,param,values) {
334
406
 
335
407
 
336
408
  queryParams.add({ [fieldTitle] : updated.map(val=>encodeURIComponent(val)).join(',') });
409
+ if(urlOnchangeIsActive){
337
410
  numbersofParamChanges++;
411
+ }
338
412
  } else {
339
413
  selectedByField.delete(fieldId);
340
414
  handleConsiderAllJobs(previousSelectedSize,selectedByField.size);
341
415
 
342
416
  queryParams.remove([fieldTitle ]);
343
- numbersofParamChanges++;
417
+ if(urlOnchangeIsActive){
418
+ numbersofParamChanges++;
419
+ }
344
420
  }
345
421
 
346
422
  const currentVals = _$w(`#${FiltersIds[field.title]}CheckBox`).value || [];
@@ -444,13 +520,16 @@ async function loadJobsRepeater(_$w) {
444
520
 
445
521
  _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
446
522
  _$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
447
- // const currentQueryParams=await location.query();
448
- // if(currentQueryParams.page)
449
- // {
523
+ const currentQueryParams=await location.query();
524
+ if(currentQueryParams.page)
525
+ {
450
526
  // //try instead of removing to add page = 1
451
527
  // //queryParams.remove(["page"]);
452
528
  // queryParams.add({ ["page"]: 1 });
453
- // }
529
+ pageIsRemoved=true
530
+ //save the selected param
531
+
532
+ }
454
533
  dontUpdateThisCheckBox=field._id;
455
534
  const selected = ev.target.value; // array of selected value IDs
456
535
  let fieldTitle=field.title.toLowerCase().replace(' ', '');
@@ -466,18 +545,26 @@ async function loadJobsRepeater(_$w) {
466
545
  //in this case we need the label not valueid
467
546
  const valueLabels=getValueFromValueId(selected,value);
468
547
  queryParams.add({ [fieldTitle] : valueLabels.map(val=>encodeURIComponent(val)).join(',') });
469
- numbersofParamChanges++;
548
+
549
+ if(urlOnchangeIsActive){
550
+ numbersofParamChanges++;
551
+ }
470
552
  }
471
553
  else{
472
554
  queryParams.add({ [fieldTitle] : selected.map(val=>encodeURIComponent(val)).join(',') });
473
- numbersofParamChanges++;
555
+ if(urlOnchangeIsActive){
556
+ numbersofParamChanges++;
557
+ }
474
558
  }
475
559
 
476
560
  } else {
477
561
  selectedByField.delete(field._id);
478
562
  handleConsiderAllJobs(previousSelectedSize,selectedByField.size);
479
563
  queryParams.remove([fieldTitle ]);
480
- numbersofParamChanges++;
564
+
565
+ if(urlOnchangeIsActive){
566
+ numbersofParamChanges++;
567
+ }
481
568
  }
482
569
 
483
570
  console.log("selectedByField: ",selectedByField)