Table of Contents
IMPORTANT
This SDK requires vue.js
and jQuery
.
Getting Started
<!DOCTYPE html>
<html>
<head>
<title>View JS Test</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@neap/fairplay-widgetjs/dist/fairplay.min.css">
</head>
<body>
<div id="wrapper"></div>
<script src="https://cdn.jsdelivr.net/npm/@neap/fairplay-widgetjs"></script>
<script type="text/javascript">
var fp = new Fairplay({
mode:'dev'
})
fp.createWidget({
el: '#wrapper',
pageSize: 2,
categories: {
5843: 'Internet & Telco',
5821: 'Internet & Telco'
}
})
fp.getJobAds({ where:{ professionId:1123 } }, (err,data) => { console.log(data) })
</script>
</body>
Where Am I Hosted?
Latest version:
You can access that JS and the default CSS using a specific version as follow:
API - Fairplay Object
To create a Fairplay object, make sure you have your clientId
(unless you're using the SDK in dev
mode):
var fp = new Fairplay({
clientId:'123456789',
businessId: 123,
classifications: {
professions: [{
ids:[1,2],
name: 'IT',
roles:[{
ids:[100],
name: 'Manager'
}, {
ids:[200,300,400],
name: 'Support'
}]
}, {
ids:[3],
name: 'Human Resources',
roles:[{
ids:[110],
name: 'Head of Recruitment'
}, {
ids:[210,310,410],
name: 'Compliance Manager'
}]
}],
locations: [{
ids:[10,20,30],
name: 'Sydney',
areas:[{
ids:[1000],
name: 'CBD'
}, {
ids:[2000,3000,4000],
name: 'Inner West'
}]
}, {
ids:[40],
name: 'Melbourne',
areas:[{
ids:[5000,6000],
name: 'CBD'
}, {
ids:[7000],
name: 'Coast'
}]
}],
workTypes: [{
ids:[60],
name: 'Full-time'
}, {
ids:[70],
name: 'Part-time'
}, {
ids:[80,90],
name: 'Contract'
}]
}
});
getJobAds
fp.getJobAds({ where:<Where> }, next:<Function>)
- where.ownerId Recruiter's ID.
- where.ownerEmail Recruiter's email.
- where.jobId
- where.professionId
- where.roleId
- where.locationId
- where.areaId
- where.workTypeId
- where.salary.per
- where.salary.lowest
- where.salary.highest
JobAd Object
{
"id": "1265",
"title": "Junior IT specialist for Hospital systems",
"summary": "Looking for Junior IT specialist for Hospital systems to help supporting all IT systems in the hospital.",
"bulletPoints": [
"Advantageous package",
"Flexible holidays"
],
"created": "2018-12-20T03:22:19Z",
"owner": null,
"profession":
{
"id": "5843",
"name": "IT",
"role":
{
"id": "6286",
"name": "Helpdesk & Support",
"link": "?professions=IT-5843&roles=Helpdesk%20%26%20Support-6286"
},
"link": "?professions=IT-5843"
},
"location":
{
"id": "6628",
"name": "Sydney",
"area":
{
"id": "6654",
"name": "North West & Hills District"
}
},
"workType":
{
"id": "5815",
"name": "Full Time"
},
"salary":
{
"per": "Hour",
"lowest": 40,
"highest": 50,
"lower": 40,
"upper": 50,
"id": 4,
"description": "$40 - $50 per hour"
},
"date": "20/12/2018",
"link": "/jobs/it/junior-it-specialist-for-hospital-systems/1265",
"consultant": {
}
}
submitForm
Examples
fp.submitForm([formDOM:<Element>, event:<Event>, input:<Object>, next:<Function>])
Example 01 - Using a Form Element
document.getElementById('main-form').addEventListener('submit', function(event) {
fp.submitForm(this,event, (error, res) => {
if (error) {
console.log('ERROR')
console.log(JSON.stringify(error))
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
}
})
})
var formDOM = document.getElementById('main-form')
var extraInputs = { offer:'Submit Resume' }
fp.submitForm(formDOM, extraInputs,function(error,res) {
if (error) {
console.log('ERROR')
console.log(JSON.stringify(error))
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
}
})
Example 03 - Using Explicit Fields With No Form Element
fp.submitForm({ firstName:'Nic', lastName:'Dao' }, function(error,res) {
if (error) {
console.log('ERROR')
console.log(JSON.stringify(error))
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
}
})
Submitting resume
<form onsubmit="submitResume(this, event)">
...
</form>
function submitResume(form, event) {
event.preventDefault();
var payload = {
offer: "Submit Resume",
type: "candidate",
recipients:['nic@neap.co'],
recipientsOnly: true
}
showSubmitting();
fp.submitForm(form, payload, (error, res) => {
hideSubmitting()
if (error) {
var logMsg = error && error.data && error.data.error && typeof(error.data.error) == 'string' ? error.data.error.split('\n')[0] : 'Unknown error'
console.log(logMsg)
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
form.reset();
}
})
}
Submitting vacancy
<form onsubmit="submitResume(this, event)">
...
</form>
function submitResume(form, event) {
event.preventDefault();
var payload = {
offer: "Submit Vacancy",
type: "client",
recipients:['nic@neap.co'],
recipientsOnly: true
}
showSubmitting();
fp.submitForm(form, payload, (error, res) => {
hideSubmitting()
if (error) {
var logMsg = error && error.data && error.data.error && typeof(error.data.error) == 'string' ? error.data.error.split('\n')[0] : 'Unknown error'
console.log(logMsg)
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
form.reset();
}
})
}
Subscribing to job alerts
Contact us
<form onsubmit="contactUs(this, event)">
...
</form>
function contactUs(form, event) {
event.preventDefault();
var payload = {
offer: "Contact Us",
recipients:['nic@neap.co'],
recipientsOnly: true
}
showSubmitting();
fp.submitForm(form, payload, (error, res) => {
hideSubmitting()
if (error) {
var logMsg = error && error.data && error.data.error && typeof(error.data.error) == 'string' ? error.data.error.split('\n')[0] : 'Unknown error'
console.log(logMsg)
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
form.reset();
}
})
}
Getting a free report
Apply to job
Refer a friend
<form onsubmit="referFriend(this, event)">
...
</form>
function referFriend(form, event) {
event.preventDefault();
var formData = new FormData(form);
var payload = {
offer: "Refer Friend",
type: "candidate",
firstName: formData.get("from_firstname"),
lastName: formData.get("from_lastname"),
email: formData.get("from_email"),
phone: formData.get("from_phone"),
message: formData.get("message"),
friend: {
firstName: formData.get("friend_firstname"),
lastName: formData.get("friend_lastname"),
email: formData.get("friend_email"),
phone: formData.get("friend_phone"),
profession: formData.get("friend_profession")
},
recipients:['nic@neap.co'],
recipientsOnly: true
}
showSubmitting();
fp.submitForm(form, payload, (error, res) => {
hideSubmitting()
if (error) {
var message = error && error.data && error.data.error && typeof(error.data.error) == 'string' ? error.data.error.split('\n')[0] : 'Unknown error'
console.log(message)
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
form.reset();
}
})
}
fp.repo.profession.find
fp.repo.profession.find({ where:<Object> })
WARNING: This API only returns values if the optional classifications
input was setup during the Fairplay instance creation.
var p01 = fp.repo.profession.find({ where:{ id:1 } })
var p02 = fp.repo.profession.find({ where:{ id:'2' } })
var p03 = fp.repo.profession.find({ where:{ id:'1_2' } })
profession
is not the only type of classification that cna be searched. The others are:
profession
role
location
area
workType
fp.on
fp.on(eventName:<String>, next:<Function>)
As of today, the only supported event is job-alert-created
, which is fired after the Create Job Alert button is clicked.
fp.on('job-alert-created', data => {
console.log(data.profession)
console.log(data.role)
console.log(data.location)
console.log(data.area)
console.log(data.type)
console.log(data.consultant)
console.log(data.keywords)
console.log(data.salary)
})
How To
How To Test Locally?
Simply run this:
npm run dev
This will host 2 version of the widget:
Dev: http://localhost:8080/dev
Prod: http://localhost:8080/prod
Prod uses the minified/uglified ES5 version of the code (to see how to compile that code, jump to the section).
How To Compile The Code To ES5?
Simply run:
npm run build
This will produce multiple artefacts under the dist folder.
How To Deploy A New Version?
- Make sure the code is linted properly:
npm run lint
- Build all the artefacts:
npm run dev
npm run build
- Commit your changes:
git commit 'your message'
- Get the current verison:
npm run v
- Bump to higher version:
npm run rls <the new version>
- Publish:
npm run push
This will host the minified version to https://cdn.jsdelivr.net/npm/@neap/fairplay-widgetjs. The minified CSS is located at https://cdn.jsdelivr.net/npm/@neap/fairplay-widgetjs@0.2.1/dist/fairplay.min.css
You can access that JS and the default CSS using a specific version as follow:
How to send email to specific recipients only?
var formDOM = document.getElementById('main-form')
var extraInputs = {
offer:'Submit Resume',
recipients:['somebody@example.com.au'],
recipientsOnly: true
}
fp.submitForm(formDOM, extraInputs,function(error,res) {
if (error) {
console.log('ERROR')
console.log(JSON.stringify(error))
} else {
console.log(`Status: ${res.status}`)
console.log(`Data: ${res.data}`)
}
})
Annexes