Forum Discussion
SystemsBVI
8 years agoQrew Assistant Captain
So, ideally if i have service worker script for each table, we dont really need the old style IOL technique anymore. right ? All that could be done via IOL can be done from within the service worker scripts ?
- _anomDiebolt_8 years agoQrew EliteA Service Worker has the concept of a scope which restricts what URLs will execute the Service Worker. A Service Worker will only execute against URL paths that are at the same level or lower. Because of QuickBase's URL architecture you can register a Service Worker against the scope https://SUBDOMAIN.quickase.com/db (basically the entire account) or against the scope of a single dbid https://SUBDOMAIN.quickase.com/db/DBID.
Once registered the Service Worker will execute against any page in the defined scope (not just add, view, edit, report or grid pages). Every page including charts and administrative pages. So within your Service worker you have to put the appropriate logic to decode what particular code should be executed based on the current URL or query parameters or some other condition.. - SystemsBVI8 years agoQrew Assistant Captainright. which would mean that we don't need to use the old style IOL technique (of embedding a field into each form). right ?
- _anomDiebolt_8 years agoQrew EliteYes.
- SystemsBVI8 years agoQrew Assistant CaptainBut Dan, if we have the need to do DOM based adjustments (such as adding a new div element etc), for that we have to wait for the DOM to fully load and only then we can perform the necessary javascript based alterations. how will we do all that with a service worker ?
In the service worker, we are intercepting fetch requests which is way before the DOM is even loaded in the browser. right ? - _anomDiebolt_8 years agoQrew EliteService Workers do not have access to the DOM so you have to perform text level manipulation on the response. Perhaps the simpliest way of meeting your needs is to just appending a <script> tag to the end of the document:
UPDATED:
https://haversineconsulting.quickbase.com/db/bmtpmup9q?a=dbpage&pagename=sw6.js
Note the above code adds the <script> tag after the <body> - I know this might look malformed but the browser will figure it out. In a nutshell your Service Worker is just adding a custom <script> to the bottom over every page in scope.
If you really think you need DOM access you can import the library cherioe.js which is used in sw8.js:
https://haversineconsulting.quickbase.com/db/bmtpmup9q?a=dbpage&pagename=sw8.js
cheerio.js is a jQuery equivalent sometimes used with node.
Ask away - I doubt you could come up with a issue I have not already explored as I spent a ton of time on this two years ago and things have only gotten better in terms of browser support. - SystemsBVI8 years agoQrew Assistant CaptainDan, it appears both the links above are to the same page. Could you send me the one where you are adding the script tag ?
- SystemsBVI8 years agoQrew Assistant Captainok. no worries, looks like you updated it.