源码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| <textarea rows="5" id="output" style="width:99%;margin-right:auto"></textarea> <br> <input type="button" value="变成大写" onclick="daxie()" /> <input type="button" value="变成小写" onclick="xiaoxie()" /> <input type="button" value="生成c语言头文件声明" onclick="cyuyantouwenjianshengming()" /> <input type="button" value="清空输入框" onclick="clean()" /> <input type="button" value="html空格转移符" onclick="HTMLSpase()"> <input type="button" value="转成markdown表格" onclick="mdTableCopy()"> <input type="button" value="正则 java多行注释" onclick="java_annotation()"> <script> function java_annotation() { var java_java_doc_annotation = "\\s*(?:\\/\\*{1,2}|\\*\\/|\\*)"; var output = document.getElementById("output"); output.value = java_java_doc_annotation; copy(); } function mdTableCopy() { var input = document.getElementById("output"); var str = input.value; str = str.replace(/^\s*$(\n|\r\n)/mg, ""); str = str.replace(/^(.+)$/mg, "|$1|"); var result = ""; var array = str.split("\n"); var line = ""; var count = 0; for (var j = 0, length = array.length; j < length; j++) { line = array[j]; count++ if (count == 1) { var cols = line.match(/\S+/g).length; line = line.replace(/\s+/g, "|"); result += line + "\n"; for (var i = 0; i < cols; i++) { result += "|:---"; } result += "|\n"; } line = line.replace(/\s+/g, "|"); if (j < length - 1) { result += line + "\n"; } else { result += line; } } input.value = result; copy(); } function daxie() { var input = document.getElementById("output"); if (input.value == null || input.value == "") { alert("请先输入"); return; } input.value = input.value.toUpperCase(); copy() } function xiaoxie() { var input = document.getElementById("output"); if (input.value == null || input.value == "") { alert("请先输入"); return; } input.value = input.value.toLowerCase(); copy(); } function HTMLSpase() { document.getElementById("output").value = " "; copy(); } function clean() { document.getElementById("output").value = ""; } function copy() { var in_output = document.getElementById("output"); in_output.select(); document.execCommand("Copy"); if (confirm("代码已经复制到剪贴板粘贴即可")) { in_output.value = ""; } } function cyuyantouwenjianshengming() { var input = document.getElementById("output"); var oldValue = input.value; if (oldValue == null || oldValue == "") { alert("请先输入头文件名(一个单词)"); return; } var isOneWord = /^\w+$/; if (isOneWord.test(oldValue)) { var daxie = input.value.toUpperCase(); input.value = "//" + oldValue + ".h\n" + "#ifndef _" + daxie + "_H_ //如果没有引入头文件" + oldValue + ".h\n" + " #define _" + daxie + "_H_ //那就引入头文件" + oldValue + ".h\n" + "#endif"; copy(); } else if (confirm("输入格式错误,是否清空输入框")) document.getElementById("output").value = ""; } </script>
|
参考链接