[Pas2js] about API Offline javascript
Michael Van Canneyt
michael at freepascal.org
Fri Oct 18 23:26:10 CEST 2019
On Fri, 18 Oct 2019, Pedro Pablo Oviedo Vera wrote:
> I'm try learn about APIOffline and I need applicationCache method from
> window class....but it has not that....so I written something as a draft
> ....I'm not sure....:-(...:here I go:
>
> (* in order to give support to method window.applicationOffline *)
> TJSnsrefcnt = integer;
> TJSnsISupports = class;
> TJSnsIDOMOfflineResourcesList = class;
>
> TJSnsIDOMEventListenerEvent = TJSEvent;
>
> TJSnsIDOMEventListener = reference to function(aEvent:
> TJSnsIDOMEventListenerEvent):Boolean;
> TJSnsVoidIDOMEventHandler = reference to procedure(aUrl: TJSDOMString);
>
> TJSnsIDOMOfflineResourcesList = class external name
> 'nsIDOMOfflineResourcesList'(TJSnsISupport)
> private
> fmozItems : TJSnsIDOMOfflineResourseList; external name 'mozItems';
> fmozLength : longint; external name 'mozLength';
> fonerror : TJSnsIDOMEventListener; external name 'onerror';
> fonnoupdate : TJSnsIDOMEventListener; external name 'onnoupdate';
> fonprogress : TJSnsIDOMEventListener; external name 'onprogress';
> fonupdateready : TJSnsIDOMEventListener; external name 'onupdateready';
> foncached : TJSnsIDOMEventListener; external name 'oncached';
> fstatus : word; external name 'status';
> public
> const
> UNCACHED = 0;
> IDLE = 1;
> CHECKIG = 2;
> DOWNLOADING = 3;
> UPDATEREADY = 4;
> OBSOLETE = 5;
> public
> procedure addEventListener(aname : string; aListener :
> TJSnsIDOMEventHandler);
> procedure addEventListener(aname : string; aListener : TJSRawEventHandler);
>
> function mozHasItem(aUrl: TJSDOMString): Boolean;
> function mozItem(aIndex: longint): TJSDOMString;
> procedure mozaAdd(aUrl: TJSDOMString);
> procedure mozRemove(aUrl: TJSDOMString);
> procedure swapCache;
> procedure update;
>
> property mozItems : TJSnsIDOMOfflineResourseList read fmozItems;
> property mozLength : word read fmozLength ;
> property status : word read fstatus;
>
> end;
>
> TJSnsISupports = class external name 'nsISupport'
> public
> function AddRef: TJSnsrefcnt; ??
> procedure QueryInterface(aUuid: TJSnsIIDRef?; aParams: array of JSValue);
> function Release: TJSnsrefcnt;
> end;
>
> (* in window class .....*)
> function applicationCache: TJSnsIDOMOfflineResourceList;
>
> .......question is......is it ok?
It looks correct, but this API is deprecated.
You should use service workers instead.
Michael.
More information about the Pas2js
mailing list