scloud Archives - SCLOUD http://soya.moe Featured Webservices Sun, 29 Jul 2018 02:06:19 +0000 ko-KR hourly 1 https://wordpress.org/?v=6.0.11 http://soya.moe/wp-content/uploads/2018/06/cropped-icon-1-32x32.png scloud Archives - SCLOUD http://soya.moe 32 32 Berryz Skin Project (Code:1) http://soya.moe/archives/854 http://soya.moe/archives/854#respond Sun, 29 Jul 2018 01:44:21 +0000 http://soya.moe/?p=854 Original Code (ES5) /* Hello World */ "use strict"; // 로그인/아웃 후 URL 정리 if(document.URL.toLowerCase().indexOf("?action=log") != -1) location.replace("./"); // 페이지...

The post Berryz Skin Project (Code:1) appeared first on SCLOUD.

]]>
Original Code (ES5)

/* Hello World */
"use strict";

// 로그인/아웃 후 URL 정리
if(document.URL.toLowerCase().indexOf("?action=log") != -1) location.replace("./");

// 페이지 선택 및 키보드 입력 제한
$("body *").attr("unselectable", "on");
$("html").on("keydown", function(event)
{
  var e  = event || window.event;
  var ek = event.keyCode || event.which;
  var whiteList = /^(27|33|34|35|36|37|38|40|39|100|102|116|122)$/;
  if(!whiteList.test(ek)) { return false };
});

 

Fixed Code (ES6)

"use strict";

if(document.URL.toLowerCase().indexOf("?action=log") != -1) {
  location.replace("./");
}

$("body *").attr("unselectale", "on");
$("html").on("keydown"), (event) => {
  let e = event || window.event;
  let eKey = event.keyCode || event.which;
  let whiteList = /^(27|33|34|35|36|37|38|40|39|100|102|116|122)$/;

  if(!whiteList.text(eKey)) {
    return false;
  }
}

 

Comment & Discussion

 

기존의 ES5 문법을 최대한 ES6 문법으로 적용합니다. jQeury문은 불가피하게 계속 사용하게 될 것 같습니다.

  • 로그인 후, URL (“?action=login” / “?action=logout”) 처리
  • 미디어 뷰어에 허용된 단축키 외, whitelist를 통해 이벤트 제어

The post Berryz Skin Project (Code:1) appeared first on SCLOUD.

]]>
http://soya.moe/archives/854/feed 0