<commit_before>'use strict';

var parseArgs = require('minimist');
var process = require('process');
var console = require('console');
var crypto = require('crypto');
var path = require('path');
var fs = require('fs');
var mkdirp = require('mkdirp');
var DebugLogtron = require('debug-logtron');
var extend = require('xtend');
var textTable = require('text-table');
var readJSON = require('read-json');
var parallel = require('run-parallel');

var gitexec = require('../git-exec.js');
var ThriftMetaFile = require('../thrift-meta-file.js');

/*eslint no-process-env: 0*/
var HOME = process.env.HOME;

/*eslint no-console: 0, no-process-exit:0 */
module.exports = ThriftGet;

if (require.main === module) {
    main();
}

function main() {
    var argv = parseArgs(process.argv.slice(2));
    var thriftGet = ThriftGet(argv);
    thriftGet.processArgs(function onFini(err, text) {
        if (err) {
            console.error('ERR: ' + err);
            process.exit(1);
        }

        if (text) {
            console.log(text.toString());
        }
    });
}

function ThriftGet(opts) {
    if (!(this instanceof ThriftGet)) {
        return new ThriftGet(opts);
    }

    var self = this;

    if (!opts.repository) {
        throw new Error('--repository is required');
    }

    self.remainder = opts._;
    self.command = self.remainder[0];
    self.repository = opts.repository;

    self.cacheDir = opts.cacheDir ||
        path.join(HOME, '.thrift-god', 'upstream-cache');
    self.cwd = opts.cwd || process.cwd();

    self.logger = opts.logger || DebugLogtron('thriftgod');

    self.repoHash = sha1(self.repository);
    self.repoCacheLocation = path.join(
        self.cacheDir, self.repoHash
    );

    self.meta = null;
}

ThriftGet.exec = function exec(string, options, cb) {
    if (typeof options === 'function') {
        cb = options;
        options = {};
    }

    var opts = extend(options, parseArgs(string.split(' ')));
    var thriftGet = ThriftGet(opts);

    thriftGet.processArgs(cb);
    return thriftGet;
};

ThriftGet.prototype.processArgs = function processArgs(cb) {
    var self = this;

    self.fetchRepository(onRepository);

    function onRepository(err) {
        if (err) {
            return cb(err);
        }

        switch (self.command) {
            case 'list':
                self.list(cb);
                break;

            case 'add':
                var name = self.remainder[1];

                if (!name) {
                    return cb(new Error('must specify name to add'));
                }

                self.add(name, cb);
                break;

            case 'update':
                self.update(cb);
                break;

            default:
                cb(new Error('unknown command ' + self.command));
                break;
        }
    }
};

ThriftGet.prototype.list = function list(cb) {
    var self = this;

    return cb(null, ListText(self.meta));
};

function ListText(meta) {
    if (!(this instanceof ListText)) {
        return new ListText(meta);
    }

    var self = this;

    self.remotes = meta.remotes;
}

ListText.prototype.toString = function toString() {
    var self = this;

    var tuples = Object.keys(self.remotes)
        .map(function toTuple(remoteKey) {
            var remote = self.remotes[remoteKey];

            return [' - ' + remoteKey, remote.time];
        });

    return textTable(tuples);
};

ThriftGet.prototype.add = function add(name, cb) {
    var self = this;

    // TODO read remote meta data and do properly
    var destination = path.join(
        self.cwd, 'thrift', name + '.thrift'
    );
    var source = path.join(
        self.repoCacheLocation, 'thrift', name + '.thrift'
    );

    mkdirp(path.dirname(destination), onDir);

    function onDir(err) {
        if (err) {
            return cb(err);
        }

        fs.createReadStream(source)
            .once('error', cb)
            .pipe(fs.createWriteStream(destination))
            .once('error', cb)
            .once('finish', onFinish);
    }

    function onFinish() {
        var metaFile = ThriftMetaFile({
            fileName: path.join(self.cwd, 'thrift', 'meta.json')
        });

        metaFile.readFile(onFileRead);

        function onFileRead(err) {
            if (err) {
                return cb(err);
            }

            metaFile.updateRecord(name, {
                sha: self.meta.remotes[name].sha,
                time: self.meta.remotes[name].time
            }, onMetaUpdated);
        }
    }

    function onMetaUpdated(err) {
        if (err) {
            return cb(err);
        }

        cb(null);
    }
};

ThriftGet.prototype.update =
function update(cb) {
    var self = this;

    var metaFile = path.join(self.cwd, 'thrift', 'meta.json');
    readJSON(metaFile, onMeta);

    function onMeta(err, meta) {
        if (err) {
            // no meta file; nothing to do
            return cb(null);
        }

        var remotes = Object.keys(meta.remotes);
        parallel(remotes.map(function buildThunk(remote) {
            return self.add.bind(self, remote);
        }), cb);
    }
};

ThriftGet.prototype.fetchRepository =
function fetchRepository(cb) {
    var self = this;

    fs.exists(self.repoCacheLocation, onExists);

    function onExists(exists) {
        if (exists) {
            self.pullRepository(onFetched);
        } else {
            self.cloneRepository(onFetched);
        }
    }

    function onFetched(err) {
        if (err) {
            return cb(err);
        }

        var metaFileName = path.join(
            self.repoCacheLocation, 'meta.json'
        );
        readJSON(metaFileName, onMeta);
    }

    function onMeta(err, meta) {
        if (err) {
            return cb(err);
        }

        self.meta = meta;
        cb(null);
    }
};

ThriftGet.prototype.cloneRepository =
function cloneRepository(cb) {
    var self = this;

    mkdirp(self.cacheDir, onCacheDir);

    function onCacheDir(err) {
        if (err) {
            return cb(err);
        }

        var cwd = path.dirname(self.repoCacheLocation);

        var command = 'git clone ' +
            self.repository + ' ' +
            self.repoCacheLocation;
        gitexec(command, {
            cwd: cwd,
            logger: self.logger,
            ignoreStderr: true
        }, cb);
    }
};

ThriftGet.prototype.pullRepository =
function pullRepository(cb) {
    var self = this;

    var cwd = self.repoCacheLocation;
    var command = 'git fetch --all';
    gitexec(command, {
        cwd: cwd,
        logger: self.logger,
        ignoreStderr: true
    }, onFetch);

    function onFetch(err) {
        if (err) {
            return cb(err);
        }

        var command2 = 'git merge --ff-only origin/master';
        gitexec(command2, {
            cwd: cwd,
            logger: self.logger
        }, cb);
    }
};

function sha1(content) {
    var hash = crypto.createHash('sha1');
    hash.update(content);
    return hash.digest('hex');
}
<commit_msg>add help print<commit_after>'use strict';

var parseArgs = require('minimist');
var process = require('process');
var console = require('console');
var crypto = require('crypto');
var path = require('path');
var fs = require('fs');
var mkdirp = require('mkdirp');
var DebugLogtron = require('debug-logtron');
var extend = require('xtend');
var textTable = require('text-table');
var readJSON = require('read-json');
var parallel = require('run-parallel');

var gitexec = require('../git-exec.js');
var ThriftMetaFile = require('../thrift-meta-file.js');

/*eslint no-process-env: 0*/
var HOME = process.env.HOME;

/*eslint no-console: 0, no-process-exit:0 */
module.exports = ThriftGet;

function main() {
    var argv = parseArgs(process.argv.slice(2));
    var thriftGet = ThriftGet(argv);
    thriftGet.processArgs(function onFini(err, text) {
        if (err) {
            console.error('ERR: ' + err);
            process.exit(1);
        }

        if (text) {
            console.log(text.toString());
        }
    });
}

function ThriftGet(opts) {
    if (!(this instanceof ThriftGet)) {
        return new ThriftGet(opts);
    }

    var self = this;

    if (!opts.repository) {
        throw new Error('--repository is required');
    }

    self.remainder = opts._;
    self.command = self.remainder[0];
    self.repository = opts.repository;
    self.helpFlag = opts.h || opts.help;

    self.cacheDir = opts.cacheDir ||
        path.join(HOME, '.thrift-god', 'upstream-cache');
    self.cwd = opts.cwd || process.cwd();

    self.logger = opts.logger || DebugLogtron('thriftgod');

    self.repoHash = sha1(self.repository);
    self.repoCacheLocation = path.join(
        self.cacheDir, self.repoHash
    );

    self.meta = null;
}

ThriftGet.prototype.help = function help() {
    console.log('usage: thrift-get --repository=<repo> [--help] [-h]');
    console.log('                  <command> <args>');
    console.log('');
    console.log('Where <command> is one of: ');
    console.log('  - list');
    console.log('  - add <name>');
    console.log('  - update');
};

ThriftGet.exec = function exec(string, options, cb) {
    if (typeof options === 'function') {
        cb = options;
        options = {};
    }

    var opts = extend(options, parseArgs(string.split(' ')));
    var thriftGet = ThriftGet(opts);

    thriftGet.processArgs(cb);
    return thriftGet;
};

ThriftGet.prototype.processArgs = function processArgs(cb) {
    var self = this;

    if (self.helpFlag) {
        return self.help();
    }

    self.fetchRepository(onRepository);

    function onRepository(err) {
        if (err) {
            return cb(err);
        }

        switch (self.command) {
            case 'list':
                self.list(cb);
                break;

            case 'add':
                var name = self.remainder[1];

                if (!name) {
                    return cb(new Error('must specify name to add'));
                }

                self.add(name, cb);
                break;

            case 'update':
                self.update(cb);
                break;

            default:
                cb(new Error('unknown command ' + self.command));
                break;
        }
    }
};

ThriftGet.prototype.list = function list(cb) {
    var self = this;

    return cb(null, ListText(self.meta));
};

function ListText(meta) {
    if (!(this instanceof ListText)) {
        return new ListText(meta);
    }

    var self = this;

    self.remotes = meta.remotes;
}

ListText.prototype.toString = function toString() {
    var self = this;

    var tuples = Object.keys(self.remotes)
        .map(function toTuple(remoteKey) {
            var remote = self.remotes[remoteKey];

            return [' - ' + remoteKey, remote.time];
        });

    return textTable(tuples);
};

ThriftGet.prototype.add = function add(name, cb) {
    var self = this;

    // TODO read remote meta data and do properly
    var destination = path.join(
        self.cwd, 'thrift', name + '.thrift'
    );
    var source = path.join(
        self.repoCacheLocation, 'thrift', name + '.thrift'
    );

    mkdirp(path.dirname(destination), onDir);

    function onDir(err) {
        if (err) {
            return cb(err);
        }

        fs.createReadStream(source)
            .once('error', cb)
            .pipe(fs.createWriteStream(destination))
            .once('error', cb)
            .once('finish', onFinish);
    }

    function onFinish() {
        var metaFile = ThriftMetaFile({
            fileName: path.join(self.cwd, 'thrift', 'meta.json')
        });

        metaFile.readFile(onFileRead);

        function onFileRead(err) {
            if (err) {
                return cb(err);
            }

            metaFile.updateRecord(name, {
                sha: self.meta.remotes[name].sha,
                time: self.meta.remotes[name].time
            }, onMetaUpdated);
        }
    }

    function onMetaUpdated(err) {
        if (err) {
            return cb(err);
        }

        cb(null);
    }
};

