Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions job-listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
</head>
<body>
<div class="container">
<!-- Additional job cards -->
<!-- Job Card 2 -->
<h1>Available Jobs</h1>
<div class="job-card">
<div class="job-title">
Expand All @@ -72,11 +70,10 @@ <h1>Available Jobs</h1>
• 24 yrs old • 10,000 employees • Remote 70 • 600 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Leader in Streaming Entertainment</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="netflix-data-scientist">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 3 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Facebook</span> - Product Designer
Expand All @@ -87,11 +84,10 @@ <h1>Available Jobs</h1>
• 18 yrs old • 60,000 employees • Remote 40 • 800 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Social Media Giant</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="facebook-product-designer">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 4 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Apple</span> - iOS Developer
Expand All @@ -102,11 +98,10 @@ <h1>Available Jobs</h1>
• 45 yrs old • 150,000 employees • Remote 25 • 1,200 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Innovator in Consumer Electronics</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="apple-ios-developer">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 5 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Uber</span> - Operations Manager
Expand All @@ -117,11 +112,10 @@ <h1>Available Jobs</h1>
• 13 yrs old • 50,000 employees • Remote 60 • 500 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Leading Ride-Hailing Service</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="uber-operations-manager">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 6 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Airbnb</span> - Content Strategist
Expand All @@ -132,11 +126,10 @@ <h1>Available Jobs</h1>
• 15 yrs old • 15,000 employees • Remote 80 • 400 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Pioneer in Short-Term Rentals</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="airbnb-content-strategist">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 7 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Twitch</span> - Community Manager
Expand All @@ -147,11 +140,10 @@ <h1>Available Jobs</h1>
• 10 yrs old • 3,000 employees • Remote 90 • 300 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Leading Live Streaming Platform</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="twitch-community-manager">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 8 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">LinkedIn</span> - Sales Representative
Expand All @@ -162,11 +154,10 @@ <h1>Available Jobs</h1>
• 16 yrs old • 12,000 employees • Remote 85 • 250 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Professional Networking Site</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="linkedin-sales-representative">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 9 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Zoom</span> - UX/UI Designer
Expand All @@ -177,11 +168,10 @@ <h1>Available Jobs</h1>
• 9 yrs old • 5,000 employees • Remote 95 • 200 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Leader in Video Conferencing</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="zoom-ux-ui-designer">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 10 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Snap Inc.</span> - Marketing Analyst
Expand All @@ -192,11 +182,10 @@ <h1>Available Jobs</h1>
• 11 yrs old • 7,500 employees • Remote 75 • 350 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Creator of Snapchat</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="snap-marketing-analyst">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 11 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Pinterest</span> - Content Moderator
Expand All @@ -207,11 +196,10 @@ <h1>Available Jobs</h1>
• 10 yrs old • 4,000 employees • Remote 80 • 275 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Visual Discovery Engine</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="pinterest-content-moderator">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>

<!-- Job Card 12 -->
<div class="job-card">
<div class="job-title">
<span class="company-name">Twitter</span> - Software Engineer
Expand All @@ -222,8 +210,9 @@ <h1>Available Jobs</h1>
• 15 yrs old • 6,000 employees • Remote 85 • 425 open jobs <br>
<span style="color: #4CAF50;">TOP 200 • Social Media Platform</span>
</div>
<a href="#" class="btn">Am I a fit?</a>
<a href="#" class="btn" data-job-id="twitter-software-engineer">Am I a fit?</a>
<a href="#" class="btn btn-analytics">Keyword analysis</a>
</div>
</div>
</body>
</body>
</html>
12 changes: 12 additions & 0 deletions js/compatibilityModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compatibilityModel.js

// Function to calculate compatibility between a user and a job
// Parameters changed from userProfile and jobDescription to user and job
function calculateCompatibility(user, job) {
// Initial mock implementation returning a random compatibility score
const score = Math.random() * 100;
return score;
}

// Exporting the calculateCompatibility function to be used in jobRoutes.js
module.exports = { calculateCompatibility };
36 changes: 35 additions & 1 deletion public/js/interactivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@ document.addEventListener('DOMContentLoaded', function() {
e.preventDefault();
window.location.href = '/jobpost';
});

document.getElementById('checkCompatibilityBtn').addEventListener('click', function(e) {
e.preventDefault();
const jobId = this.getAttribute('data-job-id');
checkJobCompatibility(jobId);
});
});

const express = require('express');
const router = express.Router();
const Job = require('../models/Job');
const { requireAuth } = require('./middleware/authMiddleware');
const { calculateCompatibility } = require('./compatibilityModel.js');

