<commit_before>/* Copyright G. Hemingway, 2015 - All rights reserved */
"use strict";

var http        = require('http'),
    path        = require('path'),
    _           = require('lodash'),
    opts        = require('commander'),
    winston     = require('winston'),
    configurator= require('./configurator'),

    file     = require('./api/v3/file.js');
/*****************************************************************************************/
var app;
//console.log(fileobj);
function CoreServer() {
    var pjson = require('../../package.json');
    opts
        .version(pjson.version)
        .option('-p, --port [port]', 'Port on which to run the server [8080]', '')
        .option('-c, --config [file]', 'Configuration File [./config/config.json]', './config/config.json')
        .option('-e, --environment [env]', 'Environment to use [development]', 'development')
        .option('-t, --tool [tool-file]', 'Machine tool file to use [""]', '')
        .option('-f, --file [filepath]', 'Step NC filepath to use [""]', '')
        .parse(process.argv);
    this.config = configurator(opts.config, opts.environment);
    this.port = opts.port || this.config.port || 8080;

    // set up machine tool option
    this.machinetool = opts.tool;

    // set up filepath option
    this.project = opts.filepath;
    file.init(opts.filepath, opts.tool);

    // Establish core
    this.models = {};
    this.controllers = {};
    this.logger = new winston.Logger({
        transports: [
            new (winston.transports.Console)({ level: 'debug' })
        ]
    });
    // Setup the rest of the primary infrastructure connections
}

CoreServer.prototype._setControllers = function() {
    this.controllers = {
//        Attachment:         require('./core/controllers/attachment')(this),
//        Comment:            require('./core/controllers/comment')(this),
//        Email:              require('./core/controllers/email')(this),
//        Group:              require('./core/controllers/group')(this),
//        Mailbox:            require('./core/controllers/mailbox')(this),
//        Member:             require('./core/controllers/member')(this),
//        Notification:       require('./core/controllers/notification')(this),
//        Permission:         require('./core/controllers/permission')(this),
//        Project:            require('./core/controllers/Project')(this),
//        Role:               require('./core/controllers/role')(this),
//        Search:             require('./core/controllers/search')(this),
//        Tool:               require('./core/controllers/tool')(this),
//        ToolInstance:       require('./core/controllers/tool_instance')(this),
//        User:               require('./core/controllers/user')(this)
    };
};

/*****************************************************************************************/

module.exports = CoreServer;<commit_msg>fixed my mistake<commit_after>/* Copyright G. Hemingway, 2015 - All rights reserved */
"use strict";

var http        = require('http'),
    path        = require('path'),
    _           = require('lodash'),
    opts        = require('commander'),
    winston     = require('winston'),
    configurator= require('./configurator'),

    file     = require('./api/v3/file.js');
/*****************************************************************************************/
var app;
//console.log(fileobj);
function CoreServer() {
    var pjson = require('../../package.json');
    opts
        .version(pjson.version)
        .option('-p, --port [port]', 'Port on which to run the server [8080]', '')
        .option('-c, --config [file]', 'Configuration File [./config/config.json]', './config/config.json')
        .option('-e, --environment [env]', 'Environment to use [development]', 'development')
        .option('-t, --tool [tool-file]', 'Machine tool file to use [""]', '')
        .option('-f, --file [filepath]', 'Step NC filepath to use [""]', '')
        .parse(process.argv);
    this.config = configurator(opts.config, opts.environment);
    this.port = opts.port || this.config.port || 8080;

    // set up machine tool option
    this.machinetool = opts.tool;

    // set up filepath option
    this.project = opts.file;
    file.init(opts.file, opts.tool);

    // Establish core
    this.models = {};
    this.controllers = {};
    this.logger = new winston.Logger({
        transports: [
            new (winston.transports.Console)({ level: 'debug' })
        ]
    });
    // Setup the rest of the primary infrastructure connections
}

CoreServer.prototype._setControllers = function() {
    this.controllers = {
//        Attachment:         require('./core/controllers/attachment')(this),
//        Comment:            require('./core/controllers/comment')(this),
//        Email:              require('./core/controllers/email')(this),
//        Group:              require('./core/controllers/group')(this),
//        Mailbox:            require('./core/controllers/mailbox')(this),
//        Member:             require('./core/controllers/member')(this),
//        Notification:       require('./core/controllers/notification')(this),
//        Permission:         require('./core/controllers/permission')(this),
//        Project:            require('./core/controllers/Project')(this),
//        Role:               require('./core/controllers/role')(this),
//        Search:             require('./core/controllers/search')(this),
//        Tool:               require('./core/controllers/tool')(this),
//        ToolInstance:       require('./core/controllers/tool_instance')(this),
//        User:               require('./core/controllers/user')(this)
    };
};

/*****************************************************************************************/

module.exports = CoreServer;<|endoftext|>


<commit_before>Shade.Scale.linear = function(opts)
{
    opts = _.defaults(opts || {}, {
        domain: [0, 1],
        range: [0, 1]
    });

    //////////////////////////////////////////////////////////////////////////
    // typechecking

    // that condition is written awkwardly so it catches
    // opts.domain === undefined as well.
    if (!(opts.domain.length >= 2)) {
        throw "Shade.Scale.linear requires arrays of length at least 2";
    }
    if (opts.domain.length !== opts.range.length) {
        throw "Shade.Scale.linear requires domain and range to be arrays of the same length";
    }

    opts.domain = _.map(opts.domain, Shade.make);
    opts.range = _.map(opts.range, Shade.make);

    var domain_types = _.map(opts.domain, function(v) { return v.type; });
    var range_types =  _.map(opts.range,  function(v) { return v.type; });
    var allowable_types = [
        Shade.Types.float_t,
        Shade.Types.vec2,
        Shade.Types.vec3,
        Shade.Types.vec4
    ];
    // if (!(domain_types[0].equals(Shade.Types.float_t)))
    //     throw "Shade.Scale.linear requires domain type to be float";
    if (!(_.any(allowable_types, function(v) { return v.equals(domain_types[0]); })))
        throw "Shade.Scale.linear requires domain type to be one of {float, vec2, vec3, vec4}";
    if (!(_.all(domain_types, function(v) { return v.equals(domain_types[0]); })))
        throw "Shade.Scale.linear requires domain elements to have the same type";
    if (!(_.any(allowable_types, function(v) { return v.equals(range_types[0]); })))
        throw "Shade.Scale.linear requires range type to be one of {float, vec2, vec3, vec4}";
    if (!(_.all(range_types, function(v) { return v.equals(range_types[0]); })))
        throw "Shade.Scale.linear requires range elements to have the same type";

    // Special-case the two-element scale for performance
    if (opts.domain.length === 2) {
        var f1 = opts.domain[0];
        var f2 = opts.domain[1];
        var t1 = opts.range[0];
        var t2 = opts.range[1];
        var df = Shade.sub(f2, f1);
        var dt = Shade.sub(t2, t1);

        return Shade(function(x) {
            return x.sub(f1).mul(dt.div(df)).add(t1);
        });
    } else {
        throw "Shade.Scale.linear unimplemented polylinear, sorry!";
    }
};
<commit_msg>polylinear scales<commit_after>Shade.Scale.linear = function(opts)
{
    opts = _.defaults(opts || {}, {
        domain: [0, 1],
        range: [0, 1]
    });

    //////////////////////////////////////////////////////////////////////////
    // typechecking

    // that condition is written awkwardly so it catches
    // opts.domain === undefined as well.
    if (!(opts.domain.length >= 2)) {
        throw "Shade.Scale.linear requires arrays of length at least 2";
    }
    if (opts.domain.length !== opts.range.length) {
        throw "Shade.Scale.linear requires domain and range to be arrays of the same length";
    }

    opts.domain = _.map(opts.domain, Shade.make);
    opts.range = _.map(opts.range, Shade.make);

    var domain_types = _.map(opts.domain, function(v) { return v.type; });
    var range_types =  _.map(opts.range,  function(v) { return v.type; });
    var allowable_types = [
        Shade.Types.float_t,
        Shade.Types.vec2,
        Shade.Types.vec3,
        Shade.Types.vec4
    ];
    // if (!(domain_types[0].equals(Shade.Types.float_t)))
    //     throw "Shade.Scale.linear requires domain type to be float";
    if (!(_.any(allowable_types, function(v) { return v.equals(domain_types[0]); })))
        throw "Shade.Scale.linear requires domain type to be one of {float, vec2, vec3, vec4}";
    if (!(_.all(domain_types, function(v) { return v.equals(domain_types[0]); })))
        throw "Shade.Scale.linear requires domain elements to have the same type";
    if (!(_.any(allowable_types, function(v) { return v.equals(range_types[0]); })))
        throw "Shade.Scale.linear requires range type to be one of {float, vec2, vec3, vec4}";
    if (!(_.all(range_types, function(v) { return v.equals(range_types[0]); })))
        throw "Shade.Scale.linear requires range elements to have the same type";

    // Special-case the two-element scale for performance
    if (opts.domain.length === 2) {
        var f1 = opts.domain[0];
        var f2 = opts.domain[1];
        var t1 = opts.range[0];
        var t2 = opts.range[1];
        var df = Shade.sub(f2, f1);
        var dt = Shade.sub(t2, t1);

        return Shade(function(x) {
            return x.sub(f1).mul(dt.div(df)).add(t1);
        });
    } else {
        var domain_array = Shade.array(opts.domain);
        var range_array = Shade.array(opts.range);

        return Shade(function(v) {
            var bs = domain_array.locate(v);
            var u = v.sub(bs("vl")).div(bs("vr").sub(bs("vl")));
            var color = Shade.mix(range_array.at(bs("l")), range_array.at(bs("r")), u);
            return color;
        });
    }
};
<|endoftext|>


<commit_before>let Nightmare = require('nightmare')
let vo = require('vo')
let fs = require('fs-extra')
let nightmare = Nightmare({
    electronPath: require('../../node_modules/electron')
})
let json2xls = require('json2xls');
let _ = require('lodash');

class Parser {
    constructor(ipc, app) {
        this.ipc = ipc
        this.app = app
        this.link = 'https://f.ua/shop/dlya-avtomobilya/'
        this.items = []
        this.filesDir = `${this.app.getPath('appData')}/scrabber/`;
        this.event = null;
        this.init()
    }

    init() {
        this.ipc.on('start-parse-f-ua', (event, arg) => {
            this.event = event.sender;
            this.returnJsonData().then((data) => {
                // console.log('using locally data', data)
                event.sender.send('f-ua-results', data)
            }).catch(err => {
                console.log('err: ', err);
                if (err.action) {
                    console.log('Starting parsing');
                    this.goThroughtCateogories().then(() => {
                        // console.log('parsing has been ended')
                        event.sender.send('f-ua-results', this.items)
                    }).catch(console.error)
                }
            })

        })

        this.ipc.on('export-to-excel', (event, arg) => {
            this.returnJsonData().then((jsonFile) => {
                const file = this.filesDir + 'f_ua.xlsx'
                const jsonData = _.flatten(jsonFile)

                jsonData.forEach((elem) => {
                    let title = elem.title.name
                    delete elem.title
                    elem.title = title
                })

                const xls = json2xls(_.flatten(jsonData))
                fs.writeFileSync(file, xls, 'binary')
                console.log('jsonFile: ', jsonFile);
            })
        })

    }

    goThroughtCateogories() {
        return this.getCategoriesLinks().then(this.getCategoriesData.bind(this))
    }

    returnJsonData() {
        const file = this.filesDir + 'f_ua.json'

        if (fs.existsSync(file)) {
            console.log('Using results data json file instead of parsing');
            return fs.readFile(file, 'utf-8').then(file => JSON.parse(file)).catch(console.error)
        }

        return Promise.reject({ action: true })
    }

    getCategoriesData(urls) {

        console.log('urls: ', urls);

        return urls.reduce((accumulator, url) => {
            return accumulator.then((results) => {
                return nightmare.goto(url.href)
                    .wait('body')
                    .evaluate((category) => {
                        let elementInfo = [];
                        let container = document.querySelectorAll('.wrapper .container')

                        container.forEach((item) => {
                            let titleInfo = { name: null, href: null };
                            let priceInfo = null;

                            titleInfo.name = item.querySelector('.title a').innerHTML
                            titleInfo.href = item.querySelector('.title a').href

                            let prices = item.querySelectorAll('.price div')

                            if (prices.length) {
                                prices.forEach((price) => {
                                    if (getComputedStyle(price).getPropertyValue('display') === 'block') {
                                        let elem = price.querySelector('span').firstChild.nodeValue
                                        let value = price.querySelector('span span').innerHTML.replace(' ', '')
                                        priceInfo = elem + ' ' + value
                                    }
                                })
                            }

                            if (item.querySelector('.price_block_container.no_product')) {
                                priceInfo = 'Нет в наличии'
                            }

                            elementInfo.push({
                                title: titleInfo,
                                price: priceInfo,
                                category
                            })

                        })

                        return elementInfo
                    }, url.name)
                    .then((result) => {
                        console.log('single result', result)
                        this.event.send('single-product', result)
                        this.items.push(result)
                    }).catch((err) => {
                        console.log('error while parsing product: ', err);
                    });
            });
        }, Promise.resolve([])).then(this.writeResult.bind(this)).catch(console.log)
    }

    writeResult() {
        fs.writeJson(this.filesDir + 'f_ua.json', this.items, err => {
            if (err) throw err
            console.log('Files has been written to ' + this.filesDir)
        })
    }

    saveCategoryLinks(data) {
        fs.writeJson(this.filesDir + 'categories.json', data, err => {
            if (err) throw err
            console.log('Files has been written to ' + this.filesDir)
        })
    }

    getCategoriesLinks() {
        const file = this.filesDir + 'categories.json';

        if (fs.existsSync(file)) {
            console.log('Using lcoally categories json file instead of parsing');
            return fs.readFile(file, 'utf-8').then(file => JSON.parse(file)).catch(console.error)
        }

        return fs.ensureFile(this.filesDir + 'categories.json').then((data) => {
            return nightmare
                .goto(this.link)
                .evaluate(() => {
                    var cats = [];
                    document.querySelectorAll('.subrubric_list .container .title a').forEach(element => {
                        cats.push({
                            href: element.href,
                            name: element.innerHTML
                        })
                    })
                    return cats
                })
                .end()
                .then((res) => {
                    this.saveCategoryLinks(res)
                    return res
                })
        }).catch(console.error)

    }

}

module.exports = Parser<commit_msg>added debug data<commit_after>let Nightmare = require('nightmare')
let vo = require('vo')
let fs = require('fs-extra')
let nightmare = Nightmare({
    electronPath: require('../../node_modules/electron')
})
let json2xls = require('json2xls');
let _ = require('lodash');

class Parser {
    constructor(ipc, app) {
        this.ipc = ipc
        this.app = app
        this.link = 'https://f.ua/shop/dlya-avtomobilya/'
        this.items = []
        this.filesDir = `${this.app.getPath('appData')}/scrabber/`;
        this.event = null;
        this.init()
    }

    init() {
        this.ipc.on('start-parse-f-ua', (event, arg) => {
            this.event = event.sender;
            this.returnJsonData().then((data) => {
                console.log('using locally data', data)
                event.sender.send('f-ua-results', data)
            }).catch(err => {
                console.log('err: ', err);
                if (err.action) {
                    console.log('Starting parsing');
                    this.goThroughtCateogories().then(() => {
                        console.log('parsing has been ended')
                        event.sender.send('f-ua-results', this.items)
                    }).catch(console.error)
                }
            })

        })

        this.ipc.on('export-to-excel', (event, arg) => {
            this.returnJsonData().then((jsonFile) => {
                const file = this.filesDir + 'f_ua.xlsx'
                const jsonData = _.flatten(jsonFile)

                jsonData.forEach((elem) => {
                    let title = elem.title.name
                    delete elem.title
                    elem.title = title
                })

                const xls = json2xls(_.flatten(jsonData))
                fs.writeFileSync(file, xls, 'binary')
            })
        })

    }

    goThroughtCateogories() {
        return this.getCategoriesLinks().then(this.getCategoriesData.bind(this))
    }

    returnJsonData() {
        const file = this.filesDir + 'f_ua.json'

        if (fs.existsSync(file)) {
            console.log('Using results data json file instead of parsing');
            return fs.readFile(file, 'utf-8').then(file => JSON.parse(file)).catch(console.error)
        }

        return Promise.reject({ action: true })
    }

    getCategoriesData(urls) {

        return urls.reduce((accumulator, url) => {
            return accumulator.then((results) => {
                return nightmare.goto(url.href)
                    .wait('body')
                    .evaluate((category) => {
                        let elementInfo = [];
                        let container = document.querySelectorAll('.wrapper .container')

                        container.forEach((item) => {
                            let titleInfo = { name: null, href: null };
                            let priceInfo = null;

                            titleInfo.name = item.querySelector('.title a').innerHTML
                            titleInfo.href = item.querySelector('.title a').href

                            let prices = item.querySelectorAll('.price div')

                            if (prices.length) {
                                prices.forEach((price) => {
                                    if (getComputedStyle(price).getPropertyValue('display') === 'block') {
                                        let elem = price.querySelector('span').firstChild.nodeValue
                                        let value = price.querySelector('span span').innerHTML.replace(' ', '')
                                        priceInfo = elem + ' ' + value
                                    }
                                })
                            }

                            if (item.querySelector('.price_block_container.no_product')) {
                                priceInfo = 'Нет в наличии'
                            }

                            elementInfo.push({
                                title: titleInfo,
                                price: priceInfo,
                                category
                            })

                        })

                        return elementInfo
                    }, url.name)
                    .then((result) => {
                        console.log('single result', result)
                        this.event.send('single-product', result)
                        this.items.push(result)
                    }).catch((err) => {
                        console.log('error while parsing product: ', err);
                    });
            });
        }, Promise.resolve([])).then(this.writeResult.bind(this)).catch(console.log)
    }

    writeResult() {
        fs.writeJson(this.filesDir + 'f_ua.json', this.items, err => {
            if (err) throw err
            console.log('Files has been written to ' + this.filesDir)
        })
    }

    saveCategoryLinks(data) {
        fs.writeJson(this.filesDir + 'categories.json', data, err => {
            if (err) throw err
            console.log('Files has been written to ' + this.filesDir)
        })
    }

    getCategoriesLinks() {
        const file = this.filesDir + 'categories.json';

        if (fs.existsSync(file)) {
            console.log('Using lcoally categories json file instead of parsing');
            return fs.readFile(file, 'utf-8').then(file => JSON.parse(file)).catch(console.error)
        }

        return fs.ensureFile(this.filesDir + 'categories.json').then((data) => {
            return nightmare
                .goto(this.link)
                .evaluate(() => {
                    var cats = [];
                    document.querySelectorAll('.subrubric_list .container .title a').forEach(element => {
                        cats.push({
                            href: element.href,
                            name: element.innerHTML
                        })
                    })
                    return cats
                })
                .end()
                .then((res) => {
                    this.saveCategoryLinks(res)
                    return res
                })
        }).catch(console.error)

    }

}

module.exports = Parser<|endoftext|>


<commit_before>import curry from 'lodash/function/curry';
import flow from 'lodash/function/flow';

import clamp from 'utils/clamp';

import player from 'state/models/player';
import { coordsToId } from 'state/utils/coordsToId';

const xOffsets = Object.freeze({
  left:  -1,
  right:  1,
});

const yOffsets = Object.freeze({
  up:   -1,
  down:  1,
});

export const type = 'MOVE';

// TODO: `memoize`
const terminalCell = curry((method, prop, collection) => {
  return collection[method]((item) => item.get(prop)).get(prop);
});
const minCol = terminalCell('minBy', 'col');
const maxCol = terminalCell('maxBy', 'col');
const minRow = terminalCell('minBy', 'row');
const maxRow = terminalCell('maxBy', 'row');

const clampToWorld = curry((grounds, col, row) => {
  return [
    clamp(minCol(grounds), maxCol(grounds), col),
    clamp(minRow(grounds), maxRow(grounds), row)
  ];
});

export function reduce(state, { direction }) {
  const xOffset = xOffsets[direction] || 0;
  const yOffset = yOffsets[direction] || 0;
  const row = player.getRow(state);
  const col = player.getCol(state);
  const grounds = state.get('grounds');
  const entities = state.get('entities');
  let [newCol, newRow] = clampToWorld(grounds, col + xOffset, row + yOffset);
  const id = coordsToId(newCol, newRow);
  const occupiers = [
    grounds.get(id),
    entities.get(id)
  ];
  return flow(
    player.setRow(newRow),
    player.setCol(newCol),
    player.setDirection(
      (direction in xOffsets) ?
      direction :
      player.getDirection(state)
    )
  )(state);
};

export function toMove(direction) {
  return { type, direction };
};
<commit_msg>Write collision stuff in move reducer<commit_after>import compact from 'lodash/array/compact';
import curry from 'lodash/function/curry';
import flow from 'lodash/function/flow';

import clamp from 'utils/clamp';

import player from 'state/models/player';
import { coordsToId } from 'state/utils/coordsToId';
import resetState from 'state/utils/resetState';

import {
  canBlock,
  canCollect,
  canDestroy,
  canDie,
  canKill,
  canWin
} from 'state/definitions/abilities';

const xOffsets = Object.freeze({
  left:  -1,
  right:  1,
});

const yOffsets = Object.freeze({
  up:   -1,
  down:  1,
});

export const type = 'MOVE';

// TODO: `memoize`
const terminalCell = curry((method, prop, collection) => {
  return collection[method]((item) => item.get(prop)).get(prop);
});
const minCol = terminalCell('minBy', 'col');
const maxCol = terminalCell('maxBy', 'col');
const minRow = terminalCell('minBy', 'row');
const maxRow = terminalCell('maxBy', 'row');

const clampToWorld = curry((grounds, col, row) => {
  return [
    clamp(minCol(grounds), maxCol(grounds), col),
    clamp(minRow(grounds), maxRow(grounds), row)
  ];
});

export function reduce(state, { direction }) {

  const dir = direction;
  const newDir = (dir in xOffsets) ? dir : player.getDirection(state);

  const xOffset = xOffsets[dir] || 0;
  const yOffset = yOffsets[dir] || 0;

  const row = player.getRow(state);
  const col = player.getCol(state);

  const [newCol, newRow] = clampToWorld(
    state.get('grounds'),
    col + xOffset,
    row + yOffset
  );

  const eKeypath = 'entities';
  const id = coordsToId(newCol, newRow);
  const entity = state.getIn([eKeypath, id]);
  const esOccupado = !!entity;
  const type = esOccupado && entity.get('type');

  const move           = (s) => player.setCoords(newCol, newRow, s);
  const moveBack       = (s) => player.setCoords(col, row, s);
  const orient         = (s) => player.setDirection(newDir, s);
  const win            = (s) => s.set('hasWon', true);
  const removeEntity   = (s) => s.deleteIn([eKeypath, id]);
  const incrementTapes = (s) => s.update('numTapes', (num) => num + 1);
  const addPowerup     = (s) => s.update('powerups', (ps) => ps.push(type));
  const reset          = (s) => resetState();
  const ghostify       = (s) => s.setIn([eKeypath, id, 'type'], 'ghost');
  const collect        = (s) => (type === 'tape') ? incrementTapes(s) : addPowerup(s);

  const whenEntity = curry((condition, update, s) => {
    return (esOccupado && condition(s, entity)) ? update(s) : s;
  });

  return flow(
    move,
    orient,
    whenEntity(canWin, win),
    whenEntity(canDestroy, removeEntity),
    whenEntity(canCollect, flow(removeEntity, collect)),
    whenEntity(canDie, ghostify),
    whenEntity(canBlock, moveBack),
    whenEntity(canKill, reset)
  )(state);

};

export function toMove(direction) {
  return { type, direction };
};
<|endoftext|>


<commit_before>/*
 * Copyright 2006 Matthew Eernisse (mde@fleegix.org)
 * and SitePoint Pty. Ltd, www.sitepoint.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/
if (typeof fleegix == 'undefined') { var fleegix = {}; }
fleegix.xhr = new function () {

  function spawnTransporter(isSync) {
    var i = 0;
    var t = [ // Array of XHR obj to try to invoke
      function () { return new XMLHttpRequest(); },
      function () { return new ActiveXObject('Msxml2.XMLHTTP') },
      function () { return new ActiveXObject('Microsoft.XMLHTTP' )} ];
    var trans = null;
    // Instantiate XHR obj
    while (!trans && (i < t.length)) {
      try { trans = t[i++](); }
      catch(e) {}
    }
    if (trans) {
      if (isSync) {
        return trans;
      }
      else {
        fleegix.xhr.transporters.push(trans);
        var transporterId = fleegix.xhr.transporters.length - 1;
        return transporterId;
      }
    }
    else {
      throw('Could not create XMLHttpRequest object.');
    }
  }

  // Public members
  // ================================
  // Array of XHR obj transporters, spawned as needed up to
  // maxTransporters ceiling
  this.transporters = [];
  // Maximum number of XHR objects to spawn to handle requests
  // IE6 and IE7 are shite for XHR re-use -- fortunately
  // copious numbers of XHR objs don't seem to be a problem
  // Moz/Safari perform significantly better with XHR re-use
  this.maxTransporters = document.all ? 500 : 5;
  // Used to increment request IDs -- these may be used for
  // externally tracking or aborting specific requests
  this.lastReqId = 0;
  // Queued-up requests -- appended to when all XHR transporters
  // are in use -- FIFO list, XHR objs respond to waiting
  // requests immediately as then finish processing the current one
  this.requestQueue = [];
  // List of free XHR objs -- transporters sit here when not
  // processing requests. If this is empty when a new request comes
  // in, we try to spawn a request -- if we're already at max
  // transporter number, we queue the request
  this.idleTransporters = [];
  // Hash of currently in-flight requests -- each string key is
  // the index pos in this.transporters of the XHR obj that's in use
  // Used to abort processing requests
  this.processing = {};
  // The single XHR obj used for synchronous requests -- sync
  // requests do not participate in the request pooling
  this.syncTransporter = spawnTransporter(true);

  // Public methods
  // ================================
  this.doGet = function () {
    var o = {};
    var hand = null;
    var args = Array.prototype.slice.apply(arguments);
    if (typeof args[0] == 'function') {
      o.async = true;
      hand = args.shift();
    }
    else {
      o.async = false;
    }
    var url = args.shift();
    var format = args.shift() || 'text';

    o.handleResp = hand;
    o.url = url;
    o.responseFormat = format;
    return this.doReq(o);
  };
  this.doPost = function () {
    var o = {};
    var hand = null;
    var args = Array.prototype.slice.apply(arguments);
    if (typeof args[0] == 'function') {
      o.async = true;
      hand = args.shift();
    }
    else {
      o.async = false;
    }
    var url = args.shift();
    var dataPayload = args.shift();
    var format = args.shift() || 'text';

    o.handleResp = hand;
    o.url = url;
    o.dataPayload = dataPayload;
    o.responseFormat = format;
    o.method = 'POST';
    return this.doReq(o);
  };
  this.doReq = function (o) {
    var opts = o || {};
    var req = new fleegix.xhr.Request();
    var transporterId = null;

    // Override default request opts with any specified
    for (var p in opts) {
      req[p] = opts[p];
    }

    this.lastReqId++; // Increment req ID
    req.id = this.lastReqId;

    // Return request ID or response
    // Async -- handle request or queue it up
    // -------
    if (req.async) {
      // If we have an instantiated XHR we can use, let him handle it
      if (this.idleTransporters.length) {
        transporterId = this.idleTransporters.shift();
      }
      // No available XHRs -- spawn a new one if we're still
      // below the limit
      else if (this.transporters.length < this.maxTransporters) {
        transporterId = spawnTransporter();
      }

      // If we have an XHR transporter to handle the request, do it
      // transporterId should be a number (index of XHR obj in this.transporters)
      if (transporterId != null) {
        this.processReq(transporterId, req);
      }
      // No transporter available to handle the request -- queue it up
      else {
        // Uber-requests step to the front of the line, please
        if (req.uber) {
          this.requestQueue.unshift(req);
        }
        // Normal queued requests are FIFO
        else {
          this.requestQueue.push(req);
        }
      }
      // Return request ID -- may be used for aborting,
      // external tracking, etc.
      return req.id;
    }
    // Sync -- do request inlne and return actual result
    // -------
    else {
        return this.processReq(this.syncTransporter, req);
    }
  };
  this.processReq = function (t, req) {
    var transporterId = null;
    var trans = null;
    var self = this;
    var resp = null;

    // Default err handler -- pop up full window with error
    // if request has no handler specifically defined
    function handleErrDefault(r) {
        var errorWin;
        // Create new window and display error
        try {
          errorWin = window.open('', 'errorWin');
          errorWin.document.body.innerHTML = r.responseText;
        }
        // If pop-up gets blocked, inform user
        catch(e) {
          alert('An error occurred, but the error message cannot be' +
          ' displayed because of your browser\'s pop-up blocker.\n' +
          'Please allow pop-ups from this Web site.');
        }
    }
    // Return desired type of response, text, xml, or raw obj.
    // Used both in the anonymous function for onreadystatechange
    // in async mode and in blocking mode
    function getResponseByType() {
        // Set the response according to the desired format
        switch(req.responseFormat) {
          // Text
          case 'text':
            r = trans.responseText;
            break;
          // XML
          case 'xml':
            r = trans.responseXML;
            break;
          // The object itself
          case 'object':
            r = trans;
            break;
        }
        return r;
    }

    // Async mode -- grab an XHR obj from the pool
    if (req.async) {
      transporterId = t;
      trans = this.transporters[transporterId];
      this.processing[transporterId] = trans;
    }
    // Sync mode -- use XHR transporter passed in
    else {
      trans = t;
    }
    // Set up the request
    // ==========================
    if (req.username && req.password) {
      trans.open(req.method, req.url, req.async, req.username, req.password);
    }
    else {
      trans.open(req.method, req.url, req.async);
    }
    // Override MIME type if necessary for Mozilla/Firefox & Safari
    if (req.mimeType && navigator.userAgent.indexOf('MSIE') == -1) {
      trans.overrideMimeType(req.mimeType);
    }

    // Add any custom headers that are defined
    if (req.headers.length) {
      // Set any custom headers
      for (var i = 0; i < req.headers.length; i++) {
        var headArr = req.headers[i].split(': ');
        trans.setRequestHeader(headArr[i], headArr[1]);
      }
    }
    // Otherwise set correct content-type for POST
    else {
      if (req.method == 'POST') {
        trans.setRequestHeader('Content-Type',
          'application/x-www-form-urlencoded');
      }
    }

    // Anonymous handler for async mode
    trans.onreadystatechange = function () {
      // When request completes
      if (trans.readyState == 4) {

        // Grab the desired response type
        resp = getResponseByType();

        // Request was successful -- execute response handler
        if (trans.status > 199 && trans.status < 300) {
          if (req.async) {
              // Make sure handler is defined
              if (!req.handleResp) {
                throw('No response handler defined ' +
                  'for this request');
                return;
              }
              else {
                req.handleResp(resp, req.id);
              }
          }
        }
        // Request failed -- execute error handler
        else {
          if (req.handleErr) {
            req.handleErr(resp);
          }
          else {
            handleErrDefault(trans);
          }
        }

        // Clean up, move immediately to respond to any
        // queued up requests
        if (req.async) {
          // Remove from list of transporters currently in use
          // this XHR can't be aborted until it's processing again
          delete self.processing[transporterId];

          // Requests queued up, grab one to respond to
          if (self.requestQueue.length) {
            var nextReq = self.requestQueue.shift();
            self.processReq(transporterId, nextReq);
          }
          // Otherwise this transporter is idle, waiting to respond
          else {
            self.idleTransporters.push(transporterId);
          }
        }
      }
    };

    // Send the request, along with any data for POSTing
    // ==========================
    trans.send(req.dataPayload);

    // Sync mode -- return actual result inline back to doReq
    if (!req.async) {
      resp = getResponseByType();
      return resp;
    }
  }
  this.abort = function (reqId) {
    // Abort the req if it's still processing
    var t = this.processing[reqId];
    if (t) {
      t.onreadystatechange = function () { };
      t.abort();
      return true;
    }
    else {
      return false;
    }
  };
};

fleegix.xhr.constructor = null;

fleegix.xhr.Request = function () {
  this.reqId = 0;
  this.url = null;
  this.status = null;
  this.statusText = '';
  this.method = 'GET';
  this.async = true;
  this.dataPayload = null;
  this.readyState = null;
  this.responseText = null;
  this.responseXML = null;
  this.handleResp = null;
  this.responseFormat = 'text', // 'text', 'xml', 'object'
  this.mimeType = null;
  this.username = '';
  this.password = '';
  this.headers = [];
  this.uber = false;
}
fleegix.xhr.Request.prototype.setRequestHeader = function (headerName, headerValue) {
  this.headers.push(headerName + ': ' + headerValue);
};

<commit_msg>More improvements for 0.2.1 release.<commit_after>/*
 * Copyright 2006 Matthew Eernisse (mde@fleegix.org)
 * and SitePoint Pty. Ltd, www.sitepoint.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
*/
if (typeof fleegix == 'undefined') { var fleegix = {}; }
fleegix.xhr = new function () {

  function spawnTransporter(isSync) {
    var i = 0;
    var t = [ // Array of XHR obj to try to invoke
      function () { return new XMLHttpRequest(); },
      function () { return new ActiveXObject('Msxml2.XMLHTTP') },
      function () { return new ActiveXObject('Microsoft.XMLHTTP' )} ];
    var trans = null;
    // Instantiate XHR obj
    while (!trans && (i < t.length)) {
      try { trans = t[i++](); }
      catch(e) {}
    }
    if (trans) {
      if (isSync) {
        return trans;
      }
      else {
        fleegix.xhr.transporters.push(trans);
        var transporterId = fleegix.xhr.transporters.length - 1;
        return transporterId;
      }
    }
    else {
      throw('Could not create XMLHttpRequest object.');
    }
  }

  // Public members
  // ================================
  // Array of XHR obj transporters, spawned as needed up to
  // maxTransporters ceiling
  this.transporters = [];
  // Maximum number of XHR objects to spawn to handle requests
  // IE6 and IE7 are shite for XHR re-use -- fortunately
  // copious numbers of XHR objs don't seem to be a problem
  // Moz/Safari perform significantly better with XHR re-use
  this.maxTransporters = document.all ? 500 : 5;
  // Used to increment request IDs -- these may be used for
  // externally tracking or aborting specific requests
  this.lastReqId = 0;
  // Queued-up requests -- appended to when all XHR transporters
  // are in use -- FIFO list, XHR objs respond to waiting
  // requests immediately as then finish processing the current one
  this.requestQueue = [];
  // List of free XHR objs -- transporters sit here when not
  // processing requests. If this is empty when a new request comes
  // in, we try to spawn a request -- if we're already at max
  // transporter number, we queue the request
  this.idleTransporters = [];
  // Hash of currently in-flight requests -- each string key is
  // the index pos in this.transporters of the XHR obj that's in use
  // Used to abort processing requests
  this.processing = {};
  // The single XHR obj used for synchronous requests -- sync
  // requests do not participate in the request pooling
  this.syncTransporter = spawnTransporter(true);

  // Public methods
  // ================================
  this.doGet = function () {
    var o = {};
    var hand = null;
    var args = Array.prototype.slice.apply(arguments);
    if (typeof args[0] == 'function') {
      o.async = true;
      hand = args.shift();
    }
    else {
      o.async = false;
    }
    var url = args.shift();
    // Passing in keyword/obj after URL
    if (typeof args[0] == 'object') {
      var opts = args.shift();
      for (var p in opts) {
        o[p] = opts[p];
      }
    }
    // Normal order-based params of URL, [responseFormat]
    else {
      o.responseFormat = args.shift() || 'text';
    }
    o.handleSuccess = hand;
    o.url = url;
    return this.doReq(o);
  };
  this.doPost = function () {
    var o = {};
    var hand = null;
    var args = Array.prototype.slice.apply(arguments);
    if (typeof args[0] == 'function') {
      o.async = true;
      hand = args.shift();
    }
    else {
      o.async = false;
    }
    var url = args.shift();
    var dataPayload = args.shift();
    // Passing in keyword/obj after URL
    if (typeof args[0] == 'object') {
      var opts = args.shift();
      for (var p in opts) {
        o[p] = opts[p];
      }
    }
    // Normal order-based params of URL, [responseFormat]
    else {
      o.responseFormat = args.shift() || 'text';
    }
    o.handleSuccess = hand;
    o.url = url;
    o.dataPayload = dataPayload;
    o.method = 'POST';
    return this.doReq(o);
  };
  this.doReq = function (o) {
    var opts = o || {};
    var req = new fleegix.xhr.Request();
    var transporterId = null;

    // Override default request opts with any specified
    for (var p in opts) {
      req[p] = opts[p];
    }

    this.lastReqId++; // Increment req ID
    req.id = this.lastReqId;

    // Return request ID or response
    // Async -- handle request or queue it up
    // -------
    if (req.async) {
      // If we have an instantiated XHR we can use, let him handle it
      if (this.idleTransporters.length) {
        transporterId = this.idleTransporters.shift();
      }
      // No available XHRs -- spawn a new one if we're still
      // below the limit
      else if (this.transporters.length < this.maxTransporters) {
        transporterId = spawnTransporter();
      }

      // If we have an XHR transporter to handle the request, do it
      // transporterId should be a number (index of XHR obj in this.transporters)
      if (transporterId != null) {
        this.processReq(transporterId, req);
      }
      // No transporter available to handle the request -- queue it up
      else {
        // Uber-requests step to the front of the line, please
        if (req.uber) {
          this.requestQueue.unshift(req);
        }
        // Normal queued requests are FIFO
        else {
          this.requestQueue.push(req);
        }
      }
      // Return request ID -- may be used for aborting,
      // external tracking, etc.
      return req.id;
    }
    // Sync -- do request inlne and return actual result
    // -------
    else {
        return this.processReq(this.syncTransporter, req);
    }
  };
  this.processReq = function (t, req) {
    var self = this;
    var transporterId = null;
    var trans = null;
    var url = '';
    var resp = null;

    // Return desired type of response, text, xml, or raw obj.
    // Used both in the anonymous function for onreadystatechange
    // in async mode and in blocking mode
    function getResponseByType() {
        // Set the response according to the desired format
        switch(req.responseFormat) {
          // Text
          case 'text':
            r = trans.responseText;
            break;
          // XML
          case 'xml':
            r = trans.responseXML;
            break;
          // The object itself
          case 'object':
            r = trans;
            break;
        }
        return r;
    }

    // Async mode -- grab an XHR obj from the pool
    if (req.async) {
      transporterId = t;
      trans = this.transporters[transporterId];
      this.processing[transporterId] = trans;
    }
    // Sync mode -- use XHR transporter passed in
    else {
      trans = t;
    }

    if (req.preventCache) {
      var dt = new Date.getTime();
      url = req.url.indexOf('?') > -1 ? req.url + '&preventCache=' + dt :
        req.url + '?preventCache=' + dt;
    }
    else {
      url = req.url;
    }

    // Set up the request
    // ==========================
    if (req.username && req.password) {
      trans.open(req.method, url, req.async, req.username, req.password);
    }
    else {
      trans.open(req.method, url, req.async);
    }
    // Override MIME type if necessary for Mozilla/Firefox & Safari
    if (req.mimeType && navigator.userAgent.indexOf('MSIE') == -1) {
      trans.overrideMimeType(req.mimeType);
    }

    // Add any custom headers that are defined
    if (req.headers.length) {
      // Set any custom headers
      for (var i = 0; i < req.headers.length; i++) {
        var headArr = req.headers[i].split(': ');
        trans.setRequestHeader(headArr[i], headArr[1]);
      }
    }
    // Otherwise set correct content-type for POST
    else {
      if (req.method == 'POST') {
        trans.setRequestHeader('Content-Type',
          'application/x-www-form-urlencoded');
      }
    }

    // Anonymous handler for async mode
    trans.onreadystatechange = function () {
      // When request completes
      if (trans.readyState == 4) {

        // Grab the desired response type
        resp = getResponseByType();

        // If we have a One True Event Handler, use that
        if (req.handleAll) {
          req.handleAll(resp, req.id);
        }
        // Otherwise it's split between success/failure
        else {
          // Request was successful -- execute response handler
          if (trans.status > 199 && trans.status < 300) {
            // Make sure handler is defined
            if (!req.handleSuccess) {
              throw('No response handler defined ' +
                'for this request');
              return;
            }
            else {
              req.handleSuccess(resp, req.id);
            }
          }
          // Request failed -- execute error handler
          else {
            if (req.handleErr) {
              req.handleErr(resp, req.id);
            }
            else {
              fleegix.xhr.handleErrDefault(trans);
            }
          }
        }

        // Clean up, move immediately to respond to any
        // queued up requests
        if (req.async) {
          // Remove from list of transporters currently in use
          // this XHR can't be aborted until it's processing again
          delete self.processing[transporterId];

          // Requests queued up, grab one to respond to
          if (self.requestQueue.length) {
            var nextReq = self.requestQueue.shift();
            self.processReq(transporterId, nextReq);
          }
          // Otherwise this transporter is idle, waiting to respond
          else {
            self.idleTransporters.push(transporterId);
          }
        }
      }
    };

    // Send the request, along with any data for POSTing
    // ==========================
    trans.send(req.dataPayload);

    // Sync mode -- return actual result inline back to doReq
    if (!req.async) {
      resp = getResponseByType();
      return resp;
    }
  }
  this.abort = function (reqId) {
    // Abort the req if it's still processing
    var t = this.processing[reqId];
    if (t) {
      t.onreadystatechange = function () { };
      t.abort();
      return true;
    }
    else {
      return false;
    }
  };
};

