sr-npm 1.7.1282 → 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.1282",
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);
@@ -448,13 +520,16 @@ async function loadJobsRepeater(_$w) {
448
520
 
449
521
  _$w(`#${FiltersIds[field.title]}CheckBox`).selectedIndices = []; // start empty
450
522
  _$w(`#${FiltersIds[field.title]}CheckBox`).onChange(async (ev) => {
451
- // const currentQueryParams=await location.query();
452
- // if(currentQueryParams.page)
453
- // {
523
+ const currentQueryParams=await location.query();
524
+ if(currentQueryParams.page)
525
+ {
454
526
  // //try instead of removing to add page = 1
455
527
  // //queryParams.remove(["page"]);
456
528
  // queryParams.add({ ["page"]: 1 });
457
- // }
529
+ pageIsRemoved=true
530
+ //save the selected param
531
+
532
+ }
458
533
  dontUpdateThisCheckBox=field._id;
459
534
  const selected = ev.target.value; // array of selected value IDs
460
535
  let fieldTitle=field.title.toLowerCase().replace(' ', '');