Angular2 app that saves data on an any in-browser database (thanks to PouchDb) and syncs it with a remote couchDb as soon as the connection is restored
npm install pouchdb --save
npm install @types/pouchdb --save --save-exact
(function(window, angular) { | |
'use strict'; | |
/** | |
* | |
* The `ariaLive` module provides a service for running aria live announcements. | |
* It creates an empty paragraph only "visible" to screen readers. | |
* | |
*/ |
(function(window, angular) { | |
'use strict'; | |
/** | |
* Simple list filter without "bothering" angular $scope | |
* I used OLOO as a OO Js style (instead of the classic prototypal inheritance) | |
*/ | |
var listFilter = angular.module('listFilter', []); |
(function(Observable, eleId, dom) { | |
var ball = dom.getElementById(eleId), | |
mouseOverBall = Observable.fromEvent(ball, 'mousedown'), | |
mouseUp = Observable.fromEvent(dom, "mouseup"), | |
dragBall = Observable.fromEvent(dom, 'mousemove'), | |
resize = Observable.fromEvent(window, 'resize'), | |
stylesheet = dom.styleSheets[0], | |
baseY = ((css) => { | |
try { |
(function(window, angular) { | |
'use strict'; | |
/**** | |
* Simple composition factory for Angular 1x | |
*****/ | |
var composer = angular.module('composerModule', []); | |
composer.factory('Composer', Composer); |
module.exports = function(grunt) { | |
var config = { | |
watch: {}, | |
server: {} | |
}; | |
grunt.initConfig(config); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadTasks('tasks'); | |
grunt.registerTask('default', ['server', 'watch']); | |
}; |
import { Directive, HostListener, ElementRef, Output, Input, EventEmitter, AfterContentInit } from '@angular/core'; | |
import { Observable } from 'rxjs/Rx' | |
import 'rxjs/add/observable/fromEvent'; | |
import 'rxjs/add/operator/map'; | |
import 'rxjs/add/operator/filter'; | |
import 'rxjs/add/operator/takeUntil'; | |
import 'rxjs/add/operator/concatMap'; | |
import { Subject } from 'rxjs/Subject'; | |
@Directive({ |
/* | |
Crawl a directory and return a list containing all subdirectories paths | |
*/ | |
const fs = require('fs-extra'); | |
const { promisify } = require('util'); | |
const { resolve } = require('path'); | |
const EventEmitter = require('events'); | |
const isDir = folder => fs.lstatSync( folder ).isDirectory(); |
var test = require('tape'); | |
const double = n => n*2; | |
const addOne = n => n+1; | |
const excludeTen = n => n !== 10; | |
const listPush = (list, v) => { | |
list.push(v); | |
return list; | |
} | |
const mapReducer = mapFn => |
The app works in older browsers thank to the web component polyfill loader that dynamically loads the necessary polyfills using features detection.
webpack.config.js builds the app using a custom template (app.template.html) where the root component is set, the components templates are imported (components-templates.html) and the Polyfills detector is loaded.
index.js is the app entry script, it waits until the necessary polyfills are loaded then instantiates the dependencies and bootstrap the app.