1/** 2 * å é¤ä¸ä¸ªè¯è®º 3 * @param id éè¦è¢«å é¤çè¯è®ºæ°æ® 4 * @param controller éè¦ä½¿ç¨çæ§å¶å¨ 5 * @return {Promise<any>} 6 */ 7function deleteComment(id, controller) { 8 if (controller === undefined || controller === '') { 9 console.error("è¯è®ºå¤çå¨ä¸æç¡®ï¼è¯è®ºå é¤å¤±è´¥ï¼", controller) 10 const temp = {} 11 temp[WEB_CONF.RES_RETURN] = "è¯è®ºå¤çå¨ä¸æç¡®ï¼è¯è®ºå é¤å¤±è´¥ï¼"; 12 return Promise.reject(temp) 13 } 14 return axios( 15 { 16 url: backEnd_host_href() + '/' + controller + WEB_CONF.COMMENT_DELETE, 17 params: { 18 id: id, 19 userId: my.id 20 } 21 } 22 ).then( 23 (res) => { 24 return res.data; 25 } 26 ).catch( 27 (e) => { 28 const res = {} 29 res[WEB_CONF.RES_RETURN] = e.message 30 return res; 31 } 32 ) 33} 34 35/** 36 * 37 * @param e æå®çè¯è®ºæ°æ®å®¹å¨ 38 * @param json {{id, user, userId, date, data, ip}} 39 * ææçåè¯è®ºæ°æ® json 对象 40 * @param fun1 ç¹å»åè¯è®ºå¤´åä¹åçåè°å½æ° 41 * @param fun2 å é¤è¯è®ºæåä¹åçåè°å½æ° 42 * @param controller æå®çæ§å¶å¨ 43 */ 44function addCommentSub(e, json, fun1 = undefined, fun2 = undefined, controller = WEB_CONF['CONTROLLER_TRENDS']) { 45 // è·åå½åç¨æ· 46 const user = json.user; 47 if (user !== undefined) { 48 const comment_div_reply = document.createElement("div"); 49 comment_div_reply.className = "comment_div comment_div_reply pre_div"; 50 if (isMobileDevice()) { 51 comment_div_reply.classList.add("comment_div_Mobile") 52 } 53 const img = document.createElement("img"); 54 img.className = 'avatar headSculpture' 55 getUserConfById(json.userId).then( 56 (res) => { 57 img.src = res.headSculpture[1] 58 const user_a = document.createElement("a"); 59 user_a.className = "headSculpture_a user_a user_a_id_num" 60 // å°è¯è·åå°ç¨æ·ç tempName å¹¶èµå¼ç» a 61 LY_Utils.getUserJsonByKeyById(user.id, 'tempName', (res) => user_a.innerText = res, (_) => user_a.innerText = user.name); 62 if (fun1 !== undefined) { 63 img.onclick = fun1; 64 user_a.onclick = fun1; 65 } 66 const reqDate = document.createElement("div"); 67 reqDate.innerText = "î¦ "; 68 const reqDate_span = document.createElement("span"); 69 reqDate_span.innerText = json.date; 70 reqDate.appendChild(reqDate_span); 71 const data_pre = document.createElement("pre"); 72 data_pre.className = "Trends_data_comment"; 73 data_pre.innerText = json.data; 74 const area_span = document.createElement("a"); 75 area_span.className = "area_span"; 76 area_span.innerText = "î§§ " + json.ip 77 area_span.href = 'https://www.baidu.com/s?ie=UTF-8&wd=' + json.ip; 78 area_span.target = "_blank"; 79 const buttonArea = document.createElement("div"); 80 // å¼å§æ·»å 81 comment_div_reply.appendChild(img) 82 comment_div_reply.appendChild(user_a); 83 comment_div_reply.appendChild(reqDate); 84 comment_div_reply.appendChild(data_pre); 85 if ((!isNotLogin()) && user.id.toString() === my.id) { 86 // 代表æ¯èªå·±çè¯è®º å¯ä»¥å é¤ 87 // 设置æ¤è¯è®ºçå é¤æé® 88 const delete_comment_button = document.createElement("button"); 89 delete_comment_button.setAttribute("class", "delete_comment_button user_self"); 90 delete_comment_button.innerText = "î© å 餿¤åå¤" 91 delete_comment_button.addEventListener("click", () => { 92 if (confirm("æ¨ç¡®å®è¦å 餿¤åå¤è¯è®ºåï¼")) { 93 deleteComment(json.id, controller).then( 94 (res) => { 95 if (WEB_CONF.RES_RETURN_OK_VALUE === res[WEB_CONF.RES_RETURN]) { 96 if (fun2 !== undefined) { 97 fun2() 98 } 99 } else { 100 jokerBoxPopUp.show("è¯è®ºå é¤å¤±è´¥:" + res[WEB_CONF.RES_RETURN]) 101 } 102 } 103 ) 104 } 105 }) 106 delete_comment_button.style.margin = '0' 107 area_span.style.lineHeight = delete_comment_button.style.height 108 buttonArea.appendChild(delete_comment_button) 109 } 110 111 buttonArea.style.width = '100%' 112 area_span.style.display = 'inline-block' 113 area_span.style.height = '100%' 114 comment_div_reply.style.height = '100%' 115 buttonArea.appendChild(area_span); 116 comment_div_reply.appendChild(buttonArea) 117 e.appendChild(comment_div_reply) 118 } 119 ) 120 } 121} 122 123/** 124 * åæå®å ç´ æ·»å ä¸ä¸ªè¯è®ºæ°æ® 125 * @param showArea ä¿¡æ¯è¾åºç¹ 126 * @param e æå®çè¯è®ºæ°æ®å®¹å¨ 127 * @param json { 128 * { 129 * id, user, userId, date, data, ip, sub : [ 130 * { 131 * id, user, userId, date, data 132 * } 133 * ] 134 * } 135 * } 136 * @param link å½å页é¢ç龿¥ 137 * @param fun1 åå¤è¯è®ºæåä¹åçåè° 138 * @param fun2 è¯è®ºå 餿åä¹åçåè° 139 * @param controller æ§å¶å¨çåç§°ï¼ 140 */ 141function addComment(showArea, e, json, link, fun1 = undefined, fun2 = undefined, c
141ontroller = WEB_CONF['CONTROLLER_TRENDS']) { 142 // å建åºè¯è®ºæ°æ®ç æ ç¾ 143 const comment_div = document.createElement("div"); 144 const img = document.createElement("img"); 145 const user_a = document.createElement("a"); 146 const date_div = document.createElement("div"); 147 const date_span = document.createElement("span"); 148 const data_pre = document.createElement("pre"); 149 const reply_comment_button = document.createElement("button"); 150 const reply_comment_div = document.createElement("div"); 151 // 设置æ¤è¯è®ºæ°æ®ç id 152 comment_div.setAttribute("class", "comment_div pre_div"); 153 if (isMobileDevice()) { 154 comment_div.classList.add("comment_div_Mobile") 155 } 156 comment_div.id = json.id; 157 // 设置æ¤è¯è®ºæ°æ®ç åéè 158 img.className = 'avatar headSculpture' 159 getUserConfById(json.userId).then( 160 (res) => { 161 // è·åå°ç¨æ·é ç½®æ°æ® 162 const userJson = json.user; 163 const toHome = () => toPersonHomePage(userJson); 164 img.src = res.headSculpture[1] 165 // 设置ç¹å»å¤´å跳转 166 img.onclick = toHome 167 user_a.setAttribute("class", "headSculpture_a user_a") 168 // å°è¯è·åå°å¤´å 妿åºéäºå°±ç´æ¥ç¨ userJson.name 169 LY_Utils.getUserJsonByKeyById(userJson.id, 'tempName', (res) => user_a.innerText = res, (_) => user_a.innerText = userJson.name); 170 // 设置ç¹å»ç¨æ·å跳转 171 user_a.onclick = toHome 172 comment_div.appendChild(img); 173 comment_div.appendChild(user_a); 174 // 设置æ¤è¯è®ºçæ¥æ 175 date_div.innerText = "î¦ "; 176 date_span.innerText = json.date; 177 date_div.appendChild(date_span) 178 comment_div.appendChild(date_div); 179 // 设置æ¤è¯è®ºçææ¬æ°æ® 180 data_pre.className = "Trends_data_comment"; 181 data_pre.innerText = json.data; 182 comment_div.appendChild(data_pre); 183 // 设置æ¤è¯è®ºçå°åºä½ç½® 184 const area_span = document.createElement("a"); 185 area_span.className = "area_span"; 186 area_span.innerText = "î§§ " + json.ip; 187 area_span.href = 'https://www.baidu.com/s?ie=UTF-8&wd=' + json.ip; 188 area_span.target = "_blank"; 189 comment_div.appendChild(area_span); 190 // 设置æ¤è¯è®ºçå夿°æ®æé® 191 reply_comment_button.setAttribute("class", "reply_comment_button"); 192 reply_comment_button.innerText = "î» å夿¤è¯è®º" 193 reply_comment_button.addEventListener("click", () => { 194 let subData = ''; 195 do { 196 subData = window.prompt("请è¾å ¥æ¨è¦åå¤çè¯è®º.", subData) 197 if (subData != null) { 198 if (subData.length > 256) { 199 jokerBoxPopUp.show("æ¨çè¯è®ºåæ°ä¸è½è¶ è¿ 256!!!") 200 } else { 201 break; 202 } 203 } else { 204 return; 205 } 206 } while (true); 207 addComment_button( 208 showArea, 209 link, 210 userJson.id, 211 json.id, 212 subData, 213 fun1, controller) 214 }) 215 comment_div.appendChild(reply_comment_button) 216 if ((!isNotLogin()) && userJson.id.toString() === my.id) { 217 // 设置æ¤è¯è®ºçå é¤æé® 218 const delete_comment_button = document.createElement("button"); 219 delete_comment_button.setAttribute("class", "delete_comment_button"); 220 delete_comment_button.innerText = "î© å 餿¤è¯è®º" 221 delete_comment_button.addEventListener("click", () => { 222 if (confirm("æ¨ç¡®å®è¦å 餿¤è¯è®ºåï¼")) { 223 deleteComment(json.id, controller).then( 224 (res) => { 225 if (WEB_CONF.RES_RETURN_OK_VALUE === res[WEB_CONF.RES_RETURN]) { 226 if (fun2 !== undefined) { 227 fun2() 228 } 229 } else { 230 jokerBoxPopUp.show("è¯è®ºå é¤å¤±è´¥:" + res[WEB_CONF.RES_RETURN]) 231 } 232 } 233 ) 234 } 235 }) 236 comment_div.appendChild(delete_comment_button) 237 } 238 // 设置æ¤è¯è®ºçåå夿°æ® 239 const sub = json.sub; 240 for (let i = 0; i < sub.length; i++) { 241 const subElement = sub[i]; 242 subElement.date = getDate(subElement.date); 243 addCommentSub(reply_comment_div, subElement, () => toPersonHomePage(subElement.user), fun2, controller) 244 } 245 comment_div.appendChild(reply_comment_div); 246 e.appendChild(comment_div) 247 } 248 ) 249 250} 251 252 253/** 254 * å è½½ææçè¯è®ºæ°æ® 255 * @param show_area å è½½æé´éè¦ä½¿ç¨å°çä¿¡æ¯è¾åºç¹ 256 * @param controller è¯è®ºæå±çæ§å¶å¨ 257 * @param link å½å页é¢ç龿¥ 258 * @param fun1 åå¤è¯è®ºæåä¹åçåè° 259 * @param fun2 è¯è®ºå 餿åä¹åçåè° 260 */ 261function loadAllComment(show_area, controller = WEB_CONF['CONTROLLER_TRENDS'], link, fun1 = undefined, fun2 = undefined) { 262 return axios( 263 {
264 url: backEnd_host_href() + '/' + controller + WEB_CONF.COMMENT_GET, 265 method: 'post', 266 params: { 267 father: document.getElementsByClassName("TrendsId_span")[0].innerText 268 } 269 } 270 ).then( 271 (res) => { 272 res = res.data 273 if (WEB_CONF.RES_RETURN_OK_VALUE === res[WEB_CONF.RES_RETURN]) { 274 const json_date = res[WEB_CONF.COMMENT_ALL_KEY] 275 const comment_div_pHome = document.getElementById("comment_div_PHome"); 276 for (let i = json_date.length - 1; i >= 0; i--) { 277 const jsonDateElement = json_date[i]; 278 jsonDateElement.date = getDate(jsonDateElement.date); 279 addComment(show_area, comment_div_pHome, jsonDateElement, link, fun1, fun2, controller) 280 } 281 } else { 282 show_area.innerText = res[WEB_CONF.RES_RETURN] 283 } 284 } 285 ) 286} 287 288/** 289 * åå¤ä¸ä¸ªè¯è®º 290 * @param showArea ä¿¡æ¯è¾åºç¹ 291 * @param father å½åè¯è®ºåå¤ç对象id 292 * @param data è¯è®ºçå 容 293 * @param address è¯è®ºå°åº 294 * @param link å½åçé¢ç龿¥ 295 * @param recId è¯è®ºä¿¡æ¯çéç¥äººå ä¸è¬æ¯è¢«è¯è®ºçç¨æ· 296 * @param controller è¯è®ºæå±çæ§å¶å¨ 297 * @param fun è¯è®ºæåä¹åçåè°å½æ° 298 */ 299function addCommentFunByFatherDataAddress(showArea, father, data, address, link, recId, controller, fun = undefined) { 300 if (controller === undefined || controller === '') { 301 console.error("è¯è®ºå¤çå¨ä¸æç¡®ï¼è¯è®ºåé失败ï¼", controller) 302 return; 303 } 304 axios( 305 { 306 url: backEnd_host_href() + '/' + controller + WEB_CONF.COMMENT_ADD, 307 method: 'post', 308 params: { 309 father: father, 310 data: data, 311 ipAddress: address, 312 link: link, 313 recId: recId 314 } 315 } 316 ).then( 317 (res) => { 318 res = res.data; 319 if (WEB_CONF.RES_RETURN_OK_VALUE === res[WEB_CONF.RES_RETURN]) { 320 if (fun !== undefined) { 321 fun() 322 } 323 } else { 324 show_area.innerText = new Date().toUTCString() + ": " + res[WEB_CONF.RES_RETURN]; 325 } 326 } 327 ) 328} 329 330/** 331 * æ·»å è¯è®º 332 * @param showArea ä¿¡æ¯è¾åºç¹ 333 * @param father å½åè¯è®ºåå¤ç对象id 334 * @param data è¯è®ºçå 容 335 * @param link å½åçé¢ç龿¥ 336 * @param recId è¯è®ºä¿¡æ¯çéç¥äººå ä¸è¬æ¯è¢«è¯è®ºçç¨æ· 337 * @param fun è¯è®ºæåä¹åçåè°å½æ° 338 * @param controller è¯è®ºéè¦ä½¿ç¨çæ§å¶å¨ 339 */ 340function addComment_button(showArea, link, recId, 341 father = TRENDS_DATA_TEMP.id, 342 data = document.getElementById("commentTrends_input_data").value, 343 fun = undefined, controller = WEB_CONF['CONTROLLER_TRENDS'] 344) { 345 if (data === undefined) { 346 return; 347 } 348 if (data.length <= 0) { 349 jokerBoxPopUp.show("è¯è®ºå 容ä¸è½ä¸ºç©º!!") 350 addComment_button(showArea, link, recId, father, window.prompt("è¯·ä¿®æ¹æ¨çè¯è®º.", data), fun, controller) 351 return; 352 } 353 if (data.length > 256) { 354 jokerBoxPopUp.show("è¯è®ºçåæ°ä¸å¾è¶ è¿256个å!!") 355 addComment_button(showArea, link, recId, father, window.prompt("è¯·ä¿®æ¹æ¨çè¯è®º.", data), fun, controller) 356 return; 357 } 358 if (isNotLogin()) { 359 jokerBoxPopUp.show("请å è¿è¡ç»å½æä½"); 360 return; 361 } 362 getIPLocationAndCache(my.ip).then( 363 (json) => { 364 addCommentFunByFatherDataAddress(showArea, father, data, json.address, link, recId, controller, fun) 365 } 366 ) 367}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.