Skip to content

Commit

Permalink
微調整
Browse files Browse the repository at this point in the history
  • Loading branch information
koba-ninkigumi committed Jun 29, 2016
1 parent f82d417 commit 8124158
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 19 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.DS_Store
node_modules
npm-debug.log
tsconfig.json
yubinbango-core-src.*
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
},
"homepage": "https://github.com/yubinbango/yubinbango-core",
"devDependencies": {
"gulp": "^3.8.11",
"gulp-angular-protractor": "0.0.2",
"gulp": "^3.9.1",
"gulp-angular-protractor": "^0.1.1",
"gulp-exit": "0.0.2",
"gulp-webserver": "^0.9.0",
"run-sequence": "^1.1.0",
"gulp-webserver": "^0.9.1",
"run-sequence": "^1.2.1",
"uglifyjs": "^2.4.10"
}
}
14 changes: 7 additions & 7 deletions test/spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
browser.ignoreSynchronization = true;
browser.get(browser.baseUrl+'/test/htdocs/yubinbango-core.html');

describe('yubinbango-core', function() {
it('7桁の数字を与えると住所を返す', function() {
browser.executeAsyncScript(function() {
var callback = arguments[arguments.length - 1];
var yubin7 = '1008950';
var a = new YubinBango.Core(yubin7, function(addr){callback(addr)});
}).then(function(addr) {
describe('yubinbango-core', () => {
it('7桁の数字を与えると住所を返す', () => {
browser.executeAsyncScript(() => {
const callback = arguments[arguments.length - 1];
const yubin7 = '1008950';
new YubinBango.Core(yubin7, addr => {callback(addr)});
}).then(addr => {
expect(addr.region_id).toEqual(13);
expect(addr.region).toEqual('東京都');
expect(addr.locality).toEqual('千代田区');
Expand Down
28 changes: 28 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitUseStrict": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
],
"compileOnSave": true,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
2 changes: 1 addition & 1 deletion yubinbango-core.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions yubinbango-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module YubinBango {
constructor(inputVal: string = '', callback?) {
if(inputVal){
// 全角の数字を半角に変換 ハイフンが入っていても数字のみの抽出
let a:string = inputVal.replace(/[-]/g, (s: string) => String.fromCharCode(s.charCodeAt(0) - 65248));
let b:RegExpMatchArray = a.match(/\d/g);
let c:string = b.join('');
let yubin7: string = this.chk7(c);
const a:string = inputVal.replace(/[-]/g, (s: string) => String.fromCharCode(s.charCodeAt(0) - 65248));
const b:RegExpMatchArray = a.match(/\d/g);
const c:string = b.join('');
const yubin7: string = this.chk7(c);
// 7桁の数字の時のみ作動
if (yubin7) {
this.getAddr(yubin7, callback);
Expand Down Expand Up @@ -49,14 +49,14 @@ module YubinBango {
}
jsonp(url: string, fn) {
window['$yubin'] = (data) => fn(data);
let scriptTag = document.createElement("script");
const scriptTag = document.createElement("script");
scriptTag.setAttribute("type", "text/javascript");
scriptTag.setAttribute("charset", "UTF-8");
scriptTag.setAttribute("src", url);
document.head.appendChild(scriptTag);
}
getAddr(yubin7: string, fn) {
let yubin3 = yubin7.substr(0, 3);
const yubin3 = yubin7.substr(0, 3);
if (this.cachecheck(yubin7, yubin3)) {
fn(this.selectAddr(yubin7, CACHE[yubin3][yubin7]));
} else {
Expand Down

0 comments on commit 8124158

Please sign in to comment.