<commit_before>$(function() {
  var x = 5, y = 5; /* off set for moving images to the middle of the coords set */

  var places = [
    {"cod": "1A", "title":"Torturas", "name":"1A_TORTURAS", "left":1075-x,"top":1405-y},
    {"cod": "1B", "title":"Chamamé", "name":"1B_CHAMAMÉ", "left":1100-x,"top":1405-y},
    {"cod": "2A", "title":"Ambiente Musical Auto", "name":"2A_AMBIENTE_MUSICAL_AUTO_2", "left":984-x,"top":1347-y},
    {"cod": "2B", "title":"Juan Carlos Cosmovisión", "name":"2B_JUANCARLOS_(Agus)COSMOVISIÓN", "left":789-x,"top":1424-y},
    {"cod": "2C", "title":"N'VIKÉ", "name":"2C_N'VIKÉ", "left":811-x,"top":1424-y},
    {"cod": "3A", "title":"3A Pedro Valquinta", "name":"3A_PEDRO_VALQUINTA", "left":869-x,"top":1387-y},
    {"cod": "3B", "title":"Avia Terai", "name":"3B_AVIA_TERAI", "left":871-x,"top":1296-y},
    {"cod": "4A", "title":"Niños Pampa largo", "name":"4A_NIÑOS_PAMPA_largo", "left":969-x,"top":1223-y},
    {"cod": "4B", "title":"Vacas Pampa corto", "name":"4B_VACAS_PAMPA_corto", "left":976-x,"top":1248-y},
    {"cod": "5A", "name":"5A_CONFESIÓN_ROCA", "title":"Confesión Roca", "left":1007-x,"top":1239-y},
    {"cod": "5B", "name":"5B_ROSY", "title":"Rosy", "left":938-x,"top":1175-y},
    {"cod": "6A", "name":"6A_AMANECER_RIO_BERMEJITO", "title":"Amanecer río Bermejito", "left":968-x,"top":1176-y},
    {"cod": "6B", "name":"6B_CRISTO_REDENTOR_RICARDO", "title":"Cristo Redentor Ricardo", "left":901-x,"top":1140-y},
    {"cod": "6C", "name":"6C_GENOCIDIO_NO_TERMINADO", "title":"Genocidio no terminado", "left":899-x,"top":1166-y},
    {"cod": "7A", "name":"7A_AUTO_DESATASCADO", "title":"Auto desatascado", "left":831-x,"top":1106-y},
    {"cod": "7B", "name":"7B_CHICHO_GIMÉNEZ_INTENDENTE", "title":"Chicho Giménez intendente", "left":805-x,"top":1066-y},
    {"cod": "7C", "name":"7C_OVEJAS_NUEVA_POMPEYA", "title":"Ovejas Nueva Pompeya", "left":808-x,"top":1153-y},
    {"cod": "8A", "name":"8A_INDIO_TOBA", "title":"Indio Toba", "left":831-x,"top":1066-y},
    {"cod": "8B", "name":"8B_PERROS", "title":"Perros", "left":846-x,"top":1133-y},
    {"cod": "9A", "name": "9A_INGENIERO_JUÁREZ", "title": "Ingeniero Juárez", "left":753-x,"top":946-y},
    {"cod": "10A", "name":"10A_TARTAGAL", "title":"Tartagal", "left":525-x,"top":772-y},
    {"cod": "11A", "name":"11A_FRONTERA", "title":"Frontera", "left":554-x,"top":708-y},
    {"cod": "11B", "name": "11B_ACTO_RECEPCIÓN_YACUIBA", "title": "Acto recepción yacuiba", "left":590-x,"top":692-y},
    {"cod": "12A", "name":"12A_CREPITAR_OLLA", "title":"Crepitar olla", "left":580-x,"top":708-y},
    {"cod": "12B", "name": "12B_CHACARERA_CON_VACAS", "title": "Chacarera con vacas", "left":614-x,"top":692-y},
    {"cod": "12C", "name": "12C_MENONITAS", "title": "Menonitas", "left":569-x,"top":679-y},
    {"cod": "13A", "name": "13A_MILITARES_ESCONBOL", "title": "Militares Esconbol", "left":536-x,"top":664-y},
    {"cod": "13B", "name": "13B_PLANTAS_REPSOL", "title": "Plantas repsol", "left":542-x,"top":638-y},
    {"cod": "14A", "name": "14A_PIEDRAS_RIO", "title": "Piedras río", "left":564-x,"top":610-y},
    {"cod": "15A", "name": "15A_WEENHAYEK", "title": "Weenhayek", "left":590-x,"top":610-y},
    {"cod": "15B", "name": "15B_PUENTE_(GUERRA_CHACO)", "title":"Puente (guerra chaco)", "left":614-x,"top":610-y},
    {"cod": "16A", "name": "16A_AMANECER_CAMIRI", "title": "Amanecer camiri", "left":560-x,"top":455-y},
    {"cod": "16B", "name": "16B_FELIPE_ROMÁN", "title": "Felipe Román", "left":587-x,"top":455-y},
    {"cod": "16C", "name": "16C_ARETE_GUASÚ", "title": "Arete Guasú", "left":613-x,"top":455-y},
    {"cod": "16D", "name": "16D_MARIACHIS", "title": "Mariachis", "left":639-x,"top":455-y},
    {"cod": "17A", "name": "17A_FÚTBOL_UNIBOL", "title": "Fútbol unibol", "left":583-x,"top":492-y},
    {"cod": "17B", "name": "17B_SERMÓN", "title": "Sermón", "left":608-x,"top":492-y},
    {"cod": "17C", "name": "17C_PAJARITOS_DONDE_HUBO_LUCHA", "title": "Pajaritos donde hubo lucha", "left":634-x,"top":492-y},
    {"cod": "18A", "name": "18A_LLUVIA_KAA_IYA", "title": "Lluvia Kaa Iya", "left":898-x,"top":283-y},
    {"cod": "18B", "name": "18B_RANAS_KAA_IYA", "title": "Ranas Kaa Iya", "left":923-x,"top":283-y},
    {"cod": "19A", "name": "19A_MUCHAS_RANAS_A_CORO", "title": "Muchas ranas a coro", "left":950-x,"top":283-y},
    {"cod": "20A", "name": "20A_RADIO_Y_REGGAE", "title": "Radio y reggae", "left":778-x,"top":162-y},
    {"cod": "20B", "name": "20B_TATÚ_CRUZ_ENTREVISTA_CALLEJERA", "title": "Tatú Cruz - entrevista callejera", "left":640-x,"top":610-y},
    {"cod": "21A", "name": "21A_TATÚ_CRUZ_BAND", "title": "Tatú Cruz Band", "left":665-x,"top":610-y},
    //{"cod": "23A", "name": "23A_CAMIÓN_ENLHET", "title": "Camión Enlhet", "left":427,"top":902},
    //{"cod": "23B", "name": "23B_ANCIANO_ENLHET", "title": "Anciano Enlhet", "left":707,"top":420},
    //{"cod": "24A", "name": "24A_VIENTO_SACADA_COCHE", "title": "Viento sacada coche", "left":507,"top":692},
    //{"cod": "24B", "name": "24B_CANTO_HOMBRE_AYOREO", "title": "Canto hombre Ayoreo", "left":613,"top":872},
    //{"cod": "24C", "name": "24C_CANTO_MUJER_AYOREO", "title": "Canto mujer Ayoreo", "left":696,"top":795},
    //{"cod": "25A", "name": "25A_DE_PEDO_EN_EL_BARRO", "title": "De pedo en el barro", "left":164,"top":224},
    //{"cod": "26A", "name": "26A_BARCO", "title": "Barco", "left":397,"top":813},
    //{"cod": "27B", "name": "27B_CERDO_PUERTO_DIANA", "title": "Cerdo Puerto Diana", "left":97,"top":531},
    //{"cod": "27C", "name": "27C_CANTOS_ISHIR", "title": "Cantos Ishir", "left":392,"top":277},
    //{"cod": "28A", "name": "28A_PÁJAROS_3_GIGANTES", "title": "Pájaros 3 gigantes", "left":325,"top":459},
    //{"cod": "29A", "name": "29A_MÚSICA_BRASILERA", "title": "Música brasilera", "left":440,"top":569},
    //{"cod": "29B", "name": "29B_AGUA_CASADO", "title": "Agua Casado", "left":713,"top":703},
    //{"cod": "29C", "name": "29C_AMBIENTE_CASADO", "title": "Ambiente Casado", "left":360,"top":445},
    //{"cod": "31A", "name": "31A_CHARLA_SAWHOYAMAXA", "title": "Charla Sawhoyamaxa", "left":308,"top":117},
    //{"cod": "31B", "name": "31B_NIÑOS_SAWHOYAMAXA", "title": "Niños Sawhoyamaxa", "left":610,"top":528},
    //{"cod": "J3", "name": "J3_NDE_RAMIREZ", "title": "Nde Ramirez", "left":704,"top":213},
    //{"cod": "J4", "name": "J4_ASUNCIÓN_DESDE_GRAN_HOTEL_PARANÁ", "title": "Asunción desde gran hotel Paraná", "left":757,"top":546}

  ]

  var template = ""

  Mustache.parse(template); // speeds up future uses

  places.forEach(
    function(element,index,array){
      var output = Mustache.render(template,element);
      document.getElementById('include_places').innerHTML += output;
      document.getElementById(element["cod"]).onload = function(){
        $('#'+element["cod"]+'_span').fadeIn('slow');
        //document.getElementById('pop').play()
        }

      /* onload = function(){
        //$(element["cod"]+'_lnk').show();
        placesCont = $('#include_places');
        placesCont.queue("popQueue",popImage('#'+element["cod"]+'_span'));
        setTimeout(function() {
          placesCont.dequeue("popQueue");
        }, 1000);
        //console.log(document.getElementById(element["cod"]+'_lnk'));
        //console.log('Image ' + element["cod"] + ' loaded')
      };*/
    }
  );
}());
<commit_msg>All points in their place<commit_after>$(function() {
  var x = 5, y = 5; /* off set for moving images to the middle of the coords set */

  var places = [
    {"cod": "1A", "title":"Torturas", "name":"1A_TORTURAS", "left":1075-x,"top":1405-y},
    {"cod": "1B", "title":"Chamamé", "name":"1B_CHAMAMÉ", "left":1100-x,"top":1405-y},
    {"cod": "2A", "title":"Ambiente Musical Auto", "name":"2A_AMBIENTE_MUSICAL_AUTO_2", "left":984-x,"top":1347-y},
    {"cod": "2B", "title":"Juan Carlos Cosmovisión", "name":"2B_JUANCARLOS_(Agus)COSMOVISIÓN", "left":789-x,"top":1424-y},
    {"cod": "2C", "title":"N'VIKÉ", "name":"2C_N'VIKÉ", "left":811-x,"top":1424-y},
    {"cod": "3A", "title":"3A Pedro Valquinta", "name":"3A_PEDRO_VALQUINTA", "left":869-x,"top":1387-y},
    {"cod": "3B", "title":"Avia Terai", "name":"3B_AVIA_TERAI", "left":871-x,"top":1296-y},
    {"cod": "4A", "title":"Niños Pampa largo", "name":"4A_NIÑOS_PAMPA_largo", "left":969-x,"top":1223-y},
    {"cod": "4B", "title":"Vacas Pampa corto", "name":"4B_VACAS_PAMPA_corto", "left":976-x,"top":1248-y},
    {"cod": "5A", "name":"5A_CONFESIÓN_ROCA", "title":"Confesión Roca", "left":1007-x,"top":1239-y},
    {"cod": "5B", "name":"5B_ROSY", "title":"Rosy", "left":938-x,"top":1175-y},
    {"cod": "6A", "name":"6A_AMANECER_RIO_BERMEJITO", "title":"Amanecer río Bermejito", "left":968-x,"top":1176-y},
    {"cod": "6B", "name":"6B_CRISTO_REDENTOR_RICARDO", "title":"Cristo Redentor Ricardo", "left":901-x,"top":1140-y},
    {"cod": "6C", "name":"6C_GENOCIDIO_NO_TERMINADO", "title":"Genocidio no terminado", "left":899-x,"top":1166-y},
    {"cod": "7A", "name":"7A_AUTO_DESATASCADO", "title":"Auto desatascado", "left":831-x,"top":1106-y},
    {"cod": "7B", "name":"7B_CHICHO_GIMÉNEZ_INTENDENTE", "title":"Chicho Giménez intendente", "left":805-x,"top":1066-y},
    {"cod": "7C", "name":"7C_OVEJAS_NUEVA_POMPEYA", "title":"Ovejas Nueva Pompeya", "left":808-x,"top":1153-y},
    {"cod": "8A", "name":"8A_INDIO_TOBA", "title":"Indio Toba", "left":831-x,"top":1066-y},
    {"cod": "8B", "name":"8B_PERROS", "title":"Perros", "left":846-x,"top":1133-y},
    {"cod": "9A", "name": "9A_INGENIERO_JUÁREZ", "title": "Ingeniero Juárez", "left":753-x,"top":946-y},
    {"cod": "10A", "name":"10A_TARTAGAL", "title":"Tartagal", "left":525-x,"top":772-y},
    {"cod": "11A", "name":"11A_FRONTERA", "title":"Frontera", "left":554-x,"top":708-y},
    {"cod": "11B", "name": "11B_ACTO_RECEPCIÓN_YACUIBA", "title": "Acto recepción yacuiba", "left":590-x,"top":692-y},
    {"cod": "12A", "name":"12A_CREPITAR_OLLA", "title":"Crepitar olla", "left":580-x,"top":708-y},
    {"cod": "12B", "name": "12B_CHACARERA_CON_VACAS", "title": "Chacarera con vacas", "left":614-x,"top":692-y},
    {"cod": "12C", "name": "12C_MENONITAS", "title": "Menonitas", "left":569-x,"top":679-y},
    {"cod": "13A", "name": "13A_MILITARES_ESCONBOL", "title": "Militares Esconbol", "left":536-x,"top":664-y},
    {"cod": "13B", "name": "13B_PLANTAS_REPSOL", "title": "Plantas repsol", "left":542-x,"top":638-y},
    {"cod": "14A", "name": "14A_PIEDRAS_RIO", "title": "Piedras río", "left":564-x,"top":610-y},
    {"cod": "15A", "name": "15A_WEENHAYEK", "title": "Weenhayek", "left":590-x,"top":610-y},
    {"cod": "15B", "name": "15B_PUENTE_(GUERRA_CHACO)", "title":"Puente (guerra chaco)", "left":614-x,"top":610-y},
    {"cod": "16A", "name": "16A_AMANECER_CAMIRI", "title": "Amanecer camiri", "left":560-x,"top":455-y},
    {"cod": "16B", "name": "16B_FELIPE_ROMÁN", "title": "Felipe Román", "left":587-x,"top":455-y},
    {"cod": "16C", "name": "16C_ARETE_GUASÚ", "title": "Arete Guasú", "left":613-x,"top":455-y},
    {"cod": "16D", "name": "16D_MARIACHIS", "title": "Mariachis", "left":639-x,"top":455-y},
    {"cod": "17A", "name": "17A_FÚTBOL_UNIBOL", "title": "Fútbol unibol", "left":583-x,"top":492-y},
    {"cod": "17B", "name": "17B_SERMÓN", "title": "Sermón", "left":608-x,"top":492-y},
    {"cod": "17C", "name": "17C_PAJARITOS_DONDE_HUBO_LUCHA", "title": "Pajaritos donde hubo lucha", "left":634-x,"top":492-y},
    {"cod": "18A", "name": "18A_LLUVIA_KAA_IYA", "title": "Lluvia Kaa Iya", "left":898-x,"top":283-y},
    {"cod": "18B", "name": "18B_RANAS_KAA_IYA", "title": "Ranas Kaa Iya", "left":923-x,"top":283-y},
    {"cod": "19A", "name": "19A_MUCHAS_RANAS_A_CORO", "title": "Muchas ranas a coro", "left":950-x,"top":283-y},
    {"cod": "20A", "name": "20A_RADIO_Y_REGGAE", "title": "Radio y reggae", "left":778-x,"top":162-y},
    {"cod": "20B", "name": "20B_TATÚ_CRUZ_ENTREVISTA_CALLEJERA", "title": "Tatú Cruz - entrevista callejera", "left":640-x,"top":610-y},
    {"cod": "21A", "name": "21A_TATÚ_CRUZ_BAND", "title": "Tatú Cruz Band", "left":665-x,"top":610-y},
    {"cod": "22A", "name": "22A_MENONITAS_FILADELFIA", "title": "Menonitas Filadelfia", "left":970-x,"top":751-y},
    {"cod": "23A", "name": "23A_CAMIÓN_ENLHET", "title": "Camión Enlhet", "left":1004-x,"top":800-y},
    {"cod": "23B", "name": "23B_ANCIANO_ENLHET", "title": "Anciano Enlhet", "left":969-x,"top":812-y},
    {"cod": "24A", "name": "24A_VIENTO_SACADA_COCHE", "title": "Viento sacada coche", "left":1018-x,"top":723-y},
    {"cod": "24B", "name": "24B_CANTO_HOMBRE_AYOREO", "title": "Canto hombre Ayoreo", "left":1033-x,"top":686-y},
    {"cod": "24C", "name": "24C_CANTO_MUJER_AYOREO", "title": "Canto mujer Ayoreo", "left":1059-x,"top":686-y},
    {"cod": "25A", "name": "25A_DE_PEDO_EN_EL_BARRO", "title": "De pedo en el barro", "left":1157-x,"top":664-y},
    {"cod": "26A", "name": "26A_BARCO", "title": "Barco", "left":1222-x,"top":525-y},
    {"cod": "27A", "name": "27A_VIEJUNO_ISHIR_PUERTO_DIANA", "title": "Viejuno Ishir Puerto Diana", "left":1213-x,"top":491-y},
    {"cod": "27B", "name": "27B_CERDO_Puerto_Diana", "title": "Cerdo Puerto Diana", "left":1239-x,"top":491-y},
    {"cod": "27C", "name": "27C_CANTOS_ISHIR", "title": "Cantos Ishir", "left":1264-x,"top":491-y},
    {"cod": "28A", "name": "28A_PÁJAROS_3_GIGANTES", "title": "Pájaros 3 gigantes", "left":1206-x,"top":468-y},
    {"cod": "29A", "name": "29A_MÚSICA_BRASILERA", "title": "Música brasilera", "left":1228-x,"top":680-y},
    {"cod": "29B", "name": "29B_AGUA_CASADO", "title": "Agua Casado", "left":1220-x,"top":754-y},
    {"cod": "29C", "name": "29C_AMBIENTE_CASADO", "title": "Ambiente Casado", "left":1248-x,"top":755-y},
    {"cod": "31A", "name": "31A_CHARLA_SAWHOYAMAXA", "title": "Charla Sawhoyamaxa", "left":1216-x,"top":902-y},
    {"cod": "31B", "name": "31B_NIÑOS_SAWHOYAMAXA", "title": "Niños Sawhoyamaxa", "left":1242-x,"top":902-y},
    {"cod": "J3", "name": "J3_NDE_RAMIREZ", "title": "Nde Ramirez", "left":1248-x,"top":1153-y},
    {"cod": "J4", "name": "J4_ASUNCIÓN_DESDE_GRAN_HOTEL_PARANÁ", "title": "Asunción desde gran hotel Paraná", "left":1266-x,"top":1153-y}

  ]

  var template = ""

  Mustache.parse(template); // speeds up future uses

  places.forEach(
    function(element,index,array){
      var output = Mustache.render(template,element);
      document.getElementById('include_places').innerHTML += output;
      document.getElementById(element["cod"]).onload = function(){
        $('#'+element["cod"]+'_span').fadeIn('slow');
        //document.getElementById('pop').play()
        }

      /* onload = function(){
        //$(element["cod"]+'_lnk').show();
        placesCont = $('#include_places');
        placesCont.queue("popQueue",popImage('#'+element["cod"]+'_span'));
        setTimeout(function() {
          placesCont.dequeue("popQueue");
        }, 1000);
        //console.log(document.getElementById(element["cod"]+'_lnk'));
        //console.log('Image ' + element["cod"] + ' loaded')
      };*/
    }
  );
}());
<|endoftext|>