ThriftGet.prototype.update =
function update(cb) {
    var self = this;

    var metaFile = path.join(self.cwd, 'thrift', 'meta.json');
    readJSON(metaFile, onMeta);

    function onMeta(err, meta) {
        if (err) {
            // no meta file; nothing to do
            return cb(null);
        }

        var remotes = Object.keys(meta.remotes);
        parallel(remotes.map(function buildThunk(remote) {
            return self.add.bind(self, remote);
        }), cb);
    }
};

ThriftGet.prototype.fetchRepository =
function fetchRepository(cb) {
    var self = this;

    fs.exists(self.repoCacheLocation, onExists);

    function onExists(exists) {
        if (exists) {
            self.pullRepository(onFetched);
        } else {
            self.cloneRepository(onFetched);
        }
    }

    function onFetched(err) {
        if (err) {
            return cb(err);
        }

        var metaFileName = path.join(
            self.repoCacheLocation, 'meta.json'
        );
        readJSON(metaFileName, onMeta);
    }

    function onMeta(err, meta) {
        if (err) {
            return cb(err);
        }

        self.meta = meta;
        cb(null);
    }
};

ThriftGet.prototype.cloneRepository =
function cloneRepository(cb) {
    var self = this;

    mkdirp(self.cacheDir, onCacheDir);

    function onCacheDir(err) {
        if (err) {
            return cb(err);
        }

        var cwd = path.dirname(self.repoCacheLocation);

        var command = 'git clone ' +
            self.repository + ' ' +
            self.repoCacheLocation;
        gitexec(command, {
            cwd: cwd,
            logger: self.logger,
            ignoreStderr: true
        }, cb);
    }
};

ThriftGet.prototype.pullRepository =
function pullRepository(cb) {
    var self = this;

    var cwd = self.repoCacheLocation;
    var command = 'git fetch --all';
    gitexec(command, {
        cwd: cwd,
        logger: self.logger,
        ignoreStderr: true
    }, onFetch);

    function onFetch(err) {
        if (err) {
            return cb(err);
        }

        var command2 = 'git merge --ff-only origin/master';
        gitexec(command2, {
            cwd: cwd,
            logger: self.logger
        }, cb);
    }
};

function sha1(content) {
    var hash = crypto.createHash('sha1');
    hash.update(content);
    return hash.digest('hex');
}

if (require.main === module) {
    main();
}
<|endoftext|>


<commit_before>locale.de = {
    modes: {
        add_area: {
            title: "Fläche",
            description: "Füge Parks, Gebäude, Seen oder andere Flächen zur Karte hinzu.",
            tail: "Klicke in die Karte, um das Zeichnen einer Fläche wie einen Park, einen See oder Gebäude zu starten.",
            key: "A"
        },
        add_line: {
            title: "Linie",
            description: "Linien können Autobahnen, Straßen, Fußwege oder sogar Kanäle sein.",
            tail: "Klicke in die Karte, um das Zeichnen einer Straße eines Pfades oder einer Route zu starten.",
            key: "L"
        },
        add_point: {
            title: "Punkt",
            description: "Restaurants, Denkmäler und Briefkästen sind Punkte",
            tail: "Klicke in die Karte, um einen Punkt hinzuzufügen.",
            key: "P"
        },
        browse: {
            title: "Navigation",
            description: "Verschieben und Vergrößern/Verkleinern des Kartenausschnitts.",
            key: "B"
        },
        draw_area: {
            tail: "Klicke, um Punkte zur Fläche hinzuzufügen. Klicke auf den ersten Punkt, um die Fläche abzuschließen."
        },
        draw_line: {
            tail: "Klicke, um mehr Punkte zur Linie hizuzufügen. Klicke auf eine andere Linie um die Linien zu verbinden und klicke doppelt, um die Linie zu beenden."
        }
    },

    operations: {
        add: {
            annotation: {
                point: "Punkt hinzugefügt.",
                vertex: "Stützpunkt einem Weg hinzugefügt."
            }
        },
        start: {
            annotation: {
                line: "Linie begonnen.",
                area: "Fläche begonnen."
            }
        },
        'continue': {
            annotation: {
                line: "Linie fortgesetzt.",
                area: "Fläche fortgesetzt."
            }
        },
        cancel_draw: {
            annotation: "Zeichnen abgebrochen."
        },
        change_tags: {
            annotation: "Tags verändert."
        },
        circularize: {
            title: "Abrunden",
            description: "Runde dies ab.",
            key: "O",
            annotation: {
                line: "Runde eine Linie ab.",
                area: "Runde eine Fläche ab."
            }
        },
        orthogonalize: {
            title: "Rechtwinkligkeit herstellen",
            description: "Diese Ecken rechtwinklig ausrichten.",
            key: "Q",
            annotation: {
                line: "Die Ecken einer Linie rechtwinklig ausgerichtet.",
                area: "Die Ecken einer Fläche rechtwinklig ausgerichtet."
            }
        },
        'delete': {
            title: "Löschen",
            description: "Lösche dies aus der Karte.",
            key: "⌫",
            annotation: {
                point: "Punkt gelöscht.",
                vertex: "Stützpunkt aus einem Weg gelöscht.",
                line: "Linie gelöscht.",
                area: "Fläche gelöscht.",
                relation: "Verbindung gelöscht.",
                multiple: "{n} Objekte gelöscht."
            }
        },
        connect: {
            annotation: {
                point: "Weg mit einem Punkt verbunden.",
                vertex: "Weg mit einem anderem Weg verbunden.",
                line: "Weg mit einer Linie verbunden.",
                area: "Weg mit einer Fläche verbunden."
            }
        },
        disconnect: {
            title: "Trennen",
            description: "Trenne diese Wege voneinander.",
            key: "D",
            annotation: "Wege getrennt."
        },
        merge: {
            title: "Vereinigen",
            description: "Vereinige diese Linien.",
            key: "C",
            annotation: "{n} Linien vereinigt."
        },
        move: {
            title: "Verschieben",
            description: "Verschiebe dieses Objekt an einen anderen Ort.",
            key: "M",
            annotation: {
                point: "Punkt verschoben.",
                vertex: "Stützpunkt in einen Weg veschoben.",
                line: "Linie verschoben.",
                area: "Fläche verschoben."
            }
        },
        reverse: {
            title: "Umkehren",
            description: "Ändere die Richtung dieser Linie.",
            key: "V",
            annotation: "Linienrichtung umgekehrt."
        },
        split: {
            title: "Teilen",
            description: "Teile dies in zwei Wege an diesem Punkt.",
            key: "X",
            annotation: "Weg geteilt."
        }
    },

    validations: {
        untagged_point: "Punkt ohne Attribute, der kein Teil einer Linie oder Fläche ist",
        untagged_line: "Linie ohne Attribute",
        untagged_area: "Fläche ohne Attribute",
        tag_suggests_area: "Das Attribut {tag} suggeriert eine Fläche, ist aber keine Fläche",
        deprecated_tags: "Veralterte Attribute: {tags}"
    },

    save: "Speichern",
    save_help: "Speichere Änderungen zu OpenStreetMap, so dass sie für andere Nutzer sichtbar werden",
    no_changes: "Sie haben keine Änderungen zum Speichern.",
    save_error: "Es ist ein Fehler aufgetreten beim Versuch des Speicherns",
    uploading_changes: "Lade Änderungen zu OpenStreetMap.",
    just_edited: "Sie haben gerade OpenStreetMap editiert!",
    okay: "Okay",

    "zoom-in": "Hineinzoomen",
    "zoom-out": "Herauszoomen",

    nothing_to_undo: "Nichts zum Rückgängigmachen.",
    nothing_to_redo: "Nichts zum Wiederherstellen.",

    browser_notice: "Dieser Editor wird in Firefox, Chrome, Safari, Opera, und Internet Explorer 9 und höher unterstzützt. Bitte aktualisieren Sie Ihren Browser oder nutzen Sie Potlatch 2, um die Karte zu modifizieren.",

    inspector: {
        no_documentation_combination:  "Für dieses Attribut ist keine Dokumentation verfügbar.",
        no_documentation_key: "Für dises Schlüsselwort ist keine Dokumentation verfügbar",
        new_tag: "Neues Attribut"
    },

    view_on_osm: "Bei OSM anschauen",

    zoom_in_edit: "Hineinzoomen, um die Karte zu editieren",

    edit_tags: "Attribute bearbeiten",

    geocoder: {
        title: "Suche einen Ort",
        placeholder: "suche einen Ort",
        no_results: "Der Ort '{name}' konnte nicht gefunden werden"
    },

    description: "Beschreibung",

    logout: "Abmelden",

    layerswitcher: {
        title: "Hintergrund",
        description: "Hintergrundeinstellungen",
        percent_brightness: "{opacity}% Helligkeit",
        fix_misalignment: "Fehlerhafte Ausrichtung reparieren",
        reset: "Zurücksetzen"
    }
};
<commit_msg>Update locale/de.js<commit_after>locale.de = {
    modes: {
        add_area: {
            title: "Fläche",
            description: "Füge Parks, Gebäude, Seen oder andere Flächen zur Karte hinzu.",
            tail: "Klicke in die Karte, um das Zeichnen einer Fläche wie einen Park, einen See oder Gebäude zu starten.",
            key: "A"
        },
        add_line: {
            title: "Linie",
            description: "Linien können Autobahnen, Straßen, Fußwege oder sogar Kanäle sein.",
            tail: "Klicke in die Karte, um das Zeichnen einer Straße eines Pfades oder einer Route zu starten.",
            key: "L"
        },
        add_point: {
            title: "Punkt",
            description: "Restaurants, Denkmäler und Briefkästen sind Punkte",
            tail: "Klicke in die Karte, um einen Punkt hinzuzufügen.",
            key: "P"
        },
        browse: {
            title: "Navigation",
            description: "Verschieben und Vergrößern/Verkleinern des Kartenausschnitts.",
            key: "B"
        },
        draw_area: {
            tail: "Klicke, um Punkte zur Fläche hinzuzufügen. Klicke auf den ersten Punkt, um die Fläche abzuschließen."
        },
        draw_line: {
            tail: "Klicke, um mehr Punkte zur Linie hizuzufügen. Klicke auf eine andere Linie um die Linien zu verbinden und klicke doppelt, um die Linie zu beenden."
        }
    },

    operations: {
        add: {
            annotation: {
                point: "Punkt hinzugefügt.",
                vertex: "Stützpunkt einem Weg hinzugefügt."
            }
        },
        start: {
            annotation: {
                line: "Linie begonnen.",
                area: "Fläche begonnen."
            }
        },
        'continue': {
            annotation: {
                line: "Linie fortgesetzt.",
                area: "Fläche fortgesetzt."
            }
        },
        cancel_draw: {
            annotation: "Zeichnen abgebrochen."
        },
        change_tags: {
            annotation: "Tags verändert."
        },
        circularize: {
            title: "Abrunden",
            description: "Runde dies ab.",
            key: "O",
            annotation: {
                line: "Runde eine Linie ab.",
                area: "Runde eine Fläche ab."
            }
        },
        orthogonalize: {
            title: "Rechtwinkligkeit herstellen",
            description: "Diese Ecken rechtwinklig ausrichten.",
            key: "Q",
            annotation: {
                line: "Die Ecken einer Linie rechtwinklig ausgerichtet.",
                area: "Die Ecken einer Fläche rechtwinklig ausgerichtet."
            }
        },
        'delete': {
            title: "Löschen",
            description: "Lösche dies aus der Karte.",
            key: "⌫",
            annotation: {
                point: "Punkt gelöscht.",
                vertex: "Stützpunkt aus einem Weg gelöscht.",
                line: "Linie gelöscht.",
                area: "Fläche gelöscht.",
                relation: "Verbindung gelöscht.",
                multiple: "{n} Objekte gelöscht."
            }
        },
        connect: {
            annotation: {
                point: "Weg mit einem Punkt verbunden.",
                vertex: "Weg mit einem anderem Weg verbunden.",
                line: "Weg mit einer Linie verbunden.",
                area: "Weg mit einer Fläche verbunden."
            }
        },
        disconnect: {
            title: "Trennen",
            description: "Trenne diese Wege voneinander.",
            key: "D",
            annotation: "Wege getrennt."
        },
        merge: {
            title: "Vereinigen",
            description: "Vereinige diese Linien.",
            key: "C",
            annotation: "{n} Linien vereinigt."
        },
        move: {
            title: "Verschieben",
            description: "Verschiebe dieses Objekt an einen anderen Ort.",
            key: "M",
            annotation: {
                point: "Punkt verschoben.",
                vertex: "Stützpunkt in einen Weg veschoben.",
                line: "Linie verschoben.",
                area: "Fläche verschoben."
            }
        },
        reverse: {
            title: "Umkehren",
            description: "Ändere die Richtung dieser Linie.",
            key: "V",
            annotation: "Linienrichtung umgekehrt."
        },
        split: {
            title: "Teilen",
            description: "Teile dies in zwei Wege an diesem Punkt.",
            key: "X",
            annotation: "Weg geteilt."
        }
    },

    validations: {
        untagged_point: "Punkt ohne Attribute, der kein Teil einer Linie oder Fläche ist",
        untagged_line: "Linie ohne Attribute",
        untagged_area: "Fläche ohne Attribute",
        tag_suggests_area: "Das Attribut {tag} suggeriert eine Fläche, ist aber keine Fläche",
        deprecated_tags: "Veralterte Attribute: {tags}"
    },

    save: "Speichern",
    save_help: "Speichere Änderungen auf OpenStreetMap, um diese für andere Nutzer sichtbar zu machen",
    no_changes: "Sie haben keine Änderungen zum Speichern.",
    save_error: "Beim Speichern ist ein Fehler aufgetreten",
    uploading_changes: "Änderungen werden zu OpenStreetMap hochgeladen.",
    just_edited: "Sie haben gerade OpenStreetMap editiert!",
    okay: "OK",

    "zoom-in": "Hineinzoomen",
    "zoom-out": "Herauszoomen",

    nothing_to_undo: "Nichts zum Rückgängigmachen.",
    nothing_to_redo: "Nichts zum Wiederherstellen.",

    browser_notice: "Dieser Editor wird von Firefox, Chrome, Safari, Opera, und Internet Explorer (Version 9 und höher) unterstzützt. Bitte aktualisieren Sie Ihren Browser oder nutzen Sie Potlatch 2, um die Karte zu modifizieren.",

    inspector: {
        no_documentation_combination:  "Für dieses Attribut ist keine Dokumentation verfügbar.",
        no_documentation_key: "Für dises Schlüsselwort ist keine Dokumentation verfügbar",
        new_tag: "Neues Attribut"
    },

    view_on_osm: "Auf OSM anschauen",

    zoom_in_edit: "Hineinzoomen, um die Karte zu bearbeiten",

    edit_tags: "Attribute bearbeiten",

    geocoder: {
        title: "Suche einen Ort",
        placeholder: "suche einen Ort",
        no_results: "Der Ort '{name}' konnte nicht gefunden werden"
    },

    description: "Beschreibung",

    logout: "Abmelden",

    layerswitcher: {
        title: "Hintergrund",
        description: "Hintergrundeinstellungen",
        percent_brightness: "{opacity}% Helligkeit",
        fix_misalignment: "Fehlerhafte Ausrichtung reparieren",
        reset: "Zurücksetzen"
    }
};
<|endoftext|>


