javascript
Getting Data from Multiple .then Statements in Javascript
I always have a hard time pulling data through multiple .then statements in javascript. This method works sufficiently well. Basically, define an array/object, and then as data is collected, add content to that array. All of the collected content should be available in the final .then statement. Something like this (all the data is collected […]
Read MoreGulp Minify Javascript
This will put a copy of the minified js file in the same folder in which it was found. It will require the following: useref, gulpif gulp.task(‘jsminify’, function() { return gulp.src([ “!node_modules/**/*.js”, “**/wp-content/themes/**/*.js”, “!**/**.min.js” ], { base: “./” }) .pipe(useref()) .pipe(gulpIf(‘*.js’, uglify())) .pipe(rename({suffix: ‘.min’})) .pipe(gulp.dest(‘./’)); });
Read MoreJavascript Capture Camera on Phone Doesn’t Work on iPhone
On an iphone you need to add a ‘playsinline’ parameter. I think it works by placing it either in the javascript, or as part of the HTML tag — I just added it to both to be safe, and it resolved the issue so I called it good. In javascript as part of the getUserMedia […]
Read MoreJavascript – Show or Hide an Element
Showing or hiding an element with javascript: (use “#” for elements by ID, or “.” for elements by class) document.querySelector(“#element”).style.display = ‘block’; document.querySelector(“#element”).style.display = ‘none’;
Read MorePHP JSON Returned As Object Instead of Array
I was returning, what I thought was an array from PHP, but it kept returning it as a json object, so I had something like: $listItem[0][0] = “Jan 1”; $listItem[0][1] = 100; $listItem[1][0] = “Jan 2”; $listItem[1][1] = 120; $listItem[2][0] = “Jan 2”; $listItem[2][1] = 120; …etc… This would return in javascript those an array, […]
Read MoreA Simple Slideout Menu
I just wanted an easy slideout menu. Click on a link, and the menu slides out from the left side of the screen. Click on the link again, or somewhere else on the page, and the menu slides back in. Here it is: HTML Code data-openwidth is the width in pixels of however wide you […]
Read MoreEnhancements for jPlayer Implementation
I love the jPlayer for easily being able to add modern mp3 support to web pages. I wanted a few additional features, so I created this additional script which adds a few updated features: Adding rewind/fast-forward support Ability to toggle the volume controls on and off Ability to specify the mp3 url by setting a […]
Read MorePreserving Click Events With jQuery UI
My click events weren\’t being preserved when using the jquery sortable functionality. After dragging a list item around, elements like my checkboxes would no longer work, and not just for the element that was being dragged, but for any of the checkboxes in the entire list. It took a bit of searching, but to get […]
Read MoreJavascript define a variable if it isn’t defined currently
It seems like this comes up quite a bit. This will create a new variable if the variable isn\’t currently defined: var myVariable = myVariable || “”; Or to define it as an array: var myVariable = myVariable || {};
Read MoreHandlebars Just Adds Bloat and Complication
I kind of like Handlebars for templating, but more and more, I think it’s just makes the codebase more bloated and complicated: My problems with handlebars: 1. I can’t just use my existing javascript code. For instance, I have an existing function to format a phone number, but to use this within a handlebars template, […]
Read More