<commit_before>import Vue from 'vue'
import groupApplications from '@/services/api/groupApplications'
import router from '@/router'
import { indexById, withMeta, createMetaModule, metaStatuses } from '@/store/helpers'

function initialState () {
  return {
    entries: {},
  }
}
export default {
  namespaced: true,
  modules: { meta: createMetaModule() },
  state: initialState(),
  getters: {
    get: (state, getters, rootState, rootGetters) => applicationId => {
      return getters.enrich(state.entries[applicationId])
    },
    enrich: (state, getters, rootState, rootGetters) => application => {
      return application && {
        ...application,
        user: rootGetters['users/enrich'](application.user),
        group: rootGetters['groups/get'](application.group),
        decidedBy: rootGetters['users/get'](application.decidedBy),
        isPending: application.status === 'pending',
      }
    },
    getMineForGroupIdNotEnriched: (state, getters, rootState, rootGetters) => groupId => {
      const authUserId = rootGetters['auth/userId']
      return Object.values(state.entries).find(a => a.group === groupId && a.user.id === authUserId)
    },
    getForActivePreview: (state, getters, rootState, rootGetters) => {
      const activePreview = rootGetters['groups/activePreview']
      if (!activePreview) return
      return getters.enrich(getters.getMineForGroupIdNotEnriched(activePreview.id))
    },
    groupHasMyApplication: (state, getters) => groupId => {
      return Boolean(getters.getMineForGroupIdNotEnriched(groupId))
    },
    pending: (state, getters) => Object.keys(state.entries).map(getters.get).filter(a => a.isPending).sort(sortByCreatedAt),
    allNonPending: (state, getters) => Object.keys(state.entries).map(getters.get).filter(a => !a.isPending).sort(sortByCreatedAt),
    ...metaStatuses(['apply']),
  },
  actions: {
    ...withMeta({

      async fetchMine ({ commit, rootGetters }) {
        const userId = rootGetters['auth/userId']
        const applicationList = await groupApplications.list({ user: userId, status: 'pending' })
        commit('set', applicationList)
      },

      async fetchByGroupId ({ commit, getters }, { groupId }) {
        const applicationList = await groupApplications.list({ group: groupId })
        commit('set', applicationList)
      },

      async fetchOne ({ commit }, applicationId) {
        const application = await groupApplications.get(applicationId)
        commit('set', [application])
      },

      async apply ({ commit, dispatch }, data) {
        const newApplication = await groupApplications.create(data)
        commit('update', newApplication)
        dispatch('toasts/show', {
          message: 'JOINGROUP.APPLICATION_SUBMITTED',
        }, { root: true })
        router.push({ name: 'groupPreview', params: { groupPreviewId: data.group } })
      },

      async withdraw ({ commit, dispatch }, id) {
        const removedApplication = await groupApplications.withdraw(id)
        commit('delete', removedApplication.id)
        dispatch('toasts/show', {
          message: 'JOINGROUP.APPLICATION_WITHDRAWN',
        }, { root: true })
      },

      async accept ({ commit, dispatch }, id) {
        const acceptedApplication = await groupApplications.accept(id)
        commit('update', acceptedApplication)
        dispatch('toasts/show', {
          message: 'APPLICATION.ACCEPTED',
          messageParams: { userName: acceptedApplication.user.displayName },
        }, { root: true })
      },

      async decline ({ commit, dispatch }, id) {
        const declinedApplication = await groupApplications.decline(id)
        commit('update', declinedApplication)
        dispatch('toasts/show', {
          message: 'APPLICATION.DECLINED',
          messageParams: { userName: declinedApplication.user.displayName },
        }, { root: true })
      },

    }),
    async maybeFetchOne ({ state, dispatch }, applicationId) {
      if (state.entries[applicationId]) return
      await dispatch('fetchOne', applicationId)
    },
    clearGroupPreviewAndStatus ({ dispatch }) {
      dispatch('meta/clear', ['apply'])
      dispatch('groups/clearGroupPreview', null, { root: true })
    },
    clearEntries ({ commit }) {
      commit('clear')
    },
    update ({ commit }, application) {
      commit('update', application)
    },
  },
  mutations: {
    set (state, applicationList) {
      state.entries = indexById(applicationList)
    },
    delete (state, id) {
      if (state.entries[id]) Vue.delete(state.entries, id)
    },
    update (state, application) {
      Vue.set(state.entries, application.id, application)
    },
    clear (state) {
      Object.assign(state, initialState())
    },
  },
}

export function sortByCreatedAt (a, b) {
  return a.createdAt < b.createdAt
}
<commit_msg>don't try to load group applications when not logged in<commit_after>import Vue from 'vue'
import groupApplications from '@/services/api/groupApplications'
import router from '@/router'
import { indexById, withMeta, createMetaModule, metaStatuses } from '@/store/helpers'

