'Programming/javascript & HTML'에 해당되는 글 141건

  1. 2018.10.26 js date time to epoch
  2. 2018.10.25 canvas to blob 2
  3. 2018.10.24 자바스크립트 base64 인코딩, 디코딩
  4. 2018.10.24 formdata dump
  5. 2018.10.23 js toHexString()
  6. 2018.10.18 jsmpeg div로 사용시 옵션
  7. 2018.10.16 js setinterval
  8. 2018.10.16 ajax each
  9. 2018.10.15 canvas clearRect
  10. 2018.10.15 console.log 에 객체 배열 출력하기

자바 스크립트에서 Date 객체를 이용하여

시간 정보를 epoch로 변환하는 방법


new Date(2010, 6, 26).getTime() / 1000

[링크 : https://stackoverflow.com/questions/3367415/get-epoch-for-a-specific-date-using-javascript]


+

2018.10.29


msec 단위이기 때문에 1000으로 나누어 주어야 할 듯

1970 년 1 월 1 일 00:00:00 UTC와 주어진 날짜 사이의 경과 시간 (밀리 초)을 나타내는 숫자입니다. 

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime]

'Programming > javascript & HTML' 카테고리의 다른 글

js split \n ' '  (0) 2018.10.26
curl text/plain  (0) 2018.10.26
canvas to blob  (2) 2018.10.25
자바스크립트 base64 인코딩, 디코딩  (0) 2018.10.24
formdata dump  (0) 2018.10.24
Posted by 구차니

캔버스 데이터를 blob으로 받아서 처리하는데..

머.. 결론만 말하자면 브라우저에서 파일로 받아서(input type=file)

처리하는 것 처럼 줄 방법은 없는건 매한가지 이다... 인가?


var canvas = document.getElementById('canvas');


canvas.toBlob(function(blob) {

  var newImg = document.createElement('img'),

      url = URL.createObjectURL(blob);


  newImg.onload = function() {

    // no longer need to read the blob so it's revoked

    URL.revokeObjectURL(url);

  };


  newImg.src = url;

  document.body.appendChild(newImg);

}); 

[링크 : https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob]

'Programming > javascript & HTML' 카테고리의 다른 글

curl text/plain  (0) 2018.10.26
js date time to epoch  (0) 2018.10.26
자바스크립트 base64 인코딩, 디코딩  (0) 2018.10.24
formdata dump  (0) 2018.10.24
js toHexString()  (0) 2018.10.23
Posted by 구차니

canvas에서 영상을 dataURL로 받으면 base64로 인코딩 되어서 해결책 찾는중..


window.atob (decoding)

window.btoa (encoding)