<commit_before>apos.define('apostrophe-attachments', {
  afterConstruct: function(self) {
    self.addFieldType();
    self.addHandlers();
  },
  construct: function(self, options) {
    self.name = options.name;
    self.action = options.action;
    self.uploadsUrl = options.uploadsUrl || '';

    self.addFieldType = function() {
      apos.schemas.addFieldType({
        name: self.name,
        displayer: self.displayer,
        converter: self.converter
      });
    };

    self.displayer = function(object, name, $field, $el, field, callback) {
      var $fieldset = apos.schemas.findFieldset($el, name);
      self.updateExisting($fieldset, object[name]);

      // A bulk upload button is provided separately at the array level
      // if multipleUpload: true is set on an array schema field. -Tom

      var $uploader = $fieldset.find('[data-uploader]');

      $uploader.fileupload({
        dataType: 'json',
        dropZone: $fieldset,
        maxNumberOfFiles: 1,
        url: self.action + '/upload',
        start: function (e) {
          busy(true);
        },
        // Even on an error we should note we're not spinning anymore
        always: function (e, data) {
          busy(false);
        },
        done: function (e, data) {
          if (data.result.status !== 'ok') {
            alert(data.result.status);
            return;
          }
          var file = data.result.file;
          self.updateExisting($fieldset, file);
        },
        add: function(e, data) {
          return data.submit();
        }
      });

      return setImmediate(callback);

      function busy(state) {
        $fieldset.attr('data-busy', state ? '1' : '0');
        apos.ui.busy($uploader, state);
      }

    };

    self.converter = function(data, name, $field, $el, field, callback) {
      var $fieldset = apos.schemas.findFieldset($el, name);
      if ($fieldset.attr('data-busy') === '1') {
        // If upload is in progress stay busy until this upload
        // completes. Other file attachment fields may be doing
        // the same dance.
        setTimeout(function() {
          self.converter(data, name, $field, $el, field, callback);
        }, 100);
        return;
      }
      var $fieldset = apos.schemas.findFieldset($el, name);
      data[name] = $fieldset.find('[data-existing]').data('existing');
      if (field.required && (!data[name])) {
        return setImmediate(_.partial(callback, 'required'));
      }
      return setImmediate(callback);
    };

    self.addHandlers = function() {
      apos.ui.link('trash', 'attachment', function($el, _id) {
        self.api('trash', { _id: _id }, function(result) {
          if (result.status !== 'ok') {
            return;
          }
          var $existing = $el.closest('[data-existing]');
          $existing.hide();
        });
        return false;
      });
      apos.ui.link('crop', 'attachment', function($el, _id) {
        var attachment = $el.closest('[data-existing]').data('existing');
        var $fieldset = $el.closest('fieldset');
        apos.create('apostrophe-attachments-crop-editor', {
          action: self.action,
          attachment: attachment,
          cropped: function(crop) {
            attachment.crop = crop;
            self.updateExisting($fieldset, attachment);
          }
        });
      });
    };

    self.updateExisting = function($fieldset, info) {
      var $existing = $fieldset.find('[data-existing]');
      if (!info) {
        $existing.data('existing', null);
        $existing.hide();
        return;
      }
      $existing.data('existing', info);
      $existing.attr('data-existing', info._id);
      $existing.find('[data-name]').text(info.name);
      $existing.alterClass('apos-extension-*', 'apos-extension-' + info.extension);
      var $preview = $existing.find('[data-preview]');
      if (info.group === 'images') {
        $preview.css('background-image', 'url(' + self.url(info, { size: 'one-sixth', crop: info.crop }) + ')');
        $fieldset.find('[data-crop-attachment]').show();
      } else {
        $preview.hide();
        $fieldset.find('[data-crop-attachment]').hide();
      }
      $existing.show();
    };

  }
});
<commit_msg>Adjust apostrophe-attachments schema field to use convert and populate, in light of apostrophe-schema change.<commit_after>apos.define('apostrophe-attachments', {
  afterConstruct: function(self) {
    self.addFieldType();
    self.addHandlers();
  },
  construct: function(self, options) {
    self.name = options.name;
    self.action = options.action;
    self.uploadsUrl = options.uploadsUrl || '';

    self.addFieldType = function() {
      apos.schemas.addFieldType({
        name: self.name,
        populate: self.populate,
        convert: self.convert
      });
    };

    self.populate = function(object, name, $field, $el, field, callback) {
      var $fieldset = apos.schemas.findFieldset($el, name);
      self.updateExisting($fieldset, object[name]);

      // A bulk upload button is provided separately at the array level
      // if multipleUpload: true is set on an array schema field. -Tom

      var $uploader = $fieldset.find('[data-uploader]');

      $uploader.fileupload({
        dataType: 'json',
        dropZone: $fieldset,
        maxNumberOfFiles: 1,
        url: self.action + '/upload',
        start: function (e) {
          busy(true);
        },
        // Even on an error we should note we're not spinning anymore
        always: function (e, data) {
          busy(false);
        },
        done: function (e, data) {
          if (data.result.status !== 'ok') {
            alert(data.result.status);
            return;
          }
          var file = data.result.file;
          self.updateExisting($fieldset, file);
        },
        add: function(e, data) {
          return data.submit();
        }
      });

      return setImmediate(callback);

      function busy(state) {
        $fieldset.attr('data-busy', state ? '1' : '0');
        apos.ui.busy($uploader, state);
      }

    };

    self.convert = function(data, name, $field, $el, field, callback) {
      var $fieldset = apos.schemas.findFieldset($el, name);
      if ($fieldset.attr('data-busy') === '1') {
        // If upload is in progress stay busy until this upload
        // completes. Other file attachment fields may be doing
        // the same dance.
        setTimeout(function() {
          self.converter(data, name, $field, $el, field, callback);
        }, 100);
        return;
      }
      var $fieldset = apos.schemas.findFieldset($el, name);
      data[name] = $fieldset.find('[data-existing]').data('existing');
      if (field.required && (!data[name])) {
        return setImmediate(_.partial(callback, 'required'));
      }
      return setImmediate(callback);
    };

    self.addHandlers = function() {
      apos.ui.link('trash', 'attachment', function($el, _id) {
        self.api('trash', { _id: _id }, function(result) {
          if (result.status !== 'ok') {
            return;
          }
          var $existing = $el.closest('[data-existing]');
          $existing.hide();
        });
        return false;
      });
      apos.ui.link('crop', 'attachment', function($el, _id) {
        var attachment = $el.closest('[data-existing]').data('existing');
        var $fieldset = $el.closest('fieldset');
        apos.create('apostrophe-attachments-crop-editor', {
          action: self.action,
          attachment: attachment,
          cropped: function(crop) {
            attachment.crop = crop;
            self.updateExisting($fieldset, attachment);
          }
        });
      });
    };

    self.updateExisting = function($fieldset, info) {
      var $existing = $fieldset.find('[data-existing]');
      if (!info) {
        $existing.data('existing', null);
        $existing.hide();
        return;
      }
      $existing.data('existing', info);
      $existing.attr('data-existing', info._id);
      $existing.find('[data-name]').text(info.name);
      $existing.alterClass('apos-extension-*', 'apos-extension-' + info.extension);
      var $preview = $existing.find('[data-preview]');
      if (info.group === 'images') {
        $preview.css('background-image', 'url(' + self.url(info, { size: 'one-sixth', crop: info.crop }) + ')');
        $fieldset.find('[data-crop-attachment]').show();
      } else {
        $preview.hide();
        $fieldset.find('[data-crop-attachment]').hide();
      }
      $existing.show();
    };

  }
});
<|endoftext|>


<commit_before>locale.lv = {
    modes: {
        add_area: {
            title: "Apgabals",
            description: "Pievieno parkus, ēkas, ezerus un citus apgabalus.",
            tail: "Klikšķiniet uz kartes, lai sāktu zīmēt apgabalu, piemēram, parku, ezeru, vai ēku."
        },
        add_line: {
            title: "Līnija",
            description: "Līnijas var būt ceļi, ielas, takas vai pat kanāli.",
            tail: "Klikšķiniet uz kartes, lai sāktu zīmēt līniju, piemēram, ceļu vai taku."
        },
        add_point: {
            title: "Punkts",
            description: "Kafejnīcas, pieminekļi, un veikali var būt punkti.",
            tail: "Klikšķiniet uz kartes, lai pievienotu interešu punktu."
        },
        browse: {
            title: "Pārlūkot",
            description: "Pārlūko karti."
        },
        draw_area: {
            tail: "Klikšķiniet, lai pievinotu mezglus apgabalam. Lai beigtu zīmēt apgabalu, klikšķiniet uz sākuma mezgla."
        },
        draw_line: {
            tail: "Klikšķiniet, lai pievienotu mezglus līnijai. Lai savienotu ar citām linijām, klikšķiniet uz tām. Dubultklikšķis nobeidz līniju."
        }
    },

    operations: {
        add: {
            annotation: {
                point: "Punkts pievienots.",
                vertex: "Mezgls pievienots līnijai."
            }
        },
        start: {
            annotation: {
                line: "Līnija iesākta.",
                area: "Apgabals iesākts."
            }
        },
        'continue': {
            annotation: {
                line: "Līnija turpināta.",
                area: "Apgabals turpināts."
            }
        },
        cancel_draw: {
            annotation: "Zīmēšana atcelta."
        },
        change_tags: {
            annotation: "Apzīmējumi mainīti."
        },
        circularize: {
            title: "Pārveidot par apļveida",
            description: "Pārveidot šo objektu par apļveida.",
            key: "O",
            annotation: {
                line: "Līnija pārveidota par apļveida.",
                area: "Apgabals pārveidots par apļveida."
            }
        },
        orthogonalize: {
            title: "Ortogonalizēt",
            description: "Pārveidot, lai visi leņķi būtu taisnleņķi.",
            key: "Q",
            annotation: {
                line: "Līnijas leņķi pārvedoti par taisnleņķiem.",
                area: "Apgabala leņķi pārvedoti par taisnleņķiem."
            }
        },
        'delete': {
            title: "Dzēst",
            description: "Izdzēst no kartes.",
            annotation: {
                point: "Punkts dzēsts.",
                vertex: "Mezgls dzests.",
                line: "Līnija dzēsta.",
                area: "Apgabals dzēsts.",
                relation: "Relācija dzēsta.",
                multiple: "{n} objekti dzēsti."
            }
        },
        connect: {
            annotation: {
                point: "Līnija savienota ar punktu.",
                vertex: "Līnija savienota ar citu.",
                line: "Līnija savienota ar līniju.",
                area: "Līnija savienota ar apgabalu."
            }
        },
        disconnect: {
            title: "Atvienot",
            description: "Atvieno līnijas.",
            key: "D",
            annotation: "Līnijas atvienotas."
        },
        merge: {
            title: "Sapludināt",
            description: "Sapludināt līnijas.",
            key: "C",
            annotation: "{n} līnijas sapludinātas."
        },
        move: {
            title: "Pārvietot",
            description: "Pārvieto objektu.",
            key: "M",
            annotation: {
                point: "Punkts pārvietots.",
                vertex: "Mezgls pārvietots.",
                line: "Līnija pārvietota.",
                area: "Apgabals pārvietots.",
                multiple: "Moved multiple objects."
            }
        },
        rotate: {
            title: "Pagriezt",
            description: "Pagriezt šo objektu ap tā centru.",
            key: "R",
            annotation: {
                line: "Līnija pagriezta.",
                area: "Apgabals pagriezts."
            }
        },
        reverse: {
            title: "Mainīt virzienu",
            description: "Mainīt līnijas virzienu.",
            key: "V",
            annotation: "Līnijas virziens mainīts."
        },
        split: {
            title: "Sadalīt",
            description: "Sadalīt līniju pie šī punkta.",
            key: "X",
            annotation: "Līnija sadalīta."
        }
    },

    nothing_to_undo: "Nav nekā, ko atcelt",
    nothing_to_redo: "Nav nekā, ko atsaukt",

    just_edited: "Jūs nupat rediģējāt OpenStreetMap",
    browser_notice: "Šis redaktors tiek atbalstīts ar Firefox, Chrome, Safari, Opera, un Internet Explorer 9 un jaunāku. Lūdzu, atjauniniet savu pārlūkprogrammu vai izmantojiet Potlatch 2 kartes rediģēšanai",
    view_on_osm: "Apskatīt OSM lapu",
    zoom_in_edit: "pietuviniet, lai labotu karti",
    logout: "atslēgties",
    report_a_bug: "ziņot par kļūdu",

    commit: {
        title: "Saglabāt izmaiņas",
        description_placeholder: "Īss apraksts par jūsu ieguldījumu",
        upload_explanation: "Izmaiņas, kuras jūs augšupielādējat kā {user}, būs pieejamas visās kartēs, kuras izmanto OpenStreetMap datus.",
        save: "Saglabāt",
        cancel: "Atcelt",
        warnings: "Brīdinājumi",
        modified: "Mainīts",
        deleted: "Dzēsts",
        created: "Izveidots"
    },

    contributors: {
        list: "{users} papildinājumi redzami",
        truncated_list: "{users} un {count} citu papildinājumi redzami"
    },

    geocoder: {
        title: "Atrast vietu",
        placeholder: "meklē vietu",
        no_results: "Nevar atrast vietu '{name}'"
    },

    geolocate: {
        title: "Parādīt manu atrašanās vietu"
    },

    inspector: {
        no_documentation_combination: "Šai apzīmējumu kombinācijai nav piejama dokumentācija",
        no_documentation_key: "Šai vērtībai nav piejama dokumentācija",
        new_tag: "Jauns apzīmējums",
        edit_tags: "Labot apzīmējumus",
        okay: "Labi",
        view_on_osm: "Apskatīt OSM",
        name: "Name",
        editing: "Rediģē {type}",
        additional: "Papildus apzīmējumi",
        choose: "Ko vēlaties pievienot?",
        results: "Atrasti {n} rezultāti meklējot {search}"
    },

    background: {
        title: "Fons",
        description: "Fona iestatījumi",
        percent_brightness: "{opacity}% caurspīdīgums",
        fix_misalignment: "Labot fona nobīdi",
        reset: "Atiestatīt"
    },

    restore: {
        description: "Jums ir nesaglabātas izmaiņas no iepriekšējās labošanas sesijas. Vai vēlaties ielādēt šīs izmaiņas?",
        restore: "Ielādēt",
        reset: "Atmest"
    },

    save: {
        title: "Saglabāt",
        help: "Saglabā izmaiņas, padarot tās redzamas citiem.",
        error: "Kļūda. Nevarēja saglabāt izmaiņas",
        uploading: "Augšupielādē",
        unsaved_changes: "Jums ir nesaglabātas izmaiņas"
    },

    splash: {
        welcome: "Laipni lūgti iD OpenStreetMap redaktorā",
        text: "Šī ir izstrādes versija {version}. Papildus informācijai skatīt {website} un ziņot par kļūdām {github}."
    },

    source_switch: {
        live: "live",
        dev: "dev"
    },

    tag_reference: {
        description: "Apraksts",
        on_wiki: "{tag} wiki.osm.org",
        used_with: "izmantots kopā ar {type}"
    },

    validations: {
        untagged_point: "Neapzīmēts punkts",
        untagged_line: "Neapzīmēta līnija",
        untagged_area: "Neapzīmēts apgabals",
        many_deletions: "Jūs dzēšat {n} objektus. Vai tiešām vēlaties to darīt? Tie tiks izdzēsti no kartes, ko visi var aplūkt openstreetmap.org.",
        tag_suggests_area: "Apzīmējums {tag} parasti tiek lietots apgabaliem, bet objekts nav apgabals",
        deprecated_tags: "Novecojuši apzīmējumi: {tags}"
    },

    zoom: {
        'in': "Pietuvināt",
        out: "Attālināt"
    }
};
<commit_msg>Update lv.js<commit_after>locale.lv = {
    modes: {
        add_area: {
            title: "Apgabals",
            description: "Pievieno parkus, ēkas, ezerus un citus apgabalus.",
            tail: "Klikšķiniet uz kartes, lai sāktu zīmēt apgabalu, piemēram, parku, ezeru, vai ēku."
        },
        add_line: {
            title: "Līnija",
            description: "Līnijas var būt ceļi, ielas, takas vai pat kanāli.",
            tail: "Klikšķiniet uz kartes, lai sāktu zīmēt līniju, piemēram, ceļu vai taku."
        },
        add_point: {
            title: "Punkts",
            description: "Kafejnīcas, pieminekļi, un veikali var būt punkti.",
            tail: "Klikšķiniet uz kartes, lai pievienotu interešu punktu."
        },
        browse: {
            title: "Pārlūkot",
            description: "Pārlūko karti."
        },
        draw_area: {
            tail: "Klikšķiniet, lai pievinotu mezglus apgabalam. Lai beigtu zīmēt apgabalu, klikšķiniet uz sākuma mezgla."
        },
        draw_line: {
            tail: "Klikšķiniet, lai pievienotu mezglus līnijai. Lai savienotu ar citām linijām, klikšķiniet uz tām. Dubultklikšķis nobeidz līniju."
        }
    },

    operations: {
        add: {
            annotation: {
                point: "Punkts pievienots.",
                vertex: "Mezgls pievienots līnijai."
            }
        },
        start: {
            annotation: {
                line: "Līnija iesākta.",
                area: "Apgabals iesākts."
            }
        },
        'continue': {
            annotation: {
                line: "Līnija turpināta.",
                area: "Apgabals turpināts."
            }
        },
        cancel_draw: {
            annotation: "Zīmēšana atcelta."
        },
        change_tags: {
            annotation: "Apzīmējumi mainīti."
        },
        circularize: {
            title: "Pārveidot par apļveida",
            description: "Pārveidot šo objektu par apļveida.",
            key: "O",
            annotation: {
                line: "Līnija pārveidota par apļveida.",
                area: "Apgabals pārveidots par apļveida."
            }
        },
        orthogonalize: {
            title: "Ortogonalizēt",
            description: "Pārveidot, lai visi leņķi būtu taisnleņķi.",
            key: "Q",
            annotation: {
                line: "Līnijas leņķi pārvedoti par taisnleņķiem.",
                area: "Apgabala leņķi pārvedoti par taisnleņķiem."
            }
        },
        'delete': {
            title: "Dzēst",
            description: "Izdzēst no kartes.",
            annotation: {
                point: "Punkts dzēsts.",
                vertex: "Mezgls dzests.",
                line: "Līnija dzēsta.",
                area: "Apgabals dzēsts.",
                relation: "Relācija dzēsta.",
                multiple: "{n} objekti dzēsti."
            }
        },
        connect: {
            annotation: {
                point: "Līnija savienota ar punktu.",
                vertex: "Līnija savienota ar citu.",
                line: "Līnija savienota ar līniju.",
                area: "Līnija savienota ar apgabalu."
            }
        },
        disconnect: {
            title: "Atvienot",
            description: "Atvieno līnijas.",
            key: "D",
            annotation: "Līnijas atvienotas."
        },
        merge: {
            title: "Sapludināt",
            description: "Sapludināt līnijas.",
            key: "C",
            annotation: "{n} līnijas sapludinātas."
        },
        move: {
            title: "Pārvietot",
            description: "Pārvieto objektu.",
            key: "M",
            annotation: {
                point: "Punkts pārvietots.",
                vertex: "Mezgls pārvietots.",
                line: "Līnija pārvietota.",
                area: "Apgabals pārvietots.",
                multiple: "Moved multiple objects."
            }
        },
        rotate: {
            title: "Pagriezt",
            description: "Pagriezt šo objektu ap tā centru.",
            key: "R",
            annotation: {
                line: "Līnija pagriezta.",
                area: "Apgabals pagriezts."
            }
        },
        reverse: {
            title: "Mainīt virzienu",
            description: "Mainīt līnijas virzienu.",
            key: "V",
            annotation: "Līnijas virziens mainīts."
        },
        split: {
            title: "Sadalīt",
            description: "Sadalīt līniju pie šī punkta.",
            key: "X",
            annotation: "Līnija sadalīta."
        }
    },

    nothing_to_undo: "Nav nekā, ko atcelt",
    nothing_to_redo: "Nav nekā, ko atsaukt",

    just_edited: "Jūs nupat rediģējāt OpenStreetMap",
    browser_notice: "Šis redaktors tiek atbalstīts ar Firefox, Chrome, Safari, Opera, un Internet Explorer 9 un jaunāku. Lūdzu, atjauniniet savu pārlūkprogrammu vai izmantojiet Potlatch 2 kartes rediģēšanai",
    view_on_osm: "Apskatīt OSM lapu",
    zoom_in_edit: "pietuviniet, lai labotu karti",
    logout: "atslēgties",
    report_a_bug: "ziņot par kļūdu",

    commit: {
        title: "Saglabāt izmaiņas",
        description_placeholder: "Īss apraksts par jūsu ieguldījumu",
        upload_explanation: "Izmaiņas, kuras jūs augšupielādējat kā {user}, būs pieejamas visās kartēs, kuras izmanto OpenStreetMap datus.",
        save: "Saglabāt",
        cancel: "Atcelt",
        warnings: "Brīdinājumi",
        modified: "Mainīts",
        deleted: "Dzēsts",
        created: "Izveidots"
    },

    contributors: {
        list: "{users} papildinājumi redzami",
        truncated_list: "{users} un {count} citu papildinājumi redzami"
    },

    geocoder: {
        title: "Atrast vietu",
        placeholder: "meklēt vietu",
        no_results: "Nevar atrast vietu '{name}'"
    },

    geolocate: {
        title: "Parādīt manu atrašanās vietu"
    },

    inspector: {
        no_documentation_combination: "Šai apzīmējumu kombinācijai nav piejama dokumentācija",
        no_documentation_key: "Šai vērtībai nav piejama dokumentācija",
        new_tag: "Jauns apzīmējums",
        edit_tags: "Labot apzīmējumus",
        okay: "Labi",
        view_on_osm: "Apskatīt OSM",
        name: "Name",
        editing: "Rediģē {type}",
        additional: "Papildus apzīmējumi",
        choose: "Ko vēlaties pievienot?",
        results: "Atrasti {n} rezultāti meklējot {search}"
    },

    background: {
        title: "Fons",
        description: "Fona iestatījumi",
        percent_brightness: "{opacity}% caurspīdīgums",
        fix_misalignment: "Labot fona nobīdi",
        reset: "Atiestatīt"
    },

    restore: {
        description: "Jums ir nesaglabātas izmaiņas no iepriekšējās labošanas sesijas. Vai vēlaties ielādēt šīs izmaiņas?",
        restore: "Ielādēt",
        reset: "Atmest"
    },

    save: {
        title: "Saglabāt",
        help: "Saglabā izmaiņas, padarot tās redzamas citiem.",
        error: "Kļūda. Nevarēja saglabāt izmaiņas",
        uploading: "Augšupielādē",
        unsaved_changes: "Jums ir nesaglabātas izmaiņas"
    },

    splash: {
        welcome: "Laipni lūgti iD OpenStreetMap redaktorā",
        text: "Šī ir izstrādes versija {version}. Papildus informācijai skatīt {website} un ziņot par kļūdām {github}."
    },

    source_switch: {
        live: "live",
        dev: "dev"
    },

    tag_reference: {
        description: "Apraksts",
        on_wiki: "{tag} wiki.osm.org",
        used_with: "izmantots kopā ar {type}"
    },

    validations: {
        untagged_point: "Neapzīmēts punkts",
        untagged_line: "Neapzīmēta līnija",
        untagged_area: "Neapzīmēts apgabals",
        many_deletions: "Jūs dzēšat {n} objektus. Vai tiešām vēlaties to darīt? Tie tiks izdzēsti no kartes, ko visi var aplūkt openstreetmap.org.",
        tag_suggests_area: "Apzīmējums {tag} parasti tiek lietots apgabaliem, bet objekts nav apgabals",
        deprecated_tags: "Novecojuši apzīmējumi: {tags}"
    },

    zoom: {
        'in': "Pietuvināt",
        out: "Attālināt"
    }
};
<|endoftext|>


