Skip to content

Commit

Permalink
Merge pull request abalone0204#7 from abalone0204/feature/other-provider
Browse files Browse the repository at this point in the history
Feature/other provider
  • Loading branch information
abalone0204 authored Jun 12, 2016
2 parents f57cf19 + 1f5d6e9 commit 1a77bf6
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 22 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added chromeExtension/.DS_Store
Binary file not shown.
Binary file modified chromeExtension/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chromeExtension/icon1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion chromeExtension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"content_scripts": [{
"matches": [
"https://www.104.com.tw/job/*",
"http://www.104.com.tw/job/*"
"http://www.104.com.tw/job/*",
"http://www.1111.com.tw/job-bank/job-description*"
],
"js": ["./dist/content-bundle.js"]
}]
Expand Down
4 changes: 2 additions & 2 deletions front-end/app/API/createJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {

import config from '../../../config.json'

export default function createJob({company_name, job_name, e04_job_no}) {
export default function createJob({company_name, job_name, e04_job_no, eeee_job_no}) {
const {backend} = config
const options = {
headers: {
"Content-Type": "application/json"
},
method: 'POST',
body: JSON.stringify({company_name, job_name, e04_job_no}),
body: JSON.stringify({company_name, job_name, e04_job_no, eeee_job_no}),
mode: 'cors'
}
return fetch(`${backend}/jobs`, options)
Expand Down
5 changes: 3 additions & 2 deletions front-end/app/API/fetchJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import config from '../../../config.json'
export default function fetchJob({
company_name,
job_name,
e04_job_no
e04_job_no,
eeee_job_no
}) {
const {
backend
Expand All @@ -19,7 +20,7 @@ export default function fetchJob({
mode: 'cors'
}

const url = `${backend}/jobs?company_name=${company_name}&job_name=${job_name}&e04_job_no=${e04_job_no}`
const url = `${backend}/jobs?company_name=${company_name}&job_name=${job_name}&e04_job_no=${e04_job_no}&eeee_job_no=${eeee_job_no}`
return fetch(url, options)
.then(checkStatus)
.then(parseJSON)
Expand Down
12 changes: 10 additions & 2 deletions front-end/app/actions/createJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ export const SUCCESS_CREATE_JOB = 'SUCCESS_CREATE_JOB'
export function requestCreateJob({
company_name,
job_name,
e04_job_no
e04_job_no="null",
eeee_job_no="null"
}) {
console.log('requestCreateJob:::',{
company_name,
job_name,
e04_job_no,
eeee_job_no
});
return {
type: REQUEST_CREATE_JOB,
params: {
company_name,
job_name,
e04_job_no
e04_job_no,
eeee_job_no
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions front-end/app/actions/fetchJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ export const FAIL_TO_FETCH_JOB = 'FAIL_TO_FETCH_JOB'
export const SUCCESS_FETCH_JOB = 'SUCCESS_FETCH_JOB'


export function requestFetchJob({company_name, job_name, e04_job_no}) {
export function requestFetchJob({company_name, job_name, e04_job_no="null", eeee_job_no="null"}) {
return {
type: REQUEST_FETCH_JOB,
query: {company_name, job_name, e04_job_no}
query: {company_name, job_name, e04_job_no, eeee_job_no}
}
}

Expand Down
3 changes: 1 addition & 2 deletions front-end/app/components/StatusBlock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StatusBlock extends React.Component {
comments
} = this.props

if (comments.data.length !== 0) {

let statNumbers = {
good: 0,
bad: 0,
Expand Down Expand Up @@ -45,7 +45,6 @@ class StatusBlock extends React.Component {
</div>
</div>
)
}


}
Expand Down
6 changes: 1 addition & 5 deletions front-end/app/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,17 @@ class App extends React.Component {

componentWillMount() {
const {
dispatch
dispatch, user
} = this.props

chrome.storage.sync.get('access_token', (item) => {
console.log('item ==>', item);
if (!!item['access_token']) {
dispatch(requestLogin(item['access_token']))
} else {
console.log('access token not found');
}
})

chrome.storage.sync.get('anonymous', (item) => {
if (item['anonymous'] !== undefined) {
console.log('item ==>', item['anonymous']);
if (user.anonymous !== item['anonymous']) {
dispatch(changeUserIdentity())
}
Expand Down
3 changes: 3 additions & 0 deletions front-end/app/providers/104.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const get_job_name = () => document.querySelector('#job h1')
.firstChild
.textContent.trim()

const get_company_name = () => document.querySelector('#job .company a')
.firstChild
.textContent.trim()

const get_e04_job_no = () => location.search.match(/\?jobno=([^\&]+)/)[1]


const provider = {
get_job_name,
get_company_name,
Expand Down
11 changes: 11 additions & 0 deletions front-end/app/providers/1111.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const get_job_name = () => document.querySelector('#commonTop h1').innerText.trim()
const get_company_name = () => document.querySelector('#commonTop .navbar a').innerText.trim()
const get_eeee_job_no = () => location.search.match(/\?eNo=([0-9]+)/)[1]

const provider = {
get_job_name,
get_company_name,
get_eeee_job_no
}

export default provider
6 changes: 5 additions & 1 deletion front-end/app/providers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import p104 from './104.js'
import p1111 from './1111.js'

const rootProvider = {
["104"]: p104
["104"]: p104,
["1111"]: p1111
}

export function getProviderName() {
Expand All @@ -13,9 +15,11 @@ export function getProviderName() {

export function getJobQuery(provider) {
const jobQuery = {}

Object.keys(provider).forEach(key => {
jobQuery[key.substring(4)] = provider[key]()
})

return jobQuery
}

Expand Down
19 changes: 16 additions & 3 deletions front-end/popup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@

class Popup extends React.Component {
render() {
return (
<div>
<h2>Popup</h2>
<a href="" onClick={()=>chrome.tabs.create({'url': "/options.html" } )}>選項</a>
<div style={{width: '360px', fontSize: '18px', padding: '15px'}}>
<h3>Clairvoyance</h3>
<div>
<a href="" onClick={()=>chrome.tabs.create({'url': "/options.html" } )}><h4>設置與說明書</h4></a>
</div>
<div>
<h4>關於 Clairvoyance</h4>
<div>
臉書專頁:<a href="https://www.facebook.com/Clairvoyance-%E6%B1%82%E8%81%B7%E5%A4%A9%E7%9C%BC%E9%80%9A-1084564708284768" target="_blank">Clairvoyance - 求職天眼通</a>
</div>
<div>
Source code: <a href="https://github.com/abalone0204/Clairvoyance" target="_blank">Clairvoyance</a>
</div>
</div>

</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/front-end/actions/createJob.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe('Actions/ Create job', () => {
params: {
company_name,
job_name,
e04_job_no
e04_job_no,
eeee_job_no: "null"
}
}
const actual = requestCreateJob({
Expand Down
3 changes: 2 additions & 1 deletion tests/front-end/actions/fetchJob.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe('Actions/ Fetch job', () => {
query: {
company_name,
job_name,
e04_job_no
e04_job_no,
eeee_job_no: "null"
}
}
const actual = requestFetchJob({
Expand Down

0 comments on commit 1a77bf6

Please sign in to comment.