#Geometry of 2D & 3D figures with
##2D figures
| Area | Circumference |
|---|
#Geometry of 2D & 3D figures with
##2D figures
| Area | Circumference |
|---|
| //addEventListener polyfill 1.0 / Eirik Backer / MIT Licence | |
| (function(win, doc){ | |
| if(win.addEventListener)return; //No need to polyfill | |
| function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}} | |
| function addEvent(on, fn, self){ | |
| return (self = this).attachEvent('on' + on, function(e){ | |
| e = e || win.event; | |
| e.preventDefault = e.preventDefault || function(){e.returnValue = false} | |
| e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true} |
| { | |
| "content": "Wierd Char --> 
 <--" | |
| } |
| function arrayTo2d(items, width) { | |
| var rows = []; | |
| var lastRow; | |
| items.forEach(function(item, i) { | |
| // add another row when cell index is divisble by width | |
| if ((i) % width === 0) { | |
| lastRow = []; | |
| rows.push(lastRow); | |
| } |
| // ajax.js | |
| // ajax GET and POST for JSON using a fetch() wrapper | |
| // | |
| // By Daniel Hug: https://gist.github.com/Daniel-Hug/dd703e0805364a70ba11 | |
| // MIT license: http://hug.mit-license.org/ | |
| // | |
| // use: | |
| // var request = ajax.get({ | |
| // url: 'http://example.com/people.json', | |
| // success: cb, |
| // removes all of an element's childNodes | |
| function removeChilds(el) { | |
| var last; | |
| while ((last = el.lastChild)) el.removeChild(last); | |
| } |
| // remove collection b's items from collection a | |
| function exclude(a, b) { | |
| var arr = []; | |
| a = arr.slice.call(a); | |
| for (var i = 0, l = a.length; i < l; i++) { | |
| if (arr.indexOf.call(b, a[i]) >= 0) arr.splice.call(a, i, 1); | |
| } | |
| return a; | |
| } |
| // Loop through collections: | |
| function each(arr, fn, scope) { | |
| for (var i = 0, l = arr.length; i < l; i++) { | |
| fn.call(scope, arr[i], i, arr); | |
| } | |
| } | |
| function map(arr, fn, scope) { | |
| var l = arr.length, newArr = []; | |
| for (var i = 0; i < l; i++) { | |
| newArr[i] = fn.call(scope, arr[i], i, arr); |
| // localStorage + JSON wrapper: | |
| var storage = { | |
| get: function(prop) { | |
| return JSON.parse(localStorage.getItem(prop)); | |
| }, | |
| set: function(prop, val) { | |
| localStorage.setItem(prop, JSON.stringify(val)); | |
| }, | |
| has: function(prop) { | |
| return localStorage.hasOwnProperty(prop); |
| // convert 2D array to array of objects | |
| function tableToArray(columnNames, columns) { | |
| var outputArray = []; | |
| // loop through array of columns | |
| columns.forEach(function(col, colI) { | |
| var columnName = columnNames[colI]; | |
| // loop through cells in each column array | |
| col.forEach(function(cellVal, cellI) { |