Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file file.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221(* Js_of_ocaml library
* http://www.ocsigen.org/js_of_ocaml/
* Copyright (C) 2011 Pierre Chambart
* Laboratoire PPS - CNRS Université Paris Diderot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)openJsopenDomopen!Importclasstypeblob=objectmethodsize:intreadonly_propmethod_type:js_stringtreadonly_propmethodslice:int->int->blobtmethmethodslice_withContentType:int->int->js_stringt->blobtmethendletblob_constr=Unsafe.global##._Blobtype'amake_blob=?contentType:string->?endings:[`Transparent|`Native]->'a->blobtletrecfilter_mapf=function|[]->[]|v::q->(matchfvwith|None->filter_mapfq|Somev'->v'::filter_mapfq)letmake_blob_optionscontentTypeendings=letoptions=filter_map(fun(name,v)->matchvwith|None->None|Somev->Some(name,Unsafe.inject(stringv)))["type",contentType;("endings",matchendingswith|None->None|Some`Transparent->Some"transparent"|Some`Native->Some"native")]inmatchoptionswith|[]->undefined|l->Unsafe.obj(Array.of_listl)letblob_raw?contentType?endingsa=letoptions=make_blob_optionscontentTypeendingsinnew%jsblob_constr(arraya)optionsletblob_from_string?contentType?endingss=blob_raw?contentType?endings[|strings|]letblob_from_any?contentType?endingsl=letl=List.map(function|`arrayBuffera->Unsafe.injecta|`arrayBufferViewa->Unsafe.injecta|`strings->Unsafe.inject(strings)|`js_strings->Unsafe.injects|`blobb->Unsafe.injectb)linblob_raw?contentType?endings(Array.of_listl)classtypefile=objectinheritblobmethodname:js_stringtreadonly_propmethodlastModifiedDate:js_stringtreadonly_propend(* in firefox 3.0-3.5 file.name is not available, we use the nonstandard fileName instead *)classtypefile_name_only=objectmethodname:js_stringtoptdefreadonly_propmethodfileName:js_stringtoptdefreadonly_propendletfilenamefile=letfile:file_name_onlyt=Js.Unsafe.coercefileinmatchOptdef.to_optionfile##.namewith|None->(matchOptdef.to_optionfile##.fileNamewith|None->failwith"can't retrieve file name: not implemented"|Somename->name)|Somename->nametypefile_any=<>tletdoc_constr=Unsafe.global##._DocumentmoduleCoerceTo=structexternaljson:file_any->'aOpt.t="%identity"letdocument(e:file_any)=ifinstanceofedoc_constrthenJs.some(Unsafe.coercee:elementdocumentt)elseJs.nullletblob(e:file_any)=ifinstanceofeblob_constrthenJs.some(Unsafe.coercee:#blobt)elseJs.nullletstring(e:file_any)=iftypeofe==string"string"thenJs.some(Unsafe.coercee:js_stringt)elseJs.nullletarrayBuffer(e:file_any)=ifinstanceofeTyped_array.arrayBufferthenJs.some(Unsafe.coercee:Typed_array.arrayBuffert)elseJs.nullendclasstypefileList=objectinherit[file]Dom.nodeListendclasstypefileError=objectmethodcode:intreadonly_propendclasstype['a]progressEvent=objectinherit['a]eventmethodlengthComputable:booltreadonly_propmethodloaded:intreadonly_propmethodtotal:intreadonly_propendclasstypeprogressEventTarget=object('self)methodonloadstart:('selft,'selfprogressEventt)event_listenerwriteonly_propmethodonprogress:('selft,'selfprogressEventt)event_listenerwriteonly_propmethodonload:('selft,'selfprogressEventt)event_listenerwriteonly_propmethodonabort:('selft,'selfprogressEventt)event_listenerwriteonly_propmethodonerror:('selft,'selfprogressEventt)event_listenerwriteonly_propmethodonloadend:('selft,'selfprogressEventt)event_listenerwriteonly_propendtypereadyState=|EMPTY|LOADING|DONEclasstypefileReader=object('self)methodreadAsArrayBuffer:#blobt->unitmethmethodreadAsBinaryString:#blobt->unitmethmethodreadAsText:#blobt->unitmethmethodreadAsText_withEncoding:#blobt->js_stringt->unitmethmethodreadAsDataURL:#blobt->unitmethmethodabort:unitmethmethodreadyState:readyStatereadonly_propmethodresult:file_anyreadonly_propmethoderror:fileErrortreadonly_propinheritprogressEventTargetendmoduleReaderEvent=structtypetyp=fileReaderprogressEventtDom.Event.typletloadstart=Event.make"loadstart"letprogress=Event.make"progress"letabort=Event.make"abort"leterror=Event.make"error"letload=Event.make"load"letloadend=Event.make"loadend"endletfileReader:fileReadertconstr=Js.Unsafe.global##._FileReaderletaddEventListener=Dom.addEventListener