sr-npm 1.7.1222 → 1.7.1225

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/backend/data.js CHANGED
@@ -287,7 +287,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
287
287
  const chunkPromises = chunk.map(async job => {
288
288
  try {
289
289
  const jobDetails = await fetchJobDescription(job._id);
290
- const richContentDescription=await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken,job.name);
290
+ const richContentDescription=await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken);
291
291
  const jobLocation = fetchJobLocation(jobDetails);
292
292
  const {applyLink , referFriendLink} = fetchApplyAndReferFriendLink(jobDetails);
293
293
  const updatedJob = {
@@ -114,10 +114,7 @@ async function fetchJobDescription(jobId,testObject=undefined) {
114
114
  return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
115
115
  }
116
116
 
117
- async function htmlRichContentConverter(sections,richContentConverterToken,title) {
118
- console.log("title ====");
119
- console.log(title);
120
-
117
+ async function htmlRichContentConverter(sections,richContentConverterToken) {
121
118
  const richContentObject = {}
122
119
  for (const [sectionTitle, sectionData] of Object.entries(sections)) {
123
120
  if (sectionData.text) {
@@ -139,16 +136,7 @@ async function htmlRichContentConverter(sections,richContentConverterToken,title
139
136
  );
140
137
  if (response.ok) {
141
138
  const data = await response.json();
142
- const richContentWithSpacing=addSpacingToRichContent(sectionData.text,data.richContent.richContent);
143
- if(title===" Gardening Team Member - The Warehouse, Blenheim (Fixed Term)")
144
- {
145
- console.log("richContentWithSpacing ====");
146
- console.log(richContentWithSpacing);
147
-
148
- console.log("data.richContent.richContent ====");
149
- console.log(data.richContent.richContent);
150
- }
151
- richContentObject[sectionTitle] = richContentWithSpacing
139
+ richContentObject[sectionTitle] = data.richContent.richContent;
152
140
  }
153
141
  else {
154
142
  throw new Error("Error converting html to rich content response: "+response);
@@ -158,178 +146,6 @@ async function htmlRichContentConverter(sections,richContentConverterToken,title
158
146
  return richContentObject;
159
147
  }
160
148
 
161
- //Adds empty paragraph nodes between sections in rich content
162
- // to create visual spacing that the Wix RICOS converter strips out
163
- function addSpacingToRichContent(html, richContent) {
164
- if (!richContent || !richContent.nodes) {
165
- return richContent;
166
- }
167
-
168
- // Extract paragraph texts from HTML that end with  
169
- const htmlParagraphsWithSpace = [];
170
- // Extract paragraphs with <br> tags
171
- const htmlParagraphsWithBr = new Map(); // text -> array of parts split by <br>
172
-
173
- const pTagRegex = /<p>(.*?)<\/p>/gi;
174
- let match;
175
-
176
- while ((match = pTagRegex.exec(html)) !== null) {
177
- const content = match[1];
178
-
179
- // Check if this paragraph ends with &#xa0; (before closing tags)
180
- if (content.includes('&#xa0;')) {
181
- const textOnly = content.replace(/<[^>]+>/g, '').trim();
182
- htmlParagraphsWithSpace.push(textOnly);
183
- }
184
-
185
- // Check if this paragraph contains <br> tags
186
- if (content.includes('<br>') || content.includes('<br/>') || content.includes('<br />')) {
187
- // Split by <br> tags and extract text parts
188
- const parts = content.split(/<br\s*\/?>/i).map(part =>
189
- part.replace(/<[^>]+>/g, '').trim()
190
- ).filter(part => part.length > 0);
191
-
192
- if (parts.length > 1) {
193
- // Store the parts for this paragraph
194
- const fullText = content.replace(/<[^>]+>/g, '').replace(/\s+/g, '').trim();
195
- htmlParagraphsWithBr.set(fullText, parts);
196
- }
197
- }
198
- }
199
-
200
- const nodes = richContent.nodes;
201
- const newNodes = [];
202
- let nodeIdCounter = 0;
203
-
204
- // Check if a paragraph is bold (has BOLD decoration)
205
- const isBoldParagraph = (node) => {
206
- if (node.type !== 'PARAGRAPH') return false;
207
- const decorations = node.nodes?.[0]?.textData?.decorations || [];
208
- return decorations.some(d => d.type === 'BOLD');
209
- };
210
-
211
- // Check if a paragraph node's text matches one with &#xa0; in HTML
212
- const needsSpacingAfter = (node) => {
213
- if (node.type !== 'PARAGRAPH') return false;
214
-
215
- // Add spacing after bold paragraphs
216
- if (isBoldParagraph(node)) {
217
- return true;
218
- }
219
-
220
- const text = node.nodes?.[0]?.textData?.text || '';
221
- const trimmedText = text.trim();
222
-
223
- // Check if this text matches any HTML paragraph that had &#xa0;
224
- return htmlParagraphsWithSpace.some(htmlText => {
225
- const cleanHtml = htmlText.replace(/&#xa0;/g, ' ').trim();
226
- return trimmedText.includes(cleanHtml) || cleanHtml.includes(trimmedText);
227
- });
228
- };
229
-
230
- // Check if a paragraph contains text that should be split by <br>
231
- const shouldSplitByBr = (node) => {
232
- if (node.type !== 'PARAGRAPH') return null;
233
-
234
- const text = node.nodes?.[0]?.textData?.text || '';
235
- const normalizedText = text.replace(/\s+/g, '').trim();
236
-
237
- // Find matching HTML paragraph with <br>
238
- for (const [htmlText, parts] of htmlParagraphsWithBr.entries()) {
239
- if (normalizedText.includes(htmlText) || htmlText.includes(normalizedText)) {
240
- return parts;
241
- }
242
- }
243
- return null;
244
- };
245
-
246
- // Add spacing after bulleted lists
247
- const isListEnd = (currentNode, nextNode) => {
248
- return currentNode.type === 'BULLETED_LIST' &&
249
- nextNode &&
250
- nextNode.type === 'PARAGRAPH';
251
- };
252
-
253
- for (let i = 0; i < nodes.length; i++) {
254
- const currentNode = nodes[i];
255
- const nextNode = nodes[i + 1];
256
-
257
- // Check if this paragraph should be split by <br>
258
- const brParts = shouldSplitByBr(currentNode);
259
- if (brParts && brParts.length > 1) {
260
- // Split into multiple paragraphs and add spacing between them
261
- const decorations = currentNode.nodes?.[0]?.textData?.decorations || [];
262
-
263
- brParts.forEach((part, idx) => {
264
- newNodes.push({
265
- ...currentNode,
266
- id: `${currentNode.id}_split_${idx}`,
267
- nodes: [{
268
- type: "TEXT",
269
- id: "",
270
- nodes: [],
271
- textData: {
272
- text: part,
273
- decorations: decorations
274
- }
275
- }]
276
- });
277
-
278
- // Add empty paragraph after each split part except the last
279
- if (idx < brParts.length - 1) {
280
- newNodes.push(createEmptyParagraph(`empty_br_${nodeIdCounter++}`));
281
- }
282
- });
283
-
284
- // Add spacing after the split paragraphs if there's a next node
285
- if (nextNode) {
286
- newNodes.push(createEmptyParagraph(`empty_${nodeIdCounter++}`));
287
- }
288
- } else {
289
- newNodes.push(currentNode);
290
-
291
- // Add empty paragraph ONLY after paragraphs with &#xa0; or after lists
292
- if ((needsSpacingAfter(currentNode) || isListEnd(currentNode, nextNode)) && nextNode) {
293
- newNodes.push(createEmptyParagraph(`empty_${nodeIdCounter++}`));
294
- }
295
- }
296
- }
297
-
298
- return {
299
- ...richContent,
300
- nodes: newNodes
301
- };
302
- }
303
-
304
- function createEmptyParagraph(id) {
305
- return {
306
- type: "PARAGRAPH",
307
- id: id,
308
- nodes: [
309
- {
310
- type: "TEXT",
311
- id: "",
312
- nodes: [],
313
- textData: {
314
- text: "",
315
- decorations: []
316
- }
317
- }
318
- ],
319
- paragraphData: {
320
- textStyle: {
321
- textAlignment: "AUTO"
322
- }
323
- }
324
- };
325
- }
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
149
 
334
150
 
335
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.1222",
3
+ "version": "1.7.1225",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -54,13 +54,14 @@ async function careersMultiBoxesPageOnReady(_$w,urlParams) {
54
54
  loadSelectedValuesRepeater(_$w);
55
55
  bindSearchInput(_$w);
56
56
  loadPaginationButtons(_$w);
57
- if (await window.formFactor() === "Mobile") {
58
- handleFilterInMobile(_$w);
59
- }
57
+
60
58
  await handleUrlParams(_$w, urlParams);
61
59
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.CLEAR_ALL_BUTTON_ID).onClick(async () => {
62
60
  await clearAll(_$w);
63
61
  });
62
+ if (await window.formFactor() === "Mobile") {
63
+ handleFilterInMobile(_$w);
64
+ }
64
65
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.RESULTS_MULTI_STATE_BOX).changeState("results");
65
66
  }
66
67
 
@@ -113,16 +114,26 @@ function handleFilterInMobile(_$w) {
113
114
  CAREERS_PAGE_SELECTORS.SECTION_3,
114
115
  CAREERS_PAGE_SELECTORS.LINE_3,
115
116
  CAREERS_PAGE_SELECTORS.FILTER_ICON];
117
+
118
+ const mobileFilterBoxSelectors = [
119
+ CAREERS_PAGE_SELECTORS.FILTER_BOX,
120
+ CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON,
121
+ CAREERS_PAGE_SELECTORS.EXIT_BUTTON,
122
+ ];
116
123
 
117
124
  _$w(CAREERS_PAGE_SELECTORS.FILTER_ICON).onClick(()=>{
118
- _$w(CAREERS_PAGE_SELECTORS.FILTER_BOX).expand();
125
+ mobileFilterBoxSelectors.forEach(selector => {
126
+ _$w(selector).expand();
127
+ });
119
128
  searchResultsSelectors.forEach(selector => {
120
129
  _$w(selector).collapse();
121
130
  });
122
131
  });
123
132
 
124
133
  const exitFilterBox = () => {
125
- _$w(CAREERS_PAGE_SELECTORS.FILTER_BOX).collapse();
134
+ mobileFilterBoxSelectors.forEach(selector => {
135
+ _$w(selector).collapse();
136
+ });
126
137
  searchResultsSelectors.forEach(selector => {
127
138
  _$w(selector).expand();
128
139
  });
@@ -135,6 +146,11 @@ function handleFilterInMobile(_$w) {
135
146
  _$w(CAREERS_PAGE_SELECTORS.REFINE_SEARCH_BUTTON).onClick(()=>{
136
147
  exitFilterBox();
137
148
  });
149
+
150
+ //onmobile we should collapse the filter box and the refine search button by default
151
+ mobileFilterBoxSelectors.forEach(selector => {
152
+ _$w(selector).collapse();
153
+ });
138
154
  }
139
155
 
140
156
 
@@ -237,6 +253,9 @@ async function handleParams(_$w,param,values) {
237
253
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = pagination.currentPage.toString();
238
254
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = nextPageJobs;
239
255
  handlePaginationButtons(_$w);
256
+ console.log("scrolling to secondary search input");
257
+ await _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).scrollTo();
258
+ console.log("scrolled to secondary search input");
240
259
  });
241
260
 
242
261
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.PAGE_BUTTON_PREVIOUS).onClick(async () => {
@@ -245,6 +264,10 @@ async function handleParams(_$w,param,values) {
245
264
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.paginationCurrentText).text = pagination.currentPage.toString();
246
265
  _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.JOBS_REPEATER).data = previousPageJobs;
247
266
  handlePaginationButtons(_$w);
267
+ console.log("scrolling to secondary search input");
268
+ await _$w(CAREERS_MULTI_BOXES_PAGE_CONSTS.SECONDARY_SEARCH_INPUT).scrollTo();
269
+ console.log("scrolled to secondary search input");
270
+
248
271
  });
249
272
  } catch (error) {
250
273
  console.error('Failed to load pagination buttons:', error);
@@ -192,18 +192,18 @@ function init(_$w) {
192
192
  searchInputBlurredFirstTime=false;
193
193
  }
194
194
  });
195
- _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).onChange(()=>{
195
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).onChange(()=>{
196
196
  console.log("dropdown onChange is triggered");
197
197
  applyFilters(_$w);
198
198
  });
199
- _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON, CAREERS_PAGE_SELECTORS.CLEAR_SEARCH).onClick(()=>resetFilters(_$w));
199
+ _$w(CAREERS_PAGE_SELECTORS.RESET_FILTERS_BUTTON+', '+ CAREERS_PAGE_SELECTORS.CLEAR_SEARCH).onClick(()=>resetFilters(_$w));
200
200
 