function initialState () {
  return {
    entries: {},
  }
}
export default {
  namespaced: true,
  modules: { meta: createMetaModule() },
  state: initialState(),
  getters: {
    get: (state, getters, rootState, rootGetters) => applicationId => {
      return getters.enrich(state.entries[applicationId])
    },
    enrich: (state, getters, rootState, rootGetters) => application => {
      return application && {
        ...application,
        user: rootGetters['users/enrich'](application.user),
        group: rootGetters['groups/get'](application.group),
        decidedBy: rootGetters['users/get'](application.decidedBy),
        isPending: application.status === 'pending',
      }
    },
    getMineForGroupIdNotEnriched: (state, getters, rootState, rootGetters) => groupId => {
      const authUserId = rootGetters['auth/userId']
      return Object.values(state.entries).find(a => a.group === groupId && a.user.id === authUserId)
    },
    getForActivePreview: (state, getters, rootState, rootGetters) => {
      const activePreview = rootGetters['groups/activePreview']
      if (!activePreview) return
      return getters.enrich(getters.getMineForGroupIdNotEnriched(activePreview.id))
    },
    groupHasMyApplication: (state, getters) => groupId => {
      return Boolean(getters.getMineForGroupIdNotEnriched(groupId))
    },
    pending: (state, getters) => Object.keys(state.entries).map(getters.get).filter(a => a.isPending).sort(sortByCreatedAt),
    allNonPending: (state, getters) => Object.keys(state.entries).map(getters.get).filter(a => !a.isPending).sort(sortByCreatedAt),
    ...metaStatuses(['apply']),
  },
  actions: {
    ...withMeta({

      async fetchMine ({ commit, rootGetters }) {
        const userId = rootGetters['auth/userId']
        if (!userId) return
        const applicationList = await groupApplications.list({ user: userId, status: 'pending' })
        commit('set', applicationList)
      },

      async fetchByGroupId ({ commit, getters }, { groupId }) {
        const applicationList = await groupApplications.list({ group: groupId })
        commit('set', applicationList)
      },

      async fetchOne ({ commit }, applicationId) {
        const application = await groupApplications.get(applicationId)
        commit('set', [application])
      },

      async apply ({ commit, dispatch }, data) {
        const newApplication = await groupApplications.create(data)
        commit('update', newApplication)
        dispatch('toasts/show', {
          message: 'JOINGROUP.APPLICATION_SUBMITTED',
        }, { root: true })
        router.push({ name: 'groupPreview', params: { groupPreviewId: data.group } })
      },

      async withdraw ({ commit, dispatch }, id) {
        const removedApplication = await groupApplications.withdraw(id)
        commit('delete', removedApplication.id)
        dispatch('toasts/show', {
          message: 'JOINGROUP.APPLICATION_WITHDRAWN',
        }, { root: true })
      },

      async accept ({ commit, dispatch }, id) {
        const acceptedApplication = await groupApplications.accept(id)
        commit('update', acceptedApplication)
        dispatch('toasts/show', {
          message: 'APPLICATION.ACCEPTED',
          messageParams: { userName: acceptedApplication.user.displayName },
        }, { root: true })
      },

      async decline ({ commit, dispatch }, id) {
        const declinedApplication = await groupApplications.decline(id)
        commit('update', declinedApplication)
        dispatch('toasts/show', {
          message: 'APPLICATION.DECLINED',
          messageParams: { userName: declinedApplication.user.displayName },
        }, { root: true })
      },

    }),
    async maybeFetchOne ({ state, dispatch }, applicationId) {
      if (state.entries[applicationId]) return
      await dispatch('fetchOne', applicationId)
    },
    clearGroupPreviewAndStatus ({ dispatch }) {
      dispatch('meta/clear', ['apply'])
      dispatch('groups/clearGroupPreview', null, { root: true })
    },
    clearEntries ({ commit }) {
      commit('clear')
    },
    update ({ commit }, application) {
      commit('update', application)
    },
  },
  mutations: {
    set (state, applicationList) {
      state.entries = indexById(applicationList)
    },
    delete (state, id) {
      if (state.entries[id]) Vue.delete(state.entries, id)
    },
    update (state, application) {
      Vue.set(state.entries, application.id, application)
    },
    clear (state) {
      Object.assign(state, initialState())
    },
  },
}

export function sortByCreatedAt (a, b) {
  return a.createdAt < b.createdAt
}
<|endoftext|>


<commit_before>/**
 * @namespace Lyria
 * Lyria namespace decleration
 */
;(function(Lyria, undefined) {
  'use strict';

  /**
   * @class Lyria.Video
   * This class creates an HTML5 video element
   */
  Lyria.Video = (function() {
    var Video = function() {

    };

    Video.prototype.loadFromFile = function() {

    };

    Video.prototype.play = function() {

    };

    Video.prototype.pause = function() {

    };

    Video.prototype.stop = function() {

    };

    return Video;
  })();

})(this.Lyria = this.Lyria || {});
<commit_msg>AMD-ify video file<commit_after>/**
 * @namespace Lyria
 * Lyria namespace decleration
 */
define('lyria/video', function() {
  'use strict';

  /**
   * @class Lyria.Video
   * This class creates an HTML5 video element
   */
  return (function() {
    var Video = function() {

    };

    Video.prototype.loadFromFile = function() {

    };

    Video.prototype.play = function() {

    };

    Video.prototype.pause = function() {

    };

    Video.prototype.stop = function() {

    };

    return Video;
  })();

});
<|endoftext|>


<commit_before>function TaserShape(x, y, board) {
    Shape.call(this, Shape.UNMATCHABLE_TYPE, x, y, board);
    this.state = WrappedShape.NORMAL;
    this.special = TaserShape.SPECIAL;
}

TaserShape.SPECIAL = 5;
TaserShape.NORMAL = 0;
TaserShape.ACTIVE = 1;
TaserShape.DISCHARGING = 2;
TaserShape.FINISHED = 3;

TaserShape.prototype = new Shape();
TaserShape.prototype.constructor = TaserShape;

TaserShape.prototype.update = function () {
    if (this.state === TaserShape.ACTIVE) {
        this.state = TaserShape.DISCHARGING;
    }
};

TaserShape.prototype.canBeCleared = function () {
    if (Shape.prototype.canBeCleared.call(this)) {
        return this.state === TaserShape.FINISHED;
    }
    return false;
};

TaserShape.prototype.canCrush = function () {
    if (Shape.prototype.canBeCleared.call(this)) {
        return this.state === TaserShape.NORMAL || this.state === TaserShape.FINISHED;
    }
    return false;
};

TaserShape.prototype.crush = function (board, color) {
    if (this.state === TaserShape.NORMAL) {
        this.state = TaserShape.ACTIVE;
        board.addItemToClear(new TaserEffect(board, color, this));
    }
    return {score: 0, addition: 0, multiply: 0, jelly: 0, blocker: 0};
};

function TaserEffect(board, color, taser) {
    this.board = board;
    this.totalTicks = 4;
    this.tick = this.totalTicks;
    this.progress = 0;
    this.type = color || this.board.game.rnd.between(1, AppleFools.COLOR_COUNT);
    this.taser = taser;
    // shapes to clear
    this.all = [];
    this.clearing = [];
    this.count = 0;
    this.done = false;
}

TaserEffect.prototype.elcShape = function (type) {
    var shapes = this.board.shapes;
    for (var i = 0; i < shapes.length; i++) {
        if (shapes[i].type == type && shapes[i].canCrush()) {
            this.count++;
            this.all.push(shapes[i]);
        }
    }
};

TaserEffect.prototype.update = function () {
    'use strict';
    if (this.tick === this.totalTicks) {
        if (this.progress === 0) {
            this.elcShape(this.type);
        }

        if (this.progress < this.count) {
            var sh = this.all[this.progress];
            if (this.board.getShape(sh.x, sh.y) === sh) {
                var sco = this.board.clearShape(sh.x, sh.y);
                var score = (sco.score + sco.addition) * this.count + sco.jelly + sco.blocker;
                this.board.gainScores.push({
                  x: sh.x,
                  y: sh.y,
                  type: this.type,
                  score: score
                });
                this.board.score += score;
            }
            if (this.progress === this.count-1) {
                this.done = true;
            }
        }
        //  taser has no target!
        if (this.count === 0) {
            this.done = true;
        }
    }
    if (this.progress < this.count-1 || this.tick > 0) {
        this.board.itemChanged = true;
    }
    this.tick--;
    if (this.tick <= 0) {
        this.tick = this.totalTicks;
        this.progress++;
    }
    if (this.done) {
        this.taser.state = TaserShape.FINISHED;
        this.board.clearShape(this.taser.x, this.taser.y, 0, {});
        if (!this.taser.cleared) {
            return true;
        }
    }
    return this.progress < this.count+2;
};

// returns array of [x, y, width, height, frameName]'s
TaserEffect.prototype.getSpritePositions = function () {
    var lb = Math.max(this.progress - 2, 0);
    var ub = Math.min(this.count, this.progress + 1);
    var ans = [];
    var tz = this.taser;
    var tzx = (tz.x + tz.dir.x * tz.pos / 10);
    var tzy = (tz.y + tz.dir.y * tz.pos / 10);
    var sw = 0.6, sh = 0.6;
    for (var i = lb; i < ub; i++) {
        var t = (this.progress-i + 1 - this.tick / this.totalTicks) / 3;
        var s = this.all[i];
        ans.push([
          (s.x + s.dir.x * s.pos / 10) * t + tzx * (1-t),
          (s.y + s.dir.y * s.pos / 10) * t + tzy * (1-t),
          sw, sh, "taser"
        ]);
    }
    return ans;
};
<commit_msg>fix taser clearing other shape<commit_after>function TaserShape(x, y, board) {
    Shape.call(this, Shape.UNMATCHABLE_TYPE, x, y, board);
    this.state = WrappedShape.NORMAL;
    this.special = TaserShape.SPECIAL;
}

TaserShape.SPECIAL = 5;
TaserShape.NORMAL = 0;
TaserShape.ACTIVE = 1;
TaserShape.DISCHARGING = 2;
TaserShape.FINISHED = 3;

TaserShape.prototype = new Shape();
TaserShape.prototype.constructor = TaserShape;

TaserShape.prototype.update = function () {
    if (this.state === TaserShape.ACTIVE) {
        this.state = TaserShape.DISCHARGING;
    }
};

TaserShape.prototype.canBeCleared = function () {
    if (Shape.prototype.canBeCleared.call(this)) {
        return this.state === TaserShape.FINISHED;
    }
    return false;
};

TaserShape.prototype.canCrush = function () {
    if (Shape.prototype.canBeCleared.call(this)) {
        return this.state === TaserShape.NORMAL || this.state === TaserShape.FINISHED;
    }
    return false;
};

TaserShape.prototype.crush = function (board, color) {
    if (this.state === TaserShape.NORMAL) {
        this.state = TaserShape.ACTIVE;
        board.addItemToClear(new TaserEffect(board, color, this));
    }
    return {score: 0, addition: 0, multiply: 0, jelly: 0, blocker: 0};
};

function TaserEffect(board, color, taser) {
    this.board = board;
    this.totalTicks = 4;
    this.tick = this.totalTicks;
    this.progress = 0;
    this.type = color || this.board.game.rnd.between(1, AppleFools.COLOR_COUNT);
    this.taser = taser;
    // shapes to clear
    this.all = [];
    this.clearing = [];
    this.count = 0;
    this.done = false;
}

TaserEffect.prototype.elcShape = function (type) {
    var shapes = this.board.shapes;
    for (var i = 0; i < shapes.length; i++) {
        if (shapes[i].type == type && shapes[i].canCrush()) {
            this.count++;
            this.all.push(shapes[i]);
        }
    }
};

TaserEffect.prototype.update = function () {
    'use strict';
    if (this.tick === this.totalTicks) {
        if (this.progress === 0) {
            this.elcShape(this.type);
        }

        if (this.progress < this.count) {
            var sh = this.all[this.progress];
            if (this.board.getShape(sh.x, sh.y) === sh) {
                var sco = this.board.clearShape(sh.x, sh.y);
                var score = (sco.score + sco.addition) * this.count + sco.jelly + sco.blocker;
                this.board.gainScores.push({
                  x: sh.x,
                  y: sh.y,
                  type: this.type,
                  score: score
                });
                this.board.score += score;
            }
            if (this.progress === this.count-1) {
                this.done = true;
            }
        }
        //  taser has no target!
        if (this.count === 0) {
            this.done = true;
        }
    }
    if (this.progress < this.count-1 || this.tick > 0) {
        this.board.itemChanged = true;
    }
    this.tick--;
    if (this.tick <= 0) {
        this.tick = this.totalTicks;
        this.progress++;
    }
    if (this.done) {
        this.taser.state = TaserShape.FINISHED;
        if (!this.taser.cleared) {
            this.board.clearShape(this.taser.x, this.taser.y);
            if (!this.taser.cleared) {
                return true;
            }
        }
    }
    return this.progress < this.count+2;
};

// returns array of [x, y, width, height, frameName]'s
TaserEffect.prototype.getSpritePositions = function () {
    var lb = Math.max(this.progress - 2, 0);
    var ub = Math.min(this.count, this.progress + 1);
    var ans = [];
    var tz = this.taser;
    var tzx = (tz.x + tz.dir.x * tz.pos / 10);
    var tzy = (tz.y + tz.dir.y * tz.pos / 10);
    var sw = 0.6, sh = 0.6;
    for (var i = lb; i < ub; i++) {
        var t = (this.progress-i + 1 - this.tick / this.totalTicks) / 3;
        var s = this.all[i];
        ans.push([
          (s.x + s.dir.x * s.pos / 10) * t + tzx * (1-t),
          (s.y + s.dir.y * s.pos / 10) * t + tzy * (1-t),
          sw, sh, "taser"
        ]);
    }
    return ans;
};
<|endoftext|>