fleegix.xhr.constructor = null;

fleegix.xhr.Request = function () {
  this.reqId = 0;
  this.url = null;
  this.status = null;
  this.statusText = '';
  this.method = 'GET';
  this.async = true;
  this.dataPayload = null;
  this.readyState = null;
  this.responseText = null;
  this.responseXML = null;
  this.handleAll = null;
  this.handleSuccess = null;
  this.handleErr = null;
  this.responseFormat = 'text', // 'text', 'xml', 'object'
  this.mimeType = null;
  this.username = '';
  this.password = '';
  this.headers = [];
  this.preventCache = false;
  this.uber = false;
}
fleegix.xhr.Request.prototype.setRequestHeader = function (headerName, headerValue) {
  this.headers.push(headerName + ': ' + headerValue);
};

// Default err handler -- pop up full window with error
// if request has no handler specifically defined
fleegix.xhr.handleErrDefault = function (r) {
    var errorWin;
    // Create new window and display error
    try {
      errorWin = window.open('', 'errorWin');
      errorWin.document.body.innerHTML = r.responseText;
    }
    // If pop-up gets blocked, inform user
    catch(e) {
      alert('An error occurred, but the error message cannot be' +
      ' displayed because of your browser\'s pop-up blocker.\n' +
      'Please allow pop-ups from this Web site.');
    }
};

<|endoftext|>


<commit_before>// # MongoDB Database Configuration

// ##### [Back to Table of Contents](./tableofcontents.html)
var mongoose = require('mongoose');

// Currently configured for deployment. Change to this for development:
// mongoose.connect('mongodb://127.0.0.1');
mongoose.connect(process.env.MONGOLAB_URI);

var db = mongoose.connection;

db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function(cb) {
  console.log('connected to db');
});

// Required by [Mongoose Board Model](../documentation/board.html)
module.exports = db;
<commit_msg>(fix) adjust db for local testing<commit_after>// # MongoDB Database Configuration

// ##### [Back to Table of Contents](./tableofcontents.html)
var mongoose = require('mongoose');

// Currently configured for deployment. Change to this for development:
mongoose.connect('mongodb://127.0.0.1');
// mongoose.connect(process.env.MONGOLAB_URI);

var db = mongoose.connection;

db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function(cb) {
  console.log('connected to db');
});

// Required by [Mongoose Board Model](../documentation/board.html)
module.exports = db;
<|endoftext|>


<commit_before>$.extend(true, doaj, {

    adminJournalsSearch : {
        activeEdges : {},

        makeContinuation : function (val, resultobj, renderer) {
            if (!resultobj.suggestion && !resultobj.bibjson.journal) {
                // if it's not a suggestion or an article .. (it's a
                // journal!)
                // we really need to expose _type ...
                var result = '
Make a preceding continuation';

                result += 'Make a succeeding continuation';

                return result;
            }
            return false;
        },

        relatedApplications : function (val, resultobj, renderer) {
            var result = "";
            if (resultobj.admin) {
                if (resultobj.admin.current_application) {
                    var fvurl = doaj.adminJournalsSearchConfig.applicationsUrl + '?source=%7B"query"%3A%7B"query_string"%3A%7B"query"%3A"' + resultobj.admin.current_application + '"%2C"default_operator"%3A"AND"%7D%7D%2C"from"%3A0%2C"size"%3A10%7D';
                    result += "Current Update Request: " + edges.escapeHtml(resultobj.admin.current_application) + "";
                }
                if (resultobj.admin.related_applications && resultobj.admin.related_applications.length > 0) {
                    if (result != "") {
                        result += "
";
                    }
                    result += "Related Records: ";
                    for (var i = 0; i < resultobj.admin.related_applications.length; i++) {
                        if (i > 0) {
                            result += ", ";
                        }
                        var ra = resultobj.admin.related_applications[i];
                        var fvurl = doaj.adminJournalsSearchConfig.applicationsUrl + '?source=%7B"query"%3A%7B"query_string"%3A%7B"query"%3A"' + ra.application_id + '"%2C"default_operator"%3A"AND"%7D%7D%2C"from"%3A0%2C"size"%3A10%7D';
                        var linkName = ra.date_accepted;
                        if (!linkName) {
                            linkName = ra.application_id;
                        }
                        result += "" + linkName + "";
                    }
                }
            }
            return result;
        },

        init : function(params) {
            if (!params) { params = {} }

            var current_domain = document.location.host;
            var current_scheme = window.location.protocol;

            var selector = params.selector || "#admin_journals";
            var search_url = current_scheme + "//" + current_domain + doaj.adminJournalsSearchConfig.searchPath;

            var countFormat = edges.numFormat({
                thousandsSeparator: ","
            });

            var components = [
                edges.newSearchingNotification({
                    id: "searching-notification",
                    finishedEvent: "edges:post-render",
                    renderer : doaj.renderers.newSearchingNotificationRenderer()
                }),

                // facets
                doaj.facets.inDOAJ(),
                edges.newRefiningANDTermSelector({
                    id: "has_seal",
                    category: "facet",
                    field: "index.has_seal.exact",
                    display: "DOAJ Seal",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "owner",
                    category: "facet",
                    field: "admin.owner.exact",
                    display: "Owner",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "has_editor_group",
                    category: "facet",
                    field: "index.has_editor_group.exact",
                    display: "Has Editor Group?",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "has_associate_editor",
                    category: "facet",
                    field: "index.has_editor.exact",
                    display: "Has Associate Editor?",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "editor_group",
                    category: "facet",
                    field: "admin.editor_group.exact",
                    display: "Editor Group",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "associate_editor",
                    category: "facet",
                    field: "admin.editor.exact",
                    display: "Associate Editor",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),

                edges.newRefiningANDTermSelector({
                    id: "author_pays",
                    category: "facet",
                    field: "index.has_apc.exact",
                    display: "Publication charges?",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),

                edges.newRefiningANDTermSelector({
                    id: "journal_license",
                    category: "facet",
                    field: "index.license.exact",
                    display: "Journal License",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "publisher",
                    category: "facet",
                    field: "bibjson.publisher.name.exact",
                    display: "Publisher",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "classification",
                    category: "facet",
                    field: "index.classification.exact",
                    display: "Classification",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "subject",
                    category: "facet",
                    field: "index.subject.exact",
                    display: "Subject",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "journal_language",
                    category: "facet",
                    field: "index.language.exact",
                    display: "Journal Language",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "country_publisher",
                    category: "facet",
                    field: "index.country.exact",
                    display: "Country of publisher",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "continued",
                    category: "facet",
                    field: "index.continued.exact",
                    display: "Continued",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newDateHistogramSelector({
                    id: "discontinued_date",
                    category: "facet",
                    field : "bibjson.discontinued_date",
                    interval: "year",
                    display: "Discontinued Year",
                    displayFormatter : function(val) {
                        return (new Date(parseInt(val))).getUTCFullYear();
                    },
                    sortFunction : function(values) {
                        values.reverse();
                        return values;
                    },
                    renderer: edges.bs3.newDateHistogramSelectorRenderer({
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),

                // configure the search controller
                edges.newFullSearchController({
                    id: "search-controller",
                    category: "controller",
                    sortOptions: [
                        {'display':'Date added to DOAJ','field':'created_date'},
                        {'display':'Last updated','field':'last_manual_update'}, // Note: last updated on UI points to when last updated by a person (via form)
                        {'display':'Title','field':'index.unpunctitle.exact'}
                    ],
                    fieldOptions: [
                        {'display':'Owner','field':'admin.owner'},
                        {'display':'Title','field':'index.title'},
                        {'display':'Alternative Title','field':'bibjson.alternative_title'},
                        {'display':'Subject','field':'index.subject'},
                        {'display':'Classification','field':'index.classification'},
                        {'display':'ISSN', 'field':'index.issn.exact'},
                        {'display':'Country of publisher','field':'index.country'},
                        {'display':'Journal Language','field':'index.language'},
                        {'display':'Publisher','field':'bibjson.publisher.name'}
                    ],
                    defaultOperator: "AND",
                    renderer: doaj.renderers.newFullSearchControllerRenderer({
                        freetextSubmitDelay: -1,
                        searchButton: true,
                        searchPlaceholder: "Search All Journals"
                    })
                }),

                // the pager, with the explicitly set page size options (see the openingQuery for the initial size)
                edges.newPager({
                    id: "top-pager",
                    category: "top-pager",
                    renderer: edges.bs3.newPagerRenderer({
                        sizeOptions: [10, 25, 50, 100],
                        numberFormat: countFormat,
                        scroll: false
                    })
                }),
                edges.newPager({
                    id: "bottom-pager",
                    category: "bottom-pager",
                    renderer: edges.bs3.newPagerRenderer({
                        sizeOptions: [10, 25, 50, 100],
                        numberFormat: countFormat,
                        scroll: false
                    })
                }),

                // results display
                edges.newResultsDisplay({
                    id: "results",
                    category: "results",
                    renderer: edges.bs3.newResultsFieldsByRowRenderer({
                        rowDisplay : [
                            [
                                {
                                    valueFunction: doaj.fieldRender.titleField
                                }
                            ],
                            [
                                {
                                   valueFunction: doaj.fieldRender.editJournal({editUrl: doaj.adminJournalsSearchConfig.journalEditUrl})
                                }
                            ],
                            [
                                {
                                    "pre": 'Alternative title: ',
                                    "field": "bibjson.alternative_title",
                                    "post": ""
                                }
                            ],
                            [
                                {
                                    "pre" : "In DOAJ?: ",
                                    valueFunction: doaj.fieldRender.inDoaj
                                }
                            ],
                            [
                                {
                                    "pre" : "Owner: ",
                                    valueFunction: doaj.fieldRender.owner
                                }
                            ],
                            [
                                {
                                    "pre" : "Editor Group: ",
                                    "field" : "admin.editor_group"
                                }
                            ],
                            [
                                {
                                    "pre" : "ISSN(s): ",
                                    valueFunction : doaj.fieldRender.issns
                                }
                            ],
                            [
                                {
                                    "pre": "Discontinued Date: ",
                                    "field": "bibjson.discontinued_date"
                                }
                            ],
                            [
                                {
                                    "pre": "Date added to DOAJ: ",
                                    valueFunction: doaj.fieldRender.createdDateWithTime
                                }
                            ],
                            [
                                {
                                    "pre": "Last updated: ",
                                    valueFunction: doaj.fieldRender.lastManualUpdate
                                }
                            ],
                            [
                                {
                                    valueFunction: doaj.fieldRender.links
                                }
                            ],
                            [
                                {
                                    "pre": "License: ",
                                    valueFunction: doaj.fieldRender.journalLicense
                                }
                            ],
                            [
                                {
                                    "pre": "Publisher: ",
                                    "field": "bibjson.publisher.name"
                                }
                            ],
                            [
                                {
                                    "pre": "Publication charges?: ",
                                    valueFunction: doaj.fieldRender.authorPays
                                }
                            ],
                            [
                                {
                                    "pre": "Classification: ",
                                    "field": "index.classification"
                                }
                            ],
                            [
                                {
                                    "pre": "Keywords: ",
                                    "field": "bibjson.keywords"
                                }
                            ],
                            [
                                {
                                    "pre": "Country: ",
                                    valueFunction: doaj.fieldRender.countryName
                                }
                            ],
                            [
                                {
                                    "pre": "Language: ",
                                    "field": "bibjson.language"
                                }
                            ],
                            [
                                {
                                    valueFunction: doaj.adminJournalsSearch.relatedApplications
                                }
                            ],
                            [
                                {
                                    valueFunction: doaj.adminJournalsSearch.makeContinuation
                                }
                            ]
                        ]
                    })
                }),

                // selected filters display, with all the fields given their display names
                edges.newSelectedFilters({
                    id: "selected-filters",
                    category: "selected-filters",
                    fieldDisplays: {
                        "admin.in_doaj" : "In DOAJ?",
                        "index.has_seal.exact" : "DOAJ Seal",
                        "admin.owner.exact" : "Owner",
                        "index.has_editor_group.exact" : "Has Editor Group?",
                        "index.has_editor.exact" : "Has Associate Editor?",
                        "admin.editor_group.exact" : "Editor Group",
                        "admin.editor.exact" : "Associate Editor",
                        "index.license.exact" : "Journal License",
                        "bibjson.publisher.name.exact" : "Publisher",
                        "index.classification.exact" : "Classification",
                        "index.subject.exact" : "Subject",
                        "index.language.exact" : "Journal Language",
                        "index.country.exact" : "Country of publisher",
                        "index.continued.exact" : "Continued",
                        "bibjson.discontinued_date" : "Discontinued Year",
                        "index.has_apc.exact" : "Publication charges?"
                    },
                    valueMaps : {
                        "admin.in_doaj" : {
                            true : "True",
                            false : "False"
                        }
                    },
                    rangeFunctions : {
                        "bibjson.discontinued_date" : doaj.valueMaps.displayYearPeriod
                    }
                })
            ];

            var e = edges.newEdge({
                selector: selector,
                template: edges.bs3.newFacetview(),
                search_url: search_url,
                manageUrl: true,
                components: components,
                callbacks : {
                    "edges:query-fail" : function() {
                        alert("There was an unexpected error.  Please reload the page and try again.  If the issue persists please contact an administrator.");
                    }
                }
            });
            doaj.adminJournalsSearch.activeEdges[selector] = e;
        }
    }
});

jQuery(document).ready(function($) {
    doaj.adminJournalsSearch.init();
});
<commit_msg>Use human-friendly language<commit_after>$.extend(true, doaj, {

    adminJournalsSearch : {
        activeEdges : {},

        makeContinuation : function (val, resultobj, renderer) {
            if (!resultobj.suggestion && !resultobj.bibjson.journal) {
                // if it's not a suggestion or an article .. (it's a
                // journal!)
                // we really need to expose _type ...
                var result = '
Make a preceding continuation';

                result += 'Make a succeeding continuation';

                return result;
            }
            return false;
        },

        relatedApplications : function (val, resultobj, renderer) {
            var result = "";
            if (resultobj.admin) {
                if (resultobj.admin.current_application) {
                    var fvurl = doaj.adminJournalsSearchConfig.applicationsUrl + '?source=%7B"query"%3A%7B"query_string"%3A%7B"query"%3A"' + resultobj.admin.current_application + '"%2C"default_operator"%3A"AND"%7D%7D%2C"from"%3A0%2C"size"%3A10%7D';
                    result += "Current Update Request: " + edges.escapeHtml(resultobj.admin.current_application) + "";
                }
                if (resultobj.admin.related_applications && resultobj.admin.related_applications.length > 0) {
                    if (result != "") {
                        result += "
";
                    }
                    result += "Related Records: ";
                    for (var i = 0; i < resultobj.admin.related_applications.length; i++) {
                        if (i > 0) {
                            result += ", ";
                        }
                        var ra = resultobj.admin.related_applications[i];
                        var fvurl = doaj.adminJournalsSearchConfig.applicationsUrl + '?source=%7B"query"%3A%7B"query_string"%3A%7B"query"%3A"' + ra.application_id + '"%2C"default_operator"%3A"AND"%7D%7D%2C"from"%3A0%2C"size"%3A10%7D';
                        var linkName = ra.date_accepted;
                        if (!linkName) {
                            linkName = ra.application_id;
                        }
                        result += "" + linkName + "";
                    }
                }
            }
            return result;
        },

        init : function(params) {
            if (!params) { params = {} }

            var current_domain = document.location.host;
            var current_scheme = window.location.protocol;

            var selector = params.selector || "#admin_journals";
            var search_url = current_scheme + "//" + current_domain + doaj.adminJournalsSearchConfig.searchPath;

            var countFormat = edges.numFormat({
                thousandsSeparator: ","
            });

            var components = [
                edges.newSearchingNotification({
                    id: "searching-notification",
                    finishedEvent: "edges:post-render",
                    renderer : doaj.renderers.newSearchingNotificationRenderer()
                }),

                // facets
                doaj.facets.inDOAJ(),
                edges.newRefiningANDTermSelector({
                    id: "has_seal",
                    category: "facet",
                    field: "index.has_seal.exact",
                    display: "DOAJ Seal",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "owner",
                    category: "facet",
                    field: "admin.owner.exact",
                    display: "Owner",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "has_editor_group",
                    category: "facet",
                    field: "index.has_editor_group.exact",
                    display: "Has Editor Group?",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "has_associate_editor",
                    category: "facet",
                    field: "index.has_editor.exact",
                    display: "Has Associate Editor?",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "editor_group",
                    category: "facet",
                    field: "admin.editor_group.exact",
                    display: "Editor Group",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "associate_editor",
                    category: "facet",
                    field: "admin.editor.exact",
                    display: "Associate Editor",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),

                edges.newRefiningANDTermSelector({
                    id: "author_pays",
                    category: "facet",
                    field: "index.has_apc.exact",
                    display: "Publication charges?",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),

                edges.newRefiningANDTermSelector({
                    id: "journal_license",
                    category: "facet",
                    field: "index.license.exact",
                    display: "Journal License",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "publisher",
                    category: "facet",
                    field: "bibjson.publisher.name.exact",
                    display: "Publisher",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "classification",
                    category: "facet",
                    field: "index.classification.exact",
                    display: "Classification",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "subject",
                    category: "facet",
                    field: "index.subject.exact",
                    display: "Subject",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "journal_language",
                    category: "facet",
                    field: "index.language.exact",
                    display: "Journal Language",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "country_publisher",
                    category: "facet",
                    field: "index.country.exact",
                    display: "Country of publisher",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newRefiningANDTermSelector({
                    id: "continued",
                    category: "facet",
                    field: "index.continued.exact",
                    display: "Continued",
                    deactivateThreshold: 1,
                    renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
                        controls: true,
                        open: false,
                        togglable: true,
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),
                edges.newDateHistogramSelector({
                    id: "discontinued_date",
                    category: "facet",
                    field : "bibjson.discontinued_date",
                    interval: "year",
                    display: "Discontinued Year",
                    displayFormatter : function(val) {
                        return (new Date(parseInt(val))).getUTCFullYear();
                    },
                    sortFunction : function(values) {
                        values.reverse();
                        return values;
                    },
                    renderer: edges.bs3.newDateHistogramSelectorRenderer({
                        countFormat: countFormat,
                        hideInactive: true
                    })
                }),

                // configure the search controller
                edges.newFullSearchController({
                    id: "search-controller",
                    category: "controller",
                    sortOptions: [
                        {'display':'Date added to DOAJ','field':'created_date'},
                        {'display':'Last updated','field':'last_manual_update'}, // Note: last updated on UI points to when last updated by a person (via form)
                        {'display':'Title','field':'index.unpunctitle.exact'}
                    ],
                    fieldOptions: [
                        {'display':'Owner','field':'admin.owner'},
                        {'display':'Title','field':'index.title'},
                        {'display':'Alternative Title','field':'bibjson.alternative_title'},
                        {'display':'Subject','field':'index.subject'},
                        {'display':'Classification','field':'index.classification'},
                        {'display':'ISSN', 'field':'index.issn.exact'},
                        {'display':'Country of publisher','field':'index.country'},
                        {'display':'Journal Language','field':'index.language'},
                        {'display':'Publisher','field':'bibjson.publisher.name'}
                    ],
                    defaultOperator: "AND",
                    renderer: doaj.renderers.newFullSearchControllerRenderer({
                        freetextSubmitDelay: -1,
                        searchButton: true,
                        searchPlaceholder: "Search All Journals"
                    })
                }),

                // the pager, with the explicitly set page size options (see the openingQuery for the initial size)
                edges.newPager({
                    id: "top-pager",
                    category: "top-pager",
                    renderer: edges.bs3.newPagerRenderer({
                        sizeOptions: [10, 25, 50, 100],
                        numberFormat: countFormat,
                        scroll: false
                    })
                }),
                edges.newPager({
                    id: "bottom-pager",
                    category: "bottom-pager",
                    renderer: edges.bs3.newPagerRenderer({
                        sizeOptions: [10, 25, 50, 100],
                        numberFormat: countFormat,
                        scroll: false
                    })
                }),

                // results display
                edges.newResultsDisplay({
                    id: "results",
                    category: "results",
                    renderer: edges.bs3.newResultsFieldsByRowRenderer({
                        rowDisplay : [
                            [
                                {
                                    valueFunction: doaj.fieldRender.titleField
                                }
                            ],
                            [
                                {
                                   valueFunction: doaj.fieldRender.editJournal({editUrl: doaj.adminJournalsSearchConfig.journalEditUrl})
                                }
                            ],
                            [
                                {
                                    "pre": 'Alternative title: ',
                                    "field": "bibjson.alternative_title",
                                    "post": ""
                                }
                            ],
                            [
                                {
                                    "pre" : "In DOAJ?: ",
                                    valueFunction: doaj.fieldRender.inDoaj
                                }
                            ],
                            [
                                {
                                    "pre" : "Owner: ",
                                    valueFunction: doaj.fieldRender.owner
                                }
                            ],
                            [
                                {
                                    "pre" : "Editor Group: ",
                                    "field" : "admin.editor_group"
                                }
                            ],
                            [
                                {
                                    "pre" : "ISSN(s): ",
                                    valueFunction : doaj.fieldRender.issns
                                }
                            ],
                            [
                                {
                                    "pre": "Discontinued Date: ",
                                    "field": "bibjson.discontinued_date"
                                }
                            ],
                            [
                                {
                                    "pre": "Date added to DOAJ: ",
                                    valueFunction: doaj.fieldRender.createdDateWithTime
                                }
                            ],
                            [
                                {
                                    "pre": "Last updated: ",
                                    valueFunction: doaj.fieldRender.lastManualUpdate
                                }
                            ],
                            [
                                {
                                    valueFunction: doaj.fieldRender.links
                                }
                            ],
                            [
                                {
                                    "pre": "License: ",
                                    valueFunction: doaj.fieldRender.journalLicense
                                }
                            ],
                            [
                                {
                                    "pre": "Publisher: ",
                                    "field": "bibjson.publisher.name"
                                }
                            ],
                            [
                                {
                                    "pre": "Publication charges?: ",
                                    valueFunction: doaj.fieldRender.authorPays
                                }
                            ],
                            [
                                {
                                    "pre": "Classification: ",
                                    "field": "index.classification"
                                }
                            ],
                            [
                                {
                                    "pre": "Keywords: ",
                                    "field": "bibjson.keywords"
                                }
                            ],
                            [
                                {
                                    "pre": "Country: ",
                                    valueFunction: doaj.fieldRender.countryName
                                }
                            ],
                            [
                                {
                                    "pre": "Language: ",
                                    "field": "bibjson.language"
                                }
                            ],
                            [
                                {
                                    valueFunction: doaj.adminJournalsSearch.relatedApplications
                                }
                            ],
                            [
                                {
                                    valueFunction: doaj.adminJournalsSearch.makeContinuation
                                }
                            ]
                        ]
                    })
                }),

                // selected filters display, with all the fields given their display names
                edges.newSelectedFilters({
                    id: "selected-filters",
                    category: "selected-filters",
                    fieldDisplays: {
                        "admin.in_doaj" : "In DOAJ?",
                        "index.has_seal.exact" : "DOAJ Seal",
                        "admin.owner.exact" : "Owner",
                        "index.has_editor_group.exact" : "Has Editor Group?",
                        "index.has_editor.exact" : "Has Associate Editor?",
                        "admin.editor_group.exact" : "Editor Group",
                        "admin.editor.exact" : "Associate Editor",
                        "index.license.exact" : "Journal License",
                        "bibjson.publisher.name.exact" : "Publisher",
                        "index.classification.exact" : "Classification",
                        "index.subject.exact" : "Subject",
                        "index.language.exact" : "Journal Language",
                        "index.country.exact" : "Country of publisher",
                        "index.continued.exact" : "Continued",
                        "bibjson.discontinued_date" : "Discontinued Year",
                        "index.has_apc.exact" : "Publication charges?"
                    },
                    valueMaps : {
                        "admin.in_doaj" : {
                            true : "Yes",
                            false : "No"
                        }
                    },
                    rangeFunctions : {
                        "bibjson.discontinued_date" : doaj.valueMaps.displayYearPeriod
                    }
                })
            ];

            var e = edges.newEdge({
                selector: selector,
                template: edges.bs3.newFacetview(),
                search_url: search_url,
                manageUrl: true,
                components: components,
                callbacks : {
                    "edges:query-fail" : function() {
                        alert("There was an unexpected error.  Please reload the page and try again.  If the issue persists please contact an administrator.");
                    }
                }
            });
            doaj.adminJournalsSearch.activeEdges[selector] = e;
        }
    }
});

jQuery(document).ready(function($) {
    doaj.adminJournalsSearch.init();
});
<|endoftext|>