Skip to content

Instantly share code, notes, and snippets.

@Montoya
Montoya / getElementsByClassNamePolyfill.js
Last active November 1, 2018 00:42 — forked from stereobooster/function.js
getElementsByClassName polyfill
/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, curly:true, browser:true, indent:2, maxerr:50 */
(function (document) {
"use strict";
if (!document.getElementsByClassName) {
document.getElementsByClassName = function (match) {
var result = [],
elements = document.body.getElementsByTagName('*'),
i, elem;
match = " " + match + " ";
for (i = 0; i < elements.length; i++) {
@Montoya
Montoya / fileStorage.js
Last active February 2, 2020 20:26 — forked from rally25rs/fileStorage.coffee
Cordova File API Wrapper
/* modified from https://codingwithspike.wordpress.com/2014/12/29/using-deferreds-with-the-cordova-file-api/ */
/* requires rsvp.js */
/* tested and working in iOS and Android on latest Cordova (5.2.0) and File plugin (4.0.0) */
/* uses dataDirectory which is not synced to iCloud on iOS. You can replace each reference to syncedDataDirectory, but then you will need to set cordova.file.syncedDataDirectory = cordova.file.dataDirectory on Android to maintain compatibility */
window.fileStorage = {
write: function (name, data) {
var name_arr = name.split('/');
var name_index = 0;