<commit_before>"use strict";

app.run(['$rootScope','$route', 'routeScroll', function ($rootScope, $route, routeScroll) {
    //Para que desde el HTML se pueda acceder al contextPath
    $rootScope.getContextPath = getContextPath;

}]);

app.run(['$rootScope', 'routeScroll', function ($rootScope, routeScroll) {
    //Permitirmos que se pueda poner en la ruta el parámetro "scrollTo"
    //para que al llegar a una ruta se mueva hasta el elemento.
    routeScroll.enable();

    //Permite navegar a una ruta y a un Scroll dentro de ella
    $rootScope.navigateWithScroll = function (page, scroll) {
        routeScroll.navigateWithScroll(page, scroll);
    };

}]);

<commit_msg>PAra el método "navigateWithScroll" al servicio "navigateScroll"<commit_after>"use strict";

app.run(['$rootScope','$route', 'routeScroll', function ($rootScope, $route, routeScroll) {
    //Para que desde el HTML se pueda acceder al contextPath
    $rootScope.getContextPath = getContextPath;

}]);

app.run(['$rootScope', 'routeScroll', function ($rootScope, routeScroll) {
    //Permitirmos que se pueda poner en la ruta el parámetro "scrollTo"
    //para que al llegar a una ruta se mueva hasta el elemento.
    routeScroll.enable();

    //Permite navegar a una ruta y a un Scroll dentro de ella
    //Y usarlo directamente desde el HTML
    $rootScope.navigateWithScroll = function (page, scroll) {
        routeScroll.navigateWithScroll(page, scroll);
    };

}]);

<|endoftext|>


<commit_before>// Rollup plugins
import * as path from 'path';
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import license from 'rollup-plugin-license';
import * as jsonfile from 'jsonfile';

const pkg = jsonfile.readFileSync('./package.json');

export default {
    entry: 'src/' + pkg.name + '.js',
    dest: 'dist/' + pkg.name + (process.env.NODE_ENV === 'production' ? '.min' : '') + '.js',
    format: 'umd',
    moduleName: pkg.name.replace(/^\w/, starter => starter.toUpperCase()),
    plugins: [
        babel({
            exclude: 'node_modules/**'
        }),
        (process.env.NODE_ENV === 'production' && uglify()),
        license({
            banner: {
                file: path.join(__dirname, 'BANNER')
            },
            thirdParty: {
                output: path.join(__dirname, 'dist', 'dependencies.txt'),
                includePrivate: true
            }
        })
    ]
};
<commit_msg>add makefile<commit_after>// Rollup plugins
import * as path from 'path';
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify';
import license from 'rollup-plugin-license';
import * as jsonfile from 'jsonfile';

const pkg = jsonfile.readFileSync('./package.json');

export default {
    entry: 'src/' + pkg.name + '.js',
    dest: 'dist/' + pkg.name + (process.env.NODE_ENV === 'production' ? '.min' : '') + '.js',
    format: 'umd',
    moduleName: pkg.name.replace(/^\w/, starter => starter.toUpperCase()),
    sourceMap: true,
    plugins: [
        babel({
            exclude: 'node_modules/**'
        }),
        (process.env.NODE_ENV === 'production' && uglify()),
        license({
            banner: {
                file: path.join(__dirname, 'src', 'BANNER')
            },
            thirdParty: {
                output: path.join(__dirname, 'dist', 'dependencies.txt'),
                includePrivate: true
            }
        })
    ]
};
<|endoftext|>


<commit_before>import React, { PureComponent } from 'react'
import { Switch } from 'react-router'
import { StaticRouter, HashRouter, BrowserRouter, Route } from 'react-router-dom'
import URL from 'url-parse'
import { Data } from 'react-chunky'
import { createSectionRoutes } from './Router'
import Cache from './Cache'

export default class App extends PureComponent {
  constructor (props) {
    super(props)
    this.state = { loading: true }
    this._menu = []
    this._sidebar = []
    this._cache = new Cache(props)
    this._userLogout = this.userLogout.bind(this)
    this._userLoggedIn = this.userLoggedIn.bind(this)
  }

  componentDidMount () {
    this.checkAuth()
    const ele = document.getElementById('ipl-progress-indicator')
      if(ele){
        // fade out
        ele.classList.add('available')
        setTimeout(() => {
          // remove from DOM
          ele.outerHTML = ''
        }, 2000)
      }
  }

  checkAuth () {
    return new Promise((resolve, reject) => {
      Data.Cache.retrieveAuth()
      .then(account => {
        this._resolve(account)
        resolve()
      })
      .catch((e) => {
        this._resolve()
        resolve()
      })
    })
  }

  get cache () {
    return this._cache
  }

  userLoggedIn (account) {
    return new Promise((resolve, reject) => {
      const user = firebase.auth().currentUser
      const combined = Object.assign({}, {
        uid: user.uid,
        emailVerified: user.emailVerified
      }, account)
      return Data.Cache.cacheAuth({ user: combined }).then(() => resolve(combined))
    })
    .then(() => this.checkAuth())
  }

  userLogout () {
    Data.Cache.clearAuth()
              .then(() => {
                this._resolve()
                firebase && firebase.auth().signOut()
              })
  }

  _resolveTransitionFromURI (uri) {
    const url = new URL(uri, true)
    return {
      name: `show${url.hostname.charAt(0).toUpperCase()}${url.hostname.substring(1).toLowerCase()}`,
      type: url.protocol.slice(0, -1).toLowerCase(),
      route: url.hostname
    }
  }

  _createSectionNavigatorRoutes (element, section) {
    // We want to look at a stack element and figure out its parent chunk;
    // Note that chunks may also have flavours so this looks for the flavor, if any
    const [ chunkName, chunkFlavorName ] = element.split('/')

    // This is our chunk, if it actually exists
    const chunk = this.props.chunks[chunkName]

    if (!chunk) {
      // Let's verify that it actually points to a real chunk
      return
    }

    if (chunkFlavorName && (!chunk.flavors || !chunk.flavors[chunkFlavorName])) {
      // Great, let's check the flavor now
      return
    }

    if (!chunk.routes || chunk.routes.length === 0) {
      // One last thing, let's also make sure the chunk has routes
      return
    }

    // These routes will be the ones we want to parse out of the chunk, as necessary
    var routes = []

    var rootRoute = {}

    // Let's build up global transitions, if any
    var globalTransitions = {}

    if (this.props.transitions) {
      this.props.transitions.forEach(transitionUri => {
          // Let's resolve global transitions
        const transition = this._resolveTransitionFromURI(transitionUri)
        globalTransitions[transition.name] = transition
      })
    }

    for (let routeName in chunk.routes) {
      // Great, this chunk has routes, let's look through all of them
      var route = chunk.routes[routeName]

      if (!route.screen) {
        // This route has no screens
        continue
      }

      if (route.private !== section.private) {
        continue
      }

      const screenId = `${chunkName}/${routeName}`
      const screenPath = route.path || `/${routeName}`
      const routeKey = `${screenId}${screenPath}`
      const routeMenuTitle = ((this.props.desktop && route.desktopTitle) ? route.desktopTitle : route.title)

      if (section.private && route.private) {
        route.sidebarIndex = this.sidebar.length
        this._sidebar.push({
          routeKey,
          id: `${this.sidebar.length}`,
          icon: route.icon,
          title: routeMenuTitle,
          alwaysShowIcon: route.alwaysShowIcon,
          action: route.action,
          path: route.path
        })
      }

      if (Object.keys(rootRoute).length === 0) {
        route.root = true
        route.menuTitle = routeMenuTitle

        rootRoute = Object.assign({}, route)

        // Construct a menu
        if (!route.skipMenu && !route.private && !section.private) {
          var link = `${this.menu.length === 0 ? '/' : route.path}`
          this._menu.push({
            id: `${this.menu.length}`,
            routeKey,
            icon: route.icon.replace('-', '_'),
            title: route.menuTitle,
            alwaysShowIcon: route.alwaysShowIcon,
            action: route.action,
            path: link
          })
          if (route.extendedMenu && !(route.skipExtendedMenuOnDesktop && this.props.desktop)) {
            this._menu = this._menu.concat(route.extendedMenu)
          }
        }
      } else {
        // route.icon = rootRoute.icon
        // route.menuTitle = rootRoute.menuTitle
      }

      // Let's build up the transitions, if any
      var transitions = {}

      if (chunk.transitions) {
        chunk.transitions.forEach(transitionUri => {
          // Parse this transition's URI
          const transition = this._resolveTransitionFromURI(transitionUri)
          const routeData = chunk.routes[transition.route]
          if (transition.route && routeData) {
            // This is a local transition, so let's resolve locally
            transition.data = Object.assign({}, routeData)
            transition.route = `${section.name}/${chunkName}/${transition.route}`
            transitions[transition.name] = transition
            return
          }

          if (globalTransitions[transition.name]) {
            // Let's look through the global transitions, if any
            transitions[transition.name] = Object.assign({}, globalTransitions[transition.name])
          }
        })
      }

      // Let's pass over the theme as well
      const theme = this.props.theme

      // For each route, we want to compose its properties
      const screenProps = Object.assign({
        // Defaults
        cache: this.cache,
        strings: {},
        desktop: this.props.desktop,
        account: section.account,
        env: this.props.env,
        provisioning: this.props.provisioning,
        analytics: this.props.analytics,
        onUserLogout: this._userLogout,
        onUserLoggedIn: this._userLoggedIn,
        info: this.props.info,
        session: this.props.session,
        startOperationsOnMount: true
      }, {
        theme,
        transitions,
        ...route,
        chunkName,
        menu: this.menu,
        sidebar: this.sidebar,
        private: route.private,
        sidebarIndex: route.sidebarIndex
      }, this.props.web)

      // Resolve strings
      var resolvedStrings = {}
      for (const string in screenProps.strings) {
        resolvedStrings[string] = this.props.strings[screenProps.strings[string]] || `??${screenProps.strings[string]}??`
      }
      screenProps.strings = Object.assign({}, this.props.strings, resolvedStrings)

      const ScreenRoute = this._makeScreenRoute(screenPath, screenId, route, screenProps)
      routes.push(ScreenRoute)

      if (route.variants) {
        const ScreenVariantRoute = this._makeScreenRoute(`${screenPath}/:variant`, screenId, route, screenProps)
        routes.push(ScreenVariantRoute)
      }
    }

    // We've got ourselves some routes so we should be done with this
    return routes
  }

  _makeScreenRoute (screenPath, screenId, route, screenProps) {
    const RouteScreen = route.screen
    const Screen = (props) => {
      var skip = false
      if (route.skipPaths) {
        route.skipPaths.forEach(r => {
          if (r === props.location.pathname.split('/')[1]) {
            skip = true
          }
        })
      }

      const allProps = Object.assign({}, props, screenProps, { session: this.props.session })
      return (skip ?
 : <RouteScreen {...allProps} />)
    }

    const routeKey = `${screenId}${screenPath}`

    return <Route
      exact
      refresh
      key={routeKey}
      path={screenPath}
      render={Screen} />
  }

  _createSectionNavigator (section) {
    return createSectionRoutes(section, this._createSectionNavigatorRoutes.bind(this))
  }

  _refreshRoutes (account) {
    this._routes = []
    this._sections = []
    this._menu = []
    this._sidebar = []

    for (const sectionName in this.props.sections) {
      // Look through all the app's sections and for each, build defaults if necessary
      var section = this.props.sections[sectionName]
      section.name = sectionName
      section.account = account
      section.layout = section.layout || 'default'
      section.navigator = this._createSectionNavigator(section)
      this._sections.push(section)
      this._routes = this._routes.concat(section.navigator.routes)
    }
  }

  _resolve (account) {
    this._refreshRoutes(account)
    this.setState({ loading: false, account: account || undefined, authstamp: `${Date.now()}` })
  }

  get menu () {
    return this._menu || {}
  }

  get routes () {
    return this._routes || []
  }

  get sidebar () {
    return this._sidebar || []
  }

  get sections () {
    return this._sections || []
  }

  renderStatic () {
    return (
      <StaticRouter location={this.props.route.location} context={this.props.route}>

          { this.routes }

      </StaticRouter>)
  }

  renderRoutes () {
    return this.routes
  }

  render () {
    if (this.props.route && !this.props.redirect) {
      return this.renderStatic()
    }

    if (!this.routes || this.routes.length === 0) {
      return (
)
    }

    if (this.props.autoRefresh) {
      this._refreshRoutes(this.state.account)
    }

    if (this.props.desktop) {
      return (<HashRouter>
        <Switch>
          { this.renderRoutes() }
        </Switch>
      </HashRouter>)
    }

    return (<BrowserRouter>

        { this.renderRoutes() }

    </BrowserRouter>)
  }
}
<commit_msg>option to load additional scripts<commit_after>import React, { PureComponent } from 'react'
import { Switch } from 'react-router'
import {
  StaticRouter,
  HashRouter,
  BrowserRouter,
  Route
} from 'react-router-dom'
import URL from 'url-parse'
import { Data } from 'react-chunky'
import { createSectionRoutes } from './Router'
import Cache from './Cache'

export default class App extends PureComponent {
  constructor(props) {
    super(props)
    this.state = { loading: true }
    this._menu = []
    this._sidebar = []
    this._cache = new Cache(props)
    this._userLogout = this.userLogout.bind(this)
    this._userLoggedIn = this.userLoggedIn.bind(this)
  }

  componentDidMount() {
    this.checkAuth()
    const ele = document.getElementById('ipl-progress-indicator')
    if (ele) {
      // fade out
      ele.classList.add('available')
      setTimeout(() => {
        // remove from DOM
        ele.outerHTML = ''
      }, 2000)
    }
    const { additionalScripts } = this.props
    if (additionalScripts) {
      for (let i = 0; i < additionalScripts.length; i++) {
        let { rel, href, integrity, crossOrigin } = additionalScripts[i]
        let link = document.createElement('link')
        link.rel = rel
        link.href = href
        link.integrity = integrity
        link.crossOrigin = crossOrigin
        document.head.appendChild(link)
      }
    }
  }

  checkAuth() {
    return new Promise((resolve, reject) => {
      Data.Cache.retrieveAuth()
        .then(account => {
          this._resolve(account)
          resolve()
        })
        .catch(e => {
          this._resolve()
          resolve()
        })
    })
  }

  get cache() {
    return this._cache
  }

  userLoggedIn(account) {
    return new Promise((resolve, reject) => {
      const user = firebase.auth().currentUser
      const combined = Object.assign(
        {},
        {
          uid: user.uid,
          emailVerified: user.emailVerified
        },
        account
      )
      return Data.Cache.cacheAuth({ user: combined }).then(() =>
        resolve(combined)
      )
    }).then(() => this.checkAuth())
  }

  userLogout() {
    Data.Cache.clearAuth().then(() => {
      this._resolve()
      firebase && firebase.auth().signOut()
    })
  }

  _resolveTransitionFromURI(uri) {
    const url = new URL(uri, true)
    return {
      name: `show${url.hostname
        .charAt(0)
        .toUpperCase()}${url.hostname.substring(1).toLowerCase()}`,
      type: url.protocol.slice(0, -1).toLowerCase(),
      route: url.hostname
    }
  }

  _createSectionNavigatorRoutes(element, section) {
    // We want to look at a stack element and figure out its parent chunk;
    // Note that chunks may also have flavours so this looks for the flavor, if any
    const [chunkName, chunkFlavorName] = element.split('/')

    // This is our chunk, if it actually exists
    const chunk = this.props.chunks[chunkName]

    if (!chunk) {
      // Let's verify that it actually points to a real chunk
      return
    }

    if (
      chunkFlavorName &&
      (!chunk.flavors || !chunk.flavors[chunkFlavorName])
    ) {
      // Great, let's check the flavor now
      return
    }

    if (!chunk.routes || chunk.routes.length === 0) {
      // One last thing, let's also make sure the chunk has routes
      return
    }

    // These routes will be the ones we want to parse out of the chunk, as necessary
    var routes = []

    var rootRoute = {}

    // Let's build up global transitions, if any
    var globalTransitions = {}

    if (this.props.transitions) {
      this.props.transitions.forEach(transitionUri => {
        // Let's resolve global transitions
        const transition = this._resolveTransitionFromURI(transitionUri)
        globalTransitions[transition.name] = transition
      })
    }

    for (let routeName in chunk.routes) {
      // Great, this chunk has routes, let's look through all of them
      var route = chunk.routes[routeName]

      if (!route.screen) {
        // This route has no screens
        continue
      }

      if (route.private !== section.private) {
        continue
      }

      const screenId = `${chunkName}/${routeName}`
      const screenPath = route.path || `/${routeName}`
      const routeKey = `${screenId}${screenPath}`
      const routeMenuTitle =
        this.props.desktop && route.desktopTitle
          ? route.desktopTitle
          : route.title

      if (section.private && route.private) {
        route.sidebarIndex = this.sidebar.length
        this._sidebar.push({
          routeKey,
          id: `${this.sidebar.length}`,
          icon: route.icon,
          title: routeMenuTitle,
          alwaysShowIcon: route.alwaysShowIcon,
          action: route.action,
          path: route.path
        })
      }

      if (Object.keys(rootRoute).length === 0) {
        route.root = true
        route.menuTitle = routeMenuTitle

        rootRoute = Object.assign({}, route)

        // Construct a menu
        if (!route.skipMenu && !route.private && !section.private) {
          var link = `${this.menu.length === 0 ? '/' : route.path}`
          this._menu.push({
            id: `${this.menu.length}`,
            routeKey,
            icon: route.icon.replace('-', '_'),
            title: route.menuTitle,
            alwaysShowIcon: route.alwaysShowIcon,
            action: route.action,
            path: link
          })
          if (
            route.extendedMenu &&
            !(route.skipExtendedMenuOnDesktop && this.props.desktop)
          ) {
            this._menu = this._menu.concat(route.extendedMenu)
          }
        }
      } else {
        // route.icon = rootRoute.icon
        // route.menuTitle = rootRoute.menuTitle
      }

      // Let's build up the transitions, if any
      var transitions = {}

      if (chunk.transitions) {
        chunk.transitions.forEach(transitionUri => {
          // Parse this transition's URI
          const transition = this._resolveTransitionFromURI(transitionUri)
          const routeData = chunk.routes[transition.route]
          if (transition.route && routeData) {
            // This is a local transition, so let's resolve locally
            transition.data = Object.assign({}, routeData)
            transition.route = `${section.name}/${chunkName}/${
              transition.route
            }`
            transitions[transition.name] = transition
            return
          }

          if (globalTransitions[transition.name]) {
            // Let's look through the global transitions, if any
            transitions[transition.name] = Object.assign(
              {},
              globalTransitions[transition.name]
            )
          }
        })
      }

      // Let's pass over the theme as well
      const theme = this.props.theme

      // For each route, we want to compose its properties
      const screenProps = Object.assign(
        {
          // Defaults
          cache: this.cache,
          strings: {},
          desktop: this.props.desktop,
          account: section.account,
          env: this.props.env,
          provisioning: this.props.provisioning,
          analytics: this.props.analytics,
          onUserLogout: this._userLogout,
          onUserLoggedIn: this._userLoggedIn,
          info: this.props.info,
          session: this.props.session,
          startOperationsOnMount: true
        },
        {
          theme,
          transitions,
          ...route,
          chunkName,
          menu: this.menu,
          sidebar: this.sidebar,
          private: route.private,
          sidebarIndex: route.sidebarIndex
        },
        this.props.web
      )

      // Resolve strings
      var resolvedStrings = {}
      for (const string in screenProps.strings) {
        resolvedStrings[string] =
          this.props.strings[screenProps.strings[string]] ||
          `??${screenProps.strings[string]}??`
      }
      screenProps.strings = Object.assign(
        {},
        this.props.strings,
        resolvedStrings
      )

      const ScreenRoute = this._makeScreenRoute(
        screenPath,
        screenId,
        route,
        screenProps
      )
      routes.push(ScreenRoute)

      if (route.variants) {
        const ScreenVariantRoute = this._makeScreenRoute(
          `${screenPath}/:variant`,
          screenId,
          route,
          screenProps
        )
        routes.push(ScreenVariantRoute)
      }
    }

    // We've got ourselves some routes so we should be done with this
    return routes
  }

  _makeScreenRoute(screenPath, screenId, route, screenProps) {
    const RouteScreen = route.screen
    const Screen = props => {
      var skip = false
      if (route.skipPaths) {
        route.skipPaths.forEach(r => {
          if (r === props.location.pathname.split('/')[1]) {
            skip = true
          }
        })
      }

      const allProps = Object.assign({}, props, screenProps, {
        session: this.props.session
      })
      return skip ?
 : <RouteScreen {...allProps} />
    }

    const routeKey = `${screenId}${screenPath}`

    return (
      <Route exact refresh key={routeKey} path={screenPath} render={Screen} />
    )
  }

  _createSectionNavigator(section) {
    return createSectionRoutes(
      section,
      this._createSectionNavigatorRoutes.bind(this)
    )
  }

  _refreshRoutes(account) {
    this._routes = []
    this._sections = []
    this._menu = []
    this._sidebar = []

    for (const sectionName in this.props.sections) {
      // Look through all the app's sections and for each, build defaults if necessary
      var section = this.props.sections[sectionName]
      section.name = sectionName
      section.account = account
      section.layout = section.layout || 'default'
      section.navigator = this._createSectionNavigator(section)
      this._sections.push(section)
      this._routes = this._routes.concat(section.navigator.routes)
    }
  }

  _resolve(account) {
    this._refreshRoutes(account)
    this.setState({
      loading: false,
      account: account || undefined,
      authstamp: `${Date.now()}`
    })
  }

  get menu() {
    return this._menu || {}
  }

  get routes() {
    return this._routes || []
  }

  get sidebar() {
    return this._sidebar || []
  }

  get sections() {
    return this._sections || []
  }

  renderStatic() {
    return (
      <StaticRouter
        location={this.props.route.location}
        context={this.props.route}
      >

{this.routes}

      </StaticRouter>
    )
  }

  renderRoutes() {
    return this.routes
  }

  render() {
    if (this.props.route && !this.props.redirect) {
      return this.renderStatic()
    }

    if (!this.routes || this.routes.length === 0) {
      return

    }

    if (this.props.autoRefresh) {
      this._refreshRoutes(this.state.account)
    }

    if (this.props.desktop) {
      return (
        <HashRouter>
          <Switch>{this.renderRoutes()}</Switch>
        </HashRouter>
      )
    }

    return (
      <BrowserRouter>

{this.renderRoutes()}

      </BrowserRouter>
    )
  }
}
<|endoftext|>


<commit_before>import os from 'os'
import path from 'path'
import resolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import vue from 'rollup-plugin-vue'
import uglify from 'rollup-plugin-uglify'
import sass from 'rollup-plugin-sass';
import autoprefixer from 'autoprefixer'
import postcss from 'postcss'
import csso from 'postcss-csso';
import { minify } from 'uglify-es'
import pkg from './package.json';
import replace from 'rollup-plugin-replace'

const PLUGINS = [
  'button',
  'card',
  'checkbox',
  'chips',
  'dialog',
  'drawer',
  'elevation',
  'fab',
  'grid-list',
  'icon-toggle',
  'icon',
  'layout-app',
  'layout-grid',
  'linear-progress',
  'list',
  'menu',
  'radio',
  'ripple',
  'select',
  'slider',
  'snackbar',
  'switch',
  'tabs',
  'textfield',
  'theme',
  'toolbar',
  'typography',
]

const BANNER = `/**
* @module vue-mdc-adapter{{module}} {{version}}
* @exports {{name}}
* @copyright (c) 2017-present, Sebastien Tasson
* @license https://opensource.org/licenses/MIT
* @implements {{dependencies}}
* @requires {{peerDependencies}}
* @see https://github.com/stasson/vue-mdc-adapter
*/
`
  .replace('{{version}}', pkg.version)
  .replace('{{dependencies}}', JSON.stringify(pkg.dependencies))
  .replace('{{peerDependencies}}', JSON.stringify(pkg.peerDependencies))

const babelConfig = {
  'compact': false,
  'babelrc': false,
  'presets': [
    [
      // env preset https://github.com/babel/babel-preset-env
      'env',
      // let rollup take care of modules
      { 'modules': false }
    ]
  ],
  'plugins': [
    "transform-object-assign",
    "transform-object-rest-spread",
    // let rollup bundle helpers once
    // see https://github.com/rollup/rollup-plugin-babel#helpers
    'external-helpers'
  ]
}

const capitalize = (str) => {
  return str
    .replace(/\b(\w)/g, function (_,x) {
          return x.toUpperCase();
    })
    .replace(/[_.-]/g,'')
}

function createUmdConfig(module, env, extract) {

  const isPlugin = PLUGINS.includes(module)
  const isProduction = env === `production`
  const isDevelopment = env === `development`
  const dist = isPlugin ? `dist/${module}/${module}` : 'dist/' + module
  const name = isPlugin ? 'VueMDC' + capitalize(module)  : 'VueMDCAdapter'
  const input = 'components/' + ( isPlugin ? module + '/' : '')  + 'entry.js'

  const banner = BANNER
  .replace('{{module}}', isPlugin ? module : '')
  .replace('{{name}}', name)

  const sassConfig = {
    include: [ '**/*.css', '**/*.scss' ],
    options: {includePaths: ['node_modules']},
    processor: css => postcss((isDevelopment
                        ? [autoprefixer()]
                        : [autoprefixer(), csso()]))
                      .process(css)
                      .then(result => result.css)
  }

  const output = {
    file: dist + (isDevelopment ? `.js` : `.min.js`),
    format: 'umd',
    sourcemap: isDevelopment ? 'inline' : true,
    name,
    banner
  }

  if (extract) {
    if (isProduction) {
      sassConfig.output = dist + '.min.css'
    } else {
      sassConfig.output = dist + '.css'
    }
  } else {
    sassConfig.insert = true
  }

  const config = {
    input,
    output,
    external: ['vue'],
    plugins: [
      vue ({ autoStyles: false, styleToImports: true }),
      resolve({ jsnext: true, main: true, browser: true }),
      sass(sassConfig),
      babel(babelConfig),
      commonjs(),
      replace({
        __VERSION__: pkg.version
      }),
    ],
    onwarn
  }

  if (isProduction) {
    config.plugins.push(uglify({
      output: {
        comments: function(node, comment) {
            var text = comment.value;
            var type = comment.type;
            if (type == "comment2") {
                // multiline comment
                return /@preserve|@license|@cc_on/i.test(text);
            }
        }
      }
    }, minify))
  }
  return config
}

function createEsmConfig(module) {

  const isModule = PLUGINS.includes(module)
  const dist = isModule ? `dist/${module}/index.js` : 'dist/index.js'
  const input = 'components/' + ( isModule ? module + '/' : '')  + 'index.js'
  const banner = BANNER
  .replace('{{module}}', isModule ? module : '')
  .replace('{{name}}', 'default')

  let external = []
  let paths = {}
  let outro = ''

  if (isModule) {
    PLUGINS.forEach((folder) => {
      if (folder != module) {
        let id = path.resolve('.', 'components', folder, 'index.js')
        external.push(id)
        paths[id] = `../${folder}`
      }
    })
  } else {
    PLUGINS.forEach((folder) => {
      if (folder != module) {
        let id = path.resolve('.', 'components', folder, 'index.js')
        external.push(id)
        paths[id] = `./${folder}`
      }
    })

    PLUGINS.forEach((folder) => {
      let exportName = 'VueMDC' + capitalize(folder)
      outro +=`export { ${exportName} }` + os.EOL
    })

    outro += os.EOL
    PLUGINS.forEach((folder) => {
      outro +=`export * from './${folder}'` + os.EOL
    })
  }

  const output = {
    file: dist,
    format: 'es',
    sourcemap: true,
    banner,paths,outro,
  }

  const config = {
    input,
    output,
    external,
    plugins: [
      vue ({ autoStyles: false, styleToImports: true }),
      resolve({ jsnext: true, main: true, browser: true }),
      babel(babelConfig),
      commonjs(),
      replace({
        __VERSION__: pkg.version
      }),
    ],
    onwarn
  }
  return config
}

const configs = []

// ESM
PLUGINS.forEach((module) => {
  configs.push(createEsmConfig(module))
})
configs.push(createEsmConfig('index'))

// UMD
PLUGINS.forEach((module) => {
  configs.push(createUmdConfig(module,'development',true))
  configs.push(createUmdConfig(module,'production', true))
})

configs.push(createUmdConfig('vue-mdc-adapter','development',true),)
configs.push(createUmdConfig('vue-mdc-adapter','production',true))
configs.push(createUmdConfig('vue-mdc-adapter.umd','development',false))
configs.push(createUmdConfig('vue-mdc-adapter.umd','production',false))

function onwarn (warning) {

  // skip certain warnings
  if (warning.code == 'NON_EXISTENT_EXPORT') {
    if (warning.name == 'MDCIconToggleAdapter') return;
  }

  // console.warn everything else
  console.log(warning);
  console.warn(warning.message);
}

export default configs<commit_msg>chore: touch file to make ci run<commit_after>import os from 'os';
import path from 'path';
import resolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import vue from 'rollup-plugin-vue';
import uglify from 'rollup-plugin-uglify';
import sass from 'rollup-plugin-sass';
import autoprefixer from 'autoprefixer';
import postcss from 'postcss';
import csso from 'postcss-csso';
import { minify } from 'uglify-es';
import pkg from './package.json';
import replace from 'rollup-plugin-replace';

const PLUGINS = [
  'button',
  'card',
  'checkbox',
  'chips',
  'dialog',
  'drawer',
  'elevation',
  'fab',
  'grid-list',
  'icon-toggle',
  'icon',
  'layout-app',
  'layout-grid',
  'linear-progress',
  'list',
  'menu',
  'radio',
  'ripple',
  'select',
  'slider',
  'snackbar',
  'switch',
  'tabs',
  'textfield',
  'theme',
  'toolbar',
  'typography',
];

const BANNER = `/**
* @module vue-mdc-adapter{{module}} {{version}}
* @exports {{name}}
* @copyright (c) 2017-present, Sebastien Tasson
* @license https://opensource.org/licenses/MIT
* @implements {{dependencies}}
* @requires {{peerDependencies}}
* @see https://github.com/stasson/vue-mdc-adapter
*/
`
  .replace('{{version}}', pkg.version)
  .replace('{{dependencies}}', JSON.stringify(pkg.dependencies))
  .replace('{{peerDependencies}}', JSON.stringify(pkg.peerDependencies));

const babelConfig = {
  compact: false,
  babelrc: false,
  presets: [
    [
      // env preset https://github.com/babel/babel-preset-env
      'env',
      // let rollup take care of modules
      { modules: false },
    ],
  ],
  plugins: [
    'transform-object-assign',
    'transform-object-rest-spread',
    // let rollup bundle helpers  once
    // see https://github.com/rollup/rollup-plugin-babel#helpers
    'external-helpers',
  ],
};

const capitalize = str => {
  return str
    .replace(/\b(\w)/g, function(_, x) {
      return x.toUpperCase();
    })
    .replace(/[_.-]/g, '');
};

function createUmdConfig(module, env, extract) {
  const isPlugin = PLUGINS.includes(module);
  const isProduction = env === `production`;
  const isDevelopment = env === `development`;
  const dist = isPlugin ? `dist/${module}/${module}` : 'dist/' + module;
  const name = isPlugin ? 'VueMDC' + capitalize(module) : 'VueMDCAdapter';
  const input = 'components/' + (isPlugin ? module + '/' : '') + 'entry.js';

  const banner = BANNER.replace('{{module}}', isPlugin ? module : '').replace(
    '{{name}}',
    name,
  );

  const sassConfig = {
    include: ['**/*.css', '**/*.scss'],
    options: { includePaths: ['node_modules'] },
    processor: css =>
      postcss(isDevelopment ? [autoprefixer()] : [autoprefixer(), csso()])
        .process(css)
        .then(result => result.css),
  };

  const output = {
    file: dist + (isDevelopment ? `.js` : `.min.js`),
    format: 'umd',
    sourcemap: isDevelopment ? 'inline' : true,
    name,
    banner,
  };

  if (extract) {
    if (isProduction) {
      sassConfig.output = dist + '.min.css';
    } else {
      sassConfig.output = dist + '.css';
    }
  } else {
    sassConfig.insert = true;
  }

  const config = {
    input,
    output,
    external: ['vue'],
    plugins: [
      vue({ autoStyles: false, styleToImports: true }),
      resolve({ jsnext: true, main: true, browser: true }),
      sass(sassConfig),
      babel(babelConfig),
      commonjs(),
      replace({
        __VERSION__: pkg.version,
      }),
    ],
    onwarn,
  };

  if (isProduction) {
    config.plugins.push(
      uglify(
        {
          output: {
            comments: function(node, comment) {
              var text = comment.value;
              var type = comment.type;
              if (type == 'comment2') {
                // multiline comment
                return /@preserve|@license|@cc_on/i.test(text);
              }
            },
          },
        },
        minify,
      ),
    );
  }
  return config;
}

function createEsmConfig(module) {
  const isModule = PLUGINS.includes(module);
  const dist = isModule ? `dist/${module}/index.js` : 'dist/index.js';
  const input = 'components/' + (isModule ? module + '/' : '') + 'index.js';
  const banner = BANNER.replace('{{module}}', isModule ? module : '').replace(
    '{{name}}',
    'default',
  );

  let external = [];
  let paths = {};
  let outro = '';

  if (isModule) {
    PLUGINS.forEach(folder => {
      if (folder != module) {
        let id = path.resolve('.', 'components', folder, 'index.js');
        external.push(id);
        paths[id] = `../${folder}`;
      }
    });
  } else {
    PLUGINS.forEach(folder => {
      if (folder != module) {
        let id = path.resolve('.', 'components', folder, 'index.js');
        external.push(id);
        paths[id] = `./${folder}`;
      }
    });

    PLUGINS.forEach(folder => {
      let exportName = 'VueMDC' + capitalize(folder);
      outro += `export { ${exportName} }` + os.EOL;
    });

    outro += os.EOL;
    PLUGINS.forEach(folder => {
      outro += `export * from './${folder}'` + os.EOL;
    });
  }

  const output = {
    file: dist,
    format: 'es',
    sourcemap: true,
    banner,
    paths,
    outro,
  };

  const config = {
    input,
    output,
    external,
    plugins: [
      vue({ autoStyles: false, styleToImports: true }),
      resolve({ jsnext: true, main: true, browser: true }),
      babel(babelConfig),
      commonjs(),
      replace({
        __VERSION__: pkg.version,
      }),
    ],
    onwarn,
  };
  return config;
}

const configs = [];

// ESM
PLUGINS.forEach(module => {
  configs.push(createEsmConfig(module));
});
configs.push(createEsmConfig('index'));

// UMD
PLUGINS.forEach(module => {
  configs.push(createUmdConfig(module, 'development', true));
  configs.push(createUmdConfig(module, 'production', true));
});

configs.push(createUmdConfig('vue-mdc-adapter', 'development', true));
configs.push(createUmdConfig('vue-mdc-adapter', 'production', true));
configs.push(createUmdConfig('vue-mdc-adapter.umd', 'development', false));
configs.push(createUmdConfig('vue-mdc-adapter.umd', 'production', false));

function onwarn(warning) {
  // skip certain warnings
  if (warning.code == 'NON_EXISTENT_EXPORT') {
    if (warning.name == 'MDCIconToggleAdapter') return;
  }

  // console.warn everything else
  console.log(warning);
  console.warn(warning.message);
}

export default configs;
<|endoftext|>


<commit_before>import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import babili from 'rollup-plugin-babili';

const config = {
  moduleName: 'ReactStrap',
  entry: 'src/index.js',
  exports: 'named',
  plugins: [
    nodeResolve(),
    commonjs(),
    babel({
      plugins: ['external-helpers'],
    }),
  ],
  external: [
    'react',
    'react-dom',
    'react-addons-css-transition-group',
    'react-addons-transition-group',
  ],
  // Used for the UMD bundles
  globals: {
    react: 'React',
    'react-dom': 'ReactDOM',
    'react-addons-css-transition-group': 'CSSTransitionGroup',
    'react-addons-transition-group': 'TransitionGroup',
  },
  targets: [
    { dest: 'dist/reactstrap.cjs.js', format: 'cjs' },
    { dest: 'dist/reactstrap.es.js', format: 'es' },
  ],
};

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(babili({ comments: false }));
}

export default config;
<commit_msg>build(rollup): Remove unused options from rollup config (#375)<commit_after>import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import babili from 'rollup-plugin-babili';

const config = {
  entry: 'src/index.js',
  plugins: [
    nodeResolve(),
    commonjs(),
    babel({
      plugins: ['external-helpers'],
    }),
  ],
  external: [
    'react',
    'react-dom',
    'react-addons-css-transition-group',
    'react-addons-transition-group',
  ],
  targets: [
    { dest: 'dist/reactstrap.cjs.js', format: 'cjs' },
    { dest: 'dist/reactstrap.es.js', format: 'es' },
  ],
};

if (process.env.NODE_ENV === 'production') {
  config.plugins.push(babili({ comments: false }));
}

export default config;
<|endoftext|>


<commit_before>/* jslint node: true, esnext: true */
'use strict';

import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
  format: 'cjs',
  plugins: [nodeResolve(), commonjs()]
};
<commit_msg>fix(npm): only provide unbundeled commonjs version<commit_after>/* jslint node: true, esnext: true */
'use strict';

export default {
  format: 'cjs',
  plugins: []
};
<|endoftext|>


<commit_before><commit_msg>builds public folder<commit_after><|endoftext|>


<commit_before><commit_msg>Alignment issue in product grid<commit_after><|endoftext|>


<commit_before><commit_msg>Deleted scripts.js<commit_after><|endoftext|>


<commit_before>/*
 * Leaflet layer plugins inherit from Leaflet's Layer class. A common
 * naming convention is to add the name of the layer plugin to Leaflet's
 * namespace, which is L.
 */
L.LeafletLayerTemplate = L.Layer.extend({

  /*
   * Leaflet calls the initialize function when an instance of the plugin
   * layer is created with a call to new.
   */
  initialize: function(options) {
    /*
     * A common layer plugin pattern is to pass in the position of the layer
     * and record the postion to be able to use it when handling events.
     */
    this._latLng = options.latLng;

    // Continue initializing the layer plugin here.
  },

  /*
   * Leaflet calls the onAdd function when the layer is added to the map:
   *
   *   layer.addTo(map);
   *   map.addControl(layer);
   */
  onAdd: function(map) {

    // Retain a reference to the map to be able to use it when handling events.
    this._map = map;

    /*
     * Create the DOM element that will contain the layer. The leaflet-layer-template
     * CSS class is defined in the LeafletLayerTemplate.css file. The leaflet-zoom-hide
     * CSS class is defined by Leaflet to hide layers when zooming to improve performance.
     */
    var layerElementTag = 'div';
    var layerElementClasses = '.leaflet-layer-template leaflet-zoom-hide';
    this._layerElement = L.DomUtil.create(layerElementTag, layerElementClasses);

    // Add the layer element to the Leaflet pane that holds layers.
    map.getPanes().overlayPane.appendChild(this._layerElement);

    // Start listening for Leaflet's viewreset events that are generated when the map is zoomed.
    map.on('viewreset', this._updatePosition, this);

    // Give the layer element the correct initial position.
    this._updatePosition();
  },

  /*
   * Our custom handler for Leaflet's viewreset events that are generated
   * when the map is zoomed. This function should update the position of
   * the layer to correspond to changes in the map after zooming.
   */
  _updatePosition: function() {
    /*
     * Calculate the coordinates of the point on screen (position) that corresponds
     * to the latitude and longitude coordinates on the map (this._latLng).
     */
    var position = this._map.latLngToLayerPoint(this._latLng);
    // Update the position of the layer element with the new screen location of the layer.
    L.DomUtil.setPosition(this._layerElement, position);
  },

  /*
   * Leaflet calls the onRemove function when a layer is removed from the map:
   *
   *   layer.removeFrom(map);
   *   map.removeLayer(layer);
   */
  onRemove: function(map) {
    // Remove the layer element from the Leaflet pane that holds layers.
    map.getPanes().overlayPane.removeChild(this._layerElement);

    // Stop listening for viewreset events.
    map.off('viewreset', this._updatePosition, this);
  }

});

/*
 * The standard Leaflet plugin creation pattern is to implement a factory function that
 * enables the creation of the plugin to be chained with other function calls:
 *
 *   L.leafletLayerTemplate().addTo(map);
 *
 * The common convention is to name the factory function after the class of the layer
 * plugin but make the first letter lower case.
 */
L.leafletLayerTemplate = function(options) {
  return new L.LeafletLayerTemplate(options);
};
<commit_msg>Add comment.<commit_after>/*
 * Leaflet layer plugins inherit from Leaflet's Layer class. A common
 * naming convention is to add the name of the layer plugin to Leaflet's
 * namespace, which is L.
 */
L.LeafletLayerTemplate = L.Layer.extend({

  /*
   * Leaflet calls the initialize function when an instance of the plugin
   * layer is created with a call to new.
   */
  initialize: function(options) {
    /*
     * A common layer plugin pattern is to pass in the position of the layer
     * and record the postion to be able to use it when handling events.
     */
    this._latLng = options.latLng;

    // Continue initializing the layer plugin here.
  },

  /*
   * Leaflet calls the onAdd function when the layer is added to the map:
   *
   *   layer.addTo(map);
   *   map.addControl(layer);
   */
  onAdd: function(map) {

    // Retain a reference to the map to be able to use it when handling events.
    this._map = map;

    /*
     * Create the DOM element that will contain the layer. The leaflet-layer-template
     * CSS class is defined in the LeafletLayerTemplate.css file. The leaflet-zoom-hide
     * CSS class is defined by Leaflet to hide layers when zooming to improve performance.
     */
    var layerElementTag = 'div';
    var layerElementClasses = '.leaflet-layer-template leaflet-zoom-hide';
    this._layerElement = L.DomUtil.create(layerElementTag, layerElementClasses);

    // Continue implementing the layer here.

    // Add the layer element to the Leaflet pane that holds layers.
    map.getPanes().overlayPane.appendChild(this._layerElement);

    // Start listening for Leaflet's viewreset events that are generated when the map is zoomed.
    map.on('viewreset', this._updatePosition, this);

    // Give the layer element the correct initial position.
    this._updatePosition();
  },

  /*
   * Our custom handler for Leaflet's viewreset events that are generated
   * when the map is zoomed. This function should update the position of
   * the layer to correspond to changes in the map after zooming.
   */
  _updatePosition: function() {
    /*
     * Calculate the coordinates of the point on screen (position) that corresponds
     * to the latitude and longitude coordinates on the map (this._latLng).
     */
    var position = this._map.latLngToLayerPoint(this._latLng);
    // Update the position of the layer element with the new screen location of the layer.
    L.DomUtil.setPosition(this._layerElement, position);
  },

  /*
   * Leaflet calls the onRemove function when a layer is removed from the map:
   *
   *   layer.removeFrom(map);
   *   map.removeLayer(layer);
   */
  onRemove: function(map) {
    // Remove the layer element from the Leaflet pane that holds layers.
    map.getPanes().overlayPane.removeChild(this._layerElement);

    // Stop listening for viewreset events.
    map.off('viewreset', this._updatePosition, this);
  }

});

/*
 * The standard Leaflet plugin creation pattern is to implement a factory function that
 * enables the creation of the plugin to be chained with other function calls:
 *
 *   L.leafletLayerTemplate().addTo(map);
 *
 * The common convention is to name the factory function after the class of the layer
 * plugin but make the first letter lower case.
 */
L.leafletLayerTemplate = function(options) {
  return new L.LeafletLayerTemplate(options);
};
<|endoftext|>


<commit_before>/**
Made by: J.C. de Rijcke
10645012

In assignment of: Programmeerproject
last added: 24-1-2017
**/

// dictionary for category and their colour
var colours = {defaultFill: 'black',
          "verylowBMI": '#ffffa0',
          "lowBMI" : "#fed976",
          "average" : "#feb24c",
          "overweight" : "#fd8d3c",
          "obese" : '#fc4e2a'

}

// load data
d3.json("../DATA/obesity_data.json", function(datas) {
    // slider
    var slider = document.getElementById('slider2')
    var dropDown = document.getElementById('sex')

    // add interactivity to dropdown and slider
    slider.addEventListener("click",updateMap)
    dropDown.addEventListener("click", updateMap);

    // selected categories from dropdown
    var selectedYear = slider.value
    var selectedSex = dropDown.value

    // update title
    updateTitle(selectedSex, selectedYear)

//    console.log("loaded dataset, untransformed:", datas["1999"][selectedSex])
    // takes data from loaded data and maults it into a datamap compatible dataset
    var mapDataSet = mapDataFormat(datas, selectedYear, selectedSex, "mean_bmi")

    // create datamap
    var map = new Datamap({
        scope: 'world',
        // get container to fill map with
        element: document.getElementById('infomap'),
        projection: 'mercator',
        height: document.getElementById('infomap').clientHeight,
        maxWidth: 200,
        // colours of categories
        fills: colours,
        data: mapDataSet,
        geographyConfig: {
            dataUrl: null,
            hideAntarctica: true,
            hideHawaiiAndAlaska : false,
            borderWidth: 1,
            borderOpacity: 1,
            borderColor: 'black',
            // popup properties and enablement
            popupTemplate: function(geography, data) {
              return ['
' + geography.properties.name + '',
              '
Meat import: ' + getData(geography.id, 3).toLocaleString() + ' USD' +'
',
               '
'].join('');
            },
            popupOnHover: true,
            highlightOnHover: false,
            highlightFillColor: 'red',
            highlightBorderColor: 'black',
            highlightBorderWidth: 3,
            highlightBorderOpacity: 1,
            },

            done: function(map){
            map.svg.selectAll('.datamaps-subunit').on('mouseenter', function(geo) {
            highlight_bargraph_on(geo.id)
            highlight_scatterPlot_on(geo.id);
            highlight_country(this)

            }),
            map.svg.selectAll('.datamaps-subunit').on('click', function(geo) {
            country_pick(geo.id)
            highlight_country(this)

            }),

            map.svg.selectAll('.datamaps-subunit').on('mouseleave', function(geo) {
            highlight_bargraph_off(geo.id),
            reset_opacity(),
            highlight_scatterPlot_off(geo.id
            ),
            function(d, i) {
                d3.selectAll('path')
                        .style({
                            'fill-opacity':1.0,
                            'highlight': "red"
                        });
                }
            })}

    })

// create legend
map.legend()

    // update datamap
    function updateMap() {
        selectedYear = slider.value;
        selectedSex = dropDown.value
        mapDataSet = mapDataFormat(datas, selectedYear, selectedSex, "mean_bmi")
        map.updateChoropleth(mapDataSet)
        updateTitle(selectedSex, selectedYear)
//        console.log("selected year:", selectedSex)
    }
});

// format data to datamap compatible data
function mapDataFormat(data, year, sex, category){
    preDataSet = data[year][sex];
    dataSet = {};
    for(i = 0; i < preDataSet.length; i++){

        var fillValue = correspondingFillKey(+(preDataSet[i][category]), category)
        dataSet[preDataSet[i]["country_code"]] = {"fillKey":fillValue}
    };
    return dataSet
};

// retrieve category for colour
function correspondingFillKey(value, category){
    if(category == "mean_bmi"){
        if(value < 22){
        return "verylowBMI"
        }
        if(value < 24){
        return "lowBMI"
        }
        if(value < 26){
        return "average"
        }
        if(value < 28){
        return "overweight"
        }
        else{
        return "obese"
        }
    }
    else if(category == "fraction_obese"){
        if(value < 15){
        return "verylowBMI"
        }
        if(value < 20){
        return "lowBMI"
        }
        if(value < 25){
        return "average"
        }
        if(value < 30){
        return "overweight"
        }
        else{
        return "obese"
        }
    };
};

// highlight country
function highlight_country(country_id){
    var currentState = country_id
    var thoseStates = d3
            .selectAll('path')[0]
            .filter(function(state) {
                return state !== currentState;
            });
    d3.selectAll(thoseStates)
            .style({
                'fill-opacity':.3
            });
    d3.select(currentState)
            .style({
                'fill-opacity':1.0,
                'stroke-width' : 3,
                'stroke' : "black"
            });
}

// dehighlight country
function reset_opacity(){
    d3.selectAll('path')
    .style({
        'fill-opacity':1.0,
        'stroke-width' : 1,
        'stroke' : "black"
    })
};

// retrieve sex string for right context
function sexTextConverter(sex){
var sexText = "to be determined"
        if(selectedSex == "Men"){
            return "male"
        }
        else{
            return "female"
        }
        }

// retrieve colour on mean BMI value base
function determineColour(meanBMI){
    if(meanBMI < 18){
        return '#ffffa0'
    }
    else if(meanBMI < 25){
        return "#fed976"
    }
    else if(meanBMI < 30){
        return "#feb24c"
    }
    else{
        return "red"
    }
}

// update title
function updateTitle(sex, year){
    var sexText = "to be determined"
    if(sex == "Men"){
        sexText = "male"
    }
    else{
        sexText = "female"
    }

    d3.select("#title_infomap").selectAll("*").remove()
    d3.select("#title_infomap")
        .attr("class", "Title")
               .append("text")
                    .attr("x", 200)
                    .attr("y", 0)
                    .attr("text-anchor", "middle")
                    .style("font-size", "15px")
                    .text("Average BMI of " + sexText + " population per country in " + year);
}

<commit_msg>tooltip map<commit_after>/**
Made by: J.C. de Rijcke
10645012

In assignment of: Programmeerproject
last added: 24-1-2017
**/

// dictionary for category and their colour
var colours = {defaultFill: 'black',
          "verylowBMI": '#ffffa0',
          "lowBMI" : "#fed976",
          "average" : "#feb24c",
          "overweight" : "#fd8d3c",
          "obese" : '#fc4e2a'

}

// load data
d3.json("../DATA/obesity_data.json", function(datas) {
    // slider
    var slider = document.getElementById('slider2')
    var dropDown = document.getElementById('sex')

    // add interactivity to dropdown and slider
    slider.addEventListener("click",updateMap)
    dropDown.addEventListener("click", updateMap);

    // selected categories from dropdown
    var selectedYear = slider.value
    var selectedSex = dropDown.value

    // update title
    updateTitle(selectedSex, selectedYear)

//    console.log("loaded dataset, untransformed:", datas["1999"][selectedSex])
    // takes data from loaded data and maults it into a datamap compatible dataset
    var mapDataSet = mapDataFormat(datas, selectedYear, selectedSex, "mean_bmi")

    // create datamap
    var map = new Datamap({
        scope: 'world',
        // get container to fill map with
        element: document.getElementById('infomap'),
        projection: 'mercator',
        height: document.getElementById('infomap').clientHeight,
        maxWidth: 200,
        // colours of categories
        fills: colours,
        data: mapDataSet,
        geographyConfig: {
            dataUrl: null,
            hideAntarctica: true,
            hideHawaiiAndAlaska : false,
            borderWidth: 1,
            borderOpacity: 1,
            borderColor: 'black',
            // popup properties and enablement
            popupTemplate: function(geography, datas) {
            //console.log(geography["properties"]["name"]);
            //console.log(geography.id)
            //console.log(geography.id)
              return ['
' + geography["properties"]["name"] + '',
              '
Mean BMI of the '+ sexTextConverter(selectedSex) + ' population: ' + getData(geography.id).toLocaleString() + ' kg/m2' +'
',
               '
'].join('');
            },
            popupOnHover: true,
            highlightOnHover: false,
            highlightFillColor: 'red',
            highlightBorderColor: 'black',
            highlightBorderWidth: 3,
            highlightBorderOpacity: 1,
            },

            done: function(map){
            map.svg.selectAll('.datamaps-subunit').on('mouseenter', function(geo) {
            highlight_bargraph_on(geo.id)
            highlight_scatterPlot_on(geo.id);
            highlight_country(this)

            }),
            map.svg.selectAll('.datamaps-subunit').on('click', function(geo) {
            country_pick(geo.id)
            highlight_country(this)

            }),

            map.svg.selectAll('.datamaps-subunit').on('mouseleave', function(geo) {
            highlight_bargraph_off(geo.id),
            reset_opacity(),
            highlight_scatterPlot_off(geo.id
            ),
            function(d, i) {
                d3.selectAll('path')
                        .style({
                            'fill-opacity':1.0,
                            'highlight': "red"
                        });
                }
            })}

    })

// create legend
map.legend()

    // update datamap
    function updateMap() {
        selectedYear = slider.value;
        selectedSex = dropDown.value
        mapDataSet = mapDataFormat(datas, selectedYear, selectedSex, "mean_bmi")
        map.updateChoropleth(mapDataSet)
        updateTitle(selectedSex, selectedYear)
//        console.log("selected year:", selectedSex)
    }

    function getData(country_id){
        for (country in datas[selectedYear][selectedSex]){
            if(datas[selectedYear][selectedSex][country]["country_code"] == country_id){
                return Number(datas[selectedYear][selectedSex][country]["mean_bmi"]);
            }
        }
   }

// retrieve sex string for right context
   function sexTextConverter(sex){
       var sexText = "to be determined"
       if(selectedSex == "Men"){
           return "male"
       }
       else{
           return "female"
       }
   }
});

// format data to datamap compatible data
function mapDataFormat(data, year, sex, category){
    preDataSet = data[year][sex];
    dataSet = {};
    for(i = 0; i < preDataSet.length; i++){

        var fillValue = correspondingFillKey(+(preDataSet[i][category]), category)
        dataSet[preDataSet[i]["country_code"]] = {"fillKey":fillValue}
    };
    return dataSet
};

// retrieve category for colour
function correspondingFillKey(value, category){
    if(category == "mean_bmi"){
        if(value < 22){
        return "verylowBMI"
        }
        if(value < 24){
        return "lowBMI"
        }
        if(value < 26){
        return "average"
        }
        if(value < 28){
        return "overweight"
        }
        else{
        return "obese"
        }
    }
    else if(category == "fraction_obese"){
        if(value < 15){
        return "verylowBMI"
        }
        if(value < 20){
        return "lowBMI"
        }
        if(value < 25){
        return "average"
        }
        if(value < 30){
        return "overweight"
        }
        else{
        return "obese"
        }
    };
};

// highlight country
function highlight_country(country_id){
    var currentState = country_id
    var thoseStates = d3
            .selectAll('path')[0]
            .filter(function(state) {
                return state !== currentState;
            });
    d3.selectAll(thoseStates)
            .style({
                'fill-opacity':.3
            });
    d3.select(currentState)
            .style({
                'fill-opacity':1.0,
                'stroke-width' : 3,
                'stroke' : "black"
            });
}

// dehighlight country
function reset_opacity(){
    d3.selectAll('path')
    .style({
        'fill-opacity':1.0,
        'stroke-width' : 1,
        'stroke' : "black"
    })
};

// retrieve colour on mean BMI value base
function determineColour(meanBMI){
    if(meanBMI < 18){
        return '#ffffa0'
    }
    else if(meanBMI < 25){
        return "#fed976"
    }
    else if(meanBMI < 30){
        return "#feb24c"
    }
    else{
        return "red"
    }
}

// update title
function updateTitle(sex, year){
    var sexText = "to be determined"
    if(sex == "Men"){
        sexText = "male"
    }
    else{
        sexText = "female"
    }

    d3.select("#title_infomap").selectAll("*").remove()
    d3.select("#title_infomap")
        .attr("class", "Title")
               .append("text")
                    .attr("x", 200)
                    .attr("y", 0)
                    .attr("text-anchor", "middle")
                    .style("font-size", "15px")
                    .text("Average BMI of " + sexText + " population per country in " + year);
}

<|endoftext|>


<commit_before> (function($){
    "use strict";
    $(function(){
        var $shrinkHeaderHeight = 300;
        var $fixedHeader = $('.fixed_header .header_wrap');
        var $gnb = $('.gnb');
        var $hoverEl = $('.hover');
        var $searchEl = $('.click > a');
        var $searchForm = $('.search_area');

        // Fixed header
        if($fixedHeader.length)
        {
            var fixedHeaderHeight = $fixedHeader.height();
            var hasClass = false;
            var $logoImg = $fixedHeader.find('.header h1 img');
            var logoDataSrc = $logoImg.data('logo');
            var logo = $logoImg.attr('src');

            $(window).scroll(function() {
                var scroll = $(this).scrollTop();

                if(scroll >= $shrinkHeaderHeight ) {
                    if(!hasClass)
                    {
                        $fixedHeader.addClass('shrink');
                        if(logoDataSrc) $logoImg.attr('src', logoDataSrc);
                        hasClass = true;
                    }
                } else {
                    if(hasClass)
                    {
                        $fixedHeader.removeClass('shrink');
                        if(logoDataSrc) $logoImg.attr('src', logo);
                        hasClass = false;
                    }
                }
            });
            $(window).triggerHandler('scroll');
        }
        // Gnb
        if($(document).width() > 480){
	        $gnb.addClass('pc-gnb');
        }

        var $pc_gnb = $('.pc-gnb');
        $pc_gnb.find('>ul>li>a')
        .mouseover(function(){
            $gnb.find('>ul>li>ul:visible').hide().parent('li').removeClass('on');
            $(this).next('ul:hidden').stop().fadeIn(200).parent('li').addClass('on')
        })
        .focus(function(){
            $(this).mouseover();
        })
        .end()
        .mouseleave(function(){
            $gnb.find('>ul>li>ul').hide().parent().removeClass('on')
        });

		$pc_gnb.find('>ul>li>ul>li>a')
        .mouseover(function(){
            $gnb.find('>ul>li>ul>li>ul:visible').hide().parent('li').removeClass('on');
            $(this).next('ul:hidden').stop().fadeIn(200).parent('li').addClass('on')
        })
        .focus(function(){
            $(this).mouseover();
        })
        .end()
        .mouseleave(function(){
            $gnb.find('>ul>li>ul>li>ul').hide().parent().removeClass('on')
        });

		$("#mobile_menu_btn").on('click', function(){
			var isOpened = $(this);
			if(isOpened.hasClass('opened')){
				$("#gnb").find(">ul").slideUp(200);
			}else{
				$("#gnb").find(">ul:not(:animated)").slideDown(200);
			}
			isOpened.toggleClass('opened');
		});
        // login popup
        $hoverEl.on('mouseenter mouseleave focusin focusout',function(e){
            e.preventDefault();
            if(e.type == 'mouseenter' || e.type == 'focusin'){
                $(this).addClass('on');
            } else {
                $(this).removeClass('on');
            }
        });
		// Search
        $searchEl.click(function(){
            if($searchForm.is(':hidden')){
                $searchForm.fadeIn().find('input').focus();
                if($('.magazine').length > 0){
                    $('.custom_area').css('opacity',0);
                    $('.side').css('opacity',0)
                } else{
                    $('.header').css('opacity',0)
                }
            }
            return false;
        });
        $('.btn_close').click(function(){
            var $this = $(this);
            $this.parent().fadeOut().find('input').val('');
            if($('.magazine').length > 0){
                $('.custom_area').css('opacity',1);
                $('.side').css('opacity',1)
            } else{
                $('.header').css('opacity',1)
            }
            $searchEl.focus();
            return false;
        });

        // slide
        if($.isFunction($.fn.camera) && $(".camera_wrap").length) {
            $(".camera_wrap").camera({
                height: "600px",
                pagination: true,
                thumbnails: false,
                playPause: false,
                loader: "none",
                fx: "simpleFade",
                time: 3000
            });
        }

        // Login help, warning
        $("#warning").on('click', function(e){
	        $(this).css('display', 'none');
        });

        // Scroll to top
        var scrollToTop = function() {
            var link = $('.btn_top');
            var windowW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;

            $(window).scroll(function() {
                if (($(this).scrollTop() > 150) && (windowW > 1000)) {
                    link.fadeIn(100);
                } else {
                    link.fadeOut(100);
                }
            });

            link.click(function() {
                $('html, body').animate({scrollTop: 0}, 400);
                return false;
            });
        };
        scrollToTop();

        // Sub Header Parallax
        $('.sub_type3 .bg_img').parallax('50%',0.4);
    })
})(jQuery);
(function($) {
    "use strict";
    var $window = $(window);
    var windowHeight = $window.height();

    $window.resize(function() {
        windowHeight = $window.height()
    });

    $.fn.parallax = function(xpos, speedFactor, outerHeight) {
        var $this = $(this);
        var getHeight;
        var firstTop;
        $this.each(function() {
            firstTop = $this.offset().top;
        });

        if (outerHeight) {
          getHeight = function(object) {
            return object.outerHeight(true)
          }
        } else {
          getHeight = function(object) {
            return object.height()
          }
        }
        if (arguments.length < 1 || xpos === null)
          xpos = "50%";
        if (arguments.length < 2 || speedFactor === null)
          speedFactor = 0.1;
        if (arguments.length < 3 || outerHeight === null)
          outerHeight = true;
        function update() {
          var pos = $window.scrollTop();
          $this.each(function() {
            var $element = $(this);
            var top = $element.offset().top;
            var height = getHeight($element);

            if (top + height < pos || top > pos + windowHeight) {
              return
            }
            $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px")
          })
        }
        $window.bind('scroll', update).resize(update);
        update()
  }
})(jQuery);

(function($){
	 $(function(){
		$('.bg-holder').parallaxScroll({
		  friction: 0.2
		});
    });
})(jQuery);
<commit_msg>로그인 팝업창의 로그인유지 경고알림 모바일 대응부분 js에서 click을 touchend로 변경<commit_after> (function($){
    "use strict";
    $(function(){
        var $shrinkHeaderHeight = 300;
        var $fixedHeader = $('.fixed_header .header_wrap');
        var $gnb = $('.gnb');
        var $hoverEl = $('.hover');
        var $searchEl = $('.click > a');
        var $searchForm = $('.search_area');

        // Fixed header
        if($fixedHeader.length)
        {
            var fixedHeaderHeight = $fixedHeader.height();
            var hasClass = false;
            var $logoImg = $fixedHeader.find('.header h1 img');
            var logoDataSrc = $logoImg.data('logo');
            var logo = $logoImg.attr('src');

            $(window).scroll(function() {
                var scroll = $(this).scrollTop();

                if(scroll >= $shrinkHeaderHeight ) {
                    if(!hasClass)
                    {
                        $fixedHeader.addClass('shrink');
                        if(logoDataSrc) $logoImg.attr('src', logoDataSrc);
                        hasClass = true;
                    }
                } else {
                    if(hasClass)
                    {
                        $fixedHeader.removeClass('shrink');
                        if(logoDataSrc) $logoImg.attr('src', logo);
                        hasClass = false;
                    }
                }
            });
            $(window).triggerHandler('scroll');
        }
        // Gnb
        if($(document).width() > 480){
	        $gnb.addClass('pc-gnb');
        }

        var $pc_gnb = $('.pc-gnb');
        $pc_gnb.find('>ul>li>a')
        .mouseover(function(){
            $gnb.find('>ul>li>ul:visible').hide().parent('li').removeClass('on');
            $(this).next('ul:hidden').stop().fadeIn(200).parent('li').addClass('on')
        })
        .focus(function(){
            $(this).mouseover();
        })
        .end()
        .mouseleave(function(){
            $gnb.find('>ul>li>ul').hide().parent().removeClass('on')
        });

		$pc_gnb.find('>ul>li>ul>li>a')
        .mouseover(function(){
            $gnb.find('>ul>li>ul>li>ul:visible').hide().parent('li').removeClass('on');
            $(this).next('ul:hidden').stop().fadeIn(200).parent('li').addClass('on')
        })
        .focus(function(){
            $(this).mouseover();
        })
        .end()
        .mouseleave(function(){
            $gnb.find('>ul>li>ul>li>ul').hide().parent().removeClass('on')
        });

		$("#mobile_menu_btn").on('click', function(){
			var isOpened = $(this);
			if(isOpened.hasClass('opened')){
				$("#gnb").find(">ul").slideUp(200);
			}else{
				$("#gnb").find(">ul:not(:animated)").slideDown(200);
			}
			isOpened.toggleClass('opened');
		});
        // login popup
        $hoverEl.on('mouseenter mouseleave focusin focusout',function(e){
            e.preventDefault();
            if(e.type == 'mouseenter' || e.type == 'focusin'){
                $(this).addClass('on');
            } else {
                $(this).removeClass('on');
            }
        });
		// Search
        $searchEl.click(function(){
            if($searchForm.is(':hidden')){
                $searchForm.fadeIn().find('input').focus();
                if($('.magazine').length > 0){
                    $('.custom_area').css('opacity',0);
                    $('.side').css('opacity',0)
                } else{
                    $('.header').css('opacity',0)
                }
            }
            return false;
        });
        $('.btn_close').click(function(){
            var $this = $(this);
            $this.parent().fadeOut().find('input').val('');
            if($('.magazine').length > 0){
                $('.custom_area').css('opacity',1);
                $('.side').css('opacity',1)
            } else{
                $('.header').css('opacity',1)
            }
            $searchEl.focus();
            return false;
        });

        // slide
        if($.isFunction($.fn.camera) && $(".camera_wrap").length) {
            $(".camera_wrap").camera({
                height: "600px",
                pagination: true,
                thumbnails: false,
                playPause: false,
                loader: "none",
                fx: "simpleFade",
                time: 3000
            });
        }

        // Login help, warning
        $("#warning").on('touchend', function(e){
	        $(this).css('display', 'none');
        });

        // Scroll to top
        var scrollToTop = function() {
            var link = $('.btn_top');
            var windowW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;

            $(window).scroll(function() {
                if (($(this).scrollTop() > 150) && (windowW > 1000)) {
                    link.fadeIn(100);
                } else {
                    link.fadeOut(100);
                }
            });

            link.click(function() {
                $('html, body').animate({scrollTop: 0}, 400);
                return false;
            });
        };
        scrollToTop();

        // Sub Header Parallax
        $('.sub_type3 .bg_img').parallax('50%',0.4);
    })
})(jQuery);
(function($) {
    "use strict";
    var $window = $(window);
    var windowHeight = $window.height();

    $window.resize(function() {
        windowHeight = $window.height()
    });

    $.fn.parallax = function(xpos, speedFactor, outerHeight) {
        var $this = $(this);
        var getHeight;
        var firstTop;
        $this.each(function() {
            firstTop = $this.offset().top;
        });

        if (outerHeight) {
          getHeight = function(object) {
            return object.outerHeight(true)
          }
        } else {
          getHeight = function(object) {
            return object.height()
          }
        }
        if (arguments.length < 1 || xpos === null)
          xpos = "50%";
        if (arguments.length < 2 || speedFactor === null)
          speedFactor = 0.1;
        if (arguments.length < 3 || outerHeight === null)
          outerHeight = true;
        function update() {
          var pos = $window.scrollTop();
          $this.each(function() {
            var $element = $(this);
            var top = $element.offset().top;
            var height = getHeight($element);

            if (top + height < pos || top > pos + windowHeight) {
              return
            }
            $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px")
          })
        }
        $window.bind('scroll', update).resize(update);
        update()
  }
})(jQuery);

(function($){
	 $(function(){
		$('.bg-holder').parallaxScroll({
		  friction: 0.2
		});
    });
})(jQuery);
<|endoftext|>


<commit_before>'use strict'

const facebook = require('../facebook.js'),
      brain = require('../brain/brain.js'),
      messenger = require('../messenger.js')

exports.handle = function(event) {
  let payload = event.postback.payload
  if (brain.messages[payload]) {
    let payloadClone = JSON.parse(JSON.stringify(brain.messages[payload]))
    handlePayload(event, payloadClone)
  }
}

function handlePayload(event, messages) {
  let message = messages.shift()

  if (message !== undefined) {
    messenger.sendMessage(event, message, () => {
      handlePayload(event, messages)
    })
  }
}
<commit_msg>only send the recipient<commit_after>'use strict'

const facebook = require('../facebook.js'),
      brain = require('../brain/brain.js'),
      messenger = require('../messenger.js')

exports.handle = function(event) {
  let payload = event.postback.payload
  if (brain.messages[payload]) {
    let payloadClone = JSON.parse(JSON.stringify(brain.messages[payload]))
    handlePayload(event, payloadClone)
  }
}

function handlePayload(event, messages) {
  let message = messages.shift()

  if (message !== undefined) {
    messenger.sendMessage(event.sender, message, () => {
      handlePayload(event, messages)
    })
  }
}
<|endoftext|>


<commit_before>define(['js/core/Component'], function (Component) {

    return Component.inherit('sprd.util.LocaleService', {

        defaults: {
            fallbackLanguage: 'en',
            fallbackCountry: 'EU',
            supportedLanguages: null,
            supportedCountries: null
        },

        $languageMap: {
            de: 'de',
            fr: 'fr',
            'co.uk': 'en',
            be: 'nl',
            dk: 'dk',
            es: 'es',
            ie: 'en',
            it: 'it',
            nl: 'nl',
            no: 'no',
            pl: 'pl',
            fi: 'fi',
            se: 'se',
            at: 'de',

            net: null,
            com: null
        },

        $countryMap: {
            de: 'DE',
            fr: 'FR',
            'co.uk': 'GB',
            be: 'BE',
            dk: 'DK',
            es: 'ES',
            ie: 'IE',
            it: 'IT',
            nl: 'NL',
            no: 'NO',
            pl: 'PL',
            fi: 'FI',
            se: 'SE',
            at: 'AT',

            net: "EU",
            com: "US"
        },

        getLanguage: function () {
            var browserLanguage = (navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage).split("-")[0];
            return this.determinateLanguage(this.getHost(), browserLanguage, this.$.supportedLanguages, this.$.fallbackLanguage);
        },

        getCountry: function() {
            return this.determinateCountry(this.getHost(), this.$.supportedCountries, this.$.fallbackCountry);
        },

        getHost: function() {
            return this.runsInBrowser() ? this.$stage.$window.location.host : null;
        },

        getLocale: function() {
            return this.getLanguage() + '_' + this.getCountry();
        },

        determinateLanguage: function (host, browserLanguage, supportedLanguages, fallbackLanguage) {
            fallbackLanguage = fallbackLanguage || 'en';

            if (supportedLanguages && !(supportedLanguages instanceof Array)) {
                supportedLanguages = (supportedLanguages || "").split(";")
            }

            var language;

            if (host) {
                // determinate by domain
                var domain = /\.([a-z]{2,4})$/.exec(host)[1];
                language = this.$languageMap[domain] || browserLanguage;
            }

            language = language ||browserLanguage;

            for (var key in this.$languageMap) {
                if (this.$languageMap.hasOwnProperty(key)) {
                    if (key && key === this.$languageMap[key] && (!supportedLanguages || supportedLanguages[key])) {
                        return language;
                    }
                }
            }

            return fallbackLanguage;
        },

        determinateCountry: function (host, supportedCountries, fallbackCountry) {
            fallbackCountry = fallbackCountry || 'EU';

            if (supportedCountries && !(supportedCountries instanceof Array)) {
                supportedCountries = (supportedCountries || "").split(";")
            }

            var country;

            if (host) {
                // determinate by domain
                var domain = /\.([a-z]{2,4})$/.exec(host)[1];
                country = this.$countryMap[domain];
            }

            for (var key in this.$countryMap) {
                if (this.$countryMap.hasOwnProperty(key)) {
                    if (key && key === this.$countryMap[key] && (!supportedCountries || supportedCountries[key])) {
                        return country;
                    }
                }
            }

            return fallbackCountry;
        }

    });
});<commit_msg>fixed localeservice to not throw exception is domain is an IP address<commit_after>define(['js/core/Component'], function (Component) {

    return Component.inherit('sprd.util.LocaleService', {

        defaults: {
            fallbackLanguage: 'en',
            fallbackCountry: 'EU',
            supportedLanguages: null,
            supportedCountries: null
        },

        $languageMap: {
            de: 'de',
            fr: 'fr',
            'co.uk': 'en',
            be: 'nl',
            dk: 'dk',
            es: 'es',
            ie: 'en',
            it: 'it',
            nl: 'nl',
            no: 'no',
            pl: 'pl',
            fi: 'fi',
            se: 'se',
            at: 'de',

            net: null,
            com: null
        },

        $countryMap: {
            de: 'DE',
            fr: 'FR',
            'co.uk': 'GB',
            be: 'BE',
            dk: 'DK',
            es: 'ES',
            ie: 'IE',
            it: 'IT',
            nl: 'NL',
            no: 'NO',
            pl: 'PL',
            fi: 'FI',
            se: 'SE',
            at: 'AT',

            net: "EU",
            com: "US"
        },

        getLanguage: function () {
            var browserLanguage = (navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage).split("-")[0];
            return this.determinateLanguage(this.getHost(), browserLanguage, this.$.supportedLanguages, this.$.fallbackLanguage);
        },

        getCountry: function() {
            return this.determinateCountry(this.getHost(), this.$.supportedCountries, this.$.fallbackCountry);
        },

        getHost: function() {
            return this.runsInBrowser() ? this.$stage.$window.location.host : null;
        },

        getLocale: function() {
            return this.getLanguage() + '_' + this.getCountry();
        },

        determinateLanguage: function (host, browserLanguage, supportedLanguages, fallbackLanguage) {
            fallbackLanguage = fallbackLanguage || 'en';

            if (supportedLanguages && !(supportedLanguages instanceof Array)) {
                supportedLanguages = (supportedLanguages || "").split(";")
            }

            var language;

            if (host) {
                // determinate by domain
                var domain = /\.([a-z]{2,4})$/.exec(host);
                if (domain) {
                    language = this.$languageMap[domain[1]];
                }

                language = language || browserLanguage;

            }

            language = language ||browserLanguage;

            for (var key in this.$languageMap) {
                if (this.$languageMap.hasOwnProperty(key)) {
                    if (key && key === this.$languageMap[key] && (!supportedLanguages || supportedLanguages[key])) {
                        return language;
                    }
                }
            }

            return fallbackLanguage;
        },

        determinateCountry: function (host, supportedCountries, fallbackCountry) {
            fallbackCountry = fallbackCountry || 'EU';

            if (supportedCountries && !(supportedCountries instanceof Array)) {
                supportedCountries = (supportedCountries || "").split(";")
            }

            var country;

            if (host) {
                // determinate by domain
                var domain = /\.([a-z]{2,4})$/.exec(host);
                if (domain) {
                    country = this.$countryMap[domain[1]];
                }
            }

            for (var key in this.$countryMap) {
                if (this.$countryMap.hasOwnProperty(key)) {
                    if (key && key === this.$countryMap[key] && (!supportedCountries || supportedCountries[key])) {
                        return country;
                    }
                }
            }

            return fallbackCountry;
        }

    });
});<|endoftext|>


<commit_before>module.exports = {
  docs: [
    {
      type: 'category',
      label: 'Introduction',
      collapsible: false,
      items: ['software-engineering-interview-guide'],
    },
    {
      type: 'category',
      label: 'Getting an interview',
      collapsible: false,
      items: ['resume'],
    },
    {
      type: 'category',
      label: 'Coding interview preparation',
      collapsible: false,
      items: [
        'coding-interview-prep',
        'programming-languages-for-coding-interviews',
        'coding-interview-study-plan',
        'coding-interview-cheatsheet',
        'coding-interview-techniques',
        'mock-interviews',
        'coding-interview-rubrics',
      ],
    },
    {
      type: 'category',
      label: 'System design interview preparation',
      collapsible: false,
      items: ['system-design'],
    },
    {
      type: 'category',
      label: 'Behavioral interview preparation',
      collapsible: false,
      items: [
        'behavioral-interview',
        'behavioral-interview-questions',
        'self-introduction',
        'final-questions',
      ],
    },
    {
      'Salary and offer negotiation preparation': [
        'understanding-compensation',
        'negotiation',
        'negotiation-rules',
        'choosing-between-companies',
      ],
    },
    {
      'Algorithms study cheatsheets': [
        'algorithms/study-cheatsheet',
        {
          type: 'category',
          label: 'Basics',
          collapsible: false,
          items: [
            'algorithms/array',
            'algorithms/string',
            'algorithms/hash-table',
            'algorithms/recursion',
            'algorithms/sorting-searching',
          ],
        },
        {
          type: 'category',
          label: 'Data structures',
          collapsible: false,
          items: [
            'algorithms/matrix',
            'algorithms/linked-list',
            'algorithms/queue',
            'algorithms/stack',
            'algorithms/interval',
          ],
        },
        {
          type: 'category',
          label: 'Advanced data structures',
          collapsible: false,
          items: [
            'algorithms/tree',
            'algorithms/graph',
            'algorithms/heap',
            'algorithms/trie',
          ],
        },
        {
          type: 'category',
          label: 'Additional',
          collapsible: false,
          items: [
            'algorithms/dynamic-programming',
            'algorithms/binary',
            'algorithms/math',
            'algorithms/geometry',
          ],
        },
      ],
    },
    {
      Misc: [
        'interview-formats-top-companies',
        'interviewer-cheatsheet',
        'landscape',
        'engineering-levels',
      ],
    },
  ],
};
<commit_msg>contents: add links to orphaned pages<commit_after>module.exports = {
  docs: [
    {
      type: 'category',
      label: 'Introduction',
      collapsible: false,
      items: ['software-engineering-interview-guide'],
    },
    {
      type: 'category',
      label: 'Getting an interview',
      collapsible: false,
      items: ['resume'],
    },
    {
      type: 'category',
      label: 'Coding interview preparation',
      collapsible: false,
      items: [
        'coding-interview-prep',
        'programming-languages-for-coding-interviews',
        'coding-interview-study-plan',
        'coding-interview-cheatsheet',
        'coding-interview-techniques',
        'mock-interviews',
        'coding-interview-rubrics',
      ],
    },
    {
      type: 'category',
      label: 'System design interview preparation',
      collapsible: false,
      items: ['system-design'],
    },
    {
      type: 'category',
      label: 'Behavioral interview preparation',
      collapsible: false,
      items: [
        'behavioral-interview',
        'behavioral-interview-questions',
        'self-introduction',
        'final-questions',
      ],
    },
    {
      'Salary and offer negotiation preparation': [
        'understanding-compensation',
        'negotiation',
        'negotiation-rules',
        'choosing-between-companies',
      ],
    },
    {
      'Algorithms study cheatsheets': [
        'algorithms/study-cheatsheet',
        {
          type: 'category',
          label: 'Basics',
          collapsible: false,
          items: [
            'algorithms/array',
            'algorithms/string',
            'algorithms/hash-table',
            'algorithms/recursion',
            'algorithms/sorting-searching',
          ],
        },
        {
          type: 'category',
          label: 'Data structures',
          collapsible: false,
          items: [
            'algorithms/matrix',
            'algorithms/linked-list',
            'algorithms/queue',
            'algorithms/stack',
            'algorithms/interval',
          ],
        },
        {
          type: 'category',
          label: 'Advanced data structures',
          collapsible: false,
          items: [
            'algorithms/tree',
            'algorithms/graph',
            'algorithms/heap',
            'algorithms/trie',
          ],
        },
        {
          type: 'category',
          label: 'Additional',
          collapsible: false,
          items: [
            'algorithms/dynamic-programming',
            'algorithms/binary',
            'algorithms/math',
            'algorithms/geometry',
          ],
        },
      ],
    },
    {
      Misc: [
        'interview-formats-top-companies',
        'interviewer-cheatsheet',
        'landscape',
        'engineering-levels',
        'best-coding-interview-courses',
        'best-practice-questions',
      ],
    },
  ],
};
<|endoftext|>


<commit_before>module.exports = {
  Sidebar: [
    "getting_started",
    {
      type: "category",
      label: "Guides",
      collapsed: false,
      items: [
        "cookbooks/testing",
        //"cookbooks/refresh",
      ],
    },
    {
      type: "category",
      label: "Concepts",
      items: [
        "concepts/providers",
        "concepts/reading",
        "concepts/combining_providers",
        "concepts/provider_observer",
        // "concepts/computed",
        {
          type: "category",
          label: "Modifiers",
          items: [
            "concepts/modifiers/family",
            "concepts/modifiers/auto_dispose",
          ],
        },
      ],
    },

    {
      type: "category",
      label: "Examples",
      collapsed: false,
      items: [
        {
          type: "link",
          label: "Counter",
          href:
            "https://github.com/rrousselGit/river_pod/tree/master/examples/counter",
        },
        {
          type: "link",
          label: "Todo list",
          href:
            "https://github.com/rrousselGit/river_pod/tree/master/examples/todos",
        },
        {
          type: "link",
          label: "Marvel API",
          href:
            "https://github.com/rrousselGit/river_pod/tree/master/examples/marvel",
        },
      ],
    },
    {
      type: "category",
      label: "Api references",
      items: [
        {
          type: "link",
          label: "riverpod",
          href:
            "https://pub.dev/documentation/riverpod/latest/riverpod/riverpod-library.html",
        },
        {
          type: "link",
          label: "flutter_riverpod",
          href:
            "https://pub.dev/documentation/flutter_riverpod/latest/flutter_riverpod/flutter_riverpod-library.html",
        },
        {
          type: "link",
          label: "hooks_riverpod",
          href:
            "https://pub.dev/documentation/hooks_riverpod/latest/hooks_riverpod/hooks_riverpod-library.html",
        },
      ],
    },
  ],
};
<commit_msg>Added some more example apps with Riverpod<commit_after>module.exports = {
  Sidebar: [
    "getting_started",
    {
      type: "category",
      label: "Guides",
      collapsed: false,
      items: [
        "cookbooks/testing",
        //"cookbooks/refresh",
      ],
    },
    {
      type: "category",
      label: "Concepts",
      items: [
        "concepts/providers",
        "concepts/reading",
        "concepts/combining_providers",
        "concepts/provider_observer",
        // "concepts/computed",
        {
          type: "category",
          label: "Modifiers",
          items: [
            "concepts/modifiers/family",
            "concepts/modifiers/auto_dispose",
          ],
        },
      ],
    },

    {
      type: "category",
      label: "Examples",
      collapsed: false,
      items: [
        {
          type: "link",
          label: "Counter",
          href:
            "https://github.com/rrousselGit/river_pod/tree/master/examples/counter",
        },
        {
          type: "link",
          label: "Todo list",
          href:
            "https://github.com/rrousselGit/river_pod/tree/master/examples/todos",
        },
        {
          type: "link",
          label: "Marvel API",
          href:
            "https://github.com/rrousselGit/river_pod/tree/master/examples/marvel",
        },
        {
          type: "link",
          label: "Android Launcher",
          href:
            "https://github.com/lohanidamodar/fl_live_launcher",
        },
        {
          type: "link",
          label: "Worldtime Clock",
          href:
            "https://github.com/lohanidamodar/flutter_worldtime",
        },
        {
          type: "link",
          label: "Dictionary App",
          href:
            "https://github.com/lohanidamodar/fl_dictio",
        },
        {
          type: "link",
          label: "Firebase Starter",
          href:
            "https://github.com/lohanidamodar/flutter_firebase_starter/tree/feature/riverpod",
        },
      ],
    },
    {
      type: "category",
      label: "Api references",
      items: [
        {
          type: "link",
          label: "riverpod",
          href:
            "https://pub.dev/documentation/riverpod/latest/riverpod/riverpod-library.html",
        },
        {
          type: "link",
          label: "flutter_riverpod",
          href:
            "https://pub.dev/documentation/flutter_riverpod/latest/flutter_riverpod/flutter_riverpod-library.html",
        },
        {
          type: "link",
          label: "hooks_riverpod",
          href:
            "https://pub.dev/documentation/hooks_riverpod/latest/hooks_riverpod/hooks_riverpod-library.html",
        },
      ],
    },
  ],
};
<|endoftext|>