Skip to content

Commit

Permalink
Merge pull request #4 from solobat/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tomasy authored Sep 24, 2017
2 parents c8fe739 + 0f0ad5b commit 45ae0e6
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 91 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ url block默认时长为8hours
+ `note` 创建笔记
+ `#` 查看笔记及标签
+ `jk` 查看jenkins jobs并打开
+ `epl` 查看英超赛程

---
## TODOS
6 changes: 0 additions & 6 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,5 @@
},
"youdao_subtitle": {
"message": "translate a word / phrase by youdao translator..."
},
"epl_title": {
"message": "epl matches"
},
"epl_subtitle": {
"message": "data from lesports"
}
}
6 changes: 0 additions & 6 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,5 @@
},
"youdao_subtitle": {
"message": "使用有道翻译你想知道的单词或短语..."
},
"epl_title": {
"message": "英超赛程榜"
},
"epl_subtitle": {
"message": "数据来自lesports"
}
}
62 changes: 0 additions & 62 deletions js/plugins/epl.js

This file was deleted.

85 changes: 72 additions & 13 deletions js/plugins/jenkins.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,38 @@ define(function (require, exports, module) {
var util = require('../common/util')

var name = 'jenkins'
var key = ['jk', 'jkb', 'jkc', 'jkw']
var key = ['jk', 'jkb', 'jkc', 'jkw', 'jkset']
var icon = chrome.extension.getURL('img/jenkins.png')
var title = chrome.i18n.getMessage(name + '_title')
var subtitle = chrome.i18n.getMessage(name + '_subtitle')
var SERVER_URL = window.localStorage['jenkins_url'] || ''
var jobs = []

const keyUrlMap = {
'jk': '',
'jkb': 'build',
'jkc': 'configure',
'jkw': 'ws'
}

const actionTips = {
seturl: {
key: key,
icon: icon,
id: 'action-seturl',
title: '设置jenkins url',
desc: '输入jenkins url,回车确认'
},
errorurl: {
key: key,
icon: icon,
id: 'action-error',
title: '获取不到jenkins jobs',
desc: '请使用jkset设置正确的jenkins url',
isWarn: true
}
};

function getJobs() {
if (jobs.length) {
return new Promise((resolve, reject) => {
Expand All @@ -31,14 +56,14 @@ define(function (require, exports, module) {
resolve(jobs)
})
.catch(() => {
reject('fetch jenkins jobs failed...')
reject([actionTips['errorurl']])
})
})
}

function setUrl() {
var iptval = window.prompt('jenkins url:')
function setUrl(iptval, callback) {
if (!iptval) {
callback('请输入url');
return
}

Expand All @@ -52,22 +77,36 @@ define(function (require, exports, module) {

SERVER_URL = iptval
window.localStorage['jenkins_url'] = SERVER_URL
callback();
}

const keyUrlMap = {
'jk': '',
'jkb': 'build',
'jkc': 'configure',
'jkw': 'ws'
function showActionTips(action) {
let actionTip = actionTips[action];

if (!actionTip) {
return;
}

this.showItemList([{
key: key,
icon: icon,
id: actionTip.id,
title: actionTip.title,
desc: actionTip.desc
}]);
}

function onInput(key) {
if (!SERVER_URL) {
setUrl()
if (this.cmd === 'jkset') {
showActionTips.call(this, 'seturl');

return;
}

if (!SERVER_URL) {
return
this.render('jkset ');

return;
}

getJobs().then((results) => {
Expand All @@ -87,10 +126,30 @@ define(function (require, exports, module) {
isWarn: item.healthReport.length && item.healthReport[0].score !== 100
}
}))
})
}).catch((results) => {
this.showItemList(results);
});
}

function onEnter(id) {
if (id.startsWith('action-')) {
let actionName = id.split('-')[1];

if (actionName === 'seturl') {
setUrl(this.query, (error) => {
if (error) {
alert(error);
} else {
alert('设置成功');
jobs = [];
this.render('jk ');
}
});
}

return;
}

if (id) {
window.open(id)
}
Expand Down
3 changes: 1 addition & 2 deletions js/plugins/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ define(function(require, exports, module) {
require('/js/plugins/calculate'),
require('/js/plugins/urlblock'),
require('/js/plugins/download'),
require('/js/plugins/help'),
require('/js/plugins/epl')
require('/js/plugins/help')
]

var plugins = {}
Expand Down
4 changes: 4 additions & 0 deletions js/plugins/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ define(function (require, exports, module) {
function addTodo(todo) {
var cmdbox = this;

if (!todo) {
return;
}

getTodos(function (todos) {
if (!todos || !todos.length) {
todos = [];
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Steward: 扩展/应用/标签/历史记录/alfred",
"short_name": "Steward",
"version": "2.4.5",
"version": "2.4.6",
"description": "便捷管理扩展/应用/标签/历史记录等",
"default_locale": "zh_CN",
"chrome_url_overrides" : {
Expand Down

0 comments on commit 45ae0e6

Please sign in to comment.