Skip to content

Commit bb47ac7

Browse files
committed
0717
1 parent 188b0f3 commit bb47ac7

23 files changed

+158
-147
lines changed

memlingo2.py

Lines changed: 45 additions & 43 deletions
Large diffs are not rendered by default.

pages2/ajax.js

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,68 @@
11
function sendAjaxRequest(method, url, params, successCallback, errorCallback) {
2-
var xhr = new XMLHttpRequest();
3-
4-
if (method == "GET") {
5-
xhr.open(method, url+"?"+params);
6-
} else {
7-
xhr.open(method, url);
8-
}
9-
10-
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
11-
xhr.onload = function() {
12-
if (xhr.status === 200) {
13-
successCallback(xhr.responseText);
2+
var xhr = new XMLHttpRequest();
3+
4+
if (method == "GET") {
5+
xhr.open(method, url + "?" + params);
146
} else {
15-
errorCallback(xhr.status);
7+
xhr.open(method, url);
168
}
17-
};
18-
xhr.onerror = function() {
19-
errorCallback(xhr.status);
20-
};
21-
xhr.send(params);
9+
10+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
11+
xhr.onload = function () {
12+
if (xhr.status === 200) {
13+
successCallback(xhr.responseText);
14+
} else {
15+
errorCallback(xhr.status);
16+
}
17+
};
18+
xhr.onerror = function () {
19+
errorCallback(xhr.status);
20+
};
21+
xhr.send(params);
2222
}
2323

2424
function sendGetRequest(url, params, successCallback, errorCallback) {
25-
sendAjaxRequest('GET', url, params, successCallback, errorCallback);
25+
sendAjaxRequest('GET', url, params, successCallback, errorCallback);
2626
}
2727

2828
function sendPostRequest(url, params, successCallback, errorCallback) {
29-
sendAjaxRequest('POST', url, params, successCallback, errorCallback);
29+
sendAjaxRequest('POST', url, params, successCallback, errorCallback);
3030
}
3131

3232

3333
function postAjaxRequest(url, jsonStr, successCallback, errorCallback) {
34-
var xhr = new XMLHttpRequest();
35-
36-
xhr.open('POST', url);
37-
38-
39-
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
40-
xhr.onload = function() {
41-
if (xhr.status === 200) {
42-
successCallback(xhr.responseText);
43-
} else {
44-
errorCallback(xhr.status, xhr.responseText);
45-
}
46-
};
47-
xhr.onerror = function() {
48-
errorCallback(xhr.status, xhr.responseText);
49-
};
50-
xhr.send(jsonStr);
34+
var xhr = new XMLHttpRequest();
35+
36+
xhr.open('POST', url);
37+
38+
39+
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
40+
xhr.onload = function () {
41+
if (xhr.status === 200) {
42+
successCallback(xhr.responseText);
43+
} else {
44+
errorCallback(xhr.status, xhr.responseText);
45+
}
46+
};
47+
xhr.onerror = function () {
48+
errorCallback(xhr.status, xhr.responseText);
49+
};
50+
xhr.send(jsonStr);
51+
}
52+
53+
function postAjax(url, input, successCallback) {
54+
var xhr = new XMLHttpRequest();
55+
xhr.open('POST', url);
56+
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
57+
xhr.onload = function () {
58+
if (xhr.status === 200) {
59+
successCallback(JSON.parse(xhr.responseText), xhr.responseText);
60+
} else {
61+
alert(xhr.responseText);
62+
}
63+
};
64+
xhr.onerror = function () {
65+
alert(xhr.responseText);
66+
};
67+
xhr.send(JSON.stringify(input));
5168
}

pages2/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<div id="total_duration" class="text-1 text-2">학습한 시간</div>
7272
</div>
7373
<div class="menu-2 menu-3">
74-
<img id="img_flag" class="united-states" src="img-flags/us.png" alt="United states" />
74+
<img id="img_flag" class="united-states" src="img-flags/en-us.png" alt="United states" />
7575
</div>
7676
</div>
7777
<div class="menus-1">

pages2/home.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function onlogout_click() {
88
}
99

1010
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course });
11-
postAjaxRequest('/api/logout.api', jsonStr, function (response) {
11+
postAjaxRequest('/api2/logout.api', jsonStr, function (response) {
1212
//여기서 암묵적으로 쿠키가 들어옴
1313
if (getCookie('login_status') != 'success') {
1414
//alert('Logout action is sucessfuly done');
@@ -93,7 +93,7 @@ function lang_changed() {
9393
function set_visited() {
9494
var email = localStorage.getItem("email");
9595
var jsonStr = JSON.stringify({ email: email });
96-
postAjaxRequest('/api/check_visited.api', jsonStr, function (response) {
96+
postAjaxRequest('/api2/check_visited.api', jsonStr, function (response) {
9797
responseObj = JSON.parse(response);
9898
if (responseObj["lun"] == "true") {
9999
$("lun").className = "the-day";
@@ -127,7 +127,7 @@ function set_visited() {
127127
function load_user_info() {
128128
var email = localStorage.getItem("email");
129129
var jsonStr = JSON.stringify({ email: email });
130-
postAjaxRequest('/api/load_user_info.api', jsonStr, function (response) {
130+
postAjaxRequest('/api2/load_user_info.api', jsonStr, function (response) {
131131
responseObj = JSON.parse(response);
132132
for (key in responseObj) {
133133
localStorage.setItem(key, responseObj[key]);

pages2/login.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
function isValidEmail(email) {
2+
if (email.length > 50) {
3+
return false;
4+
}
25
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
36
return emailRegex.test(email);
47
}
@@ -23,7 +26,7 @@ function onlogin_click() {
2326
// background-color: #4c5b75;
2427

2528
var jsonStr = JSON.stringify({ email1: email1, email2: email2, lang: lang });
26-
postAjaxRequest('/api/login.api', jsonStr, function (responseJSONStr) {
29+
postAjaxRequest('/api2/login.api', jsonStr, function (responseJSONStr) {
2730
responseObj = JSON.parse(responseJSONStr);
2831

2932
if (responseObj['resp'] == "OK") {

pages2/quizA.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function get_similar_words_jk(j_word, k_word) {
3636
var course = localStorage.session_course;
3737

3838
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, j_word: j_word, k_word: k_word });
39-
postAjaxRequest('/api/similar-words-jk.api', jsonStr, function (responseJSONStr) {
39+
postAjaxRequest('/api2/similar-words-jk.api', jsonStr, function (responseJSONStr) {
4040
console.log(responseJSONStr);
4141
responseObj = JSON.parse(responseJSONStr);
4242
// 서버에서 받아온 랜덤 워드를 랜덤한 유사 워드들을 화면에 출력한다.
@@ -80,14 +80,14 @@ function click_continue() {
8080
}
8181

8282

83-
// /api/card-next.api
83+
// /api2/card-next.api
8484
// userid, email, cookie:login_status, lang, course
8585
// output:
8686
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
8787
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
8888
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
8989
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: "0", index: quiz_count });
90-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
90+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
9191
responseObj = JSON.parse(responseJSONStr);
9292
console.log(responseObj);
9393
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizB.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function get_similar_words(carditem) {
66
var esp_txt = carditem.esp_txt;
77

88
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt });
9-
postAjaxRequest('/api/similar-words.api', jsonStr, function (responseJSONStr) {
9+
postAjaxRequest('/api2/similar-words.api', jsonStr, function (responseJSONStr) {
1010
console.log(responseJSONStr)
1111
responseObj = JSON.parse(responseJSONStr);
1212
selected_kors = [];
@@ -54,14 +54,14 @@ function click_continue() {
5454
}
5555

5656

57-
// /api/card-next.api
57+
// /api2/card-next.api
5858
// userid, email, cookie:login_status, lang, course
5959
// output:
6060
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
6161
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
6262
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
6363
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: "0", index: quiz_count });
64-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
64+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
6565
responseObj = JSON.parse(responseJSONStr);
6666
console.log(responseObj);
6767
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizC.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function get_similar_words_kor(carditem) {
66
var kor_txt = carditem.kor_txt;
77

88
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, kor_txt: kor_txt });
9-
postAjaxRequest('/api/similar-words-kor.api', jsonStr, function (responseJSONStr) {
9+
postAjaxRequest('/api2/similar-words-kor.api', jsonStr, function (responseJSONStr) {
1010
console.log(responseJSONStr)
1111
responseObj = JSON.parse(responseJSONStr);
1212
selected_kors = [];
@@ -50,14 +50,14 @@ function click_continue() {
5050
}
5151

5252

53-
// /api/card-next.api
53+
// /api2/card-next.api
5454
// userid, email, cookie:login_status, lang, course
5555
// output:
5656
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
5757
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
5858
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
5959
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: "0", index: quiz_count });
60-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
60+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
6161
responseObj = JSON.parse(responseJSONStr);
6262
console.log(responseObj);
6363
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizD.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function get_similar_words_kor(carditem) {
66
var kor_txt = carditem.kor_txt;
77

88
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, kor_txt: kor_txt });
9-
postAjaxRequest('/api/similar-words-kor.api', jsonStr, function (responseJSONStr) {
9+
postAjaxRequest('/api2/similar-words-kor.api', jsonStr, function (responseJSONStr) {
1010
console.log(responseJSONStr)
1111
responseObj = JSON.parse(responseJSONStr);
1212
selected_kors = [];
@@ -51,14 +51,14 @@ function click_continue() {
5151
}
5252

5353

54-
// /api/card-next.api
54+
// /api2/card-next.api
5555
// userid, email, cookie:login_status, lang, course
5656
// output:
5757
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
5858
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
5959
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
6060
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: "0", index: quiz_count });
61-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
61+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
6262
responseObj = JSON.parse(responseJSONStr);
6363
console.log(responseObj);
6464
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizE.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ function click_btn_easy_hard(easy_or_hard) {
4747
}
4848

4949

50-
// /api/card-next.api
50+
// /api2/card-next.api
5151
// userid, email, cookie:login_status, lang, course
5252
// output:
5353
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
5454
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
5555
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
5656
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: score, index: quiz_count });
57-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
57+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
5858
responseObj = JSON.parse(responseJSONStr);
5959
console.log(responseObj);
6060
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizF.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ function click_btn_easy_hard(easy_or_hard) {
4444
return;
4545
}
4646

47-
// /api/card-next.api
47+
// /api2/card-next.api
4848
// userid, email, cookie:login_status, lang, course
4949
// output:
5050
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
5151
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
5252
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
5353
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: score, index: quiz_count });
54-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
54+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
5555
responseObj = JSON.parse(responseJSONStr);
5656
console.log(responseObj);
5757
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizG.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function get_similar_words(carditem) {
1111
var esp_txt = carditem.esp_txt;
1212

1313
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt });
14-
postAjaxRequest('/api/similar-words.api', jsonStr, function (responseJSONStr) {
14+
postAjaxRequest('/api2/similar-words.api', jsonStr, function (responseJSONStr) {
1515
console.log(responseJSONStr)
1616
responseObj = JSON.parse(responseJSONStr);
1717
selected_kors = [];
@@ -58,14 +58,14 @@ function click_continue() {
5858
}
5959

6060

61-
// /api/card-next.api
61+
// /api2/card-next.api
6262
// userid, email, cookie:login_status, lang, course
6363
// output:
6464
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
6565
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
6666
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
6767
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: "0", index: quiz_count });
68-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
68+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
6969
responseObj = JSON.parse(responseJSONStr);
7070
console.log(responseObj);
7171
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizH.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function get_similar_words(carditem) {
66
var esp_txt = carditem.esp_txt;
77

88
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt });
9-
postAjaxRequest('/api/similar-words.api', jsonStr, function (responseJSONStr) {
9+
postAjaxRequest('/api2/similar-words.api', jsonStr, function (responseJSONStr) {
1010
console.log(responseJSONStr)
1111
responseObj = JSON.parse(responseJSONStr);
1212
selected_kors = [];
@@ -50,14 +50,14 @@ function click_continue() {
5050
}
5151

5252

53-
// /api/card-next.api
53+
// /api2/card-next.api
5454
// userid, email, cookie:login_status, lang, course
5555
// output:
5656
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
5757
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
5858
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
5959
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: "0", index: quiz_count });
60-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
60+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
6161
responseObj = JSON.parse(responseJSONStr);
6262
console.log(responseObj);
6363
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

pages2/quizI.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function get_similar_words_jk(j_word, k_word) {
4949
var course = localStorage.session_course;
5050

5151
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, j_word: j_word, k_word: k_word });
52-
postAjaxRequest('/api/similar-words-jk.api', jsonStr, function (responseJSONStr) {
52+
postAjaxRequest('/api2/similar-words-jk.api', jsonStr, function (responseJSONStr) {
5353
console.log(responseJSONStr);
5454
responseObj = JSON.parse(responseJSONStr);
5555
// 서버에서 받아온 랜덤 워드를 랜덤한 유사 워드들을 화면에 출력한다.
@@ -93,14 +93,14 @@ function click_continue() {
9393
}
9494

9595

96-
// /api/card-next.api
96+
// /api2/card-next.api
9797
// userid, email, cookie:login_status, lang, course
9898
// output:
9999
// quiz-card-url, 퀴즈 카드 유형을 랜덤으로 정해서 보내옴
100100
// level,esp_txt,kor,eng,group,count,next-review-time, = myprgress.tsv파일의 한 라인임
101101
// voice_img,voice_name,esp_txt.mp3 = esp_txt를 음성으로 읽어줄 캐릭터와 음성
102102
var jsonStr = JSON.stringify({ email: email, lang: lang, course: course, esp_txt: esp_txt, score: "0", index: quiz_count });
103-
postAjaxRequest('/api/card-next.api', jsonStr, function (responseJSONStr) {
103+
postAjaxRequest('/api2/card-next.api', jsonStr, function (responseJSONStr) {
104104
responseObj = JSON.parse(responseJSONStr);
105105
console.log(responseObj);
106106
// 받아온 output을 이용해서 적절하게 한장의 퀴즈 페이지를 구성한다.

0 commit comments

Comments
 (0)