Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
103 lines (89 sloc) 3.08 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Source Convertor</title>
</head>
<body>
<div>
<h1>ソースコード ジェネレータ</h1>
</div>
<div>
<h2>
タブで区切ったパラメータを入力してください
</h2>
</div>
<div>
<div>
設定値:<label id="description"></label>
</div>
<textarea id="before" rows="10" cols="80">
文字列A string strA
数値 int intB
</textarea>
</div>
<div>
<select id="formatType"></select>
<button id="convert">変換</button>
</div>
<div>
生成結果
</div>
<textarea id="after" rows="20" cols="80"></textarea>
<script>
window.onload = function () {
var formats=new Object();
formats.cs_property = new Object();
formats.cs_property.text = "論理プロパティ名 データ型 物理プロパティ名";
formats.cs_property.count = 3;
formats.cs_property.format = '/// <summary>'+'\n'+
'/// {0}'+'\n'+
'/// </summary>'+'\n'+
'public {1} {2} {set; get; }'+'\n';
formats.vb_property = new Object();
formats.vb_property.text = "論理プロパティ名 データ型 物理プロパティ名";
formats.vb_property.count = 3;
formats.vb_property.format = "''' <summary>" + "\n"+
"''' {0}" + "\n"+
"''' </summary>" + "\n"+
"Public Property {2} As {1}" + "\n";
// SELECTの選択値を設定
var formatType = document.getElementById('formatType');
for (var formatName in formats) {
e = document.createElement("option");
e.value = formatName;
e.textContent = formatName;
formatType.appendChild(e);
}
// 選択項目の変更 イベント
formatType.onchange = function(){
var target = formats[formatType.value];
var description = document.getElementById('description');
description.innerText = target.text;
}
formatType.onchange();
// 変更ボタンクリック イベント
var button = document.getElementById('convert');
button.onclick = function () {
var target = formats[formatType.value];
var beforeText = document.getElementById('before').value;
var src = beforeText.split("\n");
var desc = new Array();
for (var lineIndex = 0; lineIndex < src.length; lineIndex++) {
var temp = src[lineIndex].split("\t");
var index=0;
var formattedText = target.format;
for (var index = 0; index < temp.length; index++) {
formattedText = formattedText.replace("{"+index.toString()+"}",temp[index]);
}
if(temp.length == target.count){
desc.push(formattedText + "\n");
}
}
var after = document.getElementById('after');
after.value = desc.join("");
};
};
</script>
</body>
</html>