How can I make a really long string using IndexedDB without crashing the browser?

Storing a Blob will use a lot less space and resources as there is no longer a need for conversion to base64. You can even store “text/plain” objects as blobs: var blob = new Blob([‘blob object’], {type: ‘text/plain’}); var store = db.transaction([‘entries’], ‘readwrite’).objectStore(‘entries’); // Store the object var req = store.put(blob, ‘blob’); req.onerror = function(e) … Read more

CORS cookie credentials from mobile WebView loaded locally with file://

I realize this question is old, but I figured I’d throw in on it anyhow. In the case of CORS requests, the browser preflights them. What this means is – in spite of whatever $.ajax() method you are using, an OPTIONS request is sent to the server. What this preflighted OPTIONS request is actually doing … Read more

Failed to execute ‘requestFullScreen’ on ‘Element’: API can only be initiated by a user gesture [duplicate]

Any javascript api is intentionally made this way I guess. Just imagine if you go to a website and it automatically turns on in fullscreen without you doing anything at all. You would be exposed to a whole world of annoying popups and other stuff you dint even intend to open. So any such script … Read more

Is there a way in javascript to detect if the unload event is caused via a refresh, the back button, or closing the browser? [duplicate]

No, and if there was it would be browser dependent. What kind of code are you trying to run when the user closes the page? Is it to logout the user? Then the user would not be logged out if the browser crashes or the network connection breaks (and probably not if the computer goes … Read more

managing document.ready event(s) on a large-scale website

This is what i have done in my rails mvc project with heavy javascript, i have created a separate namespace for the controllers in js which resembles the rails controller class BusinessController def new end def index end end and Var Business = { init : function(action) { //code common to the Business module //even … Read more

Cast plain object to mongoose document

Posting my own answer so this doesn’t stay open: Version 4 models (stable released on 2015-03-25) now exposes a hydrate() method. None of the fields will be marked as dirty initially, meaning a call to save() will do nothing until a field is mutated. https://github.com/LearnBoost/mongoose/blob/41ea6010c4a84716aec7a5798c7c35ef21aa294f/lib/model.js#L1639-1657 It is very important to note that this is intended … Read more

rails best practices where to place unobtrusive javascript

I do not think there is one best practice, but I’ll let you know what I do. I have a series of js files each for with their own purpose in the public/javascripts/ directory. Some examples could be utility.js chat.js shopping_basket.js and so on. I use asset packager and define one big fat collection for … Read more