function applyJob(body) {
fetch('/jobpost', {
Expand Down Expand Up @@ -115,6 +122,17 @@ function updateProfile(profileData) {
}

function submitJobPosting(jobData) {
// Adding event listener to make submitJobPosting function accessible
document.getElementById('postJobBtn').addEventListener('click', function(e) {
e.preventDefault();
submitJobPosting({
jobTitle: document.getElementById('jobTitle').value,
jobDescription: document.getElementById('jobDescription').value,
jobRequirements: document.getElementById('jobRequirements').value,
jobCategory: document.getElementById('jobCategory').value
});
});

if (!jobData.jobTitle || !jobData.jobDescription || !jobData.jobRequirements || !jobData.jobCategory) {
alert('Please fill in all required fields.');
return;
Expand Down Expand Up @@ -146,4 +164,20 @@ function submitJobPosting(jobData) {
function validateEmail(email) {
const re = /^(([^<>()\[\]\\.,;:\s@\"]+(\.[^<>()\[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
}

function checkJobCompatibility(jobId) {
Promise.all([
fetch('/api/user/profile').then(response => response.json()),
fetch(`/api/jobs/${jobId}`).then(response => response.json())
])
.then(([userProfile, jobDescription]) => {
const compatibilityScore = calculateCompatibility(userProfile.skills, jobDescription.skillsRequired);
alert(`Your compatibility score for this job is: ${compatibilityScore}`);
})
.catch(error => {
console.error('Error fetching data:', error);
alert('An error occurred while checking job compatibility. Please try again.');
});
}
```
9 changes: 4 additions & 5 deletions routes/authRoutes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const express = require('express');
const router = express.Router();
const bcrypt = require('bcrypt');
const User = require('../models/User');
const { requireAuth, alreadyLoggedIn } = require('./middleware/authMiddleware');

Expand Down Expand Up @@ -35,7 +36,7 @@ router.post('/register', async (req, res) => {
const user = new User({ username, password, email, domainOfInterest, linkedinUrl, currentCompany, currentLevel });
await user.save();
req.session.userId = user._id;
res.redirect('/login'); // Modified line: Redirecting user to login page after successful registration
res.redirect('/login');
} catch (error) {
res.status(500).json({ message: 'Error registering user', error: error.message });
}
Expand All @@ -51,7 +52,7 @@ router.post('/login', async (req, res) => {
if (!user) {
return res.status(404).json({ message: 'User not found' });
}
const isMatch = await user.comparePassword(password);
const isMatch = await bcrypt.compare(password, user.password);
if (!isMatch) {
return res.status(401).json({ message: 'Incorrect password' });
}
Expand All @@ -75,7 +76,6 @@ router.get('/logout', requireAuth, (req, res) => {
return res.status(500).json({ message: 'Error logging out', error: err });
}
res.clearCookie('connect.sid');
// Modified line: Redirecting user to index page after successful logout
res.redirect('/');
});
});
Expand All @@ -101,5 +101,4 @@ router.get('/profile', requireAuth, async (req, res) => {
}
});


module.exports = router;
module.exports = router;
22 changes: 21 additions & 1 deletion routes/jobRoutes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const express = require('express');
const router = express.Router();
const Job = require('../models/Job');
const User = require('../models/User'); // Added to use User model
const compatibilityModel = require('../models/compatibilityModel'); // Added to use compatibilityModel for score calculation
const { requireAuth, alreadyLoggedIn} = require('./middleware/authMiddleware');

router.get('/jobpost', (req, res) => {
Expand All @@ -10,7 +12,7 @@ router.get('/jobpost', (req, res) => {
router.post('/jobpost', requireAuth, async (req, res) => {
try {
const { companyName, role, domain, location, skillsRequired, natureOfWork, jobPostingLink } = req.body;
const job = new Job({ companyName, role, domain, location, skillsRequired, natureOfWork, jobPostingLink });
const job = new Job({ companyName, role, domain, location, skillsRequired, natureOfWork, jobPosting? resolveLink : null});
await job.save();
res.redirect('/');
} catch (error) {
Expand All @@ -29,4 +31,22 @@ router.get('/jobs', async (req, res) => {
}
});

// New route for compatibility assessment
router.post('/checkCompatibility', requireAuth, async (req, res) => {
try {
const { userId, jobId } = req.body;
const user = await User.findById(userId);
const job = await Job.findById(jobId);
if (!user || !job) {
return res.status(404).json({ message: 'User or Job not found' });
}
const score = compatibilityModel.calculateCompatibility(user, job);
res.json({ compatibilityScore: score });
} catch (error) {
console.error(`Failed to check compatibility: ${error}`);
res.status(500).json({ message: 'Failed to check compatibility', error: error.message });
}
});

module.exports = router;
```