유명현

EDIT: extraInfo parsing when \n*4 or length > 40

...@@ -51,9 +51,47 @@ function setCarouselMessage(mamuls) { ...@@ -51,9 +51,47 @@ function setCarouselMessage(mamuls) {
51 51
52 if (mamuls[i]["extraInfo"] == undefined || mamuls[i]["extraInfo"] == "") { 52 if (mamuls[i]["extraInfo"] == undefined || mamuls[i]["extraInfo"] == "") {
53 mamuls[i]["extraInfo"] = "없음"; 53 mamuls[i]["extraInfo"] = "없음";
54 - } else if (mamuls[i]["extraInfo"].length > 70) { 54 + } else {
55 - mamuls[i]["extraInfo"] = mamuls[i]["extraInfo"].slice(0, 70) + "\n..."; 55 + if (
56 + mamuls[i]["platform"] === "joongna" ||
57 + mamuls[i]["platform"] === "중고나라"
58 + ) {
59 + let searchDot = mamuls[i]["extraInfo"].indexOf("...");
60 + if (searchDot !== -1) {
61 + mamuls[i]["extraInfo"] = mamuls[i]["extraInfo"].slice(0, searchDot);
62 + }
63 + }
64 +
65 + console.log(`unparsed extraInfo : \n${mamuls[i]["extraInfo"]}`);
66 + let searchValue = "\n";
67 + let pos = 0;
68 + let foundPos = 0;
69 + for (let j = 0; j < 4 && foundPos !== -1; j++) {
70 + foundPos = mamuls[i]["extraInfo"].indexOf(searchValue, pos);
71 + pos = foundPos + 1;
72 + }
73 + console.log(`pos: ${pos}`);
74 + if (foundPos !== 1) {
75 + mamuls[i]["extraInfo"] =
76 + mamuls[i]["extraInfo"].slice(0, foundPos) + "\n...";
77 + console.log(`parsed extraInfo : \n${mamuls[i]["extraInfo"]}`);
78 + } else if (mamuls[i]["extraInfo"].length > 40) {
79 + mamuls[i]["extraInfo"] =
80 + mamuls[i]["extraInfo"].slice(0, 40) + "\n...";
81 + console.log(`parsed extraInfo : \n${mamuls[i]["extraInfo"]}`);
82 + }
56 } 83 }
84 + // } else if (mamuls[i]["extraInfo"].length > 70) {
85 + // mamuls[i]["extraInfo"] = mamuls[i]["extraInfo"].slice(0, 70) + "\n...";
86 + // } else {
87 +
88 + // }
89 + // else if (mamuls[i]["extraInfo"].indexOf("\n") !== -1) {
90 + // console.log(mamuls[i]["extraInfo"].indexOf("\n", 4));
91 + // let slicePoint = mamuls[i]["extraInfo"].indexOf("\n", 4);
92 + // mamuls[i]["extraInfo"] =
93 + // mamuls[i]["extraInfo"].slice(0, slicePoint) + "\n...";
94 + // }
57 95
58 flexMessage = setFlexMessage( 96 flexMessage = setFlexMessage(
59 mamuls[i]["platform"], 97 mamuls[i]["platform"],
......