Last active
December 14, 2017 10:18
-
-
Save ApprenticeGC/714208d8af9118fd65ee156a5ee63c8f to your computer and use it in GitHub Desktop.
Using blessed to show job board in console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var blessed = require('blessed') | |
| const employeeWantedDataCollection = [ | |
| { | |
| title: 'Game Programmer', | |
| salary: 'NT 80000/Month', | |
| description: 'Fluent in C++/C# and strong knowledge in Unity', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| title: 'Illustrator', | |
| salary: 'NT 40000/Month', | |
| description: 'Strong knowledge in using Photoshop', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| title: 'Sales', | |
| salary: 'NT 30000/Month', | |
| description: 'Internalnational business requires going aboard', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| title: 'Product Manager', | |
| salary: 'NT 60000/Month', | |
| description: 'Good management skill', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| title: 'Sales', | |
| salary: 'NT 32000/Month', | |
| description: 'Local shop seeks talent people', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| title: 'Graphic Designer', | |
| salary: 'NT 42000/Month', | |
| description: 'At least 5 years industrial experience', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| title: 'Frontend Web Designer', | |
| salary: 'NT 50000/Month', | |
| description: 'Knowing Html/CSS is a must', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| title: 'Backend Programmer', | |
| salary: 'NT 89000/Month', | |
| description: 'Any one of Node.js/PHP/Python/Ruby language plus good writing skill', | |
| contact: '[email protected]' | |
| } | |
| ] | |
| const jobWantedDataCollection = [ | |
| { | |
| name: 'David Lin', | |
| degree: 'Bachelor in Architecture', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| name: 'Mary Jean', | |
| degree: 'Bachelor in Civil Engineering', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| name: 'Kelly Mole', | |
| degree: 'Master in Law', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| name: 'Kenny Lawson', | |
| degree: 'Master in Marketing', | |
| contact: '[email protected]' | |
| }, | |
| { | |
| name: 'Gary Mock', | |
| degree: 'Master in Performance Art', | |
| contact: '[email protected]' | |
| }, | |
| ] | |
| // 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