mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Use JSPM for frontend JS modules
This commit is contained in:
parent
19dc2a91a1
commit
384e9adbd7
17 changed files with 5293 additions and 127 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,6 +1,9 @@
|
|||
# Ignore the SQLite database
|
||||
violence.db
|
||||
|
||||
# JSPM
|
||||
/static/jspm_packages/*/
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
|
|
|||
12
package.json
Normal file
12
package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"jspm": {
|
||||
"name": "Reach Out Open Data",
|
||||
"directories": {
|
||||
"baseURL": "static",
|
||||
"lib": "static/js"
|
||||
},
|
||||
"dependencies": {
|
||||
"jquery": "^2.1.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
17
static/config.js
Normal file
17
static/config.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
System.config({
|
||||
"baseURL": "/static/",
|
||||
"transpiler": "6to5",
|
||||
"paths": {
|
||||
"*": "*.js",
|
||||
"Reach Out Open Data/*": "js/*.js",
|
||||
"github:*": "jspm_packages/github/*.js",
|
||||
"npm:*": "jspm_packages/npm/*.js"
|
||||
}
|
||||
});
|
||||
|
||||
System.config({
|
||||
"map": {
|
||||
"jquery": "github:components/jquery@2.1.3"
|
||||
}
|
||||
});
|
||||
|
||||
18
static/js/colors.js
Normal file
18
static/js/colors.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
export default function mixColors (colors) {
|
||||
var rgb = colors.map(function (color) {
|
||||
var r = color.substr(1, 2)
|
||||
, g = color.substr(3, 2)
|
||||
, b = color.substr(5, 2);
|
||||
|
||||
return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)];
|
||||
});
|
||||
|
||||
var result = [ 0, 0, 0 ];
|
||||
for (var i = 0, l = rgb.length; i < l; i++) {
|
||||
result[0] += rgb[i][0] / l;
|
||||
result[1] += rgb[i][1] / l;
|
||||
result[2] += rgb[i][2] / l;
|
||||
}
|
||||
|
||||
return '#' + result[0].toString(16) + result[1].toString(16) + result[2].toString(16);
|
||||
}
|
||||
19
static/js/filter.js
Normal file
19
static/js/filter.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export default {
|
||||
|
||||
/**
|
||||
* Returns only the incidents which fall into the given categories
|
||||
* @param {Array[Object]} data The incidents to filter
|
||||
* @param {Array[String]} categories
|
||||
* @return {Arreay[Obect]}
|
||||
*/
|
||||
categories: function (data, categories) {
|
||||
return response.filter(function (incident) {
|
||||
for (var i = 0, l = incident.categories.length; i < l; i++)
|
||||
if (categories.indexOf(incident.categories[i]) !== -1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
(function () {
|
||||
"use strict";
|
||||
'use strict';
|
||||
import $ from 'jquery';
|
||||
import filter from './filter';
|
||||
import {mixColors} from './colors';
|
||||
|
||||
// http://www.colourlovers.com/palette/1811244/1001_Stories
|
||||
var colors = [ '#F8B195', '#F67280', '#C06C84', '#6C5B7B', '#355C7D' ];
|
||||
|
|
@ -42,7 +44,7 @@
|
|||
$(this).parent().toggleClass('active');
|
||||
|
||||
var categories = getActiveCategories();
|
||||
var incidents = filterByCategories(categories);
|
||||
var incidents = filter.categories(reponse, categories);
|
||||
displayMarkers(incidents);
|
||||
|
||||
e.preventDefault();
|
||||
|
|
@ -59,25 +61,6 @@
|
|||
return marker;
|
||||
}
|
||||
|
||||
function mixColors (colors) {
|
||||
var rgb = colors.map(function (color) {
|
||||
var r = color.substr(1, 2)
|
||||
, g = color.substr(3, 2)
|
||||
, b = color.substr(5, 2);
|
||||
|
||||
return [parseInt(r, 16), parseInt(g, 16), parseInt(b, 16)];
|
||||
});
|
||||
|
||||
var result = [ 0, 0, 0 ];
|
||||
for (var i = 0, l = rgb.length; i < l; i++) {
|
||||
result[0] += rgb[i][0] / l;
|
||||
result[1] += rgb[i][1] / l;
|
||||
result[2] += rgb[i][2] / l;
|
||||
}
|
||||
|
||||
return '#' + result[0].toString(16) + result[1].toString(16) + result[2].toString(16);
|
||||
}
|
||||
|
||||
function pickColor (incident) {
|
||||
var categories = ['racism', 'antisemitism', 'sexism', 'homophobia'].map(function (category, index) {
|
||||
if (incident.categories.indexOf(category) !== -1)
|
||||
|
|
@ -107,19 +90,3 @@
|
|||
markers.push(createMarker(incident).bindPopup(incident.description));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns only the incidents which fall into the given categories
|
||||
* @param {Array[String]} categories
|
||||
* @return {Arreay[Obect]}
|
||||
*/
|
||||
function filterByCategories (categories) {
|
||||
return response.filter(function (incident) {
|
||||
for (var i = 0, l = incident.categories.length; i < l; i++)
|
||||
if (categories.indexOf(incident.categories[i]) !== -1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
1
static/jspm_packages/.loaderversions
Normal file
1
static/jspm_packages/.loaderversions
Normal file
|
|
@ -0,0 +1 @@
|
|||
^0.13.0,^0.13.0,,~3.3.2
|
||||
2
static/jspm_packages/6to5-polyfill.js
Normal file
2
static/jspm_packages/6to5-polyfill.js
Normal file
File diff suppressed because one or more lines are too long
1
static/jspm_packages/6to5-runtime.js
Normal file
1
static/jspm_packages/6to5-runtime.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
(function(global){var to5Runtime=global.to5Runtime={};to5Runtime.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};to5Runtime.defaults=function(obj,defaults){for(var key in defaults){if(obj[key]===undefined){obj[key]=defaults[key]}}return obj};to5Runtime.prototypeProperties=function(child,staticProps,instanceProps){if(staticProps)Object.defineProperties(child,staticProps);if(instanceProps)Object.defineProperties(child.prototype,instanceProps)};to5Runtime.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};to5Runtime.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};to5Runtime.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};to5Runtime.interopRequire=function(obj){return obj&&obj.__esModule?obj.default:obj};to5Runtime.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};to5Runtime.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else{var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}};to5Runtime.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};to5Runtime.hasOwn=Object.prototype.hasOwnProperty;to5Runtime.slice=Array.prototype.slice;to5Runtime.bind=Function.prototype.bind;to5Runtime.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};to5Runtime.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};to5Runtime.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};to5Runtime._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};to5Runtime._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};to5Runtime.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};to5Runtime.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return}else{return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){desc.value=value;return}else{var setter=desc.set;if(setter===undefined){return}return setter.call(receiver,value)}};to5Runtime.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};to5Runtime.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")}})(typeof global==="undefined"?self:global);
|
||||
23
static/jspm_packages/6to5.js
Normal file
23
static/jspm_packages/6to5.js
Normal file
File diff suppressed because one or more lines are too long
8
static/jspm_packages/es6-module-loader.js
Normal file
8
static/jspm_packages/es6-module-loader.js
Normal file
File diff suppressed because one or more lines are too long
1
static/jspm_packages/es6-module-loader.js.map
Normal file
1
static/jspm_packages/es6-module-loader.js.map
Normal file
File diff suppressed because one or more lines are too long
2776
static/jspm_packages/es6-module-loader.src.js
Normal file
2776
static/jspm_packages/es6-module-loader.src.js
Normal file
File diff suppressed because it is too large
Load diff
2
static/jspm_packages/system.js
Normal file
2
static/jspm_packages/system.js
Normal file
File diff suppressed because one or more lines are too long
1
static/jspm_packages/system.js.map
Normal file
1
static/jspm_packages/system.js.map
Normal file
File diff suppressed because one or more lines are too long
2313
static/jspm_packages/system.src.js
Normal file
2313
static/jspm_packages/system.src.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -30,8 +30,10 @@
|
|||
<div id="map"></div>
|
||||
|
||||
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
||||
<script src="http://maps.stamen.com/js/tile.stamen.js?v1.3.0"></script>
|
||||
<script src="/static/js/main.js"></script>
|
||||
|
||||
<script src="/static/jspm_packages/system.js"></script>
|
||||
<script src="/static/config.js"></script>
|
||||
<script>System.import('js/main');</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue