1/** 2 * í ìì¼ ëª©ë¡ ì²ë¦¬ 3 */ 4var Home = jindo.$Class({ 5 $autoBind : true, 6 7 $init : function() { 8 this._initVars(); 9 10 // ì¤ë ìì¼ êµ¬í´ì ìì¼ íì´íê³¼ ìì¼ ëª©ë¡ ë ¸ì¶ 11 this._changeWeekday(this._getCurrentWeekdayIndex()); 12 13 // ì í¸ì¥ë¥´ ìì 14 this._initFavoriteGenre(); 15 16 // HOT&NEW 17 this._initHotAndNew(); 18 19 // ê³µì§ ë³´ì¬ì¤ì§ ì¬ë¶ íì¸ 20 this._checkNotice(); 21 22 var self = this; // ë ëë§ ìë ë문ì ë§ì¤ì 못í´ì íë² ë í´ì¤ 23 setTimeout(function() { 24 self._changeWeekday(self._getCurrentWeekdayIndex()); 25 }, 150); 26 // ì´ë²¤í¸ í¸ë¤ë¬ ì§ì 27 this._welDailyTab.attach('[email protected]_daily', this._onClickWeekdayTab); 28 this._welWeekdayList.attach({ 29 '[email protected]_front' : this._onMouseOverCard, 30 '[email protected]_more' : this._onClickMoreBtn 31 }); 32 }, 33 34 /** 35 * ë³ì ì´ê¸°í 36 */ 37 _initVars : function() { 38 this._welWeekdayList = jindo.$Element('weekdayList'); 39 this._welDailyTab = jindo.$Element('dailyTab'); 40 this._welBlind = this._welWeekdayList.query('h2.blind'); 41 this._sBlindSurfix = this._welBlind.text().split(' ')[1]; 42 this._welFavoriteGenreTitleList = jindo.$Element('favoriteGenreTitleList'); 43 this._welHotAndNew = jindo.$Element('hotAndNew'); 44 }, 45 46 /** 47 * ì í¸ì¥ë¥´ ìì ì´ê¸°í 48 */ 49 _initFavoriteGenre : function() { 50 var MIN_TITLE_COUNT = 4; 51 // ì í¸ ì¥ë¥´ ì¶ì¶ 52 var aGenreList = this._extractFavoriteGenreList(4); 53 54 // ajaxë¡ ë°ì´í° ë¡ë© 55 var aHtml = []; 56 var bUnderCount = false; 57 for (var i = 0; i < aGenreList.length; i++) { 58 var sCurrentGenre = aGenreList[i]; 59 new jindo.$Ajax('/getFavoriteGenreTitleList', { 60 type : 'xhr', 61 method : 'get', 62 async : false, 63 timeout : 5, 64 onload : function(oRes) { 65 var oJson = oRes.json(); 66 bUnderCount = (oJson.length < MIN_TITLE_COUNT); 67 68 var htParam = { 69 genre : sCurrentGenre, 70 genreName : ghtGenreList[sCurrentGenre].sName, 71 genreSeoCode : ghtGenreList[sCurrentGenre].sSeoCode, 72 genreInstruction : ghtGenreList[sCurrentGenre].sIntoduction, 73 titleList : oJson 74 }; 75 var sHtml = jindo.$Template('tplFavoriteGenre').process(htParam); 76 aHtml.push(sHtml); 77 } 78 }).request({ genre : ghtGenreList[sCurrentGenre].nId }); 79 80 // ì¥ë¥´ì íìí ê°ìê° ëª¨ìë¼ë©´ ì ê±°íë¤. 81 if (bUnderCount) { 82 aHtml.pop(); 83 bUnderCount = false; 84 } 85 86 // 2ê° ì¥ë¥´ ì±ì ì¼ë©´ ë
87 if (aHtml.length == 2) { 88 break; 89 } 90 } 91 92 this._welFavoriteGenreTitleList.html(aHtml.join('\n')); 93 94 this._welFavoriteGenreTitleList.attach({ 95 '[email protected]_front' : this._onMouseOverCard 96 }); 97 }, 98 99 /** 100 * HOT&NEW ìì ì´ê¸°í 101 */ 102 _initHotAndNew : function() { 103 if (!this._welHotAndNew) { 104 return; 105 } 106 107 var itemCount = 0; 108 var itemPerPage = 4; 109 var oPagenation = null; 110 111 if (this._welHotAndNew.data("item-count") != null) { 112 itemCount = Number(this._welHotAndNew.data("item-count")); 113 } else { 114 // default 115 itemCount = 0; 116 } 117 118 // ì´ë²¤í¸ ì§ì 119 120 this._welHotAndNew.attach({ 121 '[email protected]_front' : this._onMouseOverCard, 122 'click@._prevBtn' : function(oEvent) { 123 oEvent.stopDefault(); 124 oHotAndNewRolling.moveBy(-itemPerPage); 125 var nPage = getCurrentPage(); 126 127 oPagenation && oPagenation.movePageTo(nPage); 128 }, 129 'click@._nextBtn' : function(oEvent) { 130 oEvent.stopDefault(); 131 oHotAndNewRolling.moveBy(itemPerPage); 132 var nPage = getCurrentPage(); 133 134 oPagenation && oPagenation.movePageTo(nPage); 135 } 136 }); 137 138 // ë¡¤ë§ & íì´ì§ 139 var oHotAndNewRolling = new jindo.CircularRolling(jindo.$('rolling'), { 140 nDuration : 400 141 }); 142 if (jindo.$('hotAndNewPagination')) { 143 oPagenation = new jindo.Pagination('hotAndNewPagination', { 144 nItem : itemCount, 145 nItemPerPage : itemPerPage, 146 sInsertTextNode : '\n', 147 sClassFirst : '', 148 sClassLast : '', 149 sPageTemplate : '<a data-buried-obj="1" data-sc-name="PC_home-page_new-point-btn" href="#" class="ico_pg N=a:hnn.page,g:' + sNclkLanguageCode + '">{=page}</a>', 150 sCurrentPageTemplate : '<strong class="ico_pg">{=page}</strong>' 151 }).attach({ 152 click : function(oCustomEvent) { 153 var nMoveCount = this.getItemPerPage(); 154 var current = getCurrentPage(); 155 var maximum = Math.ceil(itemCount / itemPerPage); 156 var event = oCustomEvent.nPage; 157 // moveCount ë°©í¥ì ìì . 158 if (getRightMoving(current, event, maximum) > -getLeftMoving(current, event, maximum)) { 159 // ì¤ë¥¸ìª½ ì´ëì´ ë ì ê² ìì§ì´ë©´ 160 nMoveCount *= getLeftMoving(current, event, maximum); 161 } else if (getRightMoving(current, event, maximum) < -getLeftMoving(current, event, maximum)) { 162 // ì¼ìª½ ì´ëì´ ë ì ê² ìì§ì´ë©´ 163 nMoveCount *= getRightMoving(current, event, maximum); 164 } else { 165 // ì ë°©í¥ì´ 모ë ê°ì¼ë©´ 166 if (current < event) { 167 // ì¼ìª½ìì ì¤ë¥¸ìª½ê±¸ ì ííì ë 168 nMoveCount *= getRightMoving(current, event, maximum); 169 } else { 170 // ì¤ë¥¸ìª½ìì ì¼ìª½ê±¸ ì ííì ë 171 // ê°ì ì´ë²¤í¸ë ë§íìì. 172 nMoveCount *= getLeftMoving(current, event, maximum); 173 } 174 } 175 oHotAndNewRolling.moveBy(nMoveCount); 176 } 177 }); 178 } 179 180 // ìì´ë ì¸ë¤ì¼ ì¹´ë ìë©´ ë§ì¤ì 181 /*var welMultiSummary = this._welHotAndNew.query('li.card_multi p.summary'); 182 Util.ellipsis(welMultiSummary, 'div.ellipsis_wrap');*/ 183 184 function getCurrentPage() { 185 return (oHotAndNewRolling.getIndex() % itemCount) / itemPerPage + 1; 186 } 187 188 function getRightMoving(current, event, max) { 189 if (event < current) { 190 event += max; 191 } 192 return event - current; 193 } 194 function getLeftMoving(current, event, max) { 195 if (current < event) { 196 current += max; 197 } 198 return event - current; 199 } 200 }, 201 202 /** 203 * ì¤ë ìì¼ ì¸ë±ì¤ ê³ì° 204 * 205 * @return {Number} ìì¼ ì¸ë±ì¤(0~6, ì~ì¼) 206 */ 207 _getCurrentWeekdayIndex : function() { 208 var oDate = jindo.$Date(); 209 var nDay = oDate.day() - 1 < 0 ? 6 : oDate.day() - 1; // ììì¼ì´ 맨 ìì ëìì 210 // ì¶ê° ì²ë¦¬ 211 return nDay; 212 }, 213 214 /** 215 * ì í ìì¼í ë³ê²½ 216 * 217 * @param nIndex {Number} ì íí ìì¼ ì¸ë±ì¤ 218 */ 219 _changeWeekday : function(nIndex) { 220 var aDailyTab = this._welDailyTab.queryAll('li'); 221 for (var i = 0, n = aDailyTab.length; i < n; i++) { 222 var welDailyTab = aDailyTab[i]; 223 // 기존 ì í í´ì 224 if (welDailyTab.hasClass('on')) { 225 welDailyTab.removeClass('on'); 226 } 227 // ì ê· ì í 228 if (i == nIndex) { 229 welDailyTab.addClass('on'); 230 } 231 } 232 233 var aWeekdayList = this._welWeekdayList.queryAll('ul.card_lst'); 234 for (var i = 0, n = aWeekdayList.length; i < n; i++) { 235 var welWeekdayList = aWeekdayList[i]; 236 // 기존 ì í í´ì 237 if (welWeekdayList.visible() == true) { 238 welWeekdayList.hide(); 239 } 240 // ì ê· ì í 241 if (i == nIndex) { 242 welWeekdayList.show(); 243 244 245 // ìì´ë ì¸ë¤ì¼ ì¹´ë ìë©´ ë§ì¤ì 246 /*var welMultiSummary = welWeekdayList.query('li.card_multi p.summary'); 247 Util.ellipsis(welMultiSummary, 'div.ellipsis_wrap');*/ 248 } 249 } 250 251 // blind í ì¤í¸ ë³ê²½ 252 this._changeBlindText(); 253 254 }, 255 256 /** 257 * blind í ì¤í¸ ë³ê²½ 258 */ 259 _changeBlindText : function() { 260 var sWeekdayName = this._welDailyTab.query('li.on a').text(); 261 this._welBlind.text(sWeekdayName + ' ' + this._sBlindSurfix); 262 }, 263 264 /** 265 * ìì¼ í´ë¦ ì´ë²¤í¸ ì²ë¦¬ 266 * 267 * @param oEvent 268 * {Wrapping Event} jindo Event ê°ì²´ 269 */ 270 _onClickWeekdayTab : function(oEvent) { 271 oEvent.stopDefault(); 272 273 var nIndex = jindo.$Element('dailyTab').indexOf(oEvent.element.parentNode); 274 this._changeWeekday(nIndex); 275 }, 276 277 /** 278 * ì¹´ëì ë§ì°ì¤ ì¤ë² í ë ì´ë²¤í¸ ì²ë¦¬ - ì¹´ë ë·ë©´ ì¤ê±°ë¦¬ë¥¼ ë§ì¤ì ì²ë¦¬íë¤. 279 * 280 * @param oEvent {Wrapping Event} jindo Event ê°ì²´ 281 */ 282 _onMouseOverCard : function(oEvent) { 283 return; 284 var elSummary = jindo.$$.getSingle('+ div.card_back div.info p.summary', oEvent.element); 285 var welSummary = jindo.$Element(elSummary); 286 if (welSummary.data('ellipsised') && welSummary.data('ellipsised') == true) { 287 return; 288 } 289 Util.ellipsis(welSummary, 'div.info'); 290 welSummary.data('ellipsised', true); 291 }, 292 293 /** 294 * MORE ë²í¼ í´ë¦ ì´ë²¤í¸ ì²ë¦¬ 295 * 296 * @param oEvent {Wrapping Event} jindo Event ê°ì²´ 297 */ 298 _onClickMoreBtn : function(oEvent) { 299 oEvent.stopDefault(); 300 301 var sWeekday = this._welDailyTab.query('li.on').data('weekday'); 302 //clickcr(this, 'hdy.more', '', '', oEvent, sNclkLanguageCode);
303 location.href = oEvent.element.href + '?weekday=' + sWeekday; 304 }, 305 306 _extractFavoriteGenreList : function(nExtractCount) { 307 // ìµê·¼ 본 ì¹í°ìì ì¥ë¥´ íµê³ ì¶ì¶ 308 var oRecentWebtoon = new RecentWebtoon(); 309 aRecentWebtoon = oRecentWebtoon.get(gsContentLanguage) || []; 310 for (var i = 0; i < aRecentWebtoon.length; i++) { 311 var oRecentWebtoon = aRecentWebtoon[i]; 312 if (oRecentWebtoon.bChallenge == true) { 313 continue; 314 } 315 316 var sGenre = oRecentWebtoon.genreCode; 317 if (!sGenre) { 318 continue; 319 } 320 // ì못ë ë°ì´í° 걸ë¬ë´ê¸° 321 // 2015.03.06 ë°°í¬ìì sGenreì ì¥ë¥´ì´ë¦ì´ ë¤ì´ê°ì¼ íëë°, trueê°ì´ ë¤ì´ê°ë 문ì ê° ë°ì íìì 322 // ì´ê² ë문ì, íìì genreê° ëì¤ì§ ìë 문ì ê° ë°ìíì¬, í´ë¹ 문ì 를 í´ê²°í기 ìí ì½ë 323 // TODO: ìê°ì´ ë§ì´ ì§ëë©´ ìì ëì´ì¼ í ì½ë 324 if(sGenre == true) { 325 continue; 326 } 327 328 // ìê¸°ê° ë´¤ë ì¥ë¥´ì ì¹í°ì´ ë³ê²½ëì´ì í´ë¹ ì¥ë¥´ ì¹í°ì´ ëì´ì ì¡´ì¬íì§ ìì ë 329 if (ghtGenreList[sGenre] == undefined) { 330 continue; 331 } 332 ghtGenreList[sGenre].nCount++; 333 } 334 335 // ë§ì´ 본 ì¥ë¥´ ìì¼ë¡ ì ë ¬ 336 var whtGenreList = jindo.$H(ghtGenreList); 337 whtGenreList.sort(function(val1, val2) { 338 var nCount1 = val1.nCount; 339 var nCount2 = val2.nCount; 340 341 return nCount2 - nCount1; // ë´ë¦¼ì°¨ì ì ë ¬ 342 }); 343 344 // ì í¸ ì¥ë¥´ ì ì (ê°ì 모ìë¼ë©´ ëë¨¸ì§ ì¥ë¥´ìì ëë¤ ì¶ì¶) 345 var aFavoriteGenreList = []; 346 var aNotFavoriteGenreList = []; 347 whtGenreList.forEach(function(v, k, o) { 348 if (v.nCount > 0) { 349 aFavoriteGenreList.push(k); 350 } else { 351 aNotFavoriteGenreList.push(k); 352 } 353 }); 354 var waFavoriteGenreList = jindo.$A(aFavoriteGenreList).concat(jindo.$A(aNotFavoriteGenreList).shuffle().slice(0, nExtractCount)); // ì 본 ì¥ë¥´ìì ëë¤ 2ê° ë½ìì 본 ì¥ë¥´ì ì¶ê° 355 356 return waFavoriteGenreList.slice(0, nExtractCount).$value(); 357 }, 358 359 /* 360 * ê³µì§ ë ¸ì¶ 361 * ì¬ì©ì ì¿ í¤ë¥¼ íì¸íì¬, ê³µì§ ë ¸ì¶ ì¬ë¶ë¥¼ ê²°ì íë¤. 362 * ìºì¬ë¥¼ íì°ê¸° ìíì¬, jsë¡ ì²ë¦¬ 363 */ 364 _checkNotice : function() { 365 var cookie = jindo.$Cookie(); 366 var noticeDoNotShow = cookie.get("noticeDoNotShow"); 367 var wEl = jindo.$Element("_notice"); 368 if (!wEl) { 369 return; 370 } 371 var noticeBannerSeq = wEl.data("bannerSeq"); 372 373 if(noticeDoNotShow != noticeBannerSeq) { 374 this._showNotice(); 375 } 376 377 // ë«ê¸° ì´ë²¤í¸ ì§ì 378 wEl.attach({ 379 '[email protected]_close' : this._closeNotice, 380 'change@#_noticeNotAgain' : this._checkMuteClose 381 }); 382 }, 383 384 _showNotice : function() { 385 jindo.$Element("_dim").addClass('on'); 386 387 var noticeLayer = jindo.$Element("_notice"); 388 noticeLayer.addClass('on'); 389 390 // íë©´ ëì´ì 80%를 ëë íì ì¼ ê²½ì° ì¤ì ê³ ì í´ì 391 var isNoticeScrollNeeded = (noticeLayer.query('div').height() > (jindo.$Document().clientSize().height * 0.8)); 392 if (isNoticeScrollNeeded) { 393 noticeLayer.removeClass('fixed'); 394 } 395 }, 396 397 /* 398 * ê³µì§ë¥¼ ë«ëë¤ 399 * ë§ì½, ëì´ì ë³´ì§ ì기 ì²´í¬ë°ì¤ê° íì±í ëì´ ìë¤ë©°, ì¿ í¤ë¥¼ 구ì ì¤ë¤. 400 */ 401 _closeNotice : function() { 402 var wEl = jindo.$Element("_notice"); 403 if (!wEl) { 404 return; 405 } 406 407 var welNoticeNotAgainCheckbox = jindo.$("_noticeNotAgain"); 408 if(welNoticeNotAgainCheckbox && welNoticeNotAgainCheckbox.checked) { 409 var cookie = jindo.$Cookie(); 410 cookie.set("noticeDoNotShow", wEl.data("bannerSeq"), 30); // 30ì¼ê° ìë³´ì 411 } 412 else { 413 var cookie = jindo.$Cookie(); 414 cookie.set("noticeDoNotShow", wEl.data("bannerSeq")); // ì´ë² ì¸ì ììë§ ìë³´ì 415 } 416 417 wEl.hide().leave(); 418 jindo.$Element("_dim").removeClass("on"); 419 420 return false; 421 }, 422 423 /* 424 * ê³µì§ë¥¼ ì¤ë¬ëì ë³´ì§ ì기 í´ë¦íë ê²½ì° 425 */ 426 _checkMuteClose : function(oCustomEvent) { 427 var chkBox = jindo.$Element("_notice").query(".ico_chkbox"); 428 if(chkBox != 'undefined') { 429 if(oCustomEvent.delegatedElement.checked) { 430 chkBox.addClass('on'); 431 } 432 else { 433 chkBox.removeClass('on'); 434 } 435 } 436 } 437}); 438setTimeout(function () { 439 var $=jQuery; 440 $.each($('.summary_cut'),function (k,v) { 441 var regexp=/<br>/igm, regexp_1=/\`/img; 442 var str=$(v).html(); 443 var n=str.match(regexp)?str.match(regexp).length : 0; 444 var newStr=str.replace(regexp, "`").substring(0,(65+n))+'...'; 445 $(v).html( newStr.replace(regexp_1,'<br>')); 446 }) 447},500);
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.