edit
@@ -10,7 +10,9 @@ | ||
10 | 10 | for(HashMap<String,String> map:list) { |
11 | 11 | ArrayList<String> setList = new ArrayList<String>(); |
12 | 12 | for(String key:map.keySet()) { |
13 | - String set = "'" + key + "':'" + map.get(key) + "'"; | |
13 | + String value = map.get(key); | |
14 | + value = value.replaceAll("\\'", "'"); | |
15 | + String set = "'" + key + "':'" + value + "'"; | |
14 | 16 | setList.add(set); |
15 | 17 | } |
16 | 18 | String[] ary = new String[setList.size()]; |
@@ -24,7 +26,11 @@ | ||
24 | 26 | public static String mapToJSON(HashMap<String,String> map) { |
25 | 27 | ArrayList<String> setList = new ArrayList<String>(); |
26 | 28 | for(String key:map.keySet()) { |
27 | - String set = "'" + key + "':'" + map.get(key) + "'"; | |
29 | + String value = map.get(key); | |
30 | + value = value.replaceAll("\\'", "'"); | |
31 | + value = value.replaceAll("\\r", "\\\\r"); | |
32 | + value = value.replaceAll("\\n", "\\\\n"); | |
33 | + String set = "'" + key + "':'" + value + "'"; | |
28 | 34 | setList.add(set); |
29 | 35 | } |
30 | 36 | String[] ary = new String[setList.size()]; |
@@ -47,7 +47,7 @@ | ||
47 | 47 | |
48 | 48 | <body> |
49 | 49 | <p>コンテンツ一覧</p> |
50 | -<div id="content_area"></div> | |
50 | +<div id="content_area">データを読み込み中です....</div> | |
51 | 51 | <div><a href="brandnew_text.html">新規作成</a></div> |
52 | 52 | </body> |
53 | 53 | </html> |
@@ -11,7 +11,18 @@ | ||
11 | 11 | <script type="text/javascript" src="js/jquery.js"></script> |
12 | 12 | |
13 | 13 | <title>新規作成</title> |
14 | - | |
14 | +<style> | |
15 | +<!-- | |
16 | +#text_body{ | |
17 | + width:500px; | |
18 | + height:350px; | |
19 | + font-size:13px; | |
20 | +} | |
21 | +#text_title{ | |
22 | + width:500px; | |
23 | +} | |
24 | + --> | |
25 | +</style> | |
15 | 26 | <script> |
16 | 27 | <!-- |
17 | 28 | window.onload = function myload() { |
@@ -19,17 +30,28 @@ | ||
19 | 30 | |
20 | 31 | } |
21 | 32 | function dataload() { |
22 | - var text = clipboardData.getData('Text'); | |
23 | - if(text) { | |
24 | - $('#content_area').text(text); | |
33 | + | |
34 | +} | |
35 | +function regist(){ | |
36 | + var title = $('#text_title').val(); | |
37 | + var body = $('#text_body').val(); | |
38 | + if(!body){ | |
39 | + alert("文章がありません"); | |
40 | + return; | |
25 | 41 | } |
26 | -/* | |
27 | - $.ajax({url : "/ContentsList.do?type=getall", | |
28 | - type : "get", | |
42 | + if(!title) { | |
43 | + title = body.substring(0, 10); | |
44 | + } | |
45 | + body = encodeURIComponent(body); | |
46 | + title = encodeURIComponent(title); | |
47 | + var data = "title=" + title; | |
48 | + data += "&body=" + body; | |
49 | + $.ajax({url : "/ContentData.do", | |
50 | + type : "post", | |
29 | 51 | success : success, |
30 | - error : errorMsg | |
52 | + error : errorMsg, | |
53 | + data : data | |
31 | 54 | }); |
32 | - */ | |
33 | 55 | } |
34 | 56 | function errorMsg(xmlObj) { |
35 | 57 | alert("エラー発生 :" + xmlObj.status + "\n" + xmlObj.responseText); |
@@ -37,13 +59,8 @@ | ||
37 | 59 | } |
38 | 60 | function success(data, status) { |
39 | 61 | if(status == "success"){ |
40 | - var records = eval(data); | |
41 | - var recHtml = ""; | |
42 | - for(var i = 0;i < records.length;i++){ | |
43 | - var line = records[i]; | |
44 | - recHtml += "<p><a href='content_show.html?idx=" + line['text_index'] + "'>" + line['title'] + "</a></p>"; | |
45 | - } | |
46 | - $('#content_area').html(recHtml); | |
62 | + alert("登録完了しました。"); | |
63 | + window.location = "./" + data; | |
47 | 64 | } |
48 | 65 | } |
49 | 66 | --> |
@@ -54,7 +71,9 @@ | ||
54 | 71 | <body> |
55 | 72 | <div> |
56 | 73 | <form> |
57 | - <textarea id="textbox" ></textarea> | |
74 | + <input type="text" id="text_title" /><br/> | |
75 | + <textarea id="text_body" ></textarea><br /> | |
76 | + <input type="button" onclick="regist();" value="登録"/> | |
58 | 77 | </form> |
59 | 78 | </div> |
60 | 79 | </body> |
@@ -47,6 +47,6 @@ | ||
47 | 47 | |
48 | 48 | <body> |
49 | 49 | <p>コンテンツ一覧</p> |
50 | -<div id="content_area"></div> | |
50 | +<div id="content_area">データを読み込み中です....</div> | |
51 | 51 | </body> |
52 | 52 | </html> |