Fix: icon color for out, in, pressed
Fix: make lib/util directory Add: refresh browser if app goes wrong
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
function DateUtil() {
|
||||
}
|
||||
|
||||
DateUtil.getYYYYMMDD = function(date) {
|
||||
// return date.toISOString().slice(0,10);
|
||||
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
}
|
||||
|
||||
DateUtil.getHHMMSS = function(date) {
|
||||
return StringUtil.getNumberStartWithZero(date.getHours(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getMinutes(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getSeconds(), 2);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
function NumberUtil() {
|
||||
}
|
||||
|
||||
|
||||
NumberUtil.numberWithCommas = function(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
}
|
||||
|
||||
NumberUtil.numberOfDigits = function(number) {
|
||||
if(number === 1000)
|
||||
return 4;
|
||||
|
||||
return Math.floor(Math.log(number) / Math.LN10 + 1); // bug : 1000 -> expected 4 but 3
|
||||
}
|
||||
|
||||
NumberUtil.getRecordText = function(value) {
|
||||
var number = Math.floor(value);
|
||||
var numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
|
||||
if(isTypingGame())
|
||||
return numberWithCommas + " 타";
|
||||
else
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
|
||||
|
||||
NumberUtil.hexToRGB = function(hexCode) {
|
||||
var hex = "";
|
||||
if(hexCode.length == 4)
|
||||
hex = "#" + hexCode[1] + hexCode[1] + hexCode[2] + hexCode[2] + hexCode[3] + hexCode[3];
|
||||
|
||||
var hexValue = "0x" + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
|
||||
// console.log(hexCode);
|
||||
// console.log(hexValue);
|
||||
return hexValue;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
function RecordUtil() {
|
||||
}
|
||||
|
||||
RecordUtil.getRecordValueWithUnit = function(record, appID) {
|
||||
var recordValue = RecordUtil.getRecordValueText(record, appID);
|
||||
var recordUnit = RecordUtil.getRecordUnit(appID);
|
||||
|
||||
return recordValue + recordUnit;
|
||||
}
|
||||
|
||||
RecordUtil.getRecordValueText = function(record, appID) {
|
||||
if(appID == 104)
|
||||
return record.toFixed(2);
|
||||
else
|
||||
return NumberUtil.numberWithCommas(Math.floor(record));
|
||||
}
|
||||
|
||||
RecordUtil.getRecordUnit = function(appID) {
|
||||
if(appID == 104)
|
||||
return " 초";
|
||||
else if(appID < 100)
|
||||
return " 타";
|
||||
else
|
||||
return " 점";
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
function StringUtil() {
|
||||
}
|
||||
|
||||
StringUtil.printMonthDay = function(date) {
|
||||
// var dateTime = new Date(date);
|
||||
var a = date.split(" ");
|
||||
var d = a[0].split("-");
|
||||
var t = "0:0:0".split(":");
|
||||
if(a.count > 0)
|
||||
var t = a[1].split(":");
|
||||
var dateTime = new Date(d[0],(d[1]-1),d[2],t[0],t[1],t[2]);
|
||||
return (dateTime.getMonth() + 1) + "월 " + dateTime.getDate() + "일";
|
||||
}
|
||||
|
||||
StringUtil.getRecordTextWithoutUnit = function(value) {
|
||||
var number = Math.floor(value);
|
||||
return NumberUtil.numberWithCommas(number);
|
||||
}
|
||||
|
||||
StringUtil.getRecordTextWithUnit = function(value) {
|
||||
var number = Math.floor(value);
|
||||
var numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
|
||||
if(isTypingGame())
|
||||
return numberWithCommas + " 타";
|
||||
else
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
|
||||
StringUtil.getNumberStartWithZero = function(number, digitCount) {
|
||||
var n = number + '';
|
||||
return n.length >= digitCount ? n : new Array(digitCount - n.length + 1).join('0') + n;
|
||||
}
|
||||
|
||||
StringUtil.toKoreanAlphabets = function(text) {
|
||||
var cCho = [ 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
var cJung = [ 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' ];
|
||||
var cJong = [ '', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
|
||||
var cho, jung, jong;
|
||||
var str = text;
|
||||
var cnt = str.length;
|
||||
var chars = [], cCode;
|
||||
|
||||
for (var i = 0; i < cnt; i++) {
|
||||
cCode = str.charCodeAt(i);
|
||||
// if (cCode == 32) { continue; } // 한글이 아닌 경우
|
||||
if (cCode < 0xAC00 || cCode > 0xD7A3) {
|
||||
chars.push(str.charAt(i));
|
||||
continue;
|
||||
}
|
||||
cCode = str.charCodeAt(i) - 0xAC00;
|
||||
jong = cCode % 28; // 종성
|
||||
jung = ((cCode - jong) / 28 ) % 21; // 중성
|
||||
cho = (((cCode - jong) / 28 ) - jung ) / 21; // 초성
|
||||
|
||||
chars.push(cCho[cho], cJung[jung]);
|
||||
if (cJong[jong] !== '') {
|
||||
chars.push(cJong[jong]);
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
};
|
||||
|
||||
StringUtil.getUnicodeAlphabetCount = function(text) {
|
||||
var chars = StringUtil.toKoreanAlphabets(text);
|
||||
// console.log('char : ' + chars);
|
||||
|
||||
var doubleJaum = [
|
||||
'ㄲ', 'ㅉ', 'ㄸ', 'ㄲ', 'ㅆ',
|
||||
'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ'
|
||||
];
|
||||
var doubleMoum = [
|
||||
'ㅒ', 'ㅖ',
|
||||
'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ'
|
||||
];
|
||||
|
||||
var alphabetCount = 0;
|
||||
var alphabet;
|
||||
for(var i = 0; i < chars.length; i++) {
|
||||
alphabet = chars[i];
|
||||
if(doubleJaum.indexOf(alphabet) > -1 || doubleMoum.indexOf(alphabet) > -1) {
|
||||
// console.log('double alphabet : ' + alphabet);
|
||||
alphabetCount += 2;
|
||||
}
|
||||
else
|
||||
alphabetCount++;
|
||||
}
|
||||
|
||||
// return chars;
|
||||
return alphabetCount;
|
||||
};
|
||||
|
||||
StringUtil.getScoreUnit = function(playingAppID) {
|
||||
if(playingAppID == 104)
|
||||
return " 초";
|
||||
else if(playingAppID < 100)
|
||||
return " 타";
|
||||
else
|
||||
return " 점";
|
||||
}
|
||||
Reference in New Issue
Block a user