201
201
  _$w(CAREERS_PAGE_SELECTORS.OPEN_FILTERS_BUTTON).onClick(()=>{
202
- _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).expand();
202
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER+', '+ CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).expand();
203
203
  });
204
204
 
205
205
  _$w(CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).onClick(()=>{
206
- _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER, CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).collapse();
206
+ _$w(CAREERS_PAGE_SELECTORS.DROPDOWN_CONTAINER+', '+ CAREERS_PAGE_SELECTORS.CLOSE_FILTERS_BUTTON).collapse();
207
207
  });
208
208
 
209
209
  //URL onChange
@@ -355,7 +355,7 @@ async function applyFilters(_$w, skipUrlUpdate = false) {
355
355
  }
356
356
 
357
357
  async function resetFilters(_$w) {
358
- _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT, CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT, CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION, CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE, CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
358
+ _$w(CAREERS_PAGE_SELECTORS.SEARCH_INPUT+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_DEPARTMENT+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_LOCATION+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_JOB_TYPE+', '+ CAREERS_PAGE_SELECTORS.DROPDOWN_BRAND).value = '';
359
359
 
360
360
  await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).setFilter(wixData.filter());
361
361
  await _$w(GLOBAL_SECTIONS_SELECTORS.JOBS_DATASET).refresh();