<commit_before>OK = 'OK';
ERROR = 'ERROR';
FORWARD_TO_FIREHOSE_STREAM = "ForwardToFirehoseStream";
DDB_SERVICE_NAME = "aws:dynamodb";
KINESIS_SERVICE_NAME = "aws:kinesis";
FIREHOSE_MAX_BATCH_COUNT = 500;
// firehose max PutRecordBatch size 4MB
FIREHOSE_MAX_BATCH_BYTES = 4 * 1024 * 1024;
MAX_RETRY_ON_FAILED_PUT = 3;
RETRY_INTERVAL_MS = 300;
targetEncoding = "utf8";
<commit_msg>Override the retry related constants with env vars<commit_after>OK = 'OK';
ERROR = 'ERROR';
FORWARD_TO_FIREHOSE_STREAM = "ForwardToFirehoseStream";
DDB_SERVICE_NAME = "aws:dynamodb";
KINESIS_SERVICE_NAME = "aws:kinesis";
FIREHOSE_MAX_BATCH_COUNT = 500;
// firehose max PutRecordBatch size 4MB
FIREHOSE_MAX_BATCH_BYTES = 4 * 1024 * 1024;
MAX_RETRY_ON_FAILED_PUT = process.env['MAX_RETRY_ON_FAILED_PUT'] || 3;
RETRY_INTERVAL_MS = process.env['RETRY_INTERVAL_MS'] || 300;
targetEncoding = "utf8";
<|endoftext|>


<commit_before>/**
 * JavaScript Behaviors Library
 *
 * @copyright 2014 Stephen Riesenberg, All Rights Reserved
 * @author Dan Yoder <dan@zeraweb.com>
 * @author Stephen Riesenberg
 * @version 0.7
 * @license MIT
 * @link http://code.google.com/p/cruiser/wiki/Behaviors
 * @link https://github.com/sjohnr/behaviors.js
 */
var Behaviors = {
	load: function() {
		$A(document.getElementsByTagName("link"))
			.select(Behaviors.Stylesheet.test)
			.pluck("href")
			.map(Behaviors.process);
	},
	process: function(href) {
		Behaviors.Stylesheet.load(href);
	}
};

Behaviors.Stylesheet = {
	test: function(link) {
		return link.rel == "behaviors";
	},
	load: function(url) {
		new Ajax.Request(url, { method: "get", onSuccess: Behaviors.Stylesheet.process });
	},
	process: function(t) {
		var rules = Behaviors.Stylesheet.parse(t.responseText);
		$H(rules).each(function(r) {
			var elements = $$(r.key);
			var attributes = r.value;
			elements.each(function(e) {
				if (!e.binding) {
					e.binding = e;
				}
				$H(attributes).each(function(a) {
					var fn = Behaviors.Attributes[a.key.camelize()];
					try {
						fn ? fn(e, a.value, a.key) : null;
					} catch(ex) {
						if (window.console) {
							console.log(ex); console.log("@ " + r.key + " { " + a.key + ": " + a.value + "; }");
						}
					};
				});
			});
		});
	},
	parse: function(s) {
		return Behaviors.Stylesheet._parse(s).first();
	}
};

Behaviors.Translator = {
	style: function(attrs) {
		return attrs.inject({}, function(h, a) {
			h[a[0]] = a[1];

			return h;
		});
	},
	rules: function(rx) {
		return rx.inject({}, function(h, r) {
			if (r) {
				h[r[0]] = r[1];
			}

			return h;
		});
	},
	parse: function(rx) {
		return rx.inject({}, function(h, r) {
			for (var key in r) {
				h[key] = r[key];
			}

			return h;
		})
	}
};

Behaviors.Grammar = {};
(function() {
	var g = Behaviors.Grammar, s = Behaviors.Stylesheet, t = Behaviors.Translator, o = Parsing.Operators;

	// basic tokens
	g.lbrace = o.token("{");
	g.rbrace = o.token("}");
	g.lparen = o.token(/\(/);
	g.rparen = o.token(/\)/);
	g.colon = o.token(":");
	g.semicolon = o.token(";");
	// comments
	g.inlineComment = o.token(/\x2F\x2F[^\n]*\n/);
	g.multilineComment = o.token(/\x2F\x2A(.|\n)*?\x2A\x2F/);
	g.comments = o.ignore(o.any(g.inlineComment, g.multilineComment));
	// attributes
	g.attrName = o.token(/[\w\-\d]+/);
	g.attrValue = o.token(/[^;\}]+/);
	g.attr = o.pair(g.attrName, g.attrValue, g.colon);
	g.attrList = o.list(g.attr, g.semicolon, true);
	g.style = o.process(o.between(g.lbrace, g.attrList, g.rbrace), t.style);
	// style rules
	g.selector = o.token(/[^\{]+/);
	g.rule = o.any(g.comments, o.each(g.selector, g.style));
	g.rules = o.process(o.many(g.rule), t.rules);
	// parser
	s._parse = g.rules;
})();

Behaviors.Bindings = {};
(function() {
	/**
	 * Set the binding property of an object
	 *
	 * @param object
	 * @param target
	 */
	function bind(o, t) {
		o.binding = ((t instanceof Element) && t.binding) ? t.binding : t;
	}

	Object.extend(Behaviors.Bindings, {
		"new":      function(e, x) { bind(e, eval("new "+x+"(e)")); },
		"object":   function(e, x) { bind(e, eval(x)); },
		"select":   function(e, x) { bind(e, $$(x)[0]); },
		"up":       function(e, x) { bind(e, e.up(x)); },
		"down":     function(e, x) { bind(e, e.down(x)); },
		"previous": function(e, x) { bind(e, e.previous(x)); },
		"next":     function(e, x) { bind(e, e.next(x)); }
	});
})();

Behaviors.Relative = {};
(function() {
	/**
	 * adds relative attribute functions: minimum, maximum, equal
	 *
	 * @param element
	 * @param attribute
	 * @param selector
	 * @param comparator
	 */
	function apply(e1, a, s, c) {
		var e2 = $$(s)[0]; if (!e2) return;
		if (c(parseInt(e1.getStyle(a)), parseInt(e2.getStyle(a)))) {
			e1.style[a] = e2.getStyle(a) ;
		}
	}

	Object.extend(Behaviors.Relative, $H({
		minimum: function(a, b) {
			return a < b;
		},
		maximum: function(a, b) {
			return a > b;
		},
		equal: function(a, b) {
			return a == b;
		}
	}).inject({}, function(r, h) {
		return r[h.key] = apply.rcurry(h.value);
	}));
})();

Behaviors.Attributes = {};
(function() {
	/**
	 * Adds an event handler to the element: blur, change, click, etc.
	 *
	 * @param element
	 * @param fname
	 * @param handler
	 */
	function observe(e, v, h) {
		e.observe(h, e.binding[v].bind(e.binding));
	}

	/**
	 * Adds relative attributes: height, width ...
	 *
	 * @param element
	 * @param function
	 * @param attribute
	 */
	function relative(e, v, a) {
		var f = parseFunction(v);
		if (!f) {
			return;
		}
		var fname = f[1]; var s = f[2];
		var fn = Behaviors.Relative[fname];
		if (fn) {
			fn(e, a, s);
		}
	}

	function parseFunction(s) {
		return s.match(/(\w+)\s*\(\s*([^\)]+)\s*\)/);
	}

	var a = Object.extend(Behaviors.Attributes, {
		binding: function(e, v) {
			var f = parseFunction(v);
			if (!f) {
				return;
			}
			var fname = f[1], x = f[2];
			var fn = Behaviors.Bindings[fname];
			if (fn) {
				fn(e, x);
			}
		},
		load: function(e, v) {
			if (e.binding[v]) {
				e.binding[v](e);
			}
		},
		hasFocus: function(e, v) {
			v = v.toLowerCase();
			if (v == "true" || v == "yes") {
				e.focus();
			}
		}
	});

	$w("blur change click dblclick contextmenu focus keydown keypress keyup mousedown mousemove mouseout mouseover mouseup resize").each(function(s) {
		a[s] = observe.rcurry(s);
	});
	$w("height width").each(function(s) {
		a[s] = relative.rcurry(s);
	});
})();

Function.prototype.rcurry = function() {
	if (!arguments.length) {
		return this;
	}

	var __method = this, args = $A(arguments);
	return function() {
		return __method.apply(this, $A(arguments).concat(args));
	}
};

document.observe("dom:loaded", Behaviors.load);<commit_msg>Added comments to methods<commit_after>/**
 * JavaScript Behaviors Library
 *
 * @copyright 2014 Stephen Riesenberg, All Rights Reserved
 * @author Dan Yoder <dan@zeraweb.com>
 * @author Stephen Riesenberg
 * @version 0.7
 * @license MIT
 * @link http://code.google.com/p/cruiser/wiki/Behaviors
 * @link https://github.com/sjohnr/behaviors.js
 */
var Behaviors = {
	/**
	 * Load and process Behaviors Stylesheets.
	 */
	load: function() {
		$A(document.getElementsByTagName("link"))
			.select(Behaviors.Stylesheet.test)
			.pluck("href")
			.map(Behaviors.process);
	},
	/**
	 * Load an individual Behaviors Stylesheet file by URL.
	 */
	process: function(href) {
		Behaviors.Stylesheet.load(href);
	}
};

Behaviors.Stylesheet = {
	/**
	 * Determine if the given <link> element is a Behaviors Stylesheet.
	 *
	 * @param link A <link> element to test
	 */
	test: function(link) {
		return link.rel == "behaviors";
	},
	/**
	 * Load the contents of a Behaviors Styleseheet via Ajax
	 * and process the result.
	 *
	 * @param url The URL to load
	 */
	load: function(url) {
		new Ajax.Request(url, { method: "get", onSuccess: Behaviors.Stylesheet.process });
	},
	/**
	 * Process an Ajax response as a Behaviors Stylesheet.
	 *
	 * @param t The Ajax response object
	 */
	process: function(t) {
		var rules = Behaviors.Stylesheet.parse(t.responseText);
		$H(rules).each(function(r) {
			var elements = $$(r.key);
			var attributes = r.value;
			elements.each(function(e) {
				if (!e.binding) {
					e.binding = e;
				}
				$H(attributes).each(function(a) {
					var fn = Behaviors.Attributes[a.key.camelize()];
					try {
						fn ? fn(e, a.value, a.key) : null;
					} catch (ex) {
						if (window.console) {
							console.log(ex);
							console.log("@ " + r.key + " { " + a.key + ": " + a.value + "; }");
						}
					};
				});
			});
		});
	},
	/**
	 * Parse a Behaviors Stylesheet.
	 *
	 * @param s The contents of the stylesheet file
	 */
	parse: function(s) {
		return Behaviors.Stylesheet._parse(s).first();
	}
};

Behaviors.Translator = {
	/**
	 * Translate style attributes an associative array.
	 *
	 * @param attrs The attributes parse tree
	 */
	style: function(attrs) {
		return attrs.inject({}, function(h, a) {
			h[a[0]] = a[1];

			return h;
		});
	},
	/**
	 * Translate rules to an associative array.
	 *
	 * @param rx The rules parse tree
	 */
	rules: function(rx) {
		return rx.inject({}, function(h, r) {
			if (r) {
				h[r[0]] = r[1];
			}

			return h;
		});
	}
};

Behaviors.Grammar = {};
(function() {
	var g = Behaviors.Grammar, s = Behaviors.Stylesheet, t = Behaviors.Translator, o = Parsing.Operators;

	// basic tokens
	g.lbrace = o.token("{");
	g.rbrace = o.token("}");
	g.lparen = o.token(/\(/);
	g.rparen = o.token(/\)/);
	g.colon = o.token(":");
	g.semicolon = o.token(";");
	// comments
	g.inlineComment = o.token(/\x2F\x2F[^\n]*\n/);
	g.multilineComment = o.token(/\x2F\x2A(.|\n)*?\x2A\x2F/);
	g.comments = o.ignore(o.any(g.inlineComment, g.multilineComment));
	// attributes
	g.attrName = o.token(/[\w\-\d]+/);
	g.attrValue = o.token(/[^;\}]+/);
	g.attr = o.pair(g.attrName, g.attrValue, g.colon);
	g.attrList = o.list(g.attr, g.semicolon, true);
	g.style = o.process(o.between(g.lbrace, g.attrList, g.rbrace), t.style);
	// style rules
	g.selector = o.token(/[^\{]+/);
	g.rule = o.any(g.comments, o.each(g.selector, g.style));
	g.rules = o.process(o.many(g.rule), t.rules);
	// parser
	s._parse = g.rules;
})();

Behaviors.Bindings = {};
(function() {
	/**
	 * Set the binding property of an object
	 *
	 * @param object
	 * @param target
	 */
	function bind(o, t) {
		o.binding = ((t instanceof Element) && t.binding) ? t.binding : t;
	}

	Object.extend(Behaviors.Bindings, {
		"new":      function(e, x) { bind(e, eval("new "+x+"(e)")); },
		"object":   function(e, x) { bind(e, eval(x)); },
		"select":   function(e, x) { bind(e, $$(x)[0]); },
		"up":       function(e, x) { bind(e, e.up(x)); },
		"down":     function(e, x) { bind(e, e.down(x)); },
		"previous": function(e, x) { bind(e, e.previous(x)); },
		"next":     function(e, x) { bind(e, e.next(x)); }
	});
})();

Behaviors.Relative = {};
(function() {
	/**
	 * adds relative attribute functions: minimum, maximum, equal
	 *
	 * @param element
	 * @param attribute
	 * @param selector
	 * @param comparator
	 */
	function apply(e1, a, s, c) {
		var e2 = $$(s)[0]; if (!e2) return;
		if (c(parseInt(e1.getStyle(a)), parseInt(e2.getStyle(a)))) {
			e1.style[a] = e2.getStyle(a) ;
		}
	}

	Object.extend(Behaviors.Relative, $H({
		minimum: function(a, b) {
			return a < b;
		},
		maximum: function(a, b) {
			return a > b;
		},
		equal: function(a, b) {
			return a == b;
		}
	}).inject({}, function(r, h) {
		return r[h.key] = apply.rcurry(h.value);
	}));
})();

Behaviors.Attributes = {};
(function() {
	/**
	 * Adds an event handler to the element: blur, change, click, etc.
	 *
	 * @param element
	 * @param fname
	 * @param handler
	 */
	function observe(e, v, h) {
		e.observe(h, e.binding[v].bind(e.binding));
	}

	/**
	 * Adds relative attributes: height, width ...
	 *
	 * @param element
	 * @param function
	 * @param attribute
	 */
	function relative(e, v, a) {
		var f = parseFunction(v);
		if (!f) {
			return;
		}
		var fname = f[1]; var s = f[2];
		var fn = Behaviors.Relative[fname];
		if (fn) {
			fn(e, a, s);
		}
	}

	function parseFunction(s) {
		return s.match(/(\w+)\s*\(\s*([^\)]+)\s*\)/);
	}

	var a = Object.extend(Behaviors.Attributes, {
		binding: function(e, v) {
			var f = parseFunction(v);
			if (!f) {
				return;
			}
			var fname = f[1], x = f[2];
			var fn = Behaviors.Bindings[fname];
			if (fn) {
				fn(e, x);
			}
		},
		load: function(e, v) {
			if (e.binding[v]) {
				e.binding[v](e);
			}
		},
		hasFocus: function(e, v) {
			v = v.toLowerCase();
			if (v == "true" || v == "yes") {
				e.focus();
			}
		}
	});

	$w("blur change click dblclick contextmenu focus keydown keypress keyup mousedown mousemove mouseout mouseover mouseup resize").each(function(s) {
		a[s] = observe.rcurry(s);
	});
	$w("height width").each(function(s) {
		a[s] = relative.rcurry(s);
	});
})();

Function.prototype.rcurry = function() {
	if (!arguments.length) {
		return this;
	}

	var __method = this, args = $A(arguments);
	return function() {
		return __method.apply(this, $A(arguments).concat(args));
	}
};

document.observe("dom:loaded", Behaviors.load);<|endoftext|>


<commit_before>;(function() {
  var lastSavedURL;

  //cache a bunch of selectors
  var $composeView = $('.compose-view');
  var $shareView = $('.share-view');
  var $shareLink = $('.share-link');
  var $twitterLink = $('.tweet-btn');
  var $facebookLink = $('.fb-post-btn');
  var $headerImages = $('.header .images');
  var $composeView = $('.compose-view');
  var $shareView = $('.share-view');
  var $shareLink = $('.share-link');
  var $composeFrom = $('.compose-view .from');
  var $composeMessage = $('.compose-view .message');
  var $body = $('body');
  var expressionKeys = Object.keys(graphTemplates);

  var graphName = '';

  //move on to step 2 (share)
  var showShare = function () {
    $composeView.hide();
    $shareView.show();
    $body.removeClass('is-loading');
  };

  //go back to step 1 (compose)
  var showCompose = function () {
    $shareView.hide();
    $composeView.show();
    desmosGraph.resize();
  };

  var getLongUrl = function () {
    var urlBase =  window.location.origin + '/view';
    var message = encodeURIComponent($composeMessage.val());
    var from = encodeURIComponent($composeFrom.val());
    return urlBase.concat('?message=',message,'&from=',from,'&graph=',graphName);
  };

  //this is called once we have a short url from the google url-shortener
  var shareCallback = function(resp){
    shareLink = resp.id || getLongUrl();
    $shareLink.val(shareLink);
    var tweetUrl = "https://twitter.com/intent/tweet?text="
                 + encodeURIComponent("For my math lovers: a Desmos Math-o-gram! " + shareLink)
                 + "&via=desmos";
    var fbUrl = 'http://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(shareLink);
    $twitterLink.attr('href', tweetUrl);
    $facebookLink.attr('href', fbUrl);
    lastSavedURL = shareLink;
    showShare();
  };

  //this initiates a request to google to shorten the url
  var share = function(){
    $body.addClass('is-loading');
    var longUrl = getLongUrl();

    //use the google api to shorten, and call googleCallback
    var r = gapi.client.urlshortener.url.insert({'resource':{'longUrl': longUrl}})
    r.execute(shareCallback);
  };

  //this is the code that interacts with the graphpaper
  var clickToSetGraph = function() {
    $('.button.selected').removeClass('selected');
    $(this).addClass('selected');
    selectGraph($(this).attr('name'));
  };

  var selectGraph = function(name){
    desmosGraph.setState(graphTemplates[name]);
    graphName = name;
  };

  //Finally: let's execute some code!
  //First, instantiate a Desmos Graph
  var graphPaper = $('.graph-paper')[0];
  var options = {
    keypad: false,
    border: false,
    settingsMenu: false,
    zoomButtons: false
  };
  var desmosGraph = Desmos.Calculator(graphPaper, options);

  //Hook up our listeners
  $('.action-share').on('click', share);
  $('.action-create-another').on('click', showCompose)
  $shareLink.on('click', function() {this.select();});
  $('.button').on('click', clickToSetGraph);

  //set the state of the graph
  selectGraph('sierpinski');
  $body.removeClass('is-loading');
})()
<commit_msg>add hashtag<commit_after>;(function() {
  var lastSavedURL;

  //cache a bunch of selectors
  var $composeView = $('.compose-view');
  var $shareView = $('.share-view');
  var $shareLink = $('.share-link');
  var $twitterLink = $('.tweet-btn');
  var $facebookLink = $('.fb-post-btn');
  var $headerImages = $('.header .images');
  var $composeView = $('.compose-view');
  var $shareView = $('.share-view');
  var $shareLink = $('.share-link');
  var $composeFrom = $('.compose-view .from');
  var $composeMessage = $('.compose-view .message');
  var $body = $('body');
  var expressionKeys = Object.keys(graphTemplates);

  var graphName = '';

  //move on to step 2 (share)
  var showShare = function () {
    $composeView.hide();
    $shareView.show();
    $body.removeClass('is-loading');
  };

  //go back to step 1 (compose)
  var showCompose = function () {
    $shareView.hide();
    $composeView.show();
    desmosGraph.resize();
  };

  var getLongUrl = function () {
    var urlBase =  window.location.origin + '/view';
    var message = encodeURIComponent($composeMessage.val());
    var from = encodeURIComponent($composeFrom.val());
    return urlBase.concat('?message=',message,'&from=',from,'&graph=',graphName);
  };

  //this is called once we have a short url from the google url-shortener
  var shareCallback = function(resp){
    shareLink = resp.id || getLongUrl();
    $shareLink.val(shareLink);
    var tweetUrl = "https://twitter.com/intent/tweet?text="
                 + encodeURIComponent("For my math lovers: a Desmos #mathogram! " + shareLink)
                 + "&via=desmos";
    var fbUrl = 'http://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(shareLink);
    $twitterLink.attr('href', tweetUrl);
    $facebookLink.attr('href', fbUrl);
    lastSavedURL = shareLink;
    showShare();
  };

  //this initiates a request to google to shorten the url
  var share = function(){
    $body.addClass('is-loading');
    var longUrl = getLongUrl();

    //use the google api to shorten, and call googleCallback
    var r = gapi.client.urlshortener.url.insert({'resource':{'longUrl': longUrl}})
    r.execute(shareCallback);
  };

  //this is the code that interacts with the graphpaper
  var clickToSetGraph = function() {
    $('.button.selected').removeClass('selected');
    $(this).addClass('selected');
    selectGraph($(this).attr('name'));
  };

  var selectGraph = function(name){
    desmosGraph.setState(graphTemplates[name]);
    graphName = name;
  };

  //Finally: let's execute some code!
  //First, instantiate a Desmos Graph
  var graphPaper = $('.graph-paper')[0];
  var options = {
    keypad: false,
    border: false,
    settingsMenu: false,
    zoomButtons: false
  };
  var desmosGraph = Desmos.Calculator(graphPaper, options);

  //Hook up our listeners
  $('.action-share').on('click', share);
  $('.action-create-another').on('click', showCompose)
  $shareLink.on('click', function() {this.select();});
  $('.button').on('click', clickToSetGraph);

  //set the state of the graph
  selectGraph('sierpinski');
  $body.removeClass('is-loading');
})()
<|endoftext|>


<commit_before>#!/usr/bin/env node

var rimraf = require('rimraf')
var fs = require('fs')
var childProcess = require('child_process')
var walkSync = require('./')

rimraf.sync('benchmark.tmp')

var directories = 100, files = 1000
function createDirWithFiles(dir) {
  fs.mkdirSync(dir)
  for (var i = 0; i < files; i++) {
    fs.writeFileSync(dir + '/' + i, 'foo')
  }
}
console.log('Creating ' + (directories * files) + ' files across ' + directories + ' directories')
createDirWithFiles('benchmark.tmp')
for (var i = 0; i < directories - 1; i++) {
  createDirWithFiles('benchmark.tmp/dir' + i)
}
childProcess.spawnSync('sync')

console.time('walkSync')
walkSync('benchmark.tmp')
console.timeEnd('walkSync')

console.time('walkSync with **/* glob')
walkSync('benchmark.tmp', ['**/*'])
console.timeEnd('walkSync with **/* glob')

console.time('walkSync with **/*DOESNOTMATCH glob')
walkSync('benchmark.tmp', ['**/*DOESNOTMATCH'])
console.timeEnd('walkSync with **/*DOESNOTMATCH glob')

console.time('walkSync with DOESNOTMATCH*/** glob')
walkSync('benchmark.tmp', ['DOESNOTMATCH*/**'])
console.timeEnd('walkSync with DOESNOTMATCH*/** glob')

rimraf.sync('benchmark.tmp')
<commit_msg>Make benchmark more reliable by running 5 times<commit_after>#!/usr/bin/env node

var rimraf = require('rimraf')
var fs = require('fs')
var childProcess = require('child_process')
var walkSync = require('./')

rimraf.sync('benchmark.tmp')

var directories = 100, files = 1000
function createDirWithFiles(dir) {
  fs.mkdirSync(dir)
  for (var i = 0; i < files; i++) {
    fs.writeFileSync(dir + '/' + i, 'foo')
  }
}
console.log('Creating ' + (directories * files) + ' files across ' + directories + ' directories')
createDirWithFiles('benchmark.tmp')
for (var i = 0; i < directories - 1; i++) {
  createDirWithFiles('benchmark.tmp/dir' + i)
}
childProcess.spawnSync('sync')

console.time('walkSync')
for (i = 0; i < 5; i++) {
  walkSync('benchmark.tmp')
}
console.timeEnd('walkSync')

console.time('walkSync with **/* glob')
for (i = 0; i < 5; i++) {
  walkSync('benchmark.tmp', ['**/*'])
}
console.timeEnd('walkSync with **/* glob')

console.time('walkSync with **/*DOESNOTMATCH glob')
for (i = 0; i < 5; i++) {
  walkSync('benchmark.tmp', ['**/*DOESNOTMATCH'])
}
console.timeEnd('walkSync with **/*DOESNOTMATCH glob')

console.time('walkSync with DOESNOTMATCH*/** glob')
for (i = 0; i < 5; i++) {
  walkSync('benchmark.tmp', ['DOESNOTMATCH*/**'])
}
console.timeEnd('walkSync with DOESNOTMATCH*/** glob')

rimraf.sync('benchmark.tmp')
<|endoftext|>


<commit_before>(function () {
  'use strict';

  angular.module('RkyApp.directives')
    .directive('d3Bars', ['d3', function(d3) {
      return {
        restrict: 'EA',
        scope: {
          data: "=",
          label: "@",
          onClick: "&"
        },
        link: function(scope, iElement, iAttrs) {
          var svg = d3.select(iElement[0])
              .append("svg")
              .attr("width", "100%");

          // on window resize, re-render d3 canvas
          window.onresize = function() {
            return scope.$apply();
          };
          scope.$watch(function(){
              return angular.element(window)[0].innerWidth;
            }, function(){
              return scope.render(scope.data);
            }
          );

          // watch for data changes and re-render
          scope.$watch('data', function(newVals, oldVals) {
            return scope.render(newVals);
          }, true);

          // define render function
          scope.render = function(data){
            // remove all previous items before render
            svg.selectAll("*").remove();

            // setup variables
            var width, height, max;
            width = d3.select(iElement[0])[0][0].offsetWidth - 20;
              // 20 is for margins and can be changed
            height = scope.data.length * 35;
              // 35 = 30(bar height) + 5(margin between bars)
            max = 98;
              // this can also be found dynamically when the data is not static
              // max = Math.max.apply(Math, _.map(data, ((val)-> val.count)))

            // set the height based on the calculations above
            svg.attr('height', height);

            //create the rectangles for the bar chart
            svg.selectAll("rect")
              .data(data)
              .enter()
                .append("rect")
                .on("click", function(d, i){return scope.onClick({item: d});})
                .attr("height", 30) // height of each bar
                .attr("width", 0) // initial width of 0 for transition
                .attr("x", 10) // half of the 20 side margin specified above
                .attr("y", function(d, i){
                  return i * 35;
                }) // height + margin between bars
                .transition()
                  .duration(1000) // time of duration
                  .attr("width", function(d){
                    return d.value/(max/width);
                  }); // width based on scale

            svg.selectAll("text")
              .data(data)
              .enter()
                .append("text")
                .attr("fill", "#fff")
                .attr("y", function(d, i){return i * 35 + 22;})
                .attr("x", 15)
                .text(function(d){return d[scope.label];});

          };
        }
      };
    }]);

}());

// -- by e-Coucou

(function () {
  'use strict';

  angular.module('RkyApp.directives')
    .directive('d3Lines', ['d3', function(d3) {
      return {
        restrict: 'EA',
        scope: {
          data: "=",
          label: "@",
          moyn: "=",
          onClick: "&"
        },
        link: function(scope, iElement, iAttrs) {
          var svg = d3.select(iElement[0])
              .append("svg")
              .attr("width", "100%");

          // on window resize, re-render d3 canvas
          window.onresize = function() {
            return scope.$apply();
          };
          scope.$watch(function(){
              return angular.element(window)[0].innerWidth;
            }, function(){
              return scope.render(scope.data);
            }
          );

          // watch for data changes and re-render
          scope.$watch('data', function(newVals, oldVals) {
            return scope.render(newVals);
          }, true);
          // define render function
          scope.render = function(data,moyn){

            // setup variables
            var width, height, max,maxi, min,mini;
            var padding = 1;

            // accessor
            function x(d,i) { return i * (width / data.length);}
            function y(d) { return (height - (d.value-min)/((max-min)/height)); }
            function h(d) { return ((d.value-min)/((max-min)/height));}

            // fonction
            function info(d,i) {
              label.text(Math.round(d.value*100)/100) ;
              var datac = [ { "x" : x(d,i), "y" : 0 }, { "x" : x(d,i), "y" : height } ];
              d3.selectAll(".curseur").remove();
              svg.append("path")
                .datum(datac)
                .attr("class", "curseur")
                .attr("d", curseur);
              }
            // remove all previous items before render
            svg.selectAll("*").remove();

            height = d3.select(iElement[0])[0][0].offsetWidth - 20;
              // 20 is for margins and can be changed
            width = 900 ;//scope.data.length * 35;
            height = 400 ;
            if (data.length > 400 ) { padding = 0; } // no padding si trop de data
            maxi = Math.max.apply(Math, data.map(function(x) {return x.value; }));
            mini = Math.min.apply(Math, data.map(function(x) {return x.value; }));
            console.log("max: ",maxi,"min: ",mini, "moyenne: ",scope.moyn);

            max = maxi + 0.07 * (maxi-mini);
            min = mini - 0.15 * (maxi-mini);

            // set the height based on the calculations above
            svg.attr('height', height)
               .attr('width',  width);

// Add the year label; the value is set on transition.
var label = svg.append("text")
    .attr("class", "year label")
    .attr("text-anchor", "end")
    .attr("y", height - 24)
    .attr("x", width)
    .text('VALEUR');

var curseur = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

var repere_min = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

var repere_max = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

var repere_moy = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

            //create the rectangles for the bar chart
            svg.selectAll("rect")
              .data(data)
              .enter()
                .append("rect")
                .on("click", function(d, i){return scope.onClick({item: d});})
                .on("mouseover",function (d,i) { return info(d,i);})
                .attr("height", 0) // height of each bar
                .attr("width", width / data.length - padding)
                .attr("x", function(d,i) { return x(d, i);})  // height + margin between bars
                .attr("fill","yellow")
                .transition()
                  .duration(3000) // time of duration
                  .attr("stroke-width",0)
                  .attr("fill", function(d) {
                    var val = ((d.value -min)/((max-min)/16));
                    return "rgb(0, 0, " + val*16 + ")";
                    })
                  .attr("height", function (d) { return h(d); }) // half of the 20 side margin specified above
                  .attr("y", function (d) { return y(d);}); // width based on scale

            // position des repères
            var ordonne = height - (mini-min)/((max-min)/height);
            var datac = [ { "x" : 0, "y" : ordonne }, { "x" : width, "y" : ordonne } ];
            d3.selectAll(".repere_min").remove();
            svg.append("path")
              .datum(datac)
              .attr("class", "repere")
              .style("stroke-dasharray", ("10,5,2,5"))
              .attr("d", repere_min);
            ordonne = height - (maxi-min)/((max-min)/height);
            datac = [ { "x" : 0, "y" : ordonne }, { "x" : width, "y" : ordonne } ];
            d3.selectAll(".repere_max").remove();
            svg.append("path")
              .datum(datac)
              .attr("class", "repere")
              .style("stroke-dasharray", ("10,5,2,5"))
              .attr("d", repere_max);
            ordonne = height - (scope.moyn-min)/((max-min)/height);
            datac = [ { "x" : 0, "y" : ordonne }, { "x" : width, "y" : ordonne } ];
            d3.selectAll(".repere_moy").remove();
            svg.append("path")
              .datum(datac)
              .attr("class", "repere")
              .style("stroke-dasharray", ("10,5,2,5"))
              .attr("d", repere_moy);

            svg.selectAll("text")
              .data(data)
              .enter()
                .append("text")
                .attr("fill", "#fff")
                .attr("y", function(d, i){return i * 35 + 22;})
                .attr("x", 15)
                .text(function(d){return d[scope.label];});

          };
        }
      };
    }]);

}());<commit_msg>valeur<commit_after>(function () {
  'use strict';

  angular.module('RkyApp.directives')
    .directive('d3Bars', ['d3', function(d3) {
      return {
        restrict: 'EA',
        scope: {
          data: "=",
          label: "@",
          onClick: "&"
        },
        link: function(scope, iElement, iAttrs) {
          var svg = d3.select(iElement[0])
              .append("svg")
              .attr("width", "100%");

          // on window resize, re-render d3 canvas
          window.onresize = function() {
            return scope.$apply();
          };
          scope.$watch(function(){
              return angular.element(window)[0].innerWidth;
            }, function(){
              return scope.render(scope.data);
            }
          );

          // watch for data changes and re-render
          scope.$watch('data', function(newVals, oldVals) {
            return scope.render(newVals);
          }, true);

          // define render function
          scope.render = function(data){
            // remove all previous items before render
            svg.selectAll("*").remove();

            // setup variables
            var width, height, max;
            width = d3.select(iElement[0])[0][0].offsetWidth - 20;
              // 20 is for margins and can be changed
            height = scope.data.length * 35;
              // 35 = 30(bar height) + 5(margin between bars)
            max = 98;
              // this can also be found dynamically when the data is not static
              // max = Math.max.apply(Math, _.map(data, ((val)-> val.count)))

            // set the height based on the calculations above
            svg.attr('height', height);

            //create the rectangles for the bar chart
            svg.selectAll("rect")
              .data(data)
              .enter()
                .append("rect")
                .on("click", function(d, i){return scope.onClick({item: d});})
                .attr("height", 30) // height of each bar
                .attr("width", 0) // initial width of 0 for transition
                .attr("x", 10) // half of the 20 side margin specified above
                .attr("y", function(d, i){
                  return i * 35;
                }) // height + margin between bars
                .transition()
                  .duration(1000) // time of duration
                  .attr("width", function(d){
                    return d.value/(max/width);
                  }); // width based on scale

            svg.selectAll("text")
              .data(data)
              .enter()
                .append("text")
                .attr("fill", "#fff")
                .attr("y", function(d, i){return i * 35 + 22;})
                .attr("x", 15)
                .text(function(d){return d[scope.label];});

          };
        }
      };
    }]);

}());

// -- by e-Coucou

(function () {
  'use strict';

  angular.module('RkyApp.directives')
    .directive('d3Lines', ['d3', function(d3) {
      return {
        restrict: 'EA',
        scope: {
          data: "=",
          label: "@",
          moyn: "=",
          onClick: "&"
        },
        link: function(scope, iElement, iAttrs) {
          var svg = d3.select(iElement[0])
              .append("svg")
              .attr("width", "100%");

          // on window resize, re-render d3 canvas
          window.onresize = function() {
            return scope.$apply();
          };
          scope.$watch(function(){
              return angular.element(window)[0].innerWidth;
            }, function(){
              return scope.render(scope.data);
            }
          );

          // watch for data changes and re-render
          scope.$watch('data', function(newVals, oldVals) {
            return scope.render(newVals);
          }, true);
          // define render function
          scope.render = function(data,moyn){

            // setup variables
            var width, height, max,maxi, min,mini;
            var padding = 1;

            // accessor
            function x(d,i) { return i * (width / data.length);}
            function y(d) { return (height - (d.value-min)/((max-min)/height)); }
            function h(d) { return ((d.value-min)/((max-min)/height));}

            // fonction
            function info(d,i) {
              label.text(Math.round(d.value*100)/100) ;
              var datac = [ { "x" : x(d,i), "y" : 0 }, { "x" : x(d,i), "y" : height } ];
              d3.selectAll(".curseur").remove();
              svg.append("path")
                .datum(datac)
                .attr("class", "curseur")
                .attr("d", curseur);
              }
            // remove all previous items before render
            svg.selectAll("*").remove();

            height = d3.select(iElement[0])[0][0].offsetWidth - 20;
              // 20 is for margins and can be changed
            width = 900 ;//scope.data.length * 35;
            height = 400 ;
            if (data.length > 400 ) { padding = 0; } // no padding si trop de data
            maxi = Math.max.apply(Math, data.map(function(x) {return x.value; }));
            mini = Math.min.apply(Math, data.map(function(x) {return x.value; }));
            console.log("max: ",maxi,"min: ",mini, "moyenne: ",scope.moyn);

            max = maxi + 0.07 * (maxi-mini);
            min = mini - 0.15 * (maxi-mini);

            // set the height based on the calculations above
            svg.attr('height', height)
               .attr('width',  width);

// Add the year label; the value is set on transition.
var label = svg.append("text")
    .attr("class", "year label")
    .attr("text-anchor", "end")
    .attr("y",  100)
    .attr("x", width)
    .text('VALEUR');

var curseur = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

var repere_min = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

var repere_max = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

var repere_moy = d3.svg.line()
    .x(function(d) { return d.x; })
    .y(function(d) { return d.y; });

            //create the rectangles for the bar chart
            svg.selectAll("rect")
              .data(data)
              .enter()
                .append("rect")
                .on("click", function(d, i){return scope.onClick({item: d});})
                .on("mouseover",function (d,i) { return info(d,i);})
                .attr("height", 0) // height of each bar
                .attr("width", width / data.length - padding)
                .attr("x", function(d,i) { return x(d, i);})  // height + margin between bars
                .attr("fill","yellow")
                .transition()
                  .duration(3000) // time of duration
                  .attr("stroke-width",0)
                  .attr("fill", function(d) {
                    var val = ((d.value -min)/((max-min)/16));
                    return "rgb(0, 0, " + val*16 + ")";
                    })
                  .attr("height", function (d) { return h(d); }) // half of the 20 side margin specified above
                  .attr("y", function (d) { return y(d);}); // width based on scale

            // position des repères
            var ordonne = height - (mini-min)/((max-min)/height);
            var datac = [ { "x" : 0, "y" : ordonne }, { "x" : width, "y" : ordonne } ];
            d3.selectAll(".repere_min").remove();
            svg.append("path")
              .datum(datac)
              .attr("class", "repere")
              .style("stroke-dasharray", ("10,5,2,5"))
              .attr("d", repere_min);
            ordonne = height - (maxi-min)/((max-min)/height);
            datac = [ { "x" : 0, "y" : ordonne }, { "x" : width, "y" : ordonne } ];
            d3.selectAll(".repere_max").remove();
            svg.append("path")
              .datum(datac)
              .attr("class", "repere")
              .style("stroke-dasharray", ("10,5,2,5"))
              .attr("d", repere_max);
            ordonne = height - (scope.moyn-min)/((max-min)/height);
            datac = [ { "x" : 0, "y" : ordonne }, { "x" : width, "y" : ordonne } ];
            d3.selectAll(".repere_moy").remove();
            svg.append("path")
              .datum(datac)
              .attr("class", "repere")
              .style("stroke-dasharray", ("10,5,2,5"))
              .attr("d", repere_moy);

            svg.selectAll("text")
              .data(data)
              .enter()
                .append("text")
                .attr("fill", "#fff")
                .attr("y", function(d, i){return i * 35 + 22;})
                .attr("x", 15)
                .text(function(d){return d[scope.label];});

          };
        }
      };
    }]);

}());<|endoftext|>