How to retrieve the window.localStorage.storedparameters? - html

I'm storing the values in window.localstorage.storedparameters. When i'm pulling back, i have some issues. So i would like to know where these data storing in the browser ? Is this storing data differ based on browsers ?

You can use the chrome browser.
Just go to developer tools by pressing F12. And then go to "Resources" tab and then go to "Local storage" option. And you will see all your local storage of browser there.

You can retrieve them programmatically using the window.localStorage object. To get a single item, either localStorage.nameOfItem or localStorage.getItem('nameOfItem') will work.

Related

Viewer quality settings (for one viewer on the page)

I have two viewers on the same page. And I want to set performance settings for only one viewer with following code:
this.viewer.setQualityLevel(false, false);
this.viewer.setGroundShadow(false);
this.viewer.setGroundReflection(false);
this.viewer.setProgressiveRendering(true);
BUT (!) settings are applied for both viewers for some reason. Is there any way to apply them only for one viewer on the page?
The viewer settings are kept in localStorage, so changing them using methods like viewer.setQualityLevel probably propagates the updates to other viewer instances as well. Let me discuss this behavior with the dev team as (I think) it could be considered a bug.
In the meantime, if you need to change settings for a single instance of the viewer, consider using "lower level" methods that don't use the local storage. For example, instead of viewer.setQualityLevel(useSAO, useFXAA) you could use viewer.impl.togglePostProcess(useSAO, useFXAA), and instead of viewer.setGroundShadow(bool) you could use viewer.impl.toggleGroundShadow(bool).
EDIT
Also try the Profile API to persist settings - you can get the current profile with:
viewer.profile
I was unable to replicate the issue unfortunately ... looking at your code did you assign two viewers to the same handle? can you post your code to initialize viewers? what version of viewer btw?

chrome behaviour when writing indexeddb. "data may be stale"

I have an app which downloads 1000 small images and writes them to indexedDb (using localForage). Upon the completion of the download, and the 1000 indexedDb setItems, I look in the devtools and the database is empty. I see the message "Data may be stale". Clicking "Refresh database" makes no difference. If I load a copy of the app in a second window, it sees an empty database. After a minute or so of reloading the 2nd window, the data appears.
Can anybody explain what I'm seeing, and if there any optimisations I can apply to have the data available more quickly?
It means that the indexedDb has detected an data that is not in syn with your present project. Also, be sure to include a break statement if your using a switch statement
Check out this link for more info
Data may be stale

open an URL upon my extension has been installed or uninstalled

As for open an URL upon my extension has been uninstalled, I found the easiest way to do is using chrome.runtime.setUninstallURL, (1) any other good ways?
As for open an URL upon my extension has been first time installed, I don't find something like chrome.runtime.setInstallURL, I implemented the feature with
chrome.runtime.onInstalled.addListener(function(details){
if (details.reason=="install"){chrome.tabs.create({ url: homePage});}
})
I saw AdBlock opens its options page upon first time installed, but it doesn't even used chrome.runtime.onInstalled, its source code is so much complicated , I cannot figure out how it implement the feature ,(2) how it do it ? any other ways to open an URL or its options page upon the extension has been first time installed?
(3) what are the common ways to do something when an extension has been installed or uninstalled?
SetUninstallURL seems to be specifically designed for your task, so it's certainly the right way.
Regarding the installation page, not sure how AdBlock does it, but if you have a persistent background page, one of the simpler ways would be to show the page on every launch if a certain localStorage key is not set.
// background.html startup, for example DOMContentLoaded handler
if ( !localStorage.getItem('intro_shown') ) {
localStorage.setItem('intro_shown', true);
showIntroPage();
}
Local storage of the extension's background page will be persistent, apart from several corner cases (incognito mode in FF, etc).
Upd by Makyen:
chrome.storage seems to be a much better option specifically designed for extension storage needs. It could also be automatically synced with Chrome sync (using chrome.storage.sync)

auto complete dropdown with huge and dynamic json file

i am looking for a solution for an auto-complete dropdown box which needs to load entries from a huge json (json file is also being updated / generated every second.)
I tried "typeahead.js" but by default it caches the json file in browser and was not able to display new entries added to json file.
is there a solution for an auto-complete text box which can load entries from the server as fast as possible ?
please suggest.
thanks
In your case, you can take advantage of Bloodhound, the typeahead.js suggestion engine. It provides two options. Prefetch and Remote.
In Prefetch, data is fetched and processed on initialization. If the browser supports local storage, the processed data will be cached there to prevent additional network requests on subsequent page loads.
In Remote, it will fetch data from remote source when ever you need it. But remember, in order to prevent an obscene number of requests being made to the remote endpoint, requests are rate-limited.
I think you should user Remote option in your situation.
Reference : Link
There are two ways which are mentioned in the documentation for typeahead.js
You can make the TTL value = 1 for prefetch ( this did;t work for me )
https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md
Or you can use clearPrefetchCache on click page load or click of a button .
category.clearPrefetchCache();

Why LocalStorage Stays Undeleted?

I know this was asked before but this is what I'm experiencing -
I'm working on a Chrome extension that needs to persist some data and I'm using localStorage for that . When I go to Settings->Tools->Clear Browsing Data and check everything (including 'since the beginning of time') , I would expect the localStorage of my background page to clear .
However everything stays put. The localstorage wasn't deleted!
It's not that I don't like that behavior , it's actually pretty great for my app , but is this normal ? Shouldn't localStorage delete once the user tries to clear everything , just like cookies should delete?
P.S
I found this nice blog that asks and tries to answer the same question :
http://sharonminsuk.com/blog/2011/03/21/clearing-cache-has-no-effect-on-html5-localstorage-or-sessionstorage/
Seems like the behavior changes from browser to browser . The behavior I talked about happens on Chrome 28.0.1500.71 m
This bug is not normal behavior. ( to answer your question )
I'm calling this a bug because someone might be using a computer at a library with some type of locally hosted application. There is a clear expectation that data is not retained in any way under a purge called "beginning of time"
Firefox purges localStorage data when you clear all browser data. It does this if the file is stored locally or hosted on a web domain.
Chrome purges localStorage data only if you code is hosted on a domain.
I made a video of this bug..
https://youtu.be/CgojKg4v7X0
Save this URL with HTML/JS a local drive to reproduce the bug...
https://html5dataprivacy.github.io/
steps:
- load a local web page containing javascript HTML5 storage code
interact with the page that stores your data in a way that changes the data
clear everything in history until the beginning of time
give the keyboard and mouse to another user in the library or public cafe...
result: That javascript storage is retained , another person can see your data...
expected result: The data is purged for the new person at the keyboard
notes: This bug does not exist on Firefox current version as of April 19th, 2017. Does not fail if chrome is working off a hosted domain
Workaround: After you clear things to the beginning of time you must open up the console and type "localStorage.clear()"
ps: please be kind. This is my first attempt to answer on StackOverFlow :)