line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
## HTML Object - ~/lib/HTML/Object/DOM/FileList.pm |
3
|
|
|
|
|
|
|
## Version v0.2.0 |
4
|
|
|
|
|
|
|
## Copyright(c) 2021 DEGUEST Pte. Ltd. |
5
|
|
|
|
|
|
|
## Author: Jacques Deguest <jack@deguest.jp> |
6
|
|
|
|
|
|
|
## Created 2021/12/25 |
7
|
|
|
|
|
|
|
## Modified 2022/09/18 |
8
|
|
|
|
|
|
|
## All rights reserved |
9
|
|
|
|
|
|
|
## |
10
|
|
|
|
|
|
|
## |
11
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or modify it |
12
|
|
|
|
|
|
|
## under the same terms as Perl itself. |
13
|
|
|
|
|
|
|
##---------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
package HTML::Object::DOM::FileList; |
15
|
|
|
|
|
|
|
BEGIN |
16
|
|
|
|
|
|
|
{ |
17
|
1
|
|
|
1
|
|
1383
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
18
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
19
|
1
|
|
|
1
|
|
5
|
use parent qw( Module::Generic::Array ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
20
|
1
|
|
|
1
|
|
100
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
71
|
|
21
|
1
|
|
|
1
|
|
23
|
our $VERSION = 'v0.2.0'; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
29
|
|
25
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
1
|
|
sub item { return( shift->index( @_ ) ); } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
1; |
30
|
|
|
|
|
|
|
# NOTE: POD |
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=encoding utf-8 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
HTML::Object::DOM::FileList - HTML Object DOM FileList Class |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use HTML::Object::DOM::FileList; |
42
|
|
|
|
|
|
|
my $list = HTML::Object::DOM::FileList->new || |
43
|
|
|
|
|
|
|
die( HTML::Object::DOM::FileList->error, "\n" ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
<input id="fileItem" type="file" /> |
46
|
|
|
|
|
|
|
my $file = $doc->getElementById('fileItem')->files->[0]; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 VERSION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
v0.2.0 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
An object of this type is returned by the L<HTML::Object::DOM::Element::Input/files> property of the HTML C<<input>> element; this lets you access a list of files you would have set or added, removed, etc.. It inherits from L<Module::Generic::Array> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Normally, under JavaScript, those files are selected with the C<<input type="file" />> element. It is also used on the web for a list of files dropped into web content when using the drag and drop API; see the L<DataTransfer object on Mozilla|https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer> for details on this usage. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 PROPERTIES |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 length |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Read-only. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns the number of files in the list. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 item |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns a L<HTML::Object::DOM::File> object representing the file at the specified index in the file list. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Example: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# fileInput is an HTML input element: <input type="file" id="myfileinput" multiple /> |
75
|
|
|
|
|
|
|
my $fileInput = $doc->getElementById("myfileinput"); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# files is a FileList object (similar to NodeList) |
78
|
|
|
|
|
|
|
my $files = $fileInput->files; |
79
|
|
|
|
|
|
|
my $file; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# loop through files |
82
|
|
|
|
|
|
|
for( my $i = 0; $i < $files->length; $i++ ) |
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
# get item |
85
|
|
|
|
|
|
|
$file = $files->item($i); |
86
|
|
|
|
|
|
|
# or |
87
|
|
|
|
|
|
|
$file = $files->[$i]; |
88
|
|
|
|
|
|
|
say( $file->name ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SEE ALSO |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/API/FileList> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Copyright(c) 2021 DEGUEST Pte. Ltd. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
All rights reserved |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |