Skip to content

Instantly share code, notes, and snippets.

@ApprenticeGC
Last active December 14, 2017 10:18
Show Gist options
  • Save ApprenticeGC/714208d8af9118fd65ee156a5ee63c8f to your computer and use it in GitHub Desktop.
Save ApprenticeGC/714208d8af9118fd65ee156a5ee63c8f to your computer and use it in GitHub Desktop.
Using blessed to show job board in console.
var blessed = require('blessed')
const employeeWantedDataCollection = [
{
title: 'Game Programmer',
salary: 'NT 80000/Month',
description: 'Fluent in C++/C# and strong knowledge in Unity',
contact: 'hr@ubihard.com'
},
{
title: 'Illustrator',
salary: 'NT 40000/Month',
description: 'Strong knowledge in using Photoshop',
contact: 'hr@kiki.com'
},
{
title: 'Sales',
salary: 'NT 30000/Month',
description: 'Internalnational business requires going aboard',
contact: 'hr@landbmb.com'
},
{
title: 'Product Manager',
salary: 'NT 60000/Month',
description: 'Good management skill',
contact: 'hr@ash.com'
},
{
title: 'Sales',
salary: 'NT 32000/Month',
description: 'Local shop seeks talent people',
contact: 'hr@coffeenearu.com'
},
{
title: 'Graphic Designer',
salary: 'NT 42000/Month',
description: 'At least 5 years industrial experience',
contact: 'hr@gotmilk.com'
},
{
title: 'Frontend Web Designer',
salary: 'NT 50000/Month',
description: 'Knowing Html/CSS is a must',
contact: 'hr@victorypublic.com'
},
{
title: 'Backend Programmer',
salary: 'NT 89000/Month',
description: 'Any one of Node.js/PHP/Python/Ruby language plus good writing skill',
contact: 'hr@linkedout.com'
}
]
const jobWantedDataCollection = [
{
name: 'David Lin',
degree: 'Bachelor in Architecture',
contact: 'david@gamil.com'
},
{
name: 'Mary Jean',
degree: 'Bachelor in Civil Engineering',
contact: 'mary@yahoo.com'
},
{
name: 'Kelly Mole',
degree: 'Master in Law',
contact: 'kelly@gamil.com'
},
{
name: 'Kenny Lawson',
degree: 'Master in Marketing',
contact: 'kenny@gamil.com'
},
{
name: 'Gary Mock',
degree: 'Master in Performance Art',
contact: 'gary@yahoo.com'
},
]
// Create a screen object.
var screen = blessed.screen({
smartCSR: true
})
screen.title = 'Terminal Job Board';
function createEmployeeWantedPost(amount) {
var combinedDesc = function(i) {
return `${employeeWantedDataCollection[i].title}\n${employeeWantedDataCollection[i].salary}\n${employeeWantedDataCollection[i].description}\n${employeeWantedDataCollection[i].contact}`
}
for (var i = 0; i < amount; ++ i) {
var box = blessed.box({
top: (i * 6),
left: 0,
width: '50%',
height: 6,
content: combinedDesc(i),
border: {
type: 'line'
},
style: {
border: {
fg: '#f0f0f0'
},
hover: {
bg: '#434343'
}
}
})
screen.append(box)
}
}
function createJobWantedPost(amount) {
var combinedDesc = function(i) {
return `${jobWantedDataCollection[i].name}\n${jobWantedDataCollection[i].degree}\n${jobWantedDataCollection[i].contact}`
}
for (var i = 0; i < amount; ++ i) {
var box = blessed.box({
top: (i * 6),
left: '50%',
width: '50%',
height: 6,
content: combinedDesc(i),
border: {
type: 'line'
},
style: {
border: {
fg: '#ff0000'
},
hover: {
bg: '#434343'
}
}
})
screen.append(box)
}
}
createEmployeeWantedPost(6)
createJobWantedPost(5)
// Quit on Escape, q, or Control-C.
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
})
screen.render()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment