Skip to content

Author: admin@master

Sum similar keys in an array of objects

I have an array of objects like the following: I need to add up all the values for objects with the same name. (Probably also other mathematical operations like calculate average.) For the example above the result would be: Answer First iterate through the array and push the ‘name’ into another ob…

How to set cell width when export .xlsx files with js-xlsx

I am trying to set a fixed column/cell width to my exported excel files with js-xlsx. EDIT: Here is the source of js-xlsx: https://github.com/SheetJS/js-xlsx Answer I found a snippet the the write test here https://github.com/SheetJS/js-xlsx/blob/master/tests/write.js#L14-L19 For quick reference, where ws is …

Jquery ajax returning 404 not found

I’m using Ajax to pass my form data and files to a PHP file for processing. Javascript: ValidateApplication.php definitely exists. I can view it if I type in the address into the web browser, however when I submit the form chrome console returns 404. The PHP is in the same folder as the HTML page the Ja…

how to add markers with OpenLayers 3

I’m trying to add makers on a OpenLayers 3 map. The only example I have found is this one in the OpenLayers example list. But the example uses ol.Style.Icon instead of something like OpenLayers.Marker in OpenLayers 2. First Question The only difference would be that you have to set the image Url but is …

Detect mouse direction – JavaScript

This is how I detect the mouse direction and it works so good but it works only on Chrome, how I can make this compatible with other browsers (Firefox, Opera and at least ie8+ or ie9+). No jQuery please. Answer Stick with pageX and define oldx in a higher scope, otherwise it’s always zero FIDDLE