Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
otto committed Mar 3, 2014
1 parent 3bf1812 commit f845e28
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
53 changes: 24 additions & 29 deletions dist/jquery-supertextconverter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! jQuery Super Text Converter 2014-03-03
* Vertion : 0.1.0
* Vertion : 1.0.0
* Dependencies : jQuery *
* Author : MegazalRock (Otto Kamiya)
* Copyright (c) 2014 MegazalRock (Otto Kamiya);
Expand All @@ -17,7 +17,8 @@
tilda: true,
exclamation: true,
question: true,
space: true
space: true,
hyphen: true
},
zenkakuHyphen: 'ー',
zenkakuChilda: '〜'
Expand Down Expand Up @@ -58,8 +59,9 @@
zenkaku : //g,
hankaku : '¥'
},{
zenkaku : /[―‐−]/g,
hankaku : '-'
zenkaku : /[ー―‐−]/g,
hankaku : '-',
type : 'hyphen'
},{
zenkaku : //g,
hankaku : '|'
Expand Down Expand Up @@ -100,9 +102,9 @@
hankaku : /[¥\\]/g,
zenkaku : '¥'
},{
hankaku : /[ー\-]/g,
hankaku : /[\-ー]/g,
zenkaku : stc.options.zenkakuHyphen,
type: 'macron'
type : 'hyphen'
},{
hankaku : /\|/g,
zenkaku : '|'
Expand Down Expand Up @@ -163,16 +165,17 @@
];
};

SuperTextConverter.prototype.toHankaku = function(str, convertOptions){
SuperTextConverter.prototype.toHankaku = function(str, options){
var stc = this, list, length, i = 0;
convertOptions = convertOptions || stc.options.convert;
options = $.extend(true, stc.options, options || {});

str = str.replace(stc.regexp.zenkaku,stc.fnc.toHankaku);

list = stc.list.toHankaku;
length = list.length;
for(; i < length; i += 1){
if(typeof list[i].type === 'string'){
if(convertOptions[list[i].type]){
if(options.convert[list[i].type]){
str = str.replace(list[i].zenkaku, list[i].hankaku);
}
}else{
Expand All @@ -182,20 +185,22 @@
return str;
};

SuperTextConverter.prototype.toZenkaku = function(str, convertOptions){
SuperTextConverter.prototype.toZenkaku = function(str, options){
var stc = this, list, length, i = 0;
convertOptions = convertOptions || stc.options.convert;
options = $.extend(true, stc.options, options || {});

str = str.replace(stc.regexp.hankaku,stc.fnc.toZenkaku);

list = stc.list.toZenkaku;
length = list.length;
for(; i < length; i += 1){
if(typeof list[i].type === 'string'){
if(convertOptions[list[i].type]){
if(options.convert[list[i].type]){
str = str.replace(list[i].hankaku, list[i].zenkaku);
}
}else{
str = str.replace(list[i].hankaku, list[i].zenkaku);
}
str = str.replace(list[i].hankaku, list[i].zenkaku);
}
return str;
};
Expand All @@ -221,29 +226,19 @@
return str.replace(stc.regexp.hiragana, stc.fnc.toKatakana);
};

SuperTextConverter.prototype.autoConvert = function(str, widthMode, kanaMode){
SuperTextConverter.prototype.autoConvert = function(str, options){
var stc = this;
var result;
var options, _options = {};

if($.isPlainObject(widthMode)){
_options = widthMode || {};
}else{
_options = {
widthMode: widthMode || stc.options.widthMode,
kanaMode: kanaMode || stc.options.kanaMode
};
}

options = $.extend(true, stc.options, _options);
options = $.extend(true, stc.options, options);

if(options.widthMode === 'toHankaku'){
result = stc.toHankaku(str, options.convertPunctuation);
if(options.widthMode && options.widthMode === 'toHankaku'){
result = stc.toHankaku(str, options.convert);
}else if(options.widthMode === 'toZenkaku'){
result = stc.toZenkaku(str, options.convertPunctuation);
result = stc.toZenkaku(str, options.convert);
}

if(options.hankakuKatakanaMustDie){
if(options.widthMode && options.hankakuKatakanaMustDie){
result = stc.killHankakuKatakana(result);
}

Expand Down
4 changes: 2 additions & 2 deletions dist/jquery-supertextconverter.min.js

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

0 comments on commit f845e28

Please sign in to comment.