sr-npm 1.7.952 → 1.7.954

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.952",
3
+ "version": "1.7.954",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,7 +24,7 @@ async function getCategoryValueId(customValues) {
24
24
  const categoryCustomField=await wixData.query(COLLECTIONS.CUSTOM_FIELDS).eq(CUSTOM_FIELDS_COLLECTION_FIELDS.TITLE,"Category").find().then(result => result.items[0]);
25
25
  for(const value of customValues) {
26
26
  if(value.customField===categoryCustomField._id) {
27
- return value._id;
27
+ return value;
28
28
 
29
29
  }
30
30
  }
@@ -35,11 +35,14 @@ async function getCategoryValueId(customValues) {
35
35
  _$w('#datasetJobsItem').onReady(async () => {
36
36
 
37
37
  const item = await _$w('#datasetJobsItem').getCurrentItem();
38
-
38
+ console.log("item: ",item);
39
+
39
40
  handleReferFriendButton(_$w,item);
40
41
  handleApplyButton(_$w,item);
41
42
 
42
43
 
44
+
45
+
43
46
  _$w('#companyDescriptionText').text = htmlToText(item.jobDescription.companyDescription.text);
44
47
  _$w('#responsibilitiesText').text = htmlToText(item.jobDescription.jobDescription.text);
45
48
  _$w('#qualificationsText').text = htmlToText(item.jobDescription.qualifications.text);
@@ -52,9 +55,10 @@ async function getCategoryValueId(customValues) {
52
55
  {
53
56
 
54
57
  const multiRefField=await getPositionWithMultiRefField(item._id);
55
- const categoryValueId=await getCategoryValueId(multiRefField);
56
-
57
- const relatedJobs = await getRelatedJobs({ categoryValueId, itemId: item._id ,limit:5});
58
+ const categoryValue=await getCategoryValueId(multiRefField);
59
+ handleJobDetails(_$w,item,categoryValue);
60
+
61
+ const relatedJobs = await getRelatedJobs({ categoryValueId:categoryValue._id, itemId: item._id ,limit:5});
58
62
  _$w('#relatedJobsRepNoDepartment').onItemReady(($item, itemData) => {
59
63
  $item('#relatedJobTitle').text = itemData.title;
60
64
  $item('#relatedJobLocation').text = itemData.location.fullLocation;
@@ -84,7 +88,18 @@ async function getCategoryValueId(customValues) {
84
88
  }
85
89
 
86
90
  }
91
+ function handleJobDetails(_$w,item,categoryValue) {
92
+ if(isElementExistOnPage(_$w('#jobLocation'))) {
93
+ _$w('#jobLocation').text = item.location.fullLocation;
94
+ }
95
+ if(isElementExistOnPage(_$w('#jobCategory'))) {
96
+ _$w('#jobCategory').text = categoryValue.title;
97
+ }
98
+ if(isElementExistOnPage(_$w('#jobEmploymentTime'))) {
99
+ _$w('#jobEmploymentTime').text = item.employmentType;
100
+ }
87
101
 
102
+ }
88
103
  function handleReferFriendButton(_$w,item) {
89
104
  if(!item.referFriendLink && isElementExistOnPage(_$w('#referFriendButton'))){
90
105
  _$w('#referFriendButton').hide();
package/public/utils.js CHANGED
@@ -1,21 +1,21 @@
1
1
 
2
2
  function htmlToText(html) {
3
- if (!html) return '';
4
-
5
- // Remove HTML tags and decode entities
6
- let text = html
3
+
4
+ // Let the browser decode ALL HTML entities automatically
5
+ const textarea = document.createElement('textarea');
6
+ console.log("textarea: ",textarea);
7
+ textarea.innerHTML = html;
8
+ console.log("textarea.innerHTML: ",textarea.innerHTML);
9
+ let decoded = textarea.value;
10
+ console.log("decoded: ",decoded);
11
+ // Now clean up the HTML tags and formatting
12
+ let text = decoded
7
13
  .replace(/<br\s*\/?>/gi, '\n')
8
14
  .replace(/<\/?(p|div|h[1-6])\s*\/?>/gi, '\n')
9
15
  .replace(/<li[^>]*>/gi, '• ')
10
16
  .replace(/<\/li>/gi, '\n')
11
- .replace(/<[^>]*>/g, '')
12
- .replace(/&amp;/g, '&')
13
- .replace(/&lt;/g, '<')
14
- .replace(/&gt;/g, '>')
15
- .replace(/&quot;/g, '"')
16
- .replace(/&#39;/g, "'")
17
- .replace(/&nbsp;/g, ' ');
18
-
17
+ .replace(/<[^>]*>/g, '');
18
+ console.log("text: ",text);
19
19
  // Clean up whitespace
20
20
  return text.replace(/\n\s*\n+/g, '\n\n').replace(/[ \t]+\n/g, '\n').trim();
21
21
  }