@@ -404,8 +404,7 @@ async function handleDepartmentParam(_$w,department) {
404
404
  queryParams.remove(["department" ]);
405
405
 
406
406
  }
407
-
408
-
407
+
409
408
 
410
409
  }
411
410
 
package/pages/homePage.js CHANGED
@@ -7,6 +7,7 @@ const { COLLECTIONS } = require('../backend/collectionConsts');
7
7
  const { getAllRecords } = require('./pagesUtils');
8
8
  const { handlePrimarySearch } = require('../public/primarySearchUtils');
9
9
  const { GLOBAL_SECTIONS_SELECTORS } = require('../public/selectors');
10
+ const { isElementExistOnPage } = require('psdev-utils');
10
11
 
11
12
  let thisObjectVar;
12
13
  let searchByCityFlag=false;
@@ -65,35 +66,22 @@ function bind(_$w) {
65
66
  function bindTeamRepeater(_$w) {
66
67
  _$w('#teamRepeater').onItemReady(($item, itemData) => {
67
68
  $item('#teamButton').label = `View ${itemData.count} Open Positions`;
68
- // const department = encodeURIComponent(itemData.title);
69
- // if (itemData.customField) {
70
- // [$item('#teamButton'), $item('#teamButton2')].forEach(btn => {
71
- // btn.onClick(() => {
72
- // location.to(`/search?category=${department}`);
73
- // });
74
- // });
75
-
76
- // }
77
- // else{
78
- // $item('#teamButton').onClick(()=>{
79
- // location.to(`/positions?department=${department}`);
80
- // });
81
- // }
82
69
  });
83
70
 
84
71
  _$w("#teamRepeaterItem").onClick((event) => {
85
72
 
86
73
  const $item = _$w.at(event.context);
87
74
 
88
- if(_$w("#categoriesDataset")) {
75
+ if(isElementExistOnPage(_$w("#categoriesDataset"))) {
89
76
  const clickedItemData = $item("#categoriesDataset").getCurrentItem();
90
77
  const department = encodeURIComponent(clickedItemData.title);
91
78
  location.to(`/search?category=${department}`);
92
79
  }
93
80
  else
94
81
  {
95
- console.log("check SR templates and do this ")
96
-
82
+ const clickedItemData = $item("#dataset1").getCurrentItem()
83
+ const department = encodeURIComponent(clickedItemData.title);
84
+ location.to(`/positions?department=${department}`);
97
85
  }
98
86
  });
99
87
 
@@ -10,8 +10,6 @@ const {
10
10
  } = require('../public/utils');
11
11
 
12
12
 
13
-
14
-
15
13
  async function positionPageOnReady(_$w) {
16
14
  console.log("positionPageOnReady called");
17
15
  await bind(_$w);
@@ -90,8 +88,14 @@ async function getCategoryValue(customValues) {
90
88
  }
91
89
 
92
90
  function handleReferFriendButton(_$w,item) {
93
- if(!item.referFriendLink && isElementExistOnPage(_$w('#referFriendButton'))){
94
- _$w('#referFriendButton').hide();
91
+ if(isElementExistOnPage(_$w('#referFriendButton'))){
92
+ if(!item.referFriendLink){
93
+ _$w('#referFriendButton').hide();
94
+ }
95
+ else {
96
+ _$w('#referFriendButton').target="_blank";
97
+ _$w('#referFriendButton').link=item.referFriendLink;
98
+ }
95
99
  }
96
100
  }
97
101
 
@@ -153,4 +153,5 @@ return count > 0;
153
153
 
154
154
  module.exports = {
155
155
  handlePrimarySearch,
156
+ queryPrimarySearchResults
156
157
  }