[링크 : http://1004lucifer.blogspot.com/2016/01/javascript-base64.html]

'Programming > javascript & HTML' 카테고리의 다른 글

js date time to epoch  (0) 2018.10.26
canvas to blob  (2) 2018.10.25
formdata dump  (0) 2018.10.24
js toHexString()  (0) 2018.10.23
jsmpeg div로 사용시 옵션  (0) 2018.10.18
Posted by 구차니

ajax로 formdata 보내기

[링크 : https://www.mkyong.com/jquery/jquery-ajax-submit-a-multipart-form/]



생성하기

[링크 : https://developer.mozilla.org/ko/docs/Web/API/FormData/FormData]


보는거 무지 복잡하네..

var formData = new FormData();

formData.append('key1', 'value1');

formData.append('key2', 'value2');


// Display the key/value pairs

for (var pair of formData.entries()) {

    console.log(pair[0]+ ', ' + pair[1]); 

[링크 : https://stackoverflow.com/questions/17066875/how-to-inspect-formdata]


+

var formData = new FormData();


formData.append('items', new Blob([JSON.stringify({

    name: "Book",

    quantity: "12"

})], {

    type: "application/json"

})); 

[링크 : https://stackoverflow.com/...multipart-form-data-with-a-different-content-type-on-each-parts-with-j]


+

var st = imagepath.replace(data:image/png or jpg; base64"/""); 

[링크 : https://stackoverflow.com/questions/22172604/convert-image-url-to-base64]

'Programming > javascript & HTML' 카테고리의 다른 글

canvas to blob  (2) 2018.10.25
자바스크립트 base64 인코딩, 디코딩  (0) 2018.10.24
js toHexString()  (0) 2018.10.23
jsmpeg div로 사용시 옵션  (0) 2018.10.18
js setinterval  (0) 2018.10.16
Posted by 구차니

원래 이런건 지원안해서 직접 만들어야 하나보네..


function toHexString(byteArray) {

  return Array.from(byteArray, function(byte) {

    return ('0' + (byte & 0xFF).toString(16)).slice(-2);

  }).join('')

[링크 : https://stackoverflow.com/questions/34309988/byte-array-to-hex-string-conversion-in-javascript]

'Programming > javascript & HTML' 카테고리의 다른 글

자바스크립트 base64 인코딩, 디코딩  (0) 2018.10.24
formdata dump  (0) 2018.10.24
jsmpeg div로 사용시 옵션  (0) 2018.10.18
js setinterval  (0) 2018.10.16
ajax each  (0) 2018.10.16
Posted by 구차니

내용은 있었는데 이해를 못했거늘.. 오늘 해보니 되긴하네 췟 -_-

아래와 같은 식으로 'data-'를 접두로 붙이고

문장하나하나를 전부 - 로 토막내주면 된다.

그런 이유로 disableGl은 data-disable-Gl로 변환이 되어 설정하면 된다

<div class="jsmpeg" data-url="ws://localhost:6424" data-disable-gl="true"> 


Note that camelCased options have to be hyphenated when used as data attributes. E.g. decodeFirstFrame: true becomes data-decode-first-frame="true" for the HTML element. 

[링크 : https://github.com/phoboslab/jsmpeg]

'Programming > javascript & HTML' 카테고리의 다른 글

formdata dump  (0) 2018.10.24
js toHexString()  (0) 2018.10.23
js setinterval  (0) 2018.10.16
ajax each  (0) 2018.10.16
canvas clearRect  (0) 2018.10.15
Posted by 구차니

원래 용도는 아니지만 쓰레드나 백그라운드 비슷하게 작동시킬수 있을 듯

(동기 작업으로 해놓고 그걸 백그라운드로 돌린다던가)


[링크 : https://stackoverflow.com/questions/4930439/call-jquery-ajax-request-each-x-minutes]

'Programming > javascript & HTML' 카테고리의 다른 글

js toHexString()  (0) 2018.10.23
jsmpeg div로 사용시 옵션  (0) 2018.10.18
ajax each  (0) 2018.10.16
canvas clearRect  (0) 2018.10.15
console.log 에 객체 배열 출력하기  (0) 2018.10.15
Posted by 구차니

foreach가 비동기인진 모르겠지만

each는 일단 동기로 작동한다고 한다.


[링크 : https://stackoverflow.com/.../jquery-ajax-each-callback-next-each-firing-before-ajax-completed]

[링크 : https://stackoverflow.com/.../is-jquery-each-function-synchronous]

'Programming > javascript & HTML' 카테고리의 다른 글

jsmpeg div로 사용시 옵션  (0) 2018.10.18
js setinterval  (0) 2018.10.16
canvas clearRect  (0) 2018.10.15
console.log 에 객체 배열 출력하기  (0) 2018.10.15
ajax를 동기로(?)  (0) 2018.10.15
Posted by 구차니

canvas를 지워주는 녀석

근데.. 투명 이미지의 경우 이상하게 작동하는 것 같으니

투명 이미지를 위해서 이미지 복사시에는 반드시

clearRect() 해주고

drawImage()를 해주어야 한다.


[링크 : https://stackoverflow.com/questions/2142535/how-to-clear-the-canvas-for-redrawing]

'Programming > javascript & HTML' 카테고리의 다른 글

js setinterval  (0) 2018.10.16
ajax each  (0) 2018.10.16
console.log 에 객체 배열 출력하기  (0) 2018.10.15
ajax를 동기로(?)  (0) 2018.10.15
로컬파일 접근...이 안되는거니까..  (0) 2018.10.12
Posted by 구차니

우회법으로

JSON.stringify() 를 통해 문자열로 변환하고 출력하면 될 듯.


[링크 : https://stackoverflow.com/questions/7912576/console-log-showing-contents-of-array-object]

[링크 : https://www.w3schools.com/js/js_json_stringify.asp]

Posted by 구차니