<commit_before>
// ----------------------------------------------------------------
// Login Class

class LoginModel extends SwitchModel {
  constructor({
    name,
    lsKeyView,
    triggerSelector,
    switchSelector,
    loginTrigger = 'click',
    loginSelector = null,
    loginIdSelector = null,
    loginPasswordSelector = null,
    logoutTrigger = 'click',
    logoutSelector = null
  } = {}) {
    super({
      name: name,
      lsKeyView: lsKeyView,
      triggerSelector: triggerSelector,
      switchSelector: switchSelector
    });

    this.NAME = name;
    this.LOGIN_TRIGGER = loginTrigger;
    this.LOGIN_SELECTOR = loginSelector;

    this.LOGOUT_TRIGGER = logoutTrigger;
    this.LOGOUT_SELECTOR = logoutSelector;

    this.LOGIN_ID_SELECTOR = loginIdSelector;
    this.LOGIN_PASSWORD_SELECTOR = loginPasswordSelector;
    // this.LOGIN_CHECK_SELECTOR = '#login-check';

    this.LOGIN_AREA_SELECTOR = '#login-area';
    this.$LOGIN_AREA_SELECTOR = $(this.LOGIN_AREA_SELECTOR);
    this.TEMPLATE_LOGINED_SELECTOR = '#logined-template';
    this.$TEMPLATE_LOGINED_SELECTOR = $(this.TEMPLATE_LOGINED_SELECTOR);
    this.TEMPLATE_NOT_LOGIN_SELECTOR = '#not-login-template';
    this.$TEMPLATE_NOT_LOGIN_SELECTOR = $(this.TEMPLATE_NOT_LOGIN_SELECTOR);
  }
}

class LoginView extends SwitchView {
  constructor(_model = new LoginModel()) {
    super(_model);
  }
}

// ----------------------------------------------------------------
// Controller

class LoginController extends CommonController {
  constructor(_obj) {
    super(_obj);

    this.model = new LoginModel(_obj);
    this.view = new LoginView(this.model);
  }
}

// ----------------------------------------------------------------
// Event

class LoginEvent extends CommonEvent {
  constructor({
    name = 'Login Event'
  } = {})
  {
    super({
      name: name
    });

    this.NAME = name;
    this.CONTROLLER = new LoginController({
      name: 'Login Switch',
      lsKeyView: 'login',
      triggerSelector: '#action-login',
      switchSelector: '#login-area',
      loginSelector: '#login-submit',
      loginIdSelector: '#login-id',
      loginPasswordSelector: '#login-password',
      logoutSelector: '#logined-logout'
    });

    this.LOGIN = false;
    this.ID = null;

    this.setOn();
    this.generateLoginArea();
  }

  setOn() {
    SetEvent.setOn(
      this.CONTROLLER.model.LOGIN_TRIGGER,
      this.CONTROLLER.model.LOGIN_SELECTOR,
      () => {
        this.submitLogin();
      }
    );
    SetEvent.setOn(
      this.CONTROLLER.model.LOGOUT_TRIGGER,
      this.CONTROLLER.model.LOGOUT_SELECTOR,
      () => {
        this.submitLogout();
      }
    );
  }

  generateLoginArea(_loginFailed = false) {
    let template = null;
    if (this.LOGIN) {
      // ログインしているとき
      Log.logClass(this.NAME, 'Logined');
      template = this.CONTROLLER.model.$TEMPLATE_LOGINED_SELECTOR.text();

    } else {
      // ログインしていないとき
      Log.logClass(this.NAME, 'Not login');
      template = this.CONTROLLER.model.$TEMPLATE_NOT_LOGIN_SELECTOR.text();

    }
    const compiled = _.template(template);
    const model = {
      id: this.ID
    };

    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.empty();
    if (_loginFailed) {
      const alertTemplate = this.CONTROLLER.model.$ALERT_TEMPLATE.text();
      const alertCompiled = _.template(alertTemplate);
      const alertModel = {
        type: 'danger',
        message: 'ログインに失敗しました。'
      };
      this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.append(alertCompiled(alertModel));
    }
    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.append(compiled(model));

    BCBProcess.initPopover();
  }

  generateLoading() {
    const template = this.CONTROLLER.model.$LOADING_TEMPLATE.text();
    const compiled = _.template(template);
    const model = {
      header: `${this.ID} でログイン`,
      message: 'ログイン中...'
    };
    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.empty();
    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.html(compiled(model));
  }

  submitLogin() {
    Log.logClassKey(this.NAME, 'Login', 'submit');
    this.ID = $(this.CONTROLLER.model.LOGIN_ID_SELECTOR).val();
    this.PASSWORD = $(this.CONTROLLER.model.LOGIN_PASSWORD_SELECTOR).val();

    this.generateLoading();

    $.ajax({
      url: 'ruby/getSQLiteResult.rb',
      data: {
        query: `SELECT name FROM User where name = '${this.ID}' and password = '${this.PASSWORD}';`
      },
      dataType: 'json',
      success: (_data) => {
        if (_data != null) {
          this.ID = _data['name'];
          this.LOGIN = true;
        }
        this.generateLoginArea();
      },
      error: () => {
        this.generateLoginArea(true);
      }
    });
  }

  submitLogout() {
    Log.logClassKey(this.NAME, 'Logout', 'submit');
    this.LOGIN = false;
    this.generateLoginArea();
    this.ID = null;
  }
}
<commit_msg>Fix submitLogin to working in LoginEvent<commit_after>
// ----------------------------------------------------------------
// Login Class

class LoginModel extends SwitchModel {
  constructor({
    name,
    lsKeyView,
    triggerSelector,
    switchSelector,
    loginTrigger = 'click',
    loginSelector = null,
    loginIdSelector = null,
    loginPasswordSelector = null,
    logoutTrigger = 'click',
    logoutSelector = null
  } = {}) {
    super({
      name: name,
      lsKeyView: lsKeyView,
      triggerSelector: triggerSelector,
      switchSelector: switchSelector
    });

    this.NAME = name;
    this.LOGIN_TRIGGER = loginTrigger;
    this.LOGIN_SELECTOR = loginSelector;

    this.LOGOUT_TRIGGER = logoutTrigger;
    this.LOGOUT_SELECTOR = logoutSelector;

    this.LOGIN_ID_SELECTOR = loginIdSelector;
    this.LOGIN_PASSWORD_SELECTOR = loginPasswordSelector;
    // this.LOGIN_CHECK_SELECTOR = '#login-check';

    this.LOGIN_AREA_SELECTOR = '#login-area';
    this.$LOGIN_AREA_SELECTOR = $(this.LOGIN_AREA_SELECTOR);
    this.TEMPLATE_LOGINED_SELECTOR = '#logined-template';
    this.$TEMPLATE_LOGINED_SELECTOR = $(this.TEMPLATE_LOGINED_SELECTOR);
    this.TEMPLATE_NOT_LOGIN_SELECTOR = '#not-login-template';
    this.$TEMPLATE_NOT_LOGIN_SELECTOR = $(this.TEMPLATE_NOT_LOGIN_SELECTOR);
  }
}

class LoginView extends SwitchView {
  constructor(_model = new LoginModel()) {
    super(_model);
  }
}

// ----------------------------------------------------------------
// Controller

class LoginController extends CommonController {
  constructor(_obj) {
    super(_obj);

    this.model = new LoginModel(_obj);
    this.view = new LoginView(this.model);
  }
}

// ----------------------------------------------------------------
// Event

class LoginEvent extends CommonEvent {
  constructor({
    name = 'Login Event'
  } = {})
  {
    super({
      name: name
    });

    this.NAME = name;
    this.CONTROLLER = new LoginController({
      name: 'Login Switch',
      lsKeyView: 'login',
      triggerSelector: '#action-login',
      switchSelector: '#login-area',
      loginSelector: '#login-submit',
      loginIdSelector: '#login-id',
      loginPasswordSelector: '#login-password',
      logoutSelector: '#logined-logout'
    });

    this.LOGIN = false;
    this.ID = null;

    this.setOn();
    this.generateLoginArea();
  }

  setOn() {
    SetEvent.setOn(
      this.CONTROLLER.model.LOGIN_TRIGGER,
      this.CONTROLLER.model.LOGIN_SELECTOR,
      () => {
        this.submitLogin();
      }
    );
    SetEvent.setOn(
      this.CONTROLLER.model.LOGOUT_TRIGGER,
      this.CONTROLLER.model.LOGOUT_SELECTOR,
      () => {
        this.submitLogout();
      }
    );
  }

  generateLoginArea(_loginAlert = 'success', _loginFailedMessage = null) {
    let template = null;
    if (this.LOGIN) {
      // ログインしているとき
      Log.logClass(this.NAME, 'Logined');
      template = this.CONTROLLER.model.$TEMPLATE_LOGINED_SELECTOR.text();

    } else {
      // ログインしていないとき
      Log.logClass(this.NAME, 'Not login');
      template = this.CONTROLLER.model.$TEMPLATE_NOT_LOGIN_SELECTOR.text();

    }
    const compiled = _.template(template);
    const model = {
      id: this.ID
    };

    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.empty();
    if (_loginFailedMessage != null) {
      const alertTemplate = this.CONTROLLER.model.$ALERT_TEMPLATE.text();
      const alertCompiled = _.template(alertTemplate);
      const alertModel = {
        type: _loginAlert,
        message: _loginFailedMessage
      };
      this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.append(alertCompiled(alertModel));
    }
    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.append(compiled(model));

    BCBProcess.initPopover();
  }

  generateLoading() {
    const template = this.CONTROLLER.model.$LOADING_TEMPLATE.text();
    const compiled = _.template(template);
    const model = {
      header: `${this.ID} でログイン`,
      message: 'ログイン中...'
    };
    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.empty();
    this.CONTROLLER.model.$LOGIN_AREA_SELECTOR.html(compiled(model));
  }

  submitLogin() {
    Log.logClassKey(this.NAME, 'Login', 'submit');
    this.ID = $(this.CONTROLLER.model.LOGIN_ID_SELECTOR).val();
    this.PASSWORD = $(this.CONTROLLER.model.LOGIN_PASSWORD_SELECTOR).val();

    this.generateLoading();

    $.ajax({
      url: 'ruby/getSQLiteResult.rb',
      data: {
        query: `SELECT name FROM User where name = '${this.ID}' and password = '${this.PASSWORD}';`
      },
      dataType: 'json',
      success: (_data) => {
        if (Object.keys(_data).length > 0) {
          this.ID = Object.keys(_data)[0];
          this.LOGIN = true;
          this.generateLoginArea('success', `ユーザー ${this.ID} でログインしました。`);
        } else {
          this.generateLoginArea('danger', 'IDとパスワードの組み合わせが正しくありません。');
        }
      },
      error: () => {
        this.generateLoginArea('danger', 'ajax通信に失敗しました。');
      }
    });
  }

  submitLogout() {
    Log.logClassKey(this.NAME, 'Logout', 'submit');
    this.LOGIN = false;
    this.generateLoginArea('success', 'ログアウトしました。');
    this.ID = null;
  }
}
<|endoftext|>


<commit_before>var VCs;
var verifying = false;

function submitAnswer() {
    /* Protect against multiple requests */
    if(verifying)
        return;
    verifying = true;
    $("#footer.create").attr("class", "createDisabled");

    getVCLines(createEditor.getValue());
}

function getVCLines(content) {
    removeAllVCMarkers();
    var socket = new WebSocket("wss://resolve.cs.clemson.edu/teaching/Compiler?job=genVCs&project=Teaching_Project");

    socket.onmessage = function(message) {
        if(!verifying) return;

        // Extract the array of VCs from the message (trust me, this works)
        message = JSON.parse(message.data);
        if(message.status == "error") {
            alert("Your code is syntactically incorrect and thus could not be verified.");
            verifying = false;
            $("#footer.createDisabled").attr("class", "create");

            createEditor.focus();
            return;
        }
        if(message.status != "complete") {
            return;
        }

	if(message.result == "") {
        alert("Your code could not be verified; try a simpler answer and only use declared variables.");
        verifying = false;
        $("#footer.createDisabled").attr("class", "create");

        createEditor.focus();
        return;
	}

        message = decode(message.result);
        message = $(message).text();
        message = JSON.parse(message);

        // Simplify the VC information
        VCs = [];
        $.each(message.vcs, function (index, obj) {
            if (typeof obj.vc !== "undefined") VCs.push(obj);
        });

        addVCMarkers();
        verifyVCs(createEditor.getValue());
    };

    content = encode(content);
    content = toJSON(content);

    socket.onopen = function() { socket.send(content); };
}

function verifyVCs(content) {
    var socket = new WebSocket("wss://resolve.cs.clemson.edu/teaching/Compiler?job=verify2&project=Teaching_Project");

    socket.onmessage = function(message) {
        message = JSON.parse(message.data);
        if(message.status !== "processing") return;

        updateMarker(message.result);
    };

    content = encode(content);
    content = toJSON(content);

    socket.onopen = function() { socket.send(content); };
    socket.onclose = function() {
        if(doChecks() && succeed) {
            approved = true;
            alert("Your answer was verified and was semantically meaningful. You may move on to the next lesson.");
            nextLessonAndSuccess();
        }
        if(!doChecks() && succeed) {
            approved = false;
            alert("Your answer was verified but semantically insufficient; try providing a more descriptive answer.");
            createEditor.focus();
        }
        if(!succeed) {
            alert("Your answer was syntactically correct but unverifiable; the statement you are trying to prove is not true.");
            if (currentLesson.self != currentLesson.nextLessonOnFailure)
                nextLessonAndFailure();
        }

        verifying = false;
        $("#footer.createDisabled").attr("class", "create");
        sendData();
    }
}
<commit_msg>Switch to jQuery dialogs. Resolved issue #3.<commit_after>var VCs;
var verifying = false;

function submitAnswer() {
    /* Protect against multiple requests */
    if(verifying)
        return;
    verifying = true;
    $("#footer.create").attr("class", "createDisabled");

    getVCLines(createEditor.getValue());
}

function getVCLines(content) {
    removeAllVCMarkers();
    var socket = new WebSocket("wss://resolve.cs.clemson.edu/teaching/Compiler?job=genVCs&project=Teaching_Project");

    socket.onmessage = function(message) {
        if(!verifying) return;

        // Extract the array of VCs from the message (trust me, this works)
        message = JSON.parse(message.data);
        if(message.status == "error") {
            $("#dialog-message").html("Your code is syntactically incorrect and thus could not be verified.");
            $("#dialog-box").dialog("open");
            verifying = false;
            $("#footer.createDisabled").attr("class", "create");

            createEditor.focus();
            return;
        }
        if(message.status != "complete") {
            return;
        }

	if(message.result == "") {
	    $("#dialog-message").html("Your code could not be verified; try a simpler answer and only use declared variables.");
	    $("#dialog-box").dialog("open");
        verifying = false;
        $("#footer.createDisabled").attr("class", "create");

        createEditor.focus();
        return;
	}

        message = decode(message.result);
        message = $(message).text();
        message = JSON.parse(message);

        // Simplify the VC information
        VCs = [];
        $.each(message.vcs, function (index, obj) {
            if (typeof obj.vc !== "undefined") VCs.push(obj);
        });

        addVCMarkers();
        verifyVCs(createEditor.getValue());
    };

    content = encode(content);
    content = toJSON(content);

    socket.onopen = function() { socket.send(content); };
}

function verifyVCs(content) {
    var socket = new WebSocket("wss://resolve.cs.clemson.edu/teaching/Compiler?job=verify2&project=Teaching_Project");

    socket.onmessage = function(message) {
        message = JSON.parse(message.data);
        if(message.status !== "processing") return;

        updateMarker(message.result);
    };

    content = encode(content);
    content = toJSON(content);

    socket.onopen = function() { socket.send(content); };
    socket.onclose = function() {
        if(doChecks() && succeed) {
            approved = true;
            $("#dialog-message").html("Your answer was verified and was semantically meaningful. You may move on to the next lesson.");
            $("#dialog-box").dialog("open");
            nextLessonAndSuccess();
        }
        if(!doChecks() && succeed) {
            approved = false;
            $("#dialog-message").html("Your answer was verified but semantically insufficient; try providing a more descriptive answer.");
            $("#dialog-box").dialog("open");
            createEditor.focus();
        }
        if(!succeed) {
            $("#dialog-message").html("Your answer was syntactically correct but unverifiable; the statement you are trying to prove is not true.");
            $("#dialog-box").dialog("open");
            if (currentLesson.self != currentLesson.nextLessonOnFailure)
                nextLessonAndFailure();
        }

        verifying = false;
        $("#footer.createDisabled").attr("class", "create");
        sendData();
    }
}
<|endoftext|>


<commit_before>/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file or at
 * https://developers.google.com/open-source/licenses/bsd
 */
/* global scope */
({

connectorDelim: '$$',
nameDelim: ':',

shouldUpdate({nodeTypes}) {
  return !nodeTypes.empty;
},

async update(inputs, state, {service}) {
  const {pipeline, nodeTypes} = inputs;
  if (!state.nodeTypeMap) {
    state.nodeTypeMap = {};
    values(nodeTypes).forEach(t => state.nodeTypeMap[t.$meta.name] = this.flattenNodeType(t));
  }

  if (pipeline?.nodes) {
    if (this.pipelineChanged(pipeline, state.pipeline)
        || this.nodesDidChange(pipeline.nodes, state.nodes)) {
      state.pipeline = pipeline;
      state.nodes = [...pipeline.nodes];
      return this.updateNodes(inputs, state);
    }
  }
},

flattenNodeType(nodeType, $container) {
  const flattened = {};
  keys(nodeType).forEach(key => {
    if (key.startsWith('$')) {
      flattened[key] = nodeType[key];
    } else {
      assign(flattened, this.flattenParticleSpec(key, nodeType[key], $container));
    }
  });
  return flattened;
},

flattenParticleSpec(particleId, particleSpec, $container) {
  const flattened = {
    [particleId]: {
      ...particleSpec,
      $slots: {},
      ...($container && {$container})
    }
  };
  entries(particleSpec.$slots || {}).forEach(([slotId, slotRecipe]) => {
    assign(flattened, this.flattenNodeType(slotRecipe, `${particleId}#${slotId}`));
  });
  return flattened;
},

pipelineChanged(pipeline, oldPipeline) {
  return this.pipelineId(pipeline) !== this.pipelineId(oldPipeline);
},

pipelineId(pipeline) {
  // Backward compatibility for pipelines published in versions < 0.4
  return pipeline?.$meta?.id || pipeline?.$meta?.name;
},

nodesDidChange(nodes, currentNodes) {
  if (nodes?.length === currentNodes?.length) {
    return !currentNodes?.every(node => this.hasSameNode(node, nodes));
  }
  return true;
},

hasSameNode(node, nodes) {
  const nodeInNodes = nodes.find(n => n.key === node.key);
  if (nodeInNodes) {
    if (scope.deepEqual(nodeInNodes, node)) {
      return true;
    }
  }
  //log('hasSameNode: FALSE:', nodeInNodes, node);
  return false;
},

async updateNodes({pipeline, selectedNode, customInspectors, inspectorData, globalStores}, {nodeTypeMap}) {
  pipeline.nodes = pipeline.nodes.map(
    node => this.updateNodeConnectionCandidates({node, pipeline, nodeTypeMap, globalStores}));
  const recipes = pipeline.nodes
    .map(node => this.recipeForNode(node, nodeTypeMap, pipeline, customInspectors, inspectorData || 'inspectorData', globalStores))
    .filter(recipe => recipe)
    ;
  return {
    pipeline,
    recipes,
    selectedNode: pipeline.nodes.find(n => n.key === selectedNode?.key),
  };
},

updateNodeConnectionCandidates({node, pipeline, nodeTypeMap, globalStores}) {
  const connections = this.updateNodeStoreConnections(node, pipeline, nodeTypeMap, globalStores);
  return {
    ...node,
    ...(keys(connections).length > 0 && {connections})
  };
},

updateNodeStoreConnections(node, pipeline, nodeTypeMap, globalStores) {
  const connections = {};
  const nodeType = nodeTypeMap[node.name];
  nodeType?.$stores && entries(nodeType.$stores).forEach(([storeName, store]) => {
    if (store.connection) {
      const bindings = this.findStoreBindings(storeName, nodeType);
      const candidates = this.findConnectionCandidates(storeName, store, node, pipeline, nodeTypeMap, globalStores);
      connections[storeName] = {store, bindings, candidates};
    }
  });
  if (!node.connections) {
    this.initDefaultCandidates(connections);
  }
  return connections;
},

initDefaultCandidates(connections) {
  const used = new Set();
  keys(connections).forEach(storeName => {
    const {bindings, candidates} = connections[storeName];
    if (candidates.length === 1 && bindings?.length > 0) {
      const candidateId = this.constructStoreId(candidates[0]);
      if (!used.has(candidateId)) {
        candidates[0].selected = true;
        used.add(candidateId);
      }
    }
  });
},

findConnectionCandidates(storeName, {$type}, node, {nodes}, nodeTypeMap, globalStores) {
  if (this.findGlobalCandidate(storeName, globalStores)) {
    return [{from: 'global', store: storeName, type: $type, selected: true}];
  }
  const candidates = [];
  nodes.forEach(n => {
    const candidate = this.findCandidateInNode($type, n, nodeTypeMap);
    if (candidate && candidate.from !== node.key) {
      if (node.connections) {
        candidate.selected = node.connections[storeName]?.candidates.find(({from, store}) => from === candidate.from && store === candidate.store)?.selected;
      }
      candidates.push(candidate);
    }
  });
  return candidates;
},

findGlobalCandidate(storeName, globalStores) {
  return globalStores?.find(name => name === storeName);
},

findCandidateInNode(type, node, nodeTypeMap) {
  const nodeType = nodeTypeMap[node.name];
  if (nodeType) {
    const store = this.findMatchingStore(type, nodeType.$stores);
    if (store) {
      return ({from: node.key, store: store.name, type: store.$type});
    }
  }
},

findMatchingStore(type, stores) {
  const matchingType = (storeType) => {
    // TODO(b/244191110): Type matching API to be wired here.
    return storeType === type;
  };
  const matchingStore = (store) => matchingType(store.$type) && !store.connection;
  const name = stores && keys(stores).find(name => matchingStore(stores[name]));
  if (name) {
    return {name, ...stores[name]};
  }
},

findStoreBindings(store, nodeType) {
  const bindings = [];
  this.particleNames(nodeType).forEach(particleName =>  {
    this.addInputBindings(store, nodeType, particleName, bindings);
  });
  return bindings;
},

particleNames(nodeType) {
  const isKeyword = name => name.startsWith('$');
  return keys(nodeType).filter(name => !isKeyword(name));
},

addInputBindings(store, nodeType, particleName, bindings) {
  const {$inputs} = nodeType[particleName];
  const addBinding = ({key, binding}) => {
    if ((binding || key) === store) {
      bindings.push({particleName, binding: key});
    }
  };
  $inputs?.forEach(input => addBinding(this.decodeBinding(input)));
},

decodeBinding(value) {
  if (typeof value === 'string') {
    return {key: value, binding: ''};
  } else {
    const [key, binding] = entries(value)[0];
    return {key, binding};
  }
},

recipeForNode(node, nodeTypeMap, pipeline, customInspectors, inspectorData, globalStores) {
  const nodeType = nodeTypeMap[node.name];
  const recipe = this.buildParticleSpecs(nodeType, node, globalStores);
  recipe.$meta = {
    name: this.encodeFullNodeKey(node, pipeline, this.connectorDelim)
  };
  if (nodeType?.$stores) {
    recipe.$stores = this.buildStoreSpecs(node, nodeType, nodeTypeMap, pipeline);
  }
  this.addInspectorSpecs(recipe, node, nodeType, customInspectors, inspectorData);
  return recipe;
},

addInspectorSpecs(recipe, node, nodeType, customInspectors, inspectorData) {
  let hasInspector = false;
  keys(nodeType?.$stores || {}).forEach(storeName => {
    const store = nodeType.$stores[storeName];
    const inspector = customInspectors?.[store.$type];
    if (inspector) {
      this.getParticleNames(inspector).forEach(particleName => {
        const particleId = `__${particleName}${node.key}`;
        recipe[particleId] = this.constructInspectParticle(recipe.$meta.name, inspector[particleName], storeName, inspectorData);
        hasInspector = true;
      });
    }
  });
  if (hasInspector) {
    recipe.$stores[inspectorData] = {$type: 'JSON', connection: true};
  }
},

constructInspectParticle(key, spec, storeName, inspectorData) {
  const particle = {...spec};
  particle.$container = `Inspector#custom${this.sanitize(key)}${storeName}`;
  particle.$inputs = particle.$outputs = [{data: inspectorData}];
  particle.$staticInputs = {key, propName: storeName};
  return particle;
},

buildParticleSpecs(nodeType, node, globalStores) {
  const specs = {};
  const names = this.getParticleNames(nodeType) || [];
  for (const particleName of names) {
    specs[`${node.key}${particleName}`] =
        this.buildParticleSpec(nodeType, node, particleName, `main#runner`, globalStores);
  }
  return specs;
},

getParticleNames(recipe) {
  const notKeyword = name => !name.startsWith('$');
  return recipe && keys(recipe).filter(notKeyword);
},

buildParticleSpec(nodeType, node, particleName, defaultContainer, globalStores) {
  const particleSpec = nodeType[particleName];
  const $container = this.resolveContainer(
    node.key,
    particleSpec.$container,
    node.position?.preview?.[`${node.key}${particleName}:Container`]/*?.container*/ || defaultContainer
  );
  const bindings = this.resolveBindings(nodeType, node, particleSpec, globalStores);
  const resolvedSpec = {
    $slots: {},
    ...particleSpec,
    ...bindings,
    ...($container && {$container})
  };
  return resolvedSpec;
},

resolveContainer(nodeName, containerName, defaultContainer) {
  return containerName ? `${nodeName}${containerName}` : defaultContainer;
},

resolveBindings(nodeType, node, particleSpec, globalStores) {
  const {$inputs, $outputs} = particleSpec;
  return {
    $inputs: this.resolveGroup($inputs, node, nodeType, globalStores),
    $outputs: this.resolveGroup($outputs, node, nodeType, globalStores),
  };
},

resolveGroup(bindings, node, {$stores}, globalStores) {
  return bindings?.map(coded => {
    const {key, binding} = this.decodeBinding(coded);
    const resolutions = this.resolveBinding(binding || key, node, $stores, globalStores);
    return resolutions?.map((resolution, index) => ({[`${key}${index > 0 ? String(index) : ''}`]: resolution}));
  }).flat();
},

resolveBinding(binding, node, $stores, globalStores) {
  const boundStore = $stores?.[binding];
  if (boundStore && !boundStore.connection) {
    return [`${node.key}${this.nameDelim}${binding}`];
  } else {
    const selectedConnections = node.connections?.[binding]?.candidates?.filter(c => c.selected);
    if (selectedConnections) {
      return selectedConnections.map(connection => this.constructStoreId(connection));
    } else {
      const globalCandidate = this.findGlobalCandidate(binding, globalStores);
      if (globalCandidate) {
        return [globalCandidate];
      }
    }
  }
},

buildStoreSpecs(node, nodeType, nodeTypeMap, pipeline) {
  const specs = {};
  const stores = nodeType.$stores || {};
  entries(stores).forEach(([name, store]) => {
    if (store.connection) {
      const connections = this.getStoreConnections(name, node);
      connections.forEach(connection => {
        const spec = this.findGlobalSpec(connection, nodeType)
                  || this.findStoreSpec(connection, pipeline, nodeTypeMap);
        specs[this.constructStoreId(connection)] = {...spec, connection: true};
      });
    } else {
      specs[`${node.key}${this.nameDelim}${name}`] = this.buildStoreSpec(store, node.props?.[name], node);
    }
  });
  return specs;
},

getStoreConnections(storeName, node) {
  return node.connections?.[storeName]?.candidates?.filter(c => c.selected);
},

buildStoreSpec(store, value, node) {
  return {
    ...store,
    $value: this.formatStoreValue(store, value, node)
  };
},

formatStoreValue(store, value, node) {
  if (value !== undefined) {
    return value;
  }
  // TODO(mariakleiner): Revisit how to express special default values supported by NodesConnector.
  if (store.value === `node.key`) {
    return node.key;
  }
  return store.$value;
},

constructStoreId({from, store}) {
  return `${from === 'global' ? '' : from}${store}`;
},

findGlobalSpec(connection, nodeType) {
  if (connection.from === 'global') {
    return nodeType.$stores[connection.store];
  }
},

findStoreSpec({from, store}, pipeline, nodeTypeMap) {
  const nodeTypeName = pipeline.nodes.find(n => n.key === from)?.name;
  const fromNode = nodeTypeMap[nodeTypeName];
  return fromNode?.$stores?.[store];
},

encodeFullNodeKey({key}, {$meta}, delimiter) {
  return [$meta?.name, key].filter(Boolean).join(delimiter);
},

sanitize(key) {
  return key.replace(/[^A-Za-z0-9]/g, '');
}

});
<commit_msg>add delimiter when forming storeId’s (#99)<commit_after>/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file or at
 * https://developers.google.com/open-source/licenses/bsd
 */
/* global scope */
({

connectorDelim: '$$',
nameDelim: ':',

shouldUpdate({nodeTypes}) {
  return !nodeTypes.empty;
},

async update(inputs, state, {service}) {
  const {pipeline, nodeTypes} = inputs;
  if (!state.nodeTypeMap) {
    state.nodeTypeMap = {};
    values(nodeTypes).forEach(t => state.nodeTypeMap[t.$meta.name] = this.flattenNodeType(t));
  }

  if (pipeline?.nodes) {
    if (this.pipelineChanged(pipeline, state.pipeline)
        || this.nodesDidChange(pipeline.nodes, state.nodes)) {
      state.pipeline = pipeline;
      state.nodes = [...pipeline.nodes];
      return this.updateNodes(inputs, state);
    }
  }
},

flattenNodeType(nodeType, $container) {
  const flattened = {};
  keys(nodeType).forEach(key => {
    if (key.startsWith('$')) {
      flattened[key] = nodeType[key];
    } else {
      assign(flattened, this.flattenParticleSpec(key, nodeType[key], $container));
    }
  });
  return flattened;
},

flattenParticleSpec(particleId, particleSpec, $container) {
  const flattened = {
    [particleId]: {
      ...particleSpec,
      $slots: {},
      ...($container && {$container})
    }
  };
  entries(particleSpec.$slots || {}).forEach(([slotId, slotRecipe]) => {
    assign(flattened, this.flattenNodeType(slotRecipe, `${particleId}#${slotId}`));
  });
  return flattened;
},

pipelineChanged(pipeline, oldPipeline) {
  return this.pipelineId(pipeline) !== this.pipelineId(oldPipeline);
},

pipelineId(pipeline) {
  // Backward compatibility for pipelines published in versions < 0.4
  return pipeline?.$meta?.id || pipeline?.$meta?.name;
},

nodesDidChange(nodes, currentNodes) {
  if (nodes?.length === currentNodes?.length) {
    return !currentNodes?.every(node => this.hasSameNode(node, nodes));
  }
  return true;
},

hasSameNode(node, nodes) {
  const nodeInNodes = nodes.find(n => n.key === node.key);
  if (nodeInNodes) {
    if (scope.deepEqual(nodeInNodes, node)) {
      return true;
    }
  }
  //log('hasSameNode: FALSE:', nodeInNodes, node);
  return false;
},

async updateNodes({pipeline, selectedNode, customInspectors, inspectorData, globalStores}, {nodeTypeMap}) {
  pipeline.nodes = pipeline.nodes.map(
    node => this.updateNodeConnectionCandidates({node, pipeline, nodeTypeMap, globalStores}));
  const recipes = pipeline.nodes
    .map(node => this.recipeForNode(node, nodeTypeMap, pipeline, customInspectors, inspectorData || 'inspectorData', globalStores))
    .filter(recipe => recipe)
    ;
  return {
    pipeline,
    recipes,
    selectedNode: pipeline.nodes.find(n => n.key === selectedNode?.key),
  };
},

updateNodeConnectionCandidates({node, pipeline, nodeTypeMap, globalStores}) {
  const connections = this.updateNodeStoreConnections(node, pipeline, nodeTypeMap, globalStores);
  return {
    ...node,
    ...(keys(connections).length > 0 && {connections})
  };
},

updateNodeStoreConnections(node, pipeline, nodeTypeMap, globalStores) {
  const connections = {};
  const nodeType = nodeTypeMap[node.name];
  nodeType?.$stores && entries(nodeType.$stores).forEach(([storeName, store]) => {
    if (store.connection) {
      const bindings = this.findStoreBindings(storeName, nodeType);
      const candidates = this.findConnectionCandidates(storeName, store, node, pipeline, nodeTypeMap, globalStores);
      connections[storeName] = {store, bindings, candidates};
    }
  });
  if (!node.connections) {
    this.initDefaultCandidates(connections);
  }
  return connections;
},

initDefaultCandidates(connections) {
  const used = new Set();
  keys(connections).forEach(storeName => {
    const {bindings, candidates} = connections[storeName];
    if (candidates.length === 1 && bindings?.length > 0) {
      const candidateId = this.constructStoreId(candidates[0]);
      if (!used.has(candidateId)) {
        candidates[0].selected = true;
        used.add(candidateId);
      }
    }
  });
},

findConnectionCandidates(storeName, {$type}, node, {nodes}, nodeTypeMap, globalStores) {
  if (this.findGlobalCandidate(storeName, globalStores)) {
    return [{from: 'global', store: storeName, type: $type, selected: true}];
  }
  const candidates = [];
  nodes.forEach(n => {
    const candidate = this.findCandidateInNode($type, n, nodeTypeMap);
    if (candidate && candidate.from !== node.key) {
      if (node.connections) {
        candidate.selected = node.connections[storeName]?.candidates.find(({from, store}) => from === candidate.from && store === candidate.store)?.selected;
      }
      candidates.push(candidate);
    }
  });
  return candidates;
},

findGlobalCandidate(storeName, globalStores) {
  return globalStores?.find(name => name === storeName);
},

findCandidateInNode(type, node, nodeTypeMap) {
  const nodeType = nodeTypeMap[node.name];
  if (nodeType) {
    const store = this.findMatchingStore(type, nodeType.$stores);
    if (store) {
      return ({from: node.key, store: store.name, type: store.$type});
    }
  }
},

findMatchingStore(type, stores) {
  const matchingType = (storeType) => {
    // TODO(b/244191110): Type matching API to be wired here.
    return storeType === type;
  };
  const matchingStore = (store) => matchingType(store.$type) && !store.connection;
  const name = stores && keys(stores).find(name => matchingStore(stores[name]));
  if (name) {
    return {name, ...stores[name]};
  }
},

findStoreBindings(store, nodeType) {
  const bindings = [];
  this.particleNames(nodeType).forEach(particleName =>  {
    this.addInputBindings(store, nodeType, particleName, bindings);
  });
  return bindings;
},

particleNames(nodeType) {
  const isKeyword = name => name.startsWith('$');
  return keys(nodeType).filter(name => !isKeyword(name));
},

addInputBindings(store, nodeType, particleName, bindings) {
  const {$inputs} = nodeType[particleName];
  const addBinding = ({key, binding}) => {
    if ((binding || key) === store) {
      bindings.push({particleName, binding: key});
    }
  };
  $inputs?.forEach(input => addBinding(this.decodeBinding(input)));
},

decodeBinding(value) {
  if (typeof value === 'string') {
    return {key: value, binding: ''};
  } else {
    const [key, binding] = entries(value)[0];
    return {key, binding};
  }
},

recipeForNode(node, nodeTypeMap, pipeline, customInspectors, inspectorData, globalStores) {
  const nodeType = nodeTypeMap[node.name];
  const recipe = this.buildParticleSpecs(nodeType, node, globalStores);
  recipe.$meta = {
    name: this.encodeFullNodeKey(node, pipeline, this.connectorDelim)
  };
  if (nodeType?.$stores) {
    recipe.$stores = this.buildStoreSpecs(node, nodeType, nodeTypeMap, pipeline);
  }
  this.addInspectorSpecs(recipe, node, nodeType, customInspectors, inspectorData);
  return recipe;
},

addInspectorSpecs(recipe, node, nodeType, customInspectors, inspectorData) {
  let hasInspector = false;
  keys(nodeType?.$stores || {}).forEach(storeName => {
    const store = nodeType.$stores[storeName];
    const inspector = customInspectors?.[store.$type];
    if (inspector) {
      this.getParticleNames(inspector).forEach(particleName => {
        const particleId = `__${particleName}${node.key}`;
        recipe[particleId] = this.constructInspectParticle(recipe.$meta.name, inspector[particleName], storeName, inspectorData);
        hasInspector = true;
      });
    }
  });
  if (hasInspector) {
    recipe.$stores[inspectorData] = {$type: 'JSON', connection: true};
  }
},

constructInspectParticle(key, spec, storeName, inspectorData) {
  const particle = {...spec};
  particle.$container = `Inspector#custom${this.sanitize(key)}${storeName}`;
  particle.$inputs = particle.$outputs = [{data: inspectorData}];
  particle.$staticInputs = {key, propName: storeName};
  return particle;
},

buildParticleSpecs(nodeType, node, globalStores) {
  const specs = {};
  const names = this.getParticleNames(nodeType) || [];
  for (const particleName of names) {
    specs[`${node.key}${particleName}`] =
        this.buildParticleSpec(nodeType, node, particleName, `main#runner`, globalStores);
  }
  return specs;
},

getParticleNames(recipe) {
  const notKeyword = name => !name.startsWith('$');
  return recipe && keys(recipe).filter(notKeyword);
},

buildParticleSpec(nodeType, node, particleName, defaultContainer, globalStores) {
  const particleSpec = nodeType[particleName];
  const $container = this.resolveContainer(
    node.key,
    particleSpec.$container,
    node.position?.preview?.[`${node.key}${particleName}:Container`]/*?.container*/ || defaultContainer
  );
  const bindings = this.resolveBindings(nodeType, node, particleSpec, globalStores);
  const resolvedSpec = {
    $slots: {},
    ...particleSpec,
    ...bindings,
    ...($container && {$container})
  };
  return resolvedSpec;
},

resolveContainer(nodeName, containerName, defaultContainer) {
  return containerName ? `${nodeName}${containerName}` : defaultContainer;
},

resolveBindings(nodeType, node, particleSpec, globalStores) {
  const {$inputs, $outputs} = particleSpec;
  return {
    $inputs: this.resolveGroup($inputs, node, nodeType, globalStores),
    $outputs: this.resolveGroup($outputs, node, nodeType, globalStores),
  };
},

resolveGroup(bindings, node, {$stores}, globalStores) {
  return bindings?.map(coded => {
    const {key, binding} = this.decodeBinding(coded);
    const resolutions = this.resolveBinding(binding || key, node, $stores, globalStores);
    return resolutions?.map((resolution, index) => ({[`${key}${index > 0 ? String(index) : ''}`]: resolution}));
  }).flat();
},

resolveBinding(binding, node, $stores, globalStores) {
  const boundStore = $stores?.[binding];
  if (boundStore && !boundStore.connection) {
    return [`${node.key}${this.nameDelim}${binding}`];
  } else {
    const selectedConnections = node.connections?.[binding]?.candidates?.filter(c => c.selected);
    if (selectedConnections) {
      return selectedConnections.map(connection => this.constructStoreId(connection));
    } else {
      const globalCandidate = this.findGlobalCandidate(binding, globalStores);
      if (globalCandidate) {
        return [globalCandidate];
      }
    }
  }
},

buildStoreSpecs(node, nodeType, nodeTypeMap, pipeline) {
  const specs = {};
  const stores = nodeType.$stores || {};
  entries(stores).forEach(([name, store]) => {
    if (store.connection) {
      const connections = this.getStoreConnections(name, node);
      connections.forEach(connection => {
        const spec = this.findGlobalSpec(connection, nodeType)
                  || this.findStoreSpec(connection, pipeline, nodeTypeMap);
        specs[this.constructStoreId(connection)] = {...spec, connection: true};
      });
    } else {
      specs[`${node.key}${this.nameDelim}${name}`] = this.buildStoreSpec(store, node.props?.[name], node);
    }
  });
  return specs;
},

getStoreConnections(storeName, node) {
  return node.connections?.[storeName]?.candidates?.filter(c => c.selected);
},

buildStoreSpec(store, value, node) {
  return {
    ...store,
    $value: this.formatStoreValue(store, value, node)
  };
},

formatStoreValue(store, value, node) {
  if (value !== undefined) {
    return value;
  }
  // TODO(mariakleiner): Revisit how to express special default values supported by NodesConnector.
  if (store.value === `node.key`) {
    return node.key;
  }
  return store.$value;
},

constructStoreId({from, store}) {
  return `${from === 'global' ? '' : `${from}${this.nameDelim}`}${store}`;
},

findGlobalSpec(connection, nodeType) {
  if (connection.from === 'global') {
    return nodeType.$stores[connection.store];
  }
},

findStoreSpec({from, store}, pipeline, nodeTypeMap) {
  const nodeTypeName = pipeline.nodes.find(n => n.key === from)?.name;
  const fromNode = nodeTypeMap[nodeTypeName];
  return fromNode?.$stores?.[store];
},

encodeFullNodeKey({key}, {$meta}, delimiter) {
  return [$meta?.name, key].filter(Boolean).join(delimiter);
},

sanitize(key) {
  return key.replace(/[^A-Za-z0-9]/g, '');
}

});
<|endoftext|>


<commit_before><commit_msg>Update fsm-sticky-header.js<commit_after><|endoftext|>


<commit_before>
var search_list = [];
var datearray = [];

var tooltip = d3.select("div#line_chart")
    .append("div")
    .attr("class", "remove")
    .style("position", "absolute")
    .style("z-index", "20")
    .style("visibility", "hidden")
    .style("top", "500px")
    .style("left", "500px")
    .style("font-size", "16px");

function updateData(frm){
  search_list.push(frm.toLowerCase());
  d3.csv("http://singaporenews.github.io/transposed_terms_27oct.csv", function(error, data){

    line_color.domain(d3.keys(
      data[0]).filter(function(key){ return key.toLowerCase() !== 'headline_year'; }
      )
    );

    var headline_terms = line_color.domain().map(function(term){
      return {
        term: term.toLowerCase(),
        values: data.map(function(d){
          return {year: d.headline_year, count: +d[term]};
        })
      };
    });

    if (search_list.length > 5){
      length = search_list.length;
      search_list = search_list.slice(-5);
    };

    used_data = $.map(headline_terms, function(element){
      return ($.inArray(element.term,search_list)>-1?element:null)
    });

    line_color.domain(search_list);

    //used_data = headline_terms.filter(function(d){ return d.term == frm; });

    var xAxis = d3.svg.axis()
      .scale(line_x)
      .orient("bottom")
      .ticks(used_data[0].values.map(function(d){ return d.year; }));

    var yAxis = d3.svg.axis()
      .scale(line_y)
      .orient('left');

    var minY = d3.min(used_data, function(c){ return d3.min(c.values, function(v){
                  return v.count; });
                });

    var maxY = d3.max(used_data, function(c){ return d3.max(c.values, function(v){
                  return v.count; });
                });

    line_x.domain(used_data[0].values.map(function(d){ return d.year; }));

    line_y.domain([minY, maxY]);

    var term_label = line_svg.selectAll('.term_label')
        .data(used_data);

    term_label
        .enter()
      .append('text')
        .attr('class', 'term_label');

        /*
        .transition()
        .duration(750)
        .attr('class', 'term_label')
        .attr("x", -60)
        .attr("y", function(d,i){ return i+"em"; })
        .style("text-anchor", "middle")
        .style("font-size", "16px")
        .transition()
        .duration(750)
        .style('fill', function(d){ return color(d.term); })
        .text(function(d){ return d.term; });
      */
    term_label
        .transition()
        .duration(750)
        .attr("x", -70)
        .attr("y", function(d,i){ return i+"em"; })
        .style("text-anchor", "middle")
        .style("font-size", "16px")
        .transition()
        .duration(750)
        .style('fill', function(d){ return line_color(d.term); })
        .text(function(d){ return d.term; });

    term_label.exit().transition().duration(750).remove();

    line_svg.selectAll('.line_y.axis')
      .transition()
      .duration(750)
      .call(yAxis);

    var terms = line_svg.selectAll('.terms');

    var termsLines = terms.selectAll('.line')
        .data(used_data);

    termsLines.enter().append('path')
        .transition()
        .duration(750)
        .attr('class', 'line')
        .attr('d', function(d){ return line(d.values); })
        .style('stroke', function(d){ return line_color(d.term); });

    termsLines.exit().transition().duration(750).remove();

    termsLines
      .transition()
      .duration(750)
      .attr('class', 'line')
      .attr('d', function(d){ return line(d.values); })
      .style('stroke', function(d){ return line_color(d.term); });

  });
};

function createChart(frm){
  search_list.push(frm);
  d3.csv("http://singaporenews.github.io/transposed_terms_27oct.csv", function(error, data){
    console.log(data);
    line_color.domain(d3.keys(
      data[0]).filter(function(key){ return key.toLowerCase() !== 'headline_year'; }
      )
    );

    var headline_terms = line_color.domain().map(function(term){
      return {
        term: term.toLowerCase(),
        values: data.map(function(d){
          return {year: d.headline_year, count: +d[term]};
        })
      };
    });

    used_data = headline_terms.filter(function(d){ return d.term == frm.toLowerCase(); });
    console.log(frm.toLowerCase());

    var xAxis = d3.svg.axis()
      .scale(line_x)
      .orient("bottom")
      .ticks(used_data[0].values.map(function(d){ return d.year; }));

    var yAxis = d3.svg.axis()
      .scale(line_y)
      .orient('left');

    var minY = d3.min(used_data, function(c){ return d3.min(c.values, function(v){
                  return v.count; });
                });

    var maxY = d3.max(used_data, function(c){ return d3.max(c.values, function(v){
                  return v.count; });
                });

    line_x.domain(used_data[0].values.map(function(d){ return d.year; }));

    line_y.domain([minY, maxY]);

    var term_label = line_svg.selectAll('term_label')
        .data(used_data)
        .enter()
      .append('text')
        .attr('class', 'term_label')
        .attr("x", -70)
        .attr("y", function(d,i){ return i+"em"; })
        .style("text-anchor", "middle")
        .style("font-size", "16px")
        .style("fill", "#53565A")
        .transition()
        .duration(750)
        .style('fill', function(d){ return line_color(d.term); })
        .text(function(d){ return d.term; });

    line_svg.append('g')
        .attr('class', 'line_x axis')
        .attr('transform', 'translate(0,' + height + ')')
        .call(xAxis)
        .selectAll('text')
            .style('text-anchor', 'end')
            .attr('dx', '-.8em')
            .attr('dy', '.15em')
            .attr('transform', function(d){
              return 'rotate(-65)'
            });

    line_svg.append('g')
        .attr('class', 'line_y axis')
        .call(yAxis)
      .append('text')
        .attr('transform', 'rotate(-90)')
        .attr('y', 6)
        .attr('dy', '.71em')
        .style('text-anchor', 'end')
        .text('Count');

    var terms = line_svg.append('g')
              .attr('class', 'terms');

    var termsLines = terms.selectAll('.line')
        .data(used_data);

    termsLines.enter().append('path')
        .attr('class', 'line');

    termsLines.exit().remove();

    termsLines
      .attr('d', function(d){ return line(d.values); })
      .style('stroke', function(d){ return line_color(d.term); })
      .on("mousemove", function(d, i) {
        mousex = d3.mouse(this);
        mousex = mousex[0];
        var invertedx = x.invert(mousex);
        //invertedx = invertedx.getMonth() + invertedx.getDate();
        var selected = (d.values);
        for (var k = 0; k < selected.length; k++) {
          datearray[k] = selected[k].date
          datearray[k] = datearray[k].getMonth() + datearray[k].getDate();
        }

        mousedate = datearray.indexOf(Math.round(invertedx));
        pro = d.values[mousedate].count;
        tip_year = d.values[mousedate].year;

        d3.select(this)
        .classed("hover", true)
        .attr("stroke", "#000")
        .attr("stroke-width", "0.5px"),
        tooltip.html( "
" + d.term + "|" + tip_year + pro + "
" ).style("visibility", "visible");

      })
      .on("mouseout", function(d, i) {
       svg.selectAll(".layer")
        .transition()
        .duration(250)
        .attr("opacity", "1");
        d3.select(this)
        .classed("hover", false)
        .attr("stroke-width", "0px"), tooltip.html( "
" + d.term + "|" + tip_year + pro + "
" ).style("visibility", "hidden");
  })

  });
}<commit_msg>update data<commit_after>
var search_list = [];
var datearray = [];

var tooltip = d3.select("div#line_chart")
    .append("div")
    .attr("class", "remove")
    .style("position", "absolute")
    .style("z-index", "20")
    .style("visibility", "hidden")
    .style("top", "500px")
    .style("left", "500px")
    .style("font-size", "16px");

function updateData(frm){
  search_list.push(frm.toLowerCase());
  d3.csv("http://singaporenews.github.io/transposed_terms_27oct.csv", function(error, data){

    line_color.domain(d3.keys(
      data[0]).filter(function(key){ return key.toLowerCase() !== 'headline_year'; }
      )
    );

    var headline_terms = line_color.domain().map(function(term){
      return {
        term: term.toLowerCase(),
        values: data.map(function(d){
          return {year: d.headline_year, count: +d[term]};
        })
      };
    });

    if (search_list.length > 5){
      length = search_list.length;
      search_list = search_list.slice(-5);
    };

    used_data = $.map(headline_terms, function(element){
      return ($.inArray(element.term,search_list)>-1?element:null)
    });

    line_color.domain(search_list);

    //used_data = headline_terms.filter(function(d){ return d.term == frm; });

    var xAxis = d3.svg.axis()
      .scale(line_x)
      .orient("bottom")
      .ticks(used_data[0].values.map(function(d){ return d.year; }));

    var yAxis = d3.svg.axis()
      .scale(line_y)
      .orient('left');

    var minY = d3.min(used_data, function(c){ return d3.min(c.values, function(v){
                  return v.count; });
                });

    var maxY = d3.max(used_data, function(c){ return d3.max(c.values, function(v){
                  return v.count; });
                });

    line_x.domain(used_data[0].values.map(function(d){ return d.year; }));

    line_y.domain([minY, maxY]);

    var term_label = line_svg.selectAll('.term_label')
        .data(used_data);

    term_label
        .enter()
      .append('text')
        .attr('class', 'term_label');

        /*
        .transition()
        .duration(750)
        .attr('class', 'term_label')
        .attr("x", -60)
        .attr("y", function(d,i){ return i+"em"; })
        .style("text-anchor", "middle")
        .style("font-size", "16px")
        .transition()
        .duration(750)
        .style('fill', function(d){ return color(d.term); })
        .text(function(d){ return d.term; });
      */
    term_label
        .transition()
        .duration(750)
        .attr("x", -70)
        .attr("y", function(d,i){ return i+"em"; })
        .style("text-anchor", "middle")
        .style("font-size", "16px")
        .transition()
        .duration(750)
        .style('fill', function(d){ return line_color(d.term); })
        .text(function(d){ return d.term; });

    term_label.exit().transition().duration(750).remove();

    line_svg.selectAll('.line_y.axis')
      .transition()
      .duration(750)
      .call(yAxis);

    var terms = line_svg.selectAll('.terms');

    var termsLines = terms.selectAll('.line')
        .data(used_data);

    termsLines.enter().append('path')
        .transition()
        .duration(750)
        .attr('class', 'line')
        .attr('d', function(d){ return line(d.values); })
        .style('stroke', function(d){ return line_color(d.term); });

    termsLines.exit().transition().duration(750).remove();

    termsLines
      .transition()
      .duration(750)
      .attr('class', 'line')
      .attr('d', function(d){ return line(d.values); })
      .style('stroke', function(d){ return line_color(d.term); });

  });
};

function createChart(frm){
  search_list.push(frm);
  d3.csv("http://singaporenews.github.io/transposed_terms_27oct.csv", function(error, data){
    console.log(data);
    line_color.domain(d3.keys(
      data[0]).filter(function(key){ return key.toLowerCase() !== 'headline_year'; }
      )
    );

    var headline_terms = line_color.domain().map(function(term){
      return {
        term: term.toLowerCase(),
        values: data.map(function(d){
          return {year: d.headline_year, count: +d[term]};
        })
      };
    });

    used_data = headline_terms.filter(function(d){ return d.term == frm.toLowerCase(); });
    console.log(frm.toLowerCase());

    var xAxis = d3.svg.axis()
      .scale(line_x)
      .orient("bottom")
      .ticks(used_data[0].values.map(function(d){ return d.year; }));

    var yAxis = d3.svg.axis()
      .scale(line_y)
      .orient('left');

    var minY = d3.min(used_data, function(c){ return d3.min(c.values, function(v){
                  return v.count; });
                });

    var maxY = d3.max(used_data, function(c){ return d3.max(c.values, function(v){
                  return v.count; });
                });

    line_x.domain(used_data[0].values.map(function(d){ return d.year; }));

    line_y.domain([minY, maxY]);

    var term_label = line_svg.selectAll('term_label')
        .data(used_data)
        .enter()
      .append('text')
        .attr('class', 'term_label')
        .attr("x", -70)
        .attr("y", function(d,i){ return i+"em"; })
        .style("text-anchor", "middle")
        .style("font-size", "16px")
        .style("fill", "#53565A")
        .transition()
        .duration(750)
        .style('fill', function(d){ return line_color(d.term); })
        .text(function(d){ return d.term; });

    line_svg.append('g')
        .attr('class', 'line_x axis')
        .attr('transform', 'translate(0,' + height + ')')
        .call(xAxis)
        .selectAll('text')
            .style('text-anchor', 'end')
            .attr('dx', '-.8em')
            .attr('dy', '.15em')
            .attr('transform', function(d){
              return 'rotate(-65)'
            });

    line_svg.append('g')
        .attr('class', 'line_y axis')
        .call(yAxis)
      .append('text')
        .attr('transform', 'rotate(-90)')
        .attr('y', 6)
        .attr('dy', '.71em')
        .style('text-anchor', 'end')
        .text('Count');

    var terms = line_svg.append('g')
              .attr('class', 'terms');

    var termsLines = terms.selectAll('.line')
        .data(used_data);

    termsLines.enter().append('path')
        .attr('class', 'line');

    termsLines.exit().remove();

    termsLines
      .attr('d', function(d){ return line(d.values); })
      .style('stroke', function(d){ return line_color(d.term); })
      .on("mousemove", function(d, i) {
        mousex = d3.mouse(this);
        mousex = mousex[0];
        var invertedx = x.invert(mousex);
        //invertedx = invertedx.getMonth() + invertedx.getDate();
        var selected = (d.values);
        for (var k = 0; k < selected.length; k++) {
          datearray[k] = selected[k].year;
        }

        mousedate = datearray.indexOf(Math.round(invertedx));
        pro = d.values[mousedate].count;
        tip_year = d.values[mousedate].year;

        d3.select(this)
        .classed("hover", true)
        .attr("stroke", "#000")
        .attr("stroke-width", "0.5px"),
        tooltip.html( "
" + d.term + "|" + tip_year + pro + "
" ).style("visibility", "visible");

      })
      .on("mouseout", function(d, i) {
       svg.selectAll(".layer")
        .transition()
        .duration(250)
        .attr("opacity", "1");
        d3.select(this)
        .classed("hover", false)
        .attr("stroke-width", "0px"), tooltip.html( "
" + d.term + "|" + tip_year + pro + "
" ).style("visibility", "hidden");
  })

  });
}<|endoftext|>


<commit_before>
// demonstrate the effect of modifying an objects prototype before and after the object is constructed

module("About Prototypal Inheritance (topics/about_prototypal_inheritance.js)");

// this 'class' pattern defines a class by its constructor
var Mammal = function(name) {
    this.name = name;
}
// things that don't need to be set in the constructor should be added to the constructor's prototype property.
Mammal.prototype = {
    sayHi: function() {
        return "Hello, my name is " + this.name;
    }
}

test("defining a 'class'", function() {
    var eric  = new Mammal("Eric");
    equal(__, eric.sayHi(), 'what will Eric say?');
});

// add another function to the Mammal 'type' that uses the sayHi function
Mammal.prototype.favouriteSaying = function() {
    return this.name + "'s favourite saying is " + this.sayHi();
}

test("more functions", function() {
    var bobby = new Mammal("Bobby");
    equal(__, bobby.favouriteSaying(), "what is Bobby's favourite saying?");
});

test("calling functions added to a prototype after an object was created", function() {
    var paul = new Mammal("Paul");
    Mammal.prototype.numberOfLettersInName = function() {
        return this.name.length;
    };
    // the following statement asks the paul object to call a function that was added
    // to the Mammal prototype after paul was constructed.
    equal(__, paul.numberOfLettersInName(), "how long is Paul's name?");
});

// helper function for inheritance.
// From https://developer.mozilla.org/en/JavaScript/Guide/Inheritance_Revisited
function extend(child, supertype){
    child.prototype = supertype.prototype;
}

// "Subclass" Mammal
function Bat(name, wingspan) {
    Mammal.call(this, name);
    this.wingspan = wingspan;
}

// configure inheritance
extend(Bat, Mammal);

test("Inheritance", function() {
    var lenny = new Bat("Lenny", "1.5m");
    equal(__, lenny.sayHi(), "what does Lenny say?");
    equal(__, lenny.wingspan, "what is Lenny's wingspan?");
});
<commit_msg>complete about prototypal inheritance<commit_after>
// demonstrate the effect of modifying an object's prototype before and after the object is constructed

module("About Prototypal Inheritance (topics/about_prototypal_inheritance.js)");

// this 'class' pattern defines a class by its constructor
var Mammal = function(name) {
    this.name = name;
}
// things that don't need to be set in the constructor should be added to the constructor's prototype property.
Mammal.prototype = {
    sayHi: function() {
        return "Hello, my name is " + this.name;
    }
}

test("defining a 'class'", function() {
    var eric  = new Mammal("Eric");
    equal("Hello, my name is Eric", eric.sayHi(), 'what will Eric say?');
});

// add another function to the Mammal 'type' that uses the sayHi function
Mammal.prototype.favouriteSaying = function() {
    return this.name + "'s favourite saying is " + this.sayHi();
}

test("more functions", function() {
    var bobby = new Mammal("Bobby");
    equal("Bobby's favourite saying is Hello, my name is Bobby", bobby.favouriteSaying(), "what is Bobby's favourite saying?");
});

test("calling functions added to a prototype after an object was created", function() {
    var paul = new Mammal("Paul");
    Mammal.prototype.numberOfLettersInName = function() {
        return this.name.length;
    };
    // the following statement asks the paul object to call a function that was added
    // to the Mammal prototype after paul was constructed.
    equal(4, paul.numberOfLettersInName(), "how long is Paul's name?");
});

// helper function for inheritance.
// From https://developer.mozilla.org/en/JavaScript/Guide/Inheritance_Revisited
function extend(child, supertype){
    child.prototype = supertype.prototype;
}

// "Subclass" Mammal
function Bat(name, wingspan) {
    Mammal.call(this, name);
    this.wingspan = wingspan;
}

// configure inheritance
extend(Bat, Mammal);

test("Inheritance", function() {
    var lenny = new Bat("Lenny", "1.5m");
    equal("Hello, my name is Lenny", lenny.sayHi(), "what does Lenny say?");
    equal("1.5m", lenny.wingspan, "what is Lenny's wingspan?");
});
<|endoftext|>


<commit_before><commit_msg>Fixed missing brace<commit_after><|endoftext|>


<commit_before>/* global browser */

'use strict';

exports.config = {
    onPrepare: function() {
      require('./utils/locators.js');
      browser.driver.manage().window().maximize();
    },
    //disable these if you want to run tests locally
    sauceUser: process.env.SAUCE_USERNAME,
    sauceKey: process.env.SAUCE_ACCESS_KEY,
    sauceBuild: process.env.TRAVIS_BUILD_NUMBER,
    rootElement: 'html',
    baseUrl: 'https://metadatamanagement-dev.cfapps.io/',
    specs: [
      'home/home.spec.js',
      'disclosure/disclosure.spec.js',
      'common/navbar.spec.js',
      'common/toolbar.spec.js',
    ],
    multiCapabilities: [{
      'name': 'Win10/Chrome',
      'platform': 'Windows 10',
      'browserName': 'chrome',
      'version': 'latest',
      'screenResolution': '1280x1024'
    }, {
      'name': 'Win10/Firefox',
      'platform': 'Windows 10',
      'browserName': 'firefox',
      'screenResolution': '1280x1024',
      'version': '54.0'
    }, {
      'name': 'Win10/Edge',
      'platform': 'Windows 10',
      'browserName': 'MicrosoftEdge',
      'version': 'latest',
      'screenResolution': '1280x1024'
    }, {
      'name': 'Win10/IE11',
      'platform': 'Windows 10',
      'browserName': 'internet explorer',
      'version': '11.0',
      'screenResolution': '1280x1024'
    }],
    //enable this for local tests without selenium
    //directConnect: true,
    jasmineNodeOpts: {
      defaultTimeoutInterval: 120000
    },
    allScriptsTimeout: 120000,
    getPageTimeout: 120000
  };
<commit_msg>#1277 trying to fix protractor for edge<commit_after>/* global browser */

'use strict';

exports.config = {
    onPrepare: function() {
      require('./utils/locators.js');
      browser.driver.manage().window().maximize();
    },
    //disable these if you want to run tests locally
    sauceUser: process.env.SAUCE_USERNAME,
    sauceKey: process.env.SAUCE_ACCESS_KEY,
    sauceBuild: process.env.TRAVIS_BUILD_NUMBER,
    rootElement: '[ng-app]',
    baseUrl: 'https://metadatamanagement-dev.cfapps.io/',
    specs: [
      'home/home.spec.js',
      'disclosure/disclosure.spec.js',
      'common/navbar.spec.js',
      'common/toolbar.spec.js',
    ],
    multiCapabilities: [{
      'name': 'Win10/Chrome',
      'platform': 'Windows 10',
      'browserName': 'chrome',
      'version': 'latest',
      'screenResolution': '1280x1024'
    }, {
      'name': 'Win10/Firefox',
      'platform': 'Windows 10',
      'browserName': 'firefox',
      'screenResolution': '1280x1024',
      'version': '54.0'
    }, {
      'name': 'Win10/Edge',
      'platform': 'Windows 10',
      'browserName': 'MicrosoftEdge',
      'version': 'latest',
      'screenResolution': '1280x1024'
    }, {
      'name': 'Win10/IE11',
      'platform': 'Windows 10',
      'browserName': 'internet explorer',
      'version': '11.0',
      'screenResolution': '1280x1024'
    }],
    //enable this for local tests without selenium
    //directConnect: true,
    jasmineNodeOpts: {
      defaultTimeoutInterval: 120000
    },
    allScriptsTimeout: 120000,
    getPageTimeout: 120000
  };
<|endoftext|>