SlideShare a Scribd company logo
1 of 20
File API in Firefox3.6
  with HTML5 D&D

       tnantoka
• tnantoka
•            SE

• JavaScript
• blog.bornneet.com
W3C File API
File API


• <input type="file" /> JavaScript
• HTML5#Drag and Drop
•
    html5.bornneet.com/file/multi/
• dataURI
    html5.bornneet.com/file/datauri/
Web UI
※
File




<textarea>
$(function() {
 .....

      <textarea>
html
1    <!DOCTYPE html>
2    <html lang="ja">
3    <head>
4      <meta charset="UTF-8" />
5      <title>Textarea D&D</title>
6      <link rel="stylesheet" href="style.css" />
7      <script src="script.js"></script>
8    </head>
9    <body>
10   <p>
11     <textarea id="dropbox"></textarea>
12   </p>
13   </body>
14   </html>
css
1   @charset "UTF-8";

2   p {
3     text-align: center;
4   }
5   textarea {
6   
   width: 500px;
7   
   height: 300px;
8   }

    /* dragover             */
9 .over {
10   border: 3px solid orange;
11 }
dragover
1   var db = document.getElementById('dropbox');

2   db.addEventListener('dragover', function(e){

      //
3     e.preventDefault();

      //
4     db.className = 'over';

5   }, true);
dragleave
1   db.addEventListener('dragleave', function(e){

      //
2     db.className = '';

3   }, true);
drop
1   db.addEventListener('drop', function(e) {

     // e.stopPropagation();
2     e.preventDefault();

     //
3     var file = e.dataTransfer.files[0];
4     var reader = new FileReader();
5     reader.onloadend = function() {
6        db.value = reader.result;
7     };
8     reader.readAsText(file);
9   }, true);
html5.bornneet.com/file/textarea/
Mozilla
Jetpacking
tnantoka.net/jetpack/dropta/
•   ON/OFF
    -          ^^

•
    - getEventListener

•
    - Web Workers

•   about:jetpack#Develop Bespin
    -
•
• W3C FileAPI in Firefox 3.6
  http://hacks.mozilla.org/2009/12/w3c-
  fileapi-in-firefox-3-6/

More Related Content

What's hot

JS programowanie obiektowe
JS  programowanie obiektoweJS  programowanie obiektowe
JS programowanie obiektowePiotr Czajkowski
 
Javascript per applicazioni complesse - Lo Stretto digitale
Javascript per applicazioni complesse - Lo Stretto digitaleJavascript per applicazioni complesse - Lo Stretto digitale
Javascript per applicazioni complesse - Lo Stretto digitaleGiuseppe Pizzimenti
 
Pertemuan 8 - Report Tabel
Pertemuan 8 - Report TabelPertemuan 8 - Report Tabel
Pertemuan 8 - Report TabelAdi Triyatmoko
 
Java Script - Object-Oriented Programming
Java Script - Object-Oriented ProgrammingJava Script - Object-Oriented Programming
Java Script - Object-Oriented Programmingintive
 
Максим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru Group
Максим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru GroupМаксим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru Group
Максим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru GroupMail.ru Group
 
Func
FuncFunc
FuncHvqr
 

What's hot (9)

JS programowanie obiektowe
JS  programowanie obiektoweJS  programowanie obiektowe
JS programowanie obiektowe
 
Ver
VerVer
Ver
 
Seleccion
SeleccionSeleccion
Seleccion
 
Javascript per applicazioni complesse - Lo Stretto digitale
Javascript per applicazioni complesse - Lo Stretto digitaleJavascript per applicazioni complesse - Lo Stretto digitale
Javascript per applicazioni complesse - Lo Stretto digitale
 
Ebookl membuat login php7+mysqli
Ebookl membuat login php7+mysqliEbookl membuat login php7+mysqli
Ebookl membuat login php7+mysqli
 
Pertemuan 8 - Report Tabel
Pertemuan 8 - Report TabelPertemuan 8 - Report Tabel
Pertemuan 8 - Report Tabel
 
Java Script - Object-Oriented Programming
Java Script - Object-Oriented ProgrammingJava Script - Object-Oriented Programming
Java Script - Object-Oriented Programming
 
Максим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru Group
Максим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru GroupМаксим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru Group
Максим cdump Андреев, WPAD, Security Meetup 9 апреля, Mail.Ru Group
 
Func
FuncFunc
Func
 

Viewers also liked

JavaScriptの動かし方
JavaScriptの動かし方JavaScriptの動かし方
JavaScriptの動かし方Tatsuya Tobioka
 
第0回ワススタ!! #wasbookを読もう
第0回ワススタ!! #wasbookを読もう第0回ワススタ!! #wasbookを読もう
第0回ワススタ!! #wasbookを読もうTatsuya Tobioka
 
Kin Long Company Profile
Kin Long Company ProfileKin Long Company Profile
Kin Long Company Profilextpf5240
 
RubyMotionを1週間 触ってみた印象
RubyMotionを1週間 触ってみた印象RubyMotionを1週間 触ってみた印象
RubyMotionを1週間 触ってみた印象Tatsuya Tobioka
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Tatsuya Tobioka
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging ChallengesAaron Irizarry
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Viewers also liked (9)

JavaScriptの動かし方
JavaScriptの動かし方JavaScriptの動かし方
JavaScriptの動かし方
 
第0回ワススタ!! #wasbookを読もう
第0回ワススタ!! #wasbookを読もう第0回ワススタ!! #wasbookを読もう
第0回ワススタ!! #wasbookを読もう
 
Kin Long Company Profile
Kin Long Company ProfileKin Long Company Profile
Kin Long Company Profile
 
RubyMotionを1週間 触ってみた印象
RubyMotionを1週間 触ってみた印象RubyMotionを1週間 触ってみた印象
RubyMotionを1週間 触ってみた印象
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。
 
Designing Teams for Emerging Challenges
Designing Teams for Emerging ChallengesDesigning Teams for Emerging Challenges
Designing Teams for Emerging Challenges
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

File API in Firefox3.6

  • 1. File API in Firefox3.6 with HTML5 D&D tnantoka
  • 2. • tnantoka • SE • JavaScript • blog.bornneet.com
  • 4. File API • <input type="file" /> JavaScript • HTML5#Drag and Drop
  • 5. html5.bornneet.com/file/multi/ • dataURI html5.bornneet.com/file/datauri/
  • 7.
  • 9. $(function() { ..... <textarea>
  • 10. html 1 <!DOCTYPE html> 2 <html lang="ja"> 3 <head> 4 <meta charset="UTF-8" /> 5 <title>Textarea D&D</title> 6 <link rel="stylesheet" href="style.css" /> 7 <script src="script.js"></script> 8 </head> 9 <body> 10 <p> 11 <textarea id="dropbox"></textarea> 12 </p> 13 </body> 14 </html>
  • 11. css 1 @charset "UTF-8"; 2 p { 3 text-align: center; 4 } 5 textarea { 6 width: 500px; 7 height: 300px; 8 } /* dragover */ 9 .over { 10 border: 3px solid orange; 11 }
  • 12. dragover 1 var db = document.getElementById('dropbox'); 2 db.addEventListener('dragover', function(e){ // 3 e.preventDefault(); // 4 db.className = 'over'; 5 }, true);
  • 13. dragleave 1 db.addEventListener('dragleave', function(e){ // 2 db.className = ''; 3 }, true);
  • 14. drop 1 db.addEventListener('drop', function(e) { // e.stopPropagation(); 2 e.preventDefault(); // 3 var file = e.dataTransfer.files[0]; 4 var reader = new FileReader(); 5 reader.onloadend = function() { 6 db.value = reader.result; 7 }; 8 reader.readAsText(file); 9 }, true);
  • 18. ON/OFF - ^^ • - getEventListener • - Web Workers • about:jetpack#Develop Bespin -
  • 19.
  • 20. • • W3C FileAPI in Firefox 3.6 http://hacks.mozilla.org/2009/12/w3c- fileapi-in-firefox-3-6/