<commit_before>import { createIO } from 'impure'

import { loadCustomSong } from '../CustomSongs'
import DndResources from '../../resources/dnd-resources'
import {
  downloadFileEntryFromURL,
  CustomSongResources,
} from '../../resources/custom-song-resources'
import { getIPFSResources } from '../../resources/ipfs-resources'

export function handleCustomSongFolderDrop(event) {
  return createIO(async ({ store, customSongLoader }) => {
    const resources = new DndResources(event)
    const initialLog = ['Examining dropped items...']
    return loadCustomSong(resources, initialLog, { store, customSongLoader })
  })
}

export function handleCustomSongURLLoad(url) {
  return createIO(async ({ store, customSongLoader }) => {
    const resources = new CustomSongResources({
      getFiles: async (log) => [await downloadFileEntryFromURL(url, log)],
    })
    const initialLog = ['Loading from ' + url]
    return loadCustomSong(resources, initialLog, { store, customSongLoader })
  })
}

export function handleClipboardPaste(e) {
  return createIO(async ({ store, customSongLoader }) => {
    let match
    const text = e.clipboardData.getData('text/plain')
    match = text.match(/(https?:\/\/[a-zA-Z0-9:.-]+)?(\/ipfs\/\S+)/)
    if (match) {
      const gateway = match[1] || undefined
      const path = gateway ? decodeURI(match[2]) : match[2]
      const resources = getIPFSResources(path, gateway)
      const initialLog = [
        'Loading from IPFS path ' + path + '...',
        `(Using ${resources.gatewayName})`,
      ]
      if (/^http:/.test(gateway) && window.location.protocol === 'https:') {
        initialLog.push(
          store,
          'WARNING: Loading http URL from https. This will likely fail!'
        )
      }
      return loadCustomSong(resources, initialLog, { store, customSongLoader })
    }
  })
}
<commit_msg>Allow pasting URL to bemuse-song.json<commit_after>import { createIO } from 'impure'

import { loadCustomSong } from '../CustomSongs'
import DndResources from '../../resources/dnd-resources'
import {
  downloadFileEntryFromURL,
  CustomSongResources,
} from '../../resources/custom-song-resources'
import { getIPFSResources } from '../../resources/ipfs-resources'
import { URLResources } from 'bemuse/resources/url'

export function handleCustomSongFolderDrop(event) {
  return createIO(async ({ store, customSongLoader }) => {
    const resources = new DndResources(event)
    const initialLog = ['Examining dropped items...']
    return loadCustomSong(resources, initialLog, { store, customSongLoader })
  })
}

export function handleCustomSongURLLoad(url) {
  return createIO(async ({ store, customSongLoader }) => {
    const resources = new CustomSongResources({
      getFiles: async (log) => [await downloadFileEntryFromURL(url, log)],
    })
    const initialLog = ['Loading from ' + url]
    return loadCustomSong(resources, initialLog, { store, customSongLoader })
  })
}

export function handleClipboardPaste(e) {
  return createIO(async ({ store, customSongLoader }) => {
    const text = e.clipboardData.getData('text/plain')
    {
      const match = text.match(/(https?:\/\/[a-zA-Z0-9:.-]+)?(\/ipfs\/\S+)/)
      if (match) {
        const gateway = match[1] || undefined
        const path = gateway ? decodeURI(match[2]) : match[2]
        const resources = getIPFSResources(path, gateway)
        const initialLog = [
          'Loading from IPFS path ' + path + '...',
          `(Using ${resources.gatewayName})`,
        ]
        if (/^http:/.test(gateway) && window.location.protocol === 'https:') {
          initialLog.push(
            store,
            'WARNING: Loading http URL from https. This will likely fail!'
          )
        }
        return loadCustomSong(resources, initialLog, {
          store,
          customSongLoader,
        })
      }
      {
        const match = text.match(
          /https?:\/\/[a-zA-Z0-9:.-]+\/\S+\/bemuse-song\.json/
        )
        if (match) {
          const url = match[0]
          const initialLog = ['Loading prepared song...']
          const resources = new PreparedSongResources(new URL(url))
          return loadCustomSong(resources, initialLog, {
            store,
            customSongLoader,
          })
        }
      }
    }
  })
}

class PreparedSongResources extends URLResources {
  fileList = Promise.resolve(['bemuse-song.json'])
}
<|endoftext|>


<commit_before>'use strict';

module.exports = {

  controller: function (args) {
    this.solicitantes = args;
    this.converter = new window.showdown.Converter();
  },

  view: function (ctrl) {
    return m('', ctrl.solicitantes.map(function (s) {
      return m('.solicitantes markdown margem-solicitantes', [
                m('h4', m.trust(s.tipo())),
                m.trust(ctrl.converter.makeHtml(s.requisitos()))
            ]);
    }));
  }
};
<commit_msg>Renomei variaveis para ser mais legivel - #75<commit_after>'use strict';

module.exports = {

  controller: function (args) {
    this.solicitantes = args;
    this.converter = new window.showdown.Converter();
  },

  view: function (ctrl) {
    return m('', ctrl.solicitantes.map(function (solicitante) {
      return m('.solicitantes markdown margem-solicitantes', [
                m('h4', m.trust(solicitante.tipo())),
                m.trust(ctrl.converter.makeHtml(solicitante.requisitos()))
            ]);
    }));
  }
};
<|endoftext|>


<commit_before>define(
  'ephox.alloy.menu.layered.LayeredConfig',

  [
    'ephox.alloy.alien.ComponentStructure',
    'ephox.alloy.alien.EditableFields',
    'ephox.alloy.api.SystemEvents',
    'ephox.alloy.api.behaviour.Highlighting',
    'ephox.alloy.api.behaviour.Keying',
    'ephox.alloy.api.behaviour.Positioning',
    'ephox.alloy.api.behaviour.Representing',
    'ephox.alloy.api.behaviour.Sandboxing',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.menu.layered.LayeredState',
    'ephox.alloy.menu.logic.HotspotViews',
    'ephox.alloy.menu.util.ItemEvents',
    'ephox.alloy.menu.util.MenuEvents',
    'ephox.alloy.menu.util.MenuMarkers',
    'ephox.alloy.sandbox.Manager',
    'ephox.boulder.api.FieldPresence',
    'ephox.boulder.api.FieldSchema',
    'ephox.boulder.api.Objects',
    'ephox.boulder.api.ValueSchema',
    'ephox.compass.Arr',
    'ephox.compass.Obj',
    'ephox.highway.Merger',
    'ephox.peanut.Fun',
    'ephox.perhaps.Option',
    'ephox.perhaps.Options',
    'ephox.sugar.api.Body',
    'ephox.sugar.api.Class',
    'ephox.sugar.api.Classes',
    'ephox.sugar.api.Insert',
    'ephox.sugar.api.Remove',
    'ephox.sugar.api.SelectorFilter'
  ],

  function (ComponentStructure, EditableFields, SystemEvents, Highlighting, Keying, Positioning, Representing, Sandboxing, EventHandler, LayeredState, HotspotViews, ItemEvents, MenuEvents, MenuMarkers, Manager, FieldPresence, FieldSchema, Objects, ValueSchema, Arr, Obj, Merger, Fun, Option, Options, Body, Class, Classes, Insert, Remove, SelectorFilter) {
    var schema = ValueSchema.objOf([
      FieldSchema.strict('lazyAnchor'),

      FieldSchema.strict('onOpen'),
      FieldSchema.strict('onClose'),
      FieldSchema.strict('onExecute'),

      FieldSchema.strict('scaffold'),

      FieldSchema.defaulted('fakeFocus', false),

      FieldSchema.strict('lazySink'),

      FieldSchema.field(
        'markers',
        'markers',
        FieldPresence.strict(),
        MenuMarkers.schema()
      ),

      FieldSchema.strict('backgroundClass'),

      FieldSchema.field(
        'members',
        'members',
        FieldPresence.strict(),
        ValueSchema.objOf([
          FieldSchema.strict('menu'),
          FieldSchema.strict('item')
        ])
      ),

      FieldSchema.strict('onHighlight')
    ]);

    return function (rawUiSpec) {
      var uiSpec = ValueSchema.asStructOrDie('LayeredConfig', schema, rawUiSpec);

      var buildMenus = function (sandbox, menus) {
        return Obj.map(menus, function (spec, name) {
          // NOTE: We use rawUiSpec here so the nesting isn't a struct
          var data = Merger.deepMerge(
            uiSpec.members().menu().munge(spec),
            {
              uiType: 'menu',
              value: name,
              items: spec.items,
              markers: rawUiSpec.markers,
              members: {
                item: uiSpec.members().item()
              },
              fakeFocus: uiSpec.fakeFocus(),
              onHighlight: uiSpec.onHighlight()
            }
          );
          var menu = sandbox.getSystem().build(data);
          var container = sandbox.getSystem().build(
            uiSpec.scaffold()({ built: menu })
          );

          return {
            menu: menu,
            container: container
          };
        });
      };

      var getSink = function () {
        return uiSpec.lazySink()().getOrDie();
      };

      var toMenuValues = function (sandbox, sMenus) {
        return Obj.map(sMenus, function (menuTuple) {
          var menuItems = SelectorFilter.descendants(menuTuple.menu.element(), '.' + uiSpec.markers().item());
          return Arr.bind(menuItems, function (mi) {
            return sandbox.getSystem().getByDom(mi).map(function (item) {
              return Representing.getValue(item);
            }).fold(Fun.constant([ ]), Arr.pure);
          });
        });
      };

      var addToWorld = function (component, componentMap) {
        var menuCs = Arr.map(
          Obj.values(componentMap),
          function (tuple) {
            return tuple.container;
          }
        );
        Arr.each(menuCs, component.getSystem().addToWorld);
      };

      var showMenu = function (sandbox, tuple) {
        var sink = getSink();
        Positioning.position(sink, uiSpec.lazyAnchor()(), tuple.container);

        uiSpec.onOpen()(sandbox, tuple.menu);
      };

      var showSubmenu = function (sandbox, triggerItem, submenu) {
        var sink = getSink();
        Positioning.position(sink, {
          anchor: 'submenu',
          item: triggerItem,
          bubble: Option.none()
        }, submenu.container);
      };

      var setActiveMenu = function (sandbox, tuple) {
        var menu = tuple.menu;
        Highlighting.highlight(sandbox, menu);
        Highlighting.getHighlighted(menu).orThunk(function () {
          return Highlighting.getFirst(menu);
        }).each(function (item) {
          sandbox.getSystem().triggerEvent(SystemEvents.focusItem(), item.element(), { });
        });
      };

      var populate = function (sandbox, data) {
        var componentMap = buildMenus(sandbox, data.menus);
        addToWorld(sandbox, componentMap);

        var state = LayeredState();

        state.setContents(data.primary, componentMap, data.expansions, function (sMenus) {
          return toMenuValues(sandbox, sMenus);
        });
        state.getPrimary().each(function (primary) {
          if (! Body.inBody(primary.container.element())) {
            Insert.append(sandbox.element(), primary.container.element());
          }
        });
        return state;
      };

      var enter = function (sandbox, state) {
        state.getPrimary().each(function (primaryTuple) {
          setActiveMenu(sandbox, primaryTuple);
          showMenu(sandbox, primaryTuple);
          Keying.focusIn(sandbox);
        });
      };

      var preview = function (sandbox, state) {
        state.getPrimary().each(function (primary) {
          showMenu(sandbox, primary);
        });
      };

      var clear = function (sandbox, state) {
        var tuples = state.getMenus();
        Obj.each(tuples, function (tuple, menuName) {
          sandbox.getSystem().removeFromWorld(tuple.container);
        });
        state.clear();
      };

      var isPartOf = function (sandbox, state, queryElem) {
        var tuples = Obj.values(state.getMenus());
        return Arr.exists(tuples, function (tuple) {
          return ComponentStructure.isPartOf(tuple.container, queryElem);
        });
      };

      var getMenus = function (state, menuValues) {
        return Options.cat(
          Arr.map(menuValues, state.lookupMenu)
        );
      };

      var updateMenuPath = function (component, state, path) {
        return Option.from(path[0]).bind(state.lookupMenu).map(function (newMenuCompTuple) {
          var rest = getMenus(state, path.slice(1));
          Arr.each(rest, function (r) {
            Class.add(r.menu.element(), uiSpec.backgroundClass());
          });
          if (! Body.inBody(newMenuCompTuple.container.element())) {
            Insert.append(component.element(), newMenuCompTuple.container.element());
          }
          setActiveMenu(component, newMenuCompTuple);
          var others = getMenus(state, state.otherMenus(path));
          Arr.each(others, function (o) {
            // May not need to do the active menu thing.
            Classes.remove(o.menu.element(), [ uiSpec.backgroundClass() ]);
            Remove.remove(o.container.element());
          });

          return true;
        });
      };

      var expandRight = function (sandbox, item) {
        var value = Representing.getValue(item);
        return Sandboxing.getState(sandbox).bind(function (state) {
          return state.expand(value).bind(function (path) {
            // When expanding, always select the first.
            Option.from(path[0]).bind(state.lookupMenu).each(function (newMenuCompTuple) {
              Highlighting.highlightFirst(newMenuCompTuple.menu);

              // DUPE with above. Fix later.
              if (! Body.inBody(newMenuCompTuple.container.element())) {
                Insert.append(sandbox.element(), newMenuCompTuple.container.element());
                showSubmenu(sandbox, item, newMenuCompTuple);
              }
            });

            return updateMenuPath(sandbox, state, path);
          });
        });
      };

      var collapseLeft = function (sandbox, item) {
        var value = Representing.getValue(item);
        return Sandboxing.getState(sandbox).bind(function (state) {
          return state.collapse(value).bind(function (path) {
            return updateMenuPath(sandbox, state, path);
          });
        });
      };

      var updateView = function (sandbox, item) {
        var value = Representing.getValue(item);
        return Sandboxing.getState(sandbox).bind(function (state) {
          return state.refresh(value).bind(function (path) {
            return updateMenuPath(sandbox, state, path);
          });
        });
      };

      var onRight = function (sandbox, triggerItem) {
        return sandbox.getSystem().getByDom(triggerItem).bind(function (item) {
          return EditableFields.inside(triggerItem) ? Option.none() : expandRight(sandbox, item);
        });
      };

      var onLeft = function (sandbox, target) {
        return sandbox.getSystem().getByDom(target).bind(function (item) {
          // Exclude inputs, textareas etc.
          return EditableFields.inside(target) ? Option.none() : collapseLeft(sandbox, item);
        });
      };

      var onEscape = function (sandbox, target) {
        return sandbox.getSystem().getByDom(target).bind(function (item) {
          return collapseLeft(sandbox, item).orThunk(function () {
          // This should only fire when the user presses ESC ... not any other close.
            return HotspotViews.onEscape(uiSpec.lazyAnchor()(), sandbox);
          });
        });
      };

      var events = Objects.wrapAll([
        {
          key: MenuEvents.focus(),
          value: EventHandler.nu({
            // Set "active-menu" for the menu with focus
            run: function (sandbox, simulatedEvent) {
              var menu = simulatedEvent.event().menu();
              Highlighting.highlight(sandbox, menu);
            }
          })
        },
        {
          key: ItemEvents.hover(),
          value: EventHandler.nu({
            // Hide any irrelevant submenus and expand any submenus based
            // on hovered item
            run: function (sandbox, simulatedEvent) {
              var item = simulatedEvent.event().item();
              updateView(sandbox, item);
              expandRight(sandbox, item);
            }
          })
        },
        {
          key: SystemEvents.execute(),
          value: EventHandler.nu({
            run: function (sandbox, simulatedEvent) {
              // Trigger on execute on the targeted element
              // I.e. clicking on menu item
              var target = simulatedEvent.event().target();
              return sandbox.getSystem().getByDom(target).bind(function (item) {
                return expandRight(sandbox, item).orThunk(function () {
                  return uiSpec.onExecute()(sandbox, item);
                });
              });
            }
          })
        },
        {
          key: 'alloy.menus.done',
          value: EventHandler.nu({
            run: function (sandbox, simulatedEvent) {
              if (Sandboxing.isShowing(sandbox)) {
                Sandboxing.closeSandbox(sandbox);
              }
            }
          })
        }
      ]);

      var focusManager = {
        set: function (sandbox, element) {
          sandbox.getSystem().getByDom(element).fold(Fun.noop, function (item) {
            Highlighting.getHighlighted(sandbox).each(function (menu) {
              Highlighting.highlight(menu, item);
            });
          });
        },
        get: function (sandbox) {
          return Highlighting.getHighlighted(sandbox).bind(function (menu) {
            return Highlighting.getHighlighted(menu).map(function (item) {
              return item.element();
            });
          });
        }
      };

      return {
        sandboxing: {
          manager: Manager.contract({
            clear: clear,
            isPartOf: isPartOf,
            populate: populate,
            preview: preview,
            enter: enter
          }),
          onClose: uiSpec.onClose(),
          lazySink: uiSpec.lazySink()
        },
        keying: {
          mode: 'menu',
          selector: [ '.' + uiSpec.markers().selectedMenu(), '.' + uiSpec.markers().item() ].join(' '),
          onRight: onRight,
          onLeft: onLeft,
          onEscape: onEscape,
          moveOnTab: true,
          focusManager: uiSpec.fakeFocus() ? focusManager : undefined
        },
        // Highlighting is used for highlighting the active menu
        highlighting: {
          highlightClass: uiSpec.markers().selectedMenu(),
          itemClass: uiSpec.markers().menu()
        },
        events: events
      };
    };
  }
);<commit_msg>VAN-44-wheel-hackery-apis: close sandbox<commit_after>define(
  'ephox.alloy.menu.layered.LayeredConfig',

  [
    'ephox.alloy.alien.ComponentStructure',
    'ephox.alloy.alien.EditableFields',
    'ephox.alloy.api.SystemEvents',
    'ephox.alloy.api.behaviour.Highlighting',
    'ephox.alloy.api.behaviour.Keying',
    'ephox.alloy.api.behaviour.Positioning',
    'ephox.alloy.api.behaviour.Representing',
    'ephox.alloy.api.behaviour.Sandboxing',
    'ephox.alloy.construct.EventHandler',
    'ephox.alloy.menu.layered.LayeredState',
    'ephox.alloy.menu.logic.HotspotViews',
    'ephox.alloy.menu.util.ItemEvents',
    'ephox.alloy.menu.util.MenuEvents',
    'ephox.alloy.menu.util.MenuMarkers',
    'ephox.alloy.sandbox.Manager',
    'ephox.boulder.api.FieldPresence',
    'ephox.boulder.api.FieldSchema',
    'ephox.boulder.api.Objects',
    'ephox.boulder.api.ValueSchema',
    'ephox.compass.Arr',
    'ephox.compass.Obj',
    'ephox.highway.Merger',
    'ephox.peanut.Fun',
    'ephox.perhaps.Option',
    'ephox.perhaps.Options',
    'ephox.sugar.api.Body',
    'ephox.sugar.api.Class',
    'ephox.sugar.api.Classes',
    'ephox.sugar.api.Insert',
    'ephox.sugar.api.Remove',
    'ephox.sugar.api.SelectorFilter'
  ],

  function (ComponentStructure, EditableFields, SystemEvents, Highlighting, Keying, Positioning, Representing, Sandboxing, EventHandler, LayeredState, HotspotViews, ItemEvents, MenuEvents, MenuMarkers, Manager, FieldPresence, FieldSchema, Objects, ValueSchema, Arr, Obj, Merger, Fun, Option, Options, Body, Class, Classes, Insert, Remove, SelectorFilter) {
    var schema = ValueSchema.objOf([
      FieldSchema.strict('lazyAnchor'),

      FieldSchema.strict('onOpen'),
      FieldSchema.strict('onClose'),
      FieldSchema.strict('onExecute'),

      FieldSchema.strict('scaffold'),

      FieldSchema.defaulted('fakeFocus', false),

      FieldSchema.strict('lazySink'),

      FieldSchema.field(
        'markers',
        'markers',
        FieldPresence.strict(),
        MenuMarkers.schema()
      ),

      FieldSchema.strict('backgroundClass'),

      FieldSchema.field(
        'members',
        'members',
        FieldPresence.strict(),
        ValueSchema.objOf([
          FieldSchema.strict('menu'),
          FieldSchema.strict('item')
        ])
      ),

      FieldSchema.strict('onHighlight')
    ]);

    return function (rawUiSpec) {
      var uiSpec = ValueSchema.asStructOrDie('LayeredConfig', schema, rawUiSpec);

      var buildMenus = function (sandbox, menus) {
        return Obj.map(menus, function (spec, name) {
          // NOTE: We use rawUiSpec here so the nesting isn't a struct
          var data = Merger.deepMerge(
            uiSpec.members().menu().munge(spec),
            {
              uiType: 'menu',
              value: name,
              items: spec.items,
              markers: rawUiSpec.markers,
              members: {
                item: uiSpec.members().item()
              },
              fakeFocus: uiSpec.fakeFocus(),
              onHighlight: uiSpec.onHighlight()
            }
          );
          var menu = sandbox.getSystem().build(data);
          var container = sandbox.getSystem().build(
            uiSpec.scaffold()({ built: menu })
          );

          return {
            menu: menu,
            container: container
          };
        });
      };

      var getSink = function () {
        return uiSpec.lazySink()().getOrDie();
      };

      var toMenuValues = function (sandbox, sMenus) {
        return Obj.map(sMenus, function (menuTuple) {
          var menuItems = SelectorFilter.descendants(menuTuple.menu.element(), '.' + uiSpec.markers().item());
          return Arr.bind(menuItems, function (mi) {
            return sandbox.getSystem().getByDom(mi).map(function (item) {
              return Representing.getValue(item);
            }).fold(Fun.constant([ ]), Arr.pure);
          });
        });
      };

      var addToWorld = function (component, componentMap) {
        var menuCs = Arr.map(
          Obj.values(componentMap),
          function (tuple) {
            return tuple.container;
          }
        );
        Arr.each(menuCs, component.getSystem().addToWorld);
      };

      var showMenu = function (sandbox, tuple) {
        var sink = getSink();
        Positioning.position(sink, uiSpec.lazyAnchor()(), tuple.container);

        uiSpec.onOpen()(sandbox, tuple.menu);
      };

      var showSubmenu = function (sandbox, triggerItem, submenu) {
        var sink = getSink();
        Positioning.position(sink, {
          anchor: 'submenu',
          item: triggerItem,
          bubble: Option.none()
        }, submenu.container);
      };

      var setActiveMenu = function (sandbox, tuple) {
        var menu = tuple.menu;
        Highlighting.highlight(sandbox, menu);
        Highlighting.getHighlighted(menu).orThunk(function () {
          return Highlighting.getFirst(menu);
        }).each(function (item) {
          sandbox.getSystem().triggerEvent(SystemEvents.focusItem(), item.element(), { });
        });
      };

      var populate = function (sandbox, data) {
        var componentMap = buildMenus(sandbox, data.menus);
        addToWorld(sandbox, componentMap);

        var state = LayeredState();

        state.setContents(data.primary, componentMap, data.expansions, function (sMenus) {
          return toMenuValues(sandbox, sMenus);
        });
        state.getPrimary().each(function (primary) {
          if (! Body.inBody(primary.container.element())) {
            Insert.append(sandbox.element(), primary.container.element());
          }
        });
        return state;
      };

      var enter = function (sandbox, state) {
        state.getPrimary().each(function (primaryTuple) {
          setActiveMenu(sandbox, primaryTuple);
          showMenu(sandbox, primaryTuple);
          Keying.focusIn(sandbox);
        });
      };

      var preview = function (sandbox, state) {
        state.getPrimary().each(function (primary) {
          showMenu(sandbox, primary);
        });
      };

      var clear = function (sandbox, state) {
        var tuples = state.getMenus();
        Obj.each(tuples, function (tuple, menuName) {
          sandbox.getSystem().removeFromWorld(tuple.container);
        });
        state.clear();
      };

      var isPartOf = function (sandbox, state, queryElem) {
        var tuples = Obj.values(state.getMenus());
        return Arr.exists(tuples, function (tuple) {
          return ComponentStructure.isPartOf(tuple.container, queryElem);
        });
      };

      var getMenus = function (state, menuValues) {
        return Options.cat(
          Arr.map(menuValues, state.lookupMenu)
        );
      };

      var updateMenuPath = function (component, state, path) {
        return Option.from(path[0]).bind(state.lookupMenu).map(function (newMenuCompTuple) {
          var rest = getMenus(state, path.slice(1));
          Arr.each(rest, function (r) {
            Class.add(r.menu.element(), uiSpec.backgroundClass());
          });
          if (! Body.inBody(newMenuCompTuple.container.element())) {
            Insert.append(component.element(), newMenuCompTuple.container.element());
          }
          setActiveMenu(component, newMenuCompTuple);
          var others = getMenus(state, state.otherMenus(path));
          Arr.each(others, function (o) {
            // May not need to do the active menu thing.
            Classes.remove(o.menu.element(), [ uiSpec.backgroundClass() ]);
            Remove.remove(o.container.element());
          });

          return true;
        });
      };

      var expandRight = function (sandbox, item) {
        var value = Representing.getValue(item);
        return Sandboxing.getState(sandbox).bind(function (state) {
          return state.expand(value).bind(function (path) {
            // When expanding, always select the first.
            Option.from(path[0]).bind(state.lookupMenu).each(function (newMenuCompTuple) {
              Highlighting.highlightFirst(newMenuCompTuple.menu);

              // DUPE with above. Fix later.
              if (! Body.inBody(newMenuCompTuple.container.element())) {
                Insert.append(sandbox.element(), newMenuCompTuple.container.element());
                showSubmenu(sandbox, item, newMenuCompTuple);
              }
            });

            return updateMenuPath(sandbox, state, path);
          });
        });
      };

      var collapseLeft = function (sandbox, item) {
        var value = Representing.getValue(item);
        return Sandboxing.getState(sandbox).bind(function (state) {
          return state.collapse(value).bind(function (path) {
            return updateMenuPath(sandbox, state, path);
          });
        });
      };

      var updateView = function (sandbox, item) {
        var value = Representing.getValue(item);
        return Sandboxing.getState(sandbox).bind(function (state) {
          return state.refresh(value).bind(function (path) {
            return updateMenuPath(sandbox, state, path);
          });
        });
      };

      var onRight = function (sandbox, triggerItem) {
        return sandbox.getSystem().getByDom(triggerItem).bind(function (item) {
          return EditableFields.inside(triggerItem) ? Option.none() : expandRight(sandbox, item);
        });
      };

      var onLeft = function (sandbox, target) {
        return sandbox.getSystem().getByDom(target).bind(function (item) {
          // Exclude inputs, textareas etc.
          return EditableFields.inside(target) ? Option.none() : collapseLeft(sandbox, item);
        });
      };

      var onEscape = function (sandbox, target) {
        return sandbox.getSystem().getByDom(target).bind(function (item) {
          return collapseLeft(sandbox, item).orThunk(function () {
          // This should only fire when the user presses ESC ... not any other close.
            return HotspotViews.onEscape(uiSpec.lazyAnchor()(), sandbox);
          });
        });
      };

      var events = Objects.wrapAll([
        {
          key: MenuEvents.focus(),
          value: EventHandler.nu({
            // Set "active-menu" for the menu with focus
            run: function (sandbox, simulatedEvent) {
              var menu = simulatedEvent.event().menu();
              Highlighting.highlight(sandbox, menu);
            }
          })
        },
        {
          key: ItemEvents.hover(),
          value: EventHandler.nu({
            // Hide any irrelevant submenus and expand any submenus based
            // on hovered item
            run: function (sandbox, simulatedEvent) {
              var item = simulatedEvent.event().item();
              updateView(sandbox, item);
              expandRight(sandbox, item);
            }
          })
        },
        {
          key: SystemEvents.execute(),
          value: EventHandler.nu({
            run: function (sandbox, simulatedEvent) {
              // Trigger on execute on the targeted element
              // I.e. clicking on menu item
              var target = simulatedEvent.event().target();
              return sandbox.getSystem().getByDom(target).bind(function (item) {
                return expandRight(sandbox, item).orThunk(function () {
                  return uiSpec.onExecute()(sandbox, item);
                });
              });
            }
          })
        },
        {
          key: SystemEvents.sandboxClose(),
          value: EventHandler.nu({
            run: function (sandbox, simulatedEvent) {
              if (Sandboxing.isShowing(sandbox)) Sandboxing.closeSandbox(sandbox);
            }
          })
        }
      ]);

      var focusManager = {
        set: function (sandbox, element) {
          sandbox.getSystem().getByDom(element).fold(Fun.noop, function (item) {
            Highlighting.getHighlighted(sandbox).each(function (menu) {
              Highlighting.highlight(menu, item);
            });
          });
        },
        get: function (sandbox) {
          return Highlighting.getHighlighted(sandbox).bind(function (menu) {
            return Highlighting.getHighlighted(menu).map(function (item) {
              return item.element();
            });
          });
        }
      };

      return {
        sandboxing: {
          manager: Manager.contract({
            clear: clear,
            isPartOf: isPartOf,
            populate: populate,
            preview: preview,
            enter: enter
          }),
          onClose: uiSpec.onClose(),
          lazySink: uiSpec.lazySink()
        },
        keying: {
          mode: 'menu',
          selector: [ '.' + uiSpec.markers().selectedMenu(), '.' + uiSpec.markers().item() ].join(' '),
          onRight: onRight,
          onLeft: onLeft,
          onEscape: onEscape,
          moveOnTab: true,
          focusManager: uiSpec.fakeFocus() ? focusManager : undefined
        },
        // Highlighting is used for highlighting the active menu
        highlighting: {
          highlightClass: uiSpec.markers().selectedMenu(),
          itemClass: uiSpec.markers().menu()
        },
        events: events
      };
    };
  }
);<|endoftext|>


<commit_before>$(document).ready(function() {
	oTable = $('#reports_table').dataTable( {
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": $('#reports_table').data('ajax-url'),
    "aoColumnDefs": [
      { "bSearchable": false, "aTargets": [ 0 ] },
      { "sClass": "center", "aTargets": [ -1, -2 ] },
      { "fnRender": function ( oObj ) {
					return ''+oObj.aData[0]+'';
				},
				"aTargets": [ 0 ]
      },
    ],
    "aoColumns": [
      { "sWidth": "10%" },
      { "sWidth": "20%" },
      { "sWidth": "40%" },
      { "sWidth": "15%" },
      { "sWidth": "10%" },
    ],
    "fnServerData": function (sSource, aoData, fnCallback) {
      $.getJSON( sSource, aoData, function (json) {
          fnCallback(json);
      });
    },
	} );

  oTable.find("input").on('keyup', function(e) {
    // only search when enter is pressed
    if(e.keyCode == 13) {
      oTable.fnFilter($(this).val(), oTable.find("th").index($(this).parent()));
    }
  });

  oTable.find("select").on('change', function(e) {
    oTable.fnFilter($(this).val(), oTable.find("th").index($(this).parent()));
  });

  $('#toggle-stacktrace').click(function(e) {
    if($('#stacktrace').hasClass('shown')) {
      $('#toggle-stacktrace').html('Show stacktrace');

      $('#stacktrace').slideUp(function() {
        $(this).removeClass('shown');
      })
    } else {
      $('#toggle-stacktrace').html('Hide stacktrace');

      $('#stacktrace').slideDown(function() {
        $(this).addClass('shown');
      })
    }
    return false;
  });

  setTimeout(function(){$(".alert").slideUp()}, 2000)
} );
<commit_msg>Now errors donot fade out<commit_after>$(document).ready(function() {
	oTable = $('#reports_table').dataTable( {
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": $('#reports_table').data('ajax-url'),
    "aoColumnDefs": [
      { "bSearchable": false, "aTargets": [ 0 ] },
      { "sClass": "center", "aTargets": [ -1, -2 ] },
      { "fnRender": function ( oObj ) {
					return ''+oObj.aData[0]+'';
				},
				"aTargets": [ 0 ]
      },
    ],
    "aoColumns": [
      { "sWidth": "10%" },
      { "sWidth": "20%" },
      { "sWidth": "40%" },
      { "sWidth": "15%" },
      { "sWidth": "10%" },
    ],
    "fnServerData": function (sSource, aoData, fnCallback) {
      $.getJSON( sSource, aoData, function (json) {
          fnCallback(json);
      });
    },
	} );

  oTable.find("input").on('keyup', function(e) {
    // only search when enter is pressed
    if(e.keyCode == 13) {
      oTable.fnFilter($(this).val(), oTable.find("th").index($(this).parent()));
    }
  });

  oTable.find("select").on('change', function(e) {
    oTable.fnFilter($(this).val(), oTable.find("th").index($(this).parent()));
  });

  $('#toggle-stacktrace').click(function(e) {
    if($('#stacktrace').hasClass('shown')) {
      $('#toggle-stacktrace').html('Show stacktrace');

      $('#stacktrace').slideUp(function() {
        $(this).removeClass('shown');
      })
    } else {
      $('#toggle-stacktrace').html('Hide stacktrace');

      $('#stacktrace').slideDown(function() {
        $(this).addClass('shown');
      })
    }
    return false;
  });

  setTimeout(function(){$(".alert.alert-success").slideUp()}, 2000)
} );
<|endoftext|>


<commit_before>define([
    'require',
    'promise'
], function (
    require,
    Promise
) {
    'use strict';

    function factory(config) {
        var runtime = config.runtime;
        var components = {};

        function start() {
            return true;
        }

        function stop() {
            return true;
        }

        function pluginHandler(serviceConfig, pluginConfig) {
            return Promise.try(function () {

                return Promise.all(serviceConfig.map(function (componentConfig) {
                    // keep a map of loaded components
                    if (components[componentConfig.name]) {
                        throw new Error('Component already loaded "' + componentConfig.name);
                    }

                    // simply require the module to register the component, or components.
                    // oops, that would break the model...

                    return new Promise(function (resolve, reject) {
                        var modulePaths = [];
                        modulePaths.push([pluginConfig.moduleRoot, componentConfig.module].join('/'));
                        if (componentConfig.css) {
                            modulePaths.push('css!' + [pluginConfig.moduleRoot, componentConfig.module].join('/'));
                        }
                        require(modulePaths, function (result) {
                            resolve(result);
                        }, function (err) {
                            reject(err);
                        });
                    });
                }));
            });
        }
        return {
            // lifecycle interface
            start: start,
            stop: stop,
            // plugin interface
            pluginHandler: pluginHandler
        };
    }
    return {
        make: function (config) {
            return factory(config);
        }
    };
});
<commit_msg>refacator knockout component registration - centralizes registration at plugin load time - simplifies component modules - should improve reliability (e.g. duplicate registrations will be caught at initial app startup during plugin load)<commit_after>define([
    'require',
    'promise',
    'knockout'
], function (
    require,
    Promise,
    ko
) {
    'use strict';

    function factory(config) {
        var runtime = config.runtime;
        var components = {};

        function start() {
            return true;
        }

        function stop() {
            return true;
        }

        function pluginHandler(serviceConfig, pluginConfig) {
            return Promise.try(function () {

                return Promise.all(serviceConfig.map(function (componentConfig) {
                    // keep a map of loaded components
                    if (components[componentConfig.name]) {
                        throw new Error('Component already loaded "' + componentConfig.name);
                    }

                    // simply require the module to register the component, or components.
                    // oops, that would break the model...

                    return new Promise(function (resolve, reject) {
                        var modulePaths = [];
                        modulePaths.push([pluginConfig.moduleRoot, componentConfig.module].join('/'));
                        if (componentConfig.css) {
                            modulePaths.push('css!' + [pluginConfig.moduleRoot, componentConfig.module].join('/'));
                        }
                        require(modulePaths, function (result) {
                            // The result is a component factory which takes no arguments.
                            // console.log('registering', componentConfig, result);
                            try {
                                ko.components.register(componentConfig.name, result());
                                resolve(result);
                            } catch (ex) {
                                reject(ex);
                            }
                        }, function (err) {
                            reject(err);
                        });
                    });
                }));
            });
        }
        return {
            // lifecycle interface
            start: start,
            stop: stop,
            // plugin interface
            pluginHandler: pluginHandler
        };
    }
    return {
        make: function (config) {
            return factory(config);
        }
    };
});
<|endoftext|>


<commit_before>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Basic animation controls.
 *
 */
goog.provide('goog.fx.anim');
goog.provide('goog.fx.anim.Animated');

goog.require('goog.Timer');
goog.require('goog.events');
goog.require('goog.object');

/**
 * An interface for programatically animated objects. I.e. rendered in
 * javascript frame by frame.
 *
 * @interface
 */
goog.fx.anim.Animated = function() {};

/**
 * Function called when a frame is requested for the animation.
 *
 * @param {number} now Current time in milliseconds.
 */
goog.fx.anim.Animated.prototype.onAnimationFrame;

/**
 * Default wait timeout for animations (in milliseconds).  Only used for timed
 * animation, which uses a timer (setTimeout) to schedule animation.
 *
 * @type {number}
 * @const
 */
goog.fx.anim.TIMEOUT = 20;

/**
 * Name of event received from the requestAnimationFrame in Firefox.
 *
 * @type {string}
 * @const
 * @private
 */
goog.fx.anim.MOZ_BEFORE_PAINT_EVENT_ = 'MozBeforePaint';

/**
 * A map of animations which should be cycled on the global timer.
 *
 * @type {Object.<number, goog.fx.anim.Animated>}
 * @private
 */
goog.fx.anim.activeAnimations_ = {};

/**
 * An optional animation window.
 * @type {Window}
 * @private
 */
goog.fx.anim.animationWindow_ = null;

/**
 * A timing control function.
 * @type {?function(?function(number))}
 * @private
 */
goog.fx.anim.requestAnimationFrameFn_ = null;

/**
 * Cancel function for timing control.
 * @type {?function(number)}
 * @private
 */
goog.fx.anim.cancelRequestAnimationFrameFn_ = null;

/**
 * An interval ID for the global timer or event handler uid.
 * @type {?number}
 * @private
 */
goog.fx.anim.animationTimer_ = null;

/**
 * Registers an animation to be cycled on the global timer.
 * @param {goog.fx.anim.Animated} animation The animation to register.
 */
goog.fx.anim.registerAnimation = function(animation) {
  var uid = goog.getUid(animation);
  if (!(uid in goog.fx.anim.activeAnimations_)) {
    goog.fx.anim.activeAnimations_[uid] = animation;
  }

  // If the timer is not already started, start it now.
  goog.fx.anim.requestAnimationTimer_();
};

/**
 * Removes an animation from the list of animations which are cycled on the
 * global timer.
 * @param {goog.fx.anim.Animated} animation The animation to unregister.
 */
goog.fx.anim.unregisterAnimation = function(animation) {
  var uid = goog.getUid(animation);
  delete goog.fx.anim.activeAnimations_[uid];

  // If a timer is running and we no longer have any active timers we stop the
  // timers.
  if (goog.object.isEmpty(goog.fx.anim.activeAnimations_)) {
    goog.fx.anim.cancelAnimationTimer_();
  }
};

/**
 * Registers an animation window. This allows usage of the timing control API
 * for animations. Note that this window must be visible, as non-visible
 * windows can potentially stop animating. This window does not necessarily
 * need to be the window inside which animation occurs, but must remain visible.
 * See: https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame.
 *
 * @param {Window} animationWindow The window in which to animate elements.
 */
goog.fx.anim.setAnimationWindow = function(animationWindow) {
  goog.fx.anim.animationWindow_ = animationWindow;

  var hasTimer = !!goog.fx.anim.animationTimer_;
  // If a timer is currently running, reset it and restart with new functions
  // after a timeout. This is to avoid mismatching timer UIDs if we change the
  // animation window during a running animation.
  //
  // In practice this cannot happen before some animation window and timer
  // control functions has already been set.
  if (hasTimer) {
    goog.fx.anim.cancelAnimationTimer_();
  }

  if (!animationWindow) {
    goog.fx.anim.requestAnimationFrameFn_ = null;
    goog.fx.anim.cancelRequestAnimationFrameFn_ = null;
  } else {
    goog.fx.anim.requestAnimationFrameFn_ =
        animationWindow['requestAnimationFrame'] ||
        animationWindow['webkitRequestAnimationFrame'] ||
        animationWindow['mozRequestAnimationFrame'] ||
        animationWindow['oRequestAnimationFrame'] ||
        animationWindow['msRequestAnimationFrame'] ||
        null;

    goog.fx.anim.cancelRequestAnimationFrameFn_ =
        animationWindow['cancelRequestAnimationFrame'] ||
        animationWindow['webkitCancelRequestAnimationFrame'] ||
        animationWindow['mozCancelRequestAnimationFrame'] ||
        animationWindow['oCancelRequestAnimationFrame'] ||
        animationWindow['msCancelRequestAnimationFrame'] ||
        null;
  }

  // Set up matching render timing functions, the requestAnimationTimer_ and
  // cancelAnimationTimer_ functions.
  if (goog.fx.anim.requestAnimationFrameFn_ &&
      animationWindow['mozRequestAnimationFrame'] &&
      !goog.fx.anim.cancelRequestAnimationFrameFn_) {
    // Because Firefox (Gecko) runs animation in separate threads, it also saves
    // time by running the requestAnimationFrame callbacks in that same thread.
    // Sadly this breaks the assumption of implicit thread-safety in JS, and can
    // thus create thread-based inconsistencies on counters etc.
    //
    // Calling cycleAnimations_ using the MozBeforePaint event instead of as
    // callback fixes this.
    //
    // Trigger this condition only if the mozRequestAnimationFrame is available,
    // but not the W3C requestAnimationFrame function (as in draft) or the
    // equivalent cancel functions.
    goog.fx.anim.requestAnimationTimer_ =
        goog.fx.anim.requestMozAnimationFrame_;
    goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelMozAnimationFrame_;
  } else if (goog.fx.anim.requestAnimationFrameFn_ &&
             goog.fx.anim.cancelRequestAnimationFrameFn_) {
    goog.fx.anim.requestAnimationTimer_ = goog.fx.anim.requestAnimationFrame_;
    goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelAnimationFrame_;
  } else {
    goog.fx.anim.requestAnimationTimer_ = goog.fx.anim.requestTimer_;
    goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelTimer_;
  }

  // If the timer was running, start it again.
  if (hasTimer) {
    goog.fx.anim.requestAnimationTimer_();
  }
};

/**
 * Requests a scheduled timer call.
 * @private
 */
goog.fx.anim.requestTimer_ = function() {
  if (!goog.fx.anim.animationTimer_) {
    goog.fx.anim.animationTimer_ = goog.Timer.callOnce(function() {
      goog.fx.anim.animationTimer_ = null;
      // Cycle all animations at 'the same time'.
      goog.fx.anim.cycleAnimations_(goog.now());
    }, goog.fx.anim.TIMEOUT);
  }
};

/**
 * Cancels a timer created by requestTimer_().
 * @private
 */
goog.fx.anim.cancelTimer_ = function() {
  if (goog.fx.anim.animationTimer_) {
    goog.Timer.clear(goog.fx.anim.animationTimer_);
    goog.fx.anim.animationTimer_ = null;
  }
};

/**
 * Requests an animation frame based on the requestAnimationFrame and
 * cancelRequestAnimationFrame function pair.
 * @private
 */
goog.fx.anim.requestAnimationFrame_ = function() {
  if (!goog.fx.anim.animationTimer_) {
    // requestAnimationFrame will call cycleAnimations_ with the current
    // time in ms, as returned from goog.now().
    goog.fx.anim.animationTimer_ =
        goog.fx.anim.requestAnimationFrameFn_.call(
            goog.fx.anim.animationWindow_, function(now) {
              goog.fx.anim.animationTimer_ = null;
              goog.fx.anim.cycleAnimations_(now);
            });
  }
};

/**
 * Cancels an animation frame created by requestAnimationFrame_().
 * @private
 */
goog.fx.anim.cancelAnimationFrame_ = function() {
  if (goog.fx.anim.animationTimer_) {
    goog.fx.anim.cancelRequestAnimationFrameFn_.call(
        goog.fx.anim.animationWindow_,
        goog.fx.anim.animationTimer_);
    goog.fx.anim.animationTimer_ = null;
  }
};

/**
 * Requests an animation frame based on the requestAnimationFrame and
 * cancelRequestAnimationFrame function pair.
 * @private
 */
goog.fx.anim.requestMozAnimationFrame_ = function() {
  if (!goog.fx.anim.animationTimer_) {
    goog.fx.anim.animationTimer_ = goog.events.listen(
        goog.fx.anim.animationWindow_, goog.fx.anim.MOZ_BEFORE_PAINT_EVENT_,
        function(event) {
          goog.fx.anim.cycleAnimations_(event['timeStamp'] || goog.now());
        }, false);
  }
  goog.fx.anim.requestAnimationFrameFn_.call(
      goog.fx.anim.animationWindow_, null);
};

/**
 * Cancels an animation frame created by requestAnimationFrame_().
 * @private
 */
goog.fx.anim.cancelMozAnimationFrame_ = function() {
  if (goog.fx.anim.animationTimer_) {
    goog.events.unlistenByKey(goog.fx.anim.animationTimer_);
    goog.fx.anim.animationTimer_ = null;
  }
};

/**
 * Starts the animation timer.  This is the currently active function selected
 * based on the animation window.
 * @private
 */
goog.fx.anim.requestAnimationTimer_ = goog.fx.anim.requestTimer_;

/**
 * Cancels the animation timer.  This is the currently active function selected
 * based on the animation window.
 * @private
 */
goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelTimer_;

/**
 * Cycles through all registered animations.
 * @param {number} now Current time in milliseconds.
 * @private
 */
goog.fx.anim.cycleAnimations_ = function(now) {
  goog.object.forEach(goog.fx.anim.activeAnimations_, function(anim) {
    anim.onAnimationFrame(now);
  });

  if (!goog.object.isEmpty(goog.fx.anim.activeAnimations_)) {
    goog.fx.anim.requestAnimationTimer_();
  }
};
<commit_msg><commit_after>// Copyright 2006 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Basic animation controls.
 *
 */
goog.provide('goog.fx.anim');
goog.provide('goog.fx.anim.Animated');

goog.require('goog.Timer');
goog.require('goog.events');
goog.require('goog.object');

/**
 * An interface for programatically animated objects. I.e. rendered in
 * javascript frame by frame.
 *
 * @interface
 */
goog.fx.anim.Animated = function() {};

/**
 * Function called when a frame is requested for the animation.
 *
 * @param {number} now Current time in milliseconds.
 */
goog.fx.anim.Animated.prototype.onAnimationFrame;

/**
 * Default wait timeout for animations (in milliseconds).  Only used for timed
 * animation, which uses a timer (setTimeout) to schedule animation.
 *
 * @type {number}
 * @const
 */
goog.fx.anim.TIMEOUT = 20;

/**
 * Name of event received from the requestAnimationFrame in Firefox.
 *
 * @type {string}
 * @const
 * @private
 */
goog.fx.anim.MOZ_BEFORE_PAINT_EVENT_ = 'MozBeforePaint';

/**
 * A map of animations which should be cycled on the global timer.
 *
 * @type {Object.<number, goog.fx.anim.Animated>}
 * @private
 */
goog.fx.anim.activeAnimations_ = {};

/**
 * An optional animation window.
 * @type {Window}
 * @private
 */
goog.fx.anim.animationWindow_ = null;

/**
 * A timing control function.
 * @type {?function(?function(number))}
 * @private
 */
goog.fx.anim.requestAnimationFrameFn_ = null;

/**
 * Cancel function for timing control.
 * @type {?function(number)}
 * @private
 */
goog.fx.anim.cancelAnimationFrameFn_ = null;

/**
 * An interval ID for the global timer or event handler uid.
 * @type {?number}
 * @private
 */
goog.fx.anim.animationTimer_ = null;

/**
 * Registers an animation to be cycled on the global timer.
 * @param {goog.fx.anim.Animated} animation The animation to register.
 */
goog.fx.anim.registerAnimation = function(animation) {
  var uid = goog.getUid(animation);
  if (!(uid in goog.fx.anim.activeAnimations_)) {
    goog.fx.anim.activeAnimations_[uid] = animation;
  }

  // If the timer is not already started, start it now.
  goog.fx.anim.requestAnimationTimer_();
};

/**
 * Removes an animation from the list of animations which are cycled on the
 * global timer.
 * @param {goog.fx.anim.Animated} animation The animation to unregister.
 */
goog.fx.anim.unregisterAnimation = function(animation) {
  var uid = goog.getUid(animation);
  delete goog.fx.anim.activeAnimations_[uid];

  // If a timer is running and we no longer have any active timers we stop the
  // timers.
  if (goog.object.isEmpty(goog.fx.anim.activeAnimations_)) {
    goog.fx.anim.cancelAnimationTimer_();
  }
};

/**
 * Registers an animation window. This allows usage of the timing control API
 * for animations. Note that this window must be visible, as non-visible
 * windows can potentially stop animating. This window does not necessarily
 * need to be the window inside which animation occurs, but must remain visible.
 *
 * See: https://developer.mozilla.org/en/DOM/window.mozRequestAnimationFrame.
 * See: http://w3c-test.org/webperf/specs/RequestAnimationFrame/
 *
 * @param {Window} animationWindow The window in which to animate elements.
 */
goog.fx.anim.setAnimationWindow = function(animationWindow) {
  goog.fx.anim.animationWindow_ = animationWindow;

  var hasTimer = !!goog.fx.anim.animationTimer_;
  // If a timer is currently running, reset it and restart with new functions
  // after a timeout. This is to avoid mismatching timer UIDs if we change the
  // animation window during a running animation.
  //
  // In practice this cannot happen before some animation window and timer
  // control functions has already been set.
  if (hasTimer) {
    goog.fx.anim.cancelAnimationTimer_();
  }

  if (!animationWindow) {
    goog.fx.anim.requestAnimationFrameFn_ = null;
    goog.fx.anim.cancelAnimationFrameFn_ = null;
  } else {
    goog.fx.anim.requestAnimationFrameFn_ =
        animationWindow['requestAnimationFrame'] ||  // Default name
        animationWindow['webkitRequestAnimationFrame'] ||  // Chrome 10
        animationWindow['mozRequestAnimationFrame'] ||  // Firefox 4
        animationWindow['oRequestAnimationFrame'] ||
        animationWindow['msRequestAnimationFrame'] ||  // IE10 PP2
        null;

    // NOTE: Browser specific updates may be needed here as the proposed name
    // for cancelAnimationFrame was renamed from cancelRequestAnimationFrame as
    // of draft of December 8 2011.
    goog.fx.anim.cancelAnimationFrameFn_ =
        animationWindow['cancelAnimationFrame'] ||  // Default name
        animationWindow['cancelRequestAnimationFrame'] ||  // Old default name
        animationWindow['webkitCancelRequestAnimationFrame'] ||  // Chrome 10
        // Firefox prior to v11 does not support cancelAnimationFrame calls,
        // only requestAnimationFrame with either a callback or triggering a
        // MozBeforePaint event.
        animationWindow['mozCancelAnimationFrame'] ||  // Firefox 11
        animationWindow['oCancelAnimationFrame'] ||
        animationWindow['msCancelRequestAnimationFrame'] ||  // IE10 PP2
        null;
  }

  // Set up matching render timing functions, the requestAnimationTimer_ and
  // cancelAnimationTimer_ functions.
  if (goog.fx.anim.requestAnimationFrameFn_ &&
      animationWindow['mozRequestAnimationFrame'] &&
      !goog.fx.anim.cancelAnimationFrameFn_) {
    // Because Firefox (Gecko) runs animation in separate threads, it also saves
    // time by running the requestAnimationFrame callbacks in that same thread.
    // Sadly this breaks the assumption of implicit thread-safety in JS, and can
    // thus create thread-based inconsistencies on counters etc.
    //
    // Calling cycleAnimations_ using the MozBeforePaint event instead of as
    // callback fixes this.
    //
    // Trigger this condition only if the mozRequestAnimationFrame is available,
    // but not the W3C requestAnimationFrame function (as in draft) or the
    // equivalent cancel functions.
    goog.fx.anim.requestAnimationTimer_ =
        goog.fx.anim.requestMozAnimationFrame_;
    goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelMozAnimationFrame_;
  } else if (goog.fx.anim.requestAnimationFrameFn_ &&
             goog.fx.anim.cancelAnimationFrameFn_) {
    goog.fx.anim.requestAnimationTimer_ = goog.fx.anim.requestAnimationFrame_;
    goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelAnimationFrame_;
  } else {
    goog.fx.anim.requestAnimationTimer_ = goog.fx.anim.requestTimer_;
    goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelTimer_;
  }

  // If the timer was running, start it again.
  if (hasTimer) {
    goog.fx.anim.requestAnimationTimer_();
  }
};

/**
 * Requests a scheduled timer call.
 * @private
 */
goog.fx.anim.requestTimer_ = function() {
  if (!goog.fx.anim.animationTimer_) {
    goog.fx.anim.animationTimer_ = goog.Timer.callOnce(function() {
      goog.fx.anim.animationTimer_ = null;
      // Cycle all animations at 'the same time'.
      goog.fx.anim.cycleAnimations_(goog.now());
    }, goog.fx.anim.TIMEOUT);
  }
};

/**
 * Cancels a timer created by requestTimer_().
 * @private
 */
goog.fx.anim.cancelTimer_ = function() {
  if (goog.fx.anim.animationTimer_) {
    goog.Timer.clear(goog.fx.anim.animationTimer_);
    goog.fx.anim.animationTimer_ = null;
  }
};

/**
 * Requests an animation frame based on the requestAnimationFrame and
 * cancelAnimationFrame function pair.
 * @private
 */
goog.fx.anim.requestAnimationFrame_ = function() {
  if (!goog.fx.anim.animationTimer_) {
    // requestAnimationFrame will call cycleAnimations_ with the current
    // time in ms, as returned from goog.now().
    goog.fx.anim.animationTimer_ =
        goog.fx.anim.requestAnimationFrameFn_.call(
            goog.fx.anim.animationWindow_, function(now) {
              goog.fx.anim.animationTimer_ = null;
              goog.fx.anim.cycleAnimations_(now);
            });
  }
};

/**
 * Cancels an animation frame created by requestAnimationFrame_().
 * @private
 */
goog.fx.anim.cancelAnimationFrame_ = function() {
  if (goog.fx.anim.animationTimer_) {
    goog.fx.anim.cancelAnimationFrameFn_.call(
        goog.fx.anim.animationWindow_,
        goog.fx.anim.animationTimer_);
    goog.fx.anim.animationTimer_ = null;
  }
};

/**
 * Requests an animation frame based on the requestAnimationFrame and
 * cancelAnimationFrame function pair.
 * @private
 */
goog.fx.anim.requestMozAnimationFrame_ = function() {
  if (!goog.fx.anim.animationTimer_) {
    goog.fx.anim.animationTimer_ = goog.events.listen(
        goog.fx.anim.animationWindow_, goog.fx.anim.MOZ_BEFORE_PAINT_EVENT_,
        function(event) {
          goog.fx.anim.cycleAnimations_(event['timeStamp'] || goog.now());
        }, false);
  }
  goog.fx.anim.requestAnimationFrameFn_.call(
      goog.fx.anim.animationWindow_, null);
};

/**
 * Cancels an animation frame created by requestAnimationFrame_().
 * @private
 */
goog.fx.anim.cancelMozAnimationFrame_ = function() {
  if (goog.fx.anim.animationTimer_) {
    goog.events.unlistenByKey(goog.fx.anim.animationTimer_);
    goog.fx.anim.animationTimer_ = null;
  }
};

/**
 * Starts the animation timer.  This is the currently active function selected
 * based on the animation window.
 * @private
 */
goog.fx.anim.requestAnimationTimer_ = goog.fx.anim.requestTimer_;

/**
 * Cancels the animation timer.  This is the currently active function selected
 * based on the animation window.
 * @private
 */
goog.fx.anim.cancelAnimationTimer_ = goog.fx.anim.cancelTimer_;

/**
 * Cycles through all registered animations.
 * @param {number} now Current time in milliseconds.
 * @private
 */
goog.fx.anim.cycleAnimations_ = function(now) {
  goog.object.forEach(goog.fx.anim.activeAnimations_, function(anim) {
    anim.onAnimationFrame(now);
  });

  if (!goog.object.isEmpty(goog.fx.anim.activeAnimations_)) {
    goog.fx.anim.requestAnimationTimer_();
  }
};
<|endoftext|>


<commit_before>const blessed = require('blessed');

const {GameConstants} = require('@anyware/game-logic');

export default class PanelView extends blessed.Box {
  constructor(store, windowOptions) {
    super(Object.assign({
      tags: true,
      border: {
        type: 'line'
      },
      style: {
        fg: 'white',
        bg: 'gray'
      }
    }, windowOptions));

    this.store = store;
    this.renderPanels();

    this.store.on(GameConstants.EVENT_CHANGE, this.renderPanels.bind(this));
  }

  renderPanels() {
    const lightArray = this.store.data.get('lights');
    const output = [for (stripId of lightArray) this.formatStrip(lightArray.get(stripId))];
    this.setContent(output.join('\n'));
  }

  formatStrip(strip) {
    const formattedPanels = [];
    for (let panelId of strip.panelIds) {
      const panel = strip.get(panelId);
      const formattedPanel = this.formatPanel(panel);
      formattedPanels.push(formattedPanel);
    }

    return formattedPanels.join(' ');
  }

  formatPanel(panel) {
    return `${panel.get('intensity')}`;
  }
}
<commit_msg>Made panel formatting work<commit_after>const blessed = require('blessed');

const {GameConstants} = require('@anyware/game-logic');

export default class PanelView extends blessed.Box {
  constructor(store, windowOptions) {
    super(Object.assign({
      tags: true,
      border: {
        type: 'line'
      },
      style: {
        fg: 'white',
        bg: 'gray'
      }
    }, windowOptions));

    this.store = store;
    this.renderPanels();

    this.store.on(GameConstants.EVENT_CHANGE, this.renderPanels.bind(this));
  }

  renderPanels() {
    const lightArray = this.store.data.get('lights');
    const formattedStrips = Array.from(this.formatStrips(lightArray));
    this.setContent(formattedStrips.join('\n'));
  }

  *formatStrips(lightArray) {
    for (let stripId of lightArray.stripIds) {
      const formattedPanels = Array.from(this.formatStripPanels(lightArray, stripId));
      yield `${stripId}: ${formattedPanels.join(' ')}`;
    }
  }

  *formatStripPanels(lightArray, stripId) {
    const strip = lightArray.get(stripId);
    for (let panelId of strip.panelIds) {
      yield this.formatPanel(lightArray, stripId, panelId);
    }
  }

  formatPanel(lightArray, stripId, panelId) {
    const panelIntensity = lightArray.getIntensity(stripId, panelId);

    const cellWidth = 3;
    // pad cell to cellWidth and right align in cell
    let formattedPanel = ((' '.repeat(cellWidth)) + panelIntensity).slice(-cellWidth);

    if (panelIntensity > 50) {
      formattedPanel = `{bold}${formattedPanel}{/bold}`;
    }

    const panelColor = this._colorFromKeyword(lightArray.getColor(stripId, panelId));
    if (panelColor) {
      formattedPanel = `{${panelColor}-fg}${formattedPanel}{/${panelColor}-fg}`;
    }

    const panelActive = lightArray.isActive(stripId, panelId);
    if (panelActive) {
      formattedPanel = `{white-bg}${formattedPanel}{/white-bg}`;
    }

    return formattedPanel;
  }

  _colorFromKeyword(keyword) {
    switch (keyword) {
      case "success":
        return "green";
      case "error":
        return "red";
      default:
        return;
    }
  }
}
<|endoftext|>


<commit_before>const { Subject } = require('rxjs')
const corrie = require('corrie')
const wildcardMatch = require('wildcard-match')
const HookStore = require('./HookStore')
const { tootHandler } = require('./effects')

const MODES = ['auto', 'asIs', 'sync', 'async']
const SETTINGS = corrie.DEFAULT_SETTINGS
const EFFECTS = {
  toot: tootHandler,
}

class Hooter extends Subject {
  constructor(settings) {
    super()

    let effectHandlers = Object.assign({}, SETTINGS.effectHandlers, EFFECTS)
    let state = { hooter: this }

    if (settings) {
      state = settings.state ? Object.assign(state, settings.state) : state
      effectHandlers = settings.effectHandlers
        ? Object.assign(effectHandlers, settings.effectHandlers)
        : state
    }

    settings = Object.assign({}, SETTINGS, settings, { effectHandlers, state })
    this.corrie = corrie(settings)
    this.hookStoreBefore = new HookStore(this.match)
    this.hookStore = new HookStore(this.match)
    this.hookStoreAfter = new HookStore(this.match, true)
    this.events = {}
  }

  match(a, b) {
    return wildcardMatch('.', a, b)
  }

  lift(operator) {
    // Rxjs subjects return an AnonymousSubject on lifting,
    // but we want to return an instance of Hooter

    let instance = new this.constructor()

    if (operator) {
      instance.operator = operator
    }

    instance.source = this
    return instance
  }

  _subscribe(subscriber) {
    if (this.source) {
      return this.source.subscribe(subscriber)
    }

    return super._subscribe(subscriber)
  }

  error(err) {
    if (this.source && this.source.error) {
      return this.source.error(err)
    }

    super.error(err)
  }

  complete() {
    if (this.source && this.source.complete) {
      return this.source.complete()
    }

    super.complete()
  }

  _hook(eventType, hook, hookStore) {
    if (arguments.length === 1) {
      hook = eventType
      eventType = '**'
    } else if (typeof eventType !== 'string') {
      throw new TypeError('An event type must be a string')
    }

    if (typeof hook !== 'function') {
      throw new TypeError('A hook must be a function')
    }

    return hookStore.put(eventType, hook)
  }

  hook(eventType, hook) {
    if (this.source && this.source.hook) {
      return this.source.hook(eventType, hook)
    }

    return this._hook(eventType, hook, this.hookStore)
  }

  hookStart(eventType, hook) {
    if (this.source && this.source.hookStart) {
      return this.source.hookStart(eventType, hook)
    }

    return this._hook(eventType, hook, this.hookStoreBefore)
  }

  hookEnd(eventType, hook) {
    if (this.source && this.source.hookEnd) {
      return this.source.hookEnd(eventType, hook)
    }

    return this._hook(eventType, hook, this.hookStoreAfter)
  }

  unhook(needle) {
    this.hookStoreBefore.del(needle)
    this.hookStore.del(needle)
    this.hookStoreAfter.del(needle)
  }

  next(event) {
    if (!event || typeof event !== 'object') {
      throw new TypeError('An event must be an object')
    }

    if (typeof event.type !== 'string') {
      throw new TypeError('An event type must be a string')
    }

    if (!['auto', 'asIs', 'sync', 'async'].includes(event.mode)) {
      throw new Error(
        'An event mode must be either "auto", asIs", "sync" or "async"'
      )
    }

    if (event.cb && typeof event.cb !== 'function') {
      throw new TypeError('An event callback must be a function')
    }

    if (this._prefix) {
      event = Object.assign({}, event)
      event.type = `${this._prefix}.${event.type}`
    }

    if (this.source && this.source.next) {
      return this.source.next(event)
    }

    super.next(event)

    let beforeHooks = this.hookStoreBefore.get(event.type)
    let hooks = this.hookStore.get(event.type)
    let afterHooks = this.hookStoreAfter.get(event.type)
    let handlers = beforeHooks
      .concat(hooks)
      .concat(afterHooks)
      .map((hook) => hook.fn)

    if (event.cb) {
      handlers.push(event.cb)
    }

    if (handlers.length === 0) {
      return
    } else if (event.mode === 'auto') {
      return this.corrie(...handlers).apply(event, event.args)
    } else {
      return this.corrie[event.mode](...handlers).apply(event, event.args)
    }
  }

  _toot(eventType, args, cb) {
    let registeredEvent = this.events[eventType]
    let mode = registeredEvent ? registeredEvent.mode : 'auto'
    let event = createEvent(eventType, mode, args, cb)
    return this.next(event)
  }

  toot(eventType, ...args) {
    return this._toot(eventType, args)
  }

  tootWith(eventType, cb, ...args) {
    return this._toot(eventType, args, cb)
  }

  register(eventType, mode) {
    if (this.source && this.source.register) {
      return this.source.register(eventType, mode)
    }

    if (typeof eventType !== 'string' || !eventType.length) {
      throw new Error('An event type must be a non-empty string')
    }

    if (this.events[eventType]) {
      throw new Error(`Event "${eventType}" is already registered`)
    }

    if (!MODES.includes(mode)) {
      throw new Error('A mode must be one of the following:', MODES.join(', '))
    }

    this.events[eventType] = { mode }
  }

  prefix(prefix) {
    if (typeof prefix !== 'string') {
      throw new TypeError('A prefix must be a string')
    }

    let instance = this.lift()
    instance._prefix = prefix
    return instance
  }

  filter(predicate) {
    if (typeof predicate === 'string') {
      let eventType = predicate
      predicate = (e) => this.match(e.type, eventType)
    }

    return super.filter(predicate)
  }
}

function createEvent(source, type, mode, args, cb) {
  args = args || []
  let event = { type, mode, args, source }

  if (cb) {
    event.cb = cb
  }

  return event
}

module.exports = Hooter
<commit_msg>Add bind() for creating a clone of a hooter bound to an event source<commit_after>const { Subject } = require('rxjs')
const corrie = require('corrie')
const wildcardMatch = require('wildcard-match')
const HookStore = require('./HookStore')
const { tootHandler } = require('./effects')

const MODES = ['auto', 'asIs', 'sync', 'async']
const SETTINGS = corrie.DEFAULT_SETTINGS
const EFFECTS = {
  toot: tootHandler,
}

class Hooter extends Subject {
  constructor(settings) {
    super()

    let effectHandlers = Object.assign({}, SETTINGS.effectHandlers, EFFECTS)
    let state = { hooter: this }

    if (settings) {
      state = settings.state ? Object.assign(state, settings.state) : state
      effectHandlers = settings.effectHandlers
        ? Object.assign(effectHandlers, settings.effectHandlers)
        : state
    }

    settings = Object.assign({}, SETTINGS, settings, { effectHandlers, state })
    this.corrie = corrie(settings)
    this.hookStoreBefore = new HookStore(this.match)
    this.hookStore = new HookStore(this.match)
    this.hookStoreAfter = new HookStore(this.match, true)
    this.events = {}
  }

  match(a, b) {
    return wildcardMatch('.', a, b)
  }

  lift(operator) {
    // Rxjs subjects return an AnonymousSubject on lifting,
    // but we want to return an instance of Hooter

    let instance = new this.constructor()

    if (operator) {
      instance.operator = operator
    }

    instance.source = this
    return instance
  }

  _subscribe(subscriber) {
    if (this.source) {
      return this.source.subscribe(subscriber)
    }

    return super._subscribe(subscriber)
  }

  error(err) {
    if (this.source && this.source.error) {
      return this.source.error(err)
    }

    super.error(err)
  }

  complete() {
    if (this.source && this.source.complete) {
      return this.source.complete()
    }

    super.complete()
  }

  _hook(eventType, hook, hookStore) {
    if (arguments.length === 1) {
      hook = eventType
      eventType = '**'
    } else if (typeof eventType !== 'string') {
      throw new TypeError('An event type must be a string')
    }

    if (typeof hook !== 'function') {
      throw new TypeError('A hook must be a function')
    }

    return hookStore.put(eventType, hook)
  }

  hook(eventType, hook) {
    if (this.source && this.source.hook) {
      return this.source.hook(eventType, hook)
    }

    return this._hook(eventType, hook, this.hookStore)
  }

  hookStart(eventType, hook) {
    if (this.source && this.source.hookStart) {
      return this.source.hookStart(eventType, hook)
    }

    return this._hook(eventType, hook, this.hookStoreBefore)
  }

  hookEnd(eventType, hook) {
    if (this.source && this.source.hookEnd) {
      return this.source.hookEnd(eventType, hook)
    }

    return this._hook(eventType, hook, this.hookStoreAfter)
  }

  unhook(needle) {
    this.hookStoreBefore.del(needle)
    this.hookStore.del(needle)
    this.hookStoreAfter.del(needle)
  }

  next(event) {
    if (!event || typeof event !== 'object') {
      throw new TypeError('An event must be an object')
    }

    if (typeof event.type !== 'string') {
      throw new TypeError('An event type must be a string')
    }

    if (!['auto', 'asIs', 'sync', 'async'].includes(event.mode)) {
      throw new Error(
        'An event mode must be either "auto", asIs", "sync" or "async"'
      )
    }

    if (event.cb && typeof event.cb !== 'function') {
      throw new TypeError('An event callback must be a function')
    }

    if (this._prefix) {
      event = Object.assign({}, event)
      event.type = `${this._prefix}.${event.type}`
    }

    if (this.source && this.source.next) {
      return this.source.next(event)
    }

    super.next(event)

    let beforeHooks = this.hookStoreBefore.get(event.type)
    let hooks = this.hookStore.get(event.type)
    let afterHooks = this.hookStoreAfter.get(event.type)
    let handlers = beforeHooks
      .concat(hooks)
      .concat(afterHooks)
      .map((hook) => hook.fn)

    if (event.cb) {
      handlers.push(event.cb)
    }

    if (handlers.length === 0) {
      return
    } else if (event.mode === 'auto') {
      return this.corrie(...handlers).apply(event, event.args)
    } else {
      return this.corrie[event.mode](...handlers).apply(event, event.args)
    }
  }

  _toot(eventType, args, cb) {
    let registeredEvent = this.events[eventType]
    let mode = registeredEvent ? registeredEvent.mode : 'auto'
    let event = createEvent(this.tooter, eventType, mode, args, cb)
    return this.next(event)
  }

  toot(eventType, ...args) {
    return this._toot(eventType, args)
  }

  tootWith(eventType, cb, ...args) {
    return this._toot(eventType, args, cb)
  }

  register(eventType, mode) {
    if (this.source && this.source.register) {
      return this.source.register(eventType, mode)
    }

    if (typeof eventType !== 'string' || !eventType.length) {
      throw new Error('An event type must be a non-empty string')
    }

    if (this.events[eventType]) {
      throw new Error(`Event "${eventType}" is already registered`)
    }

    if (!MODES.includes(mode)) {
      throw new Error('A mode must be one of the following:', MODES.join(', '))
    }

    this.events[eventType] = { mode }
  }

  prefix(prefix) {
    if (typeof prefix !== 'string') {
      throw new TypeError('A prefix must be a string')
    }

    let instance = this.lift()
    instance._prefix = prefix
    return instance
  }

  filter(predicate) {
    if (typeof predicate === 'string') {
      let eventType = predicate
      predicate = (e) => this.match(e.type, eventType)
    }

    return super.filter(predicate)
  }

  bind(tooter) {
    let clone = this.lift()
    clone.tooter = tooter
    return clone
  }
}

function createEvent(source, type, mode, args, cb) {
  args = args || []
  let event = { type, mode, args, source }

  if (cb) {
    event.cb = cb
  }

  return event
}

module.exports = Hooter
<|endoftext|>


<commit_before>(function(sox, $, undefined) {
    'use strict';

    sox.dialog = {
        init: function(options) {
            // options { dialog html, features data, sox version}

            var $soxSettingsDialog = $(options.html),
                $soxSettingsDialogFeatures = $soxSettingsDialog.find('#sox-settings-dialog-features'),
                $soxSettingsDialogVersion = $soxSettingsDialog.find('#sox-settings-dialog-version'),
                $soxSettingsSave = $soxSettingsDialog.find('#sox-settings-dialog-save'),
                $soxSettingsReset = $soxSettingsDialog.find('#sox-settings-dialog-reset'),
                $soxSettingsToggleAccessTokensDiv = $soxSettingsDialog.find('#sox-settings-dialog-access-tokens'),
                $soxSettingsAccessTokensToggle = $soxSettingsToggleAccessTokensDiv.find('#toggle-access-token-links'),
                $soxSettingsToggle = $soxSettingsDialog.find('#sox-settings-dialog-check-toggle'),
                $soxSettingsClose = $soxSettingsDialog.find('#sox-settings-dialog-close'),
                $searchBox = $soxSettingsDialog.find('#search'),
                $searchReset = $soxSettingsDialog.find('#search-reset');

            function addFeature(category, feature, desc) {
                var $div = $('<div/>', {
                        'class': 'feature',
                        'data-desc': desc
                    }),
                    $label = $('<label/>'),
                    $input = $('<input/>', {
                        id: feature,
                        type: 'checkbox'
                    });
                $div.append($label);
                $label.append($input);
                $input.after(desc);
                $soxSettingsDialogFeatures.find('#' + category).append($div);
            }

            function addCategory(name) {
                var $div = $('<div/>', {
                        'class': 'header category'
                    }),
                    $h3 = $('<h3/>', {
                        text: name.toLowerCase()
                    }),
                    $content = $('<div/>', {
                        id: name,
                        class: 'modal-content features'
                    });
                $div.append($h3);

                $soxSettingsDialogFeatures.find('#sox-settings-dialog-access-tokens').before($div);
                $div.after($content);
            }

            // display sox version number in the dialog
            $soxSettingsDialogVersion.text(SOX_VERSION != '??' ? ' v' + SOX_VERSION.toLowerCase() : '');

            // wire up event handlers
            $soxSettingsClose.on('click', function() {
                $soxSettingsDialog.hide();
            });
            $soxSettingsReset.on('click', function() {
                reset();
                location.reload(); // reload page to reflect changed settings
            });

            $soxSettingsToggle.on('click', function() {
                var $icon = $(this).find('i'),
                    checked = $icon.hasClass('fa-check-square-o') ? true : false;

                if (checked) {
                    $icon.removeClass('fa-check-square-o').addClass('fa-square-o');
                    $soxSettingsDialogFeatures.find('input').prop('checked', false);
                } else {
                    $icon.removeClass('fa-square-o').addClass('fa-check-square-o');
                    $soxSettingsDialogFeatures.find('input').prop('checked', true);
                }
            });

            $searchReset.on('click', function() {
                $('.category, .features, #sox-settings-dialog label').fadeIn();
                $searchBox.val('').focus();

            });

            $soxSettingsSave.on('click', function() {
                alert('save button');
                /*var extras = [];
                $soxSettingsDialogFeatures.find('input[type=checkbox]:checked').each(function() {
                    var x = $(this).closest('.modal-content').attr('id') + '-' + $(this).attr('id');

                    extras.push(x); //Add the function's ID (also the checkbox's ID) to the array
                });
                save(extras);
                location.reload(); // reload page to reflect changed settings
                */
            });

            $searchBox.on('keyup keydown', function() { //search box
                if ($(this).val() != '') {
                    var t = $(this).val();
                    $('#sox-settings-dialog label').each(function() {
                        var $features = $(this).closest('.features');
                        if ($(this).text().toLowerCase().indexOf(t) == -1) {
                            $(this).hide();
                        } else {
                            $(this).show();
                        }

                        if ($features.find('label:visible').length == 0 && $features.find('label[style*="display: inline"]').length == 0) {
                            $features.hide().prev().hide();
                        } else {
                            $features.show().prev().show();
                        }
                    });
                } else {
                    $('.category, .features, #sox-settings-dialog label').fadeIn();
                }
            });

            // append the dialog to the dialog corral
            $('.js-topbar-dialog-corral').append($settingsDialog);

        }
    };

})(window.sox = window.sox || {}, jQuery);
<commit_msg>updates<commit_after>(function(sox, $, undefined) {
    'use strict';

    sox.dialog = {
        init: function(options) {
            // options { dialog html, features data, sox version}

            var $soxSettingsDialog = $(options.html),
                $soxSettingsDialogFeatures = $soxSettingsDialog.find('#sox-settings-dialog-features'),
                $soxSettingsDialogVersion = $soxSettingsDialog.find('#sox-settings-dialog-version'),
                $soxSettingsSave = $soxSettingsDialog.find('#sox-settings-dialog-save'),
                $soxSettingsReset = $soxSettingsDialog.find('#sox-settings-dialog-reset'),
                $soxSettingsToggleAccessTokensDiv = $soxSettingsDialog.find('#sox-settings-dialog-access-tokens'),
                $soxSettingsAccessTokensToggle = $soxSettingsToggleAccessTokensDiv.find('#toggle-access-token-links'),
                $soxSettingsToggle = $soxSettingsDialog.find('#sox-settings-dialog-check-toggle'),
                $soxSettingsClose = $soxSettingsDialog.find('#sox-settings-dialog-close'),
                $searchBox = $soxSettingsDialog.find('#search'),
                $searchReset = $soxSettingsDialog.find('#search-reset');

            function addFeature(category, feature, desc) {
                var $div = $('<div/>', {
                        'class': 'feature',
                        'data-desc': desc
                    }),
                    $label = $('<label/>'),
                    $input = $('<input/>', {
                        id: feature,
                        type: 'checkbox'
                    });
                $div.append($label);
                $label.append($input);
                $input.after(desc);
                $soxSettingsDialogFeatures.find('#' + category).append($div);
            }

            function addCategory(name) {
                var $div = $('<div/>', {
                        'class': 'header category'
                    }),
                    $h3 = $('<h3/>', {
                        text: name.toLowerCase()
                    }),
                    $content = $('<div/>', {
                        id: name,
                        class: 'modal-content features'
                    });
                $div.append($h3);

                $soxSettingsDialogFeatures.find('#sox-settings-dialog-access-tokens').before($div);
                $div.after($content);
            }

            // display sox version number in the dialog
            $soxSettingsDialogVersion.text(SOX_VERSION != '??' ? ' v' + SOX_VERSION.toLowerCase() : '');

            // wire up event handlers
            $soxSettingsClose.on('click', function() {
                $soxSettingsDialog.hide();
            });
            $soxSettingsReset.on('click', function() {
                reset();
                location.reload(); // reload page to reflect changed settings
            });

            $soxSettingsToggle.on('click', function() {
                var $icon = $(this).find('i'),
                    checked = $icon.hasClass('fa-check-square-o') ? true : false;

                if (checked) {
                    $icon.removeClass('fa-check-square-o').addClass('fa-square-o');
                    $soxSettingsDialogFeatures.find('input').prop('checked', false);
                } else {
                    $icon.removeClass('fa-square-o').addClass('fa-check-square-o');
                    $soxSettingsDialogFeatures.find('input').prop('checked', true);
                }
            });

            $searchReset.on('click', function() {
                $('.category, .features, #sox-settings-dialog label').fadeIn();
                $searchBox.val('').focus();

            });

            $soxSettingsSave.on('click', function() {
                alert('save button');
                /*var extras = [];
                $soxSettingsDialogFeatures.find('input[type=checkbox]:checked').each(function() {
                    var x = $(this).closest('.modal-content').attr('id') + '-' + $(this).attr('id');

                    extras.push(x); //Add the function's ID (also the checkbox's ID) to the array
                });
                save(extras);
                location.reload(); // reload page to reflect changed settings
                */
            });

            $searchBox.on('keyup keydown', function() { //search box
                if ($(this).val() != '') {
                    var t = $(this).val();
                    $('#sox-settings-dialog label').each(function() {
                        var $features = $(this).closest('.features');
                        if ($(this).text().toLowerCase().indexOf(t) == -1) {
                            $(this).hide();
                        } else {
                            $(this).show();
                        }

                        if ($features.find('label:visible').length == 0 && $features.find('label[style*="display: inline"]').length == 0) {
                            $features.hide().prev().hide();
                        } else {
                            $features.show().prev().show();
                        }
                    });
                } else {
                    $('.category, .features, #sox-settings-dialog label').fadeIn();
                }
            });

            // create sox settings button
            var $soxSettingsButton = $('<a/>', {
                    id: 'soxSettingsButton',
                    class: 'topbar-icon yes-hover sox-settings-button',
                    title: 'Change SOX Settings',
                    style: 'color: #A1A1A1',
                    click: function(e) {
                        e.preventDefault();
                        $('#sox-settings-dialog').toggle();
                        if ($soxSettingsDialog.is(':visible')) {
                            $(this).addClass('topbar-icon-on');
                        } else {
                            $(this).removeClass('topbar-icon-on');
                        }
                    }
                }),
                $icon = $('<i/>', {
                    class: 'fa fa-cogs'
                });

            //open dialog on hover if another dialog is already open
            $('#soxSettingsButton').hover(function() { //https://github.com/soscripted/sox/issues/44, open on hover, just like the normal dropdowns
                if ($('.topbar-icon').not('#soxSettingsButton').hasClass('topbar-icon-on')) {
                    $('.topbar-dialog').hide();
                    $('.topbar-icon').removeClass('topbar-icon-on').removeClass('icon-site-switcher-on');
                    $(this).addClass('topbar-icon-on');
                    $soxSettingsDialog.show();
                }
            }, function() {
                $('.topbar-icon').not('#soxSettingsButton').hover(function() {
                    if ($('#soxSettingsButton').hasClass('topbar-icon-on')) {
                        $soxSettingsDialog.hide();
                        $('#soxSettingsButton').removeClass('topbar-icon-on');
                        var which = $(this).attr('class').match(/js[\w-]*\b/)[0].split('-')[1];
                        if (which != 'site') { //site-switcher dropdown is slightly different
                            $('.' + which + '-dialog').not('#sox-settings-dialog, #metaNewQuestionAlertDialog').show();
                            $(this).addClass('topbar-icon-on');
                        } else {
                            $('.siteSwitcher-dialog').show();
                            $(this).addClass('topbar-icon-on').addClass('icon-site-switcher-on'); //icon-site-switcher-on is special to the site-switcher dropdown (StackExchange button)
                        }
                    }
                });
            });

            //close dialog if clicked outside it
            $(document).click(function(e) {
                $target = $(e.target);
                if (!$target.is('#soxSettingsButton, #sox-settings-dialog') && !$target.parents("#soxSettingsButton, #sox-settings-dialog").is("#soxSettingsButton, #sox-settings-dialog")) {
                    $soxSettingsDialog.hide();
                    $('#soxSettingsButton').removeClass('topbar-icon-on');
                }
            });

            //close dialog if one of the links on the topbar is clicked
            $('.topbar-icon').not('.sox-settings-button').click(function() {
                $soxSettingsDialog.hide();
                $('#soxSettingsButton').removeClass('topbar-icon-on');
            });

            // add dialog to corral and sox button to topbar

$soxSettingsButton.append($icon).appendTo('div.network-items');
  $('.js-topbar-dialog-corral').append($settingsDialog);
        }
    };

})(window.sox = window.sox || {}, jQuery);
<|endoftext|>


<commit_before>/*
 * DateJS Culture String File
 * Country Code: sv-SE
 * Name: Swedish (Sweden)
 * Format: "key" : "value"
 * Key is the en-US term, Value is the Key in the current language.
 */
Date.CultureStrings = {
	"name": "sv-SE",
	"englishName": "Swedish (Sweden)",
	"nativeName": "svenska (Sverige)",
	"Sunday": "söndag",
	"Monday": "måndag",
	"Tuesday": "tisdag",
	"Wednesday": "onsdag",
	"Thursday": "torsdag",
	"Friday": "fredag",
	"Saturday": "lördag",
	"Sun": "sö",
	"Mon": "må",
	"Tue": "ti",
	"Wed": "on",
	"Thu": "to",
	"Fri": "fr",
	"Sat": "lö",
	"Su": "sö",
	"Mo": "må",
	"Tu": "ti",
	"We": "on",
	"Th": "to",
	"Fr": "fr",
	"Sa": "lö",
	"S_Sun_Initial": "s",
	"M_Mon_Initial": "m",
	"T_Tue_Initial": "t",
	"W_Wed_Initial": "o",
	"T_Thu_Initial": "t",
	"F_Fri_Initial": "f",
	"S_Sat_Initial": "l",
	"January": "januari",
	"February": "februari",
	"March": "mars",
	"April": "april",
	"May": "maj",
	"June": "juni",
	"July": "juli",
	"August": "augusti",
	"September": "september",
	"October": "oktober",
	"November": "november",
	"December": "december",
	"Jan_Abbr": "jan",
	"Feb_Abbr": "feb",
	"Mar_Abbr": "mar",
	"Apr_Abbr": "apr",
	"May_Abbr": "maj",
	"Jun_Abbr": "jun",
	"Jul_Abbr": "jul",
	"Aug_Abbr": "aug",
	"Sep_Abbr": "sep",
	"Oct_Abbr": "okt",
	"Nov_Abbr": "nov",
	"Dec_Abbr": "dec",
	"AM": "",
	"PM": "",
	"firstDayOfWeek": 1,
	"twoDigitYearMax": 2029,
	"mdy": "ymd",
	"M/d/yyyy": "yyyy-MM-dd",
	"dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy",
	"h:mm tt": "HH:mm",
	"h:mm:ss tt": "HH:mm:ss",
	"dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH:mm:ss",
	"yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss",
	"yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ",
	"ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss",
	"MMMM dd": "'den 'd MMMM",
	"MMMM, yyyy": "MMMM yyyy",
	"^jan(uary)?": "^jan(uari)?",
	"^feb(ruary)?": "^feb(ruari)?",
	"^mar(ch)?": "^mar(s)?",
	"^apr(il)?": "^apr(il)?",
	"^may": "^maj",
	"^jun(e)?": "^jun(i)?",
	"^jul(y)?": "^jul(i)?",
	"^aug(ust)?": "^aug(usti)?",
	"^sep(t(ember)?)?": "^sep(t(ember)?)?",
	"^oct(ober)?": "^okt(ober)?",
	"^nov(ember)?": "^nov(ember)?",
	"^dec(ember)?": "^dec(ember)?",
	"^su(n(day)?)?": "^söndag",
	"^mo(n(day)?)?": "^måndag",
	"^tu(e(s(day)?)?)?": "^tisdag",
	"^we(d(nesday)?)?": "^onsdag",
	"^th(u(r(s(day)?)?)?)?": "^torsdag",
	"^fr(i(day)?)?": "^fredag",
	"^sa(t(urday)?)?": "^lördag",
	"^next": "^next",
	"^last|past|prev(ious)?": "^last|past|prev(ious)?",
	"^(\\+|aft(er)?|from|hence)": "^(\\+|aft(er)?|from|hence)",
	"^(\\-|bef(ore)?|ago)": "^(\\-|bef(ore)?|ago)",
	"^yes(terday)?": "^yes(terday)?",
	"^t(od(ay)?)?": "^t(od(ay)?)?",
	"^tom(orrow)?": "^tom(orrow)?",
	"^n(ow)?": "^n(ow)?",
	"^ms|milli(second)?s?": "^ms|milli(second)?s?",
	"^sec(ond)?s?": "^sec(ond)?s?",
	"^mn|min(ute)?s?": "^mn|min(ute)?s?",
	"^h(our)?s?": "^h(our)?s?",
	"^w(eek)?s?": "^w(eek)?s?",
	"^m(onth)?s?": "^m(onth)?s?",
	"^d(ay)?s?": "^d(ay)?s?",
	"^y(ear)?s?": "^y(ear)?s?",
	"^(a|p)": "^(a|p)",
	"^(a\\.?m?\\.?|p\\.?m?\\.?)": "^(a\\.?m?\\.?|p\\.?m?\\.?)",
	"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)",
	"^\\s*(st|nd|rd|th)": "^\\s*(st|nd|rd|th)",
	"^\\s*(\\:|a(?!u|p)|p)": "^\\s*(\\:|a(?!u|p)|p)",
	"LINT": "LINT",
	"TOT": "TOT",
	"CHAST": "CHAST",
	"NZST": "NZST",
	"NFT": "NFT",
	"SBT": "SBT",
	"AEST": "AEST",
	"ACST": "ACST",
	"JST": "JST",
	"CWST": "CWST",
	"CT": "CT",
	"ICT": "ICT",
	"MMT": "MMT",
	"BIOT": "BST",
	"NPT": "NPT",
	"IST": "IST",
	"PKT": "PKT",
	"AFT": "AFT",
	"MSK": "MSK",
	"IRST": "IRST",
	"FET": "FET",
	"EET": "EET",
	"CET": "CET",
	"UTC": "UTC",
	"GMT": "GMT",
	"CVT": "CVT",
	"GST": "GST",
	"BRT": "BRT",
	"NST": "NST",
	"AST": "AST",
	"EST": "EST",
	"CST": "CST",
	"MST": "MST",
	"PST": "PST",
	"AKST": "AKST",
	"MIT": "MIT",
	"HST": "HST",
	"SST": "SST",
	"BIT": "BIT",
	"CHADT": "CHADT",
	"NZDT": "NZDT",
	"AEDT": "AEDT",
	"ACDT": "ACDT",
	"AZST": "AZST",
	"IRDT": "IRDT",
	"EEST": "EEST",
	"CEST": "CEST",
	"BST": "BST",
	"PMDT": "PMDT",
	"ADT": "ADT",
	"NDT": "NDT",
	"EDT": "EDT",
	"CDT": "CDT",
	"MDT": "MDT",
	"PDT": "PDT",
	"AKDT": "AKDT",
	"HADT": "HADT"
};
<commit_msg>Updating Swedish with better regex and translations<commit_after>/*
 * DateJS Culture String File
 * Country Code: sv-SE
 * Name: Swedish (Sweden)
 * Format: "key" : "value"
 * Key is the en-US term, Value is the Key in the current language.
 */
Date.CultureStrings = {
	"name": "sv-SE",
	"englishName": "Swedish (Sweden)",
	"nativeName": "Svenska (Sverige)",
	"Sunday": "Söndag",
	"Monday": "Måndag",
	"Tuesday": "Tisdag",
	"Wednesday": "Onsdag",
	"Thursday": "Torsdag",
	"Friday": "Fredag",
	"Saturday": "Lördag",
	"Sun": "Sön",
	"Mon": "Mån",
	"Tue": "Tis",
	"Wed": "Ons",
	"Thu": "Tor",
	"Fri": "Fre",
	"Sat": "Lör",
	"Su": "Sö",
	"Mo": "Må",
	"Tu": "Ti",
	"We": "On",
	"Th": "To",
	"Fr": "Fr",
	"Sa": "Lö",
	"S_Sun_Initial": "S",
	"M_Mon_Initial": "M",
	"T_Tue_Initial": "T",
	"W_Wed_Initial": "O",
	"T_Thu_Initial": "T",
	"F_Fri_Initial": "F",
	"S_Sat_Initial": "L",
	"January": "Januari",
	"February": "Februari",
	"March": "Mars",
	"April": "April",
	"May": "Maj",
	"June": "Juni",
	"July": "Juli",
	"August": "Augusti",
	"September": "September",
	"October": "Oktober",
	"November": "November",
	"December": "December",
	"Jan_Abbr": "Jan",
	"Feb_Abbr": "Feb",
	"Mar_Abbr": "Mar",
	"Apr_Abbr": "Apr",
	"May_Abbr": "Maj",
	"Jun_Abbr": "Jun",
	"Jul_Abbr": "Jul",
	"Aug_Abbr": "Aug",
	"Sep_Abbr": "Sep",
	"Oct_Abbr": "Okt",
	"Nov_Abbr": "Nov",
	"Dec_Abbr": "Dec",
	"AM": "",
	"PM": "",
	"firstDayOfWeek": 1,
	"twoDigitYearMax": 2029,
	"mdy": "ymd",
	"M/d/yyyy": "yyyy-MM-dd",
	"dddd, MMMM dd, yyyy": "'den 'd MMMM yyyy",
	"h:mm tt": "HH:mm",
	"h:mm:ss tt": "HH:mm:ss",
	"dddd, MMMM dd, yyyy h:mm:ss tt": "'den 'd MMMM yyyy HH:mm:ss",
	"yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss",
	"yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ",
	"ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss",
	"MMMM dd": "'den 'd MMMM",
	"MMMM, yyyy": "MMMM yyyy",
	"^jan(uary)?": "^jan(uari)?",
	"^feb(ruary)?": "^feb(ruari)?",
	"^mar(ch)?": "^mar(s)?",
	"^apr(il)?": "^apr(il)?",
	"^may": "^maj",
	"^jun(e)?": "^jun(i)?",
	"^jul(y)?": "^jul(i)?",
	"^aug(ust)?": "^aug(usti)?",
	"^sep(t(ember)?)?": "^sep(t(ember)?)?",
	"^oct(ober)?": "^okt(ober)?",
	"^nov(ember)?": "^nov(ember)?",
	"^dec(ember)?": "^dec(ember)?",
	"^su(n(day)?)?": "^sö(n(dag)?)?",
	"^mo(n(day)?)?": "^må(n(dag)?)?",
	"^tu(e(s(day)?)?)?": "^ti(s(dag)?)?",
	"^we(d(nesday)?)?": "^on(s(dag)?)?",
	"^th(u(r(s(day)?)?)?)?": "^to(r(s(dag)?)?)?",
	"^fr(i(day)?)?": "^fr(e(dag)?)?",
	"^sa(t(urday)?)?": "^lö(r(dag)?)?",

	"^next": "^nästa",
	"^last|past|prev(ious)?": "^föregående|förra|senaste",
	"^(\\+|aft(er)?|from|hence)": "^(\\+|efter|från)",
	"^(\\-|bef(ore)?|ago)": "^(\\-|före|tidigare)",

	"^yes(terday)?": "^i\\s?går|(för)går(dag)?",
	"^t(od(ay)?)?": "^i\\s?dag?",
	"^tom(orrow)?": "^i\\s?morgon|morgon(dag)?",
	"^n(ow)?": "^nu",

	"^ms|milli(second)?s?": "^ms|milli(sekund)?(er)?",
	"^sec(ond)?s?": "^sek(und)?(er)?",
	"^mn|min(ute)?s?": "^min(ut)?(er)?",
	"^h(our)?s?": "^t(im)?(ar)?",
	"^w(eek)?s?": "^v(eck(a)?)?(or)?",
	"^m(onth)?s?": "^m(ånad)?(er)?",
	"^d(ay)?s?": "^d(ag)?(ar)?",
	"^y(ear)?s?": "^å(r)?",

	"^(a|p)": "^(a|p)",
	"^(a\\.?m?\\.?|p\\.?m?\\.?)": "^(a\\.?m?\\.?|p\\.?m?\\.?)",
	"^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)",
	"^\\s*(st|nd|rd|th)": "^\\s*(st|nd|rd|th)",
	"^\\s*(\\:|a(?!u|p)|p)": "^\\s*(\\:|a(?!u|p)|p)",

	"LINT": "LINT",
	"TOT": "TOT",
	"CHAST": "CHAST",
	"NZST": "NZST",
	"NFT": "NFT",
	"SBT": "SBT",
	"AEST": "AEST",
	"ACST": "ACST",
	"JST": "JST",
	"CWST": "CWST",
	"CT": "CT",
	"ICT": "ICT",
	"MMT": "MMT",
	"BIOT": "BST",
	"NPT": "NPT",
	"IST": "IST",
	"PKT": "PKT",
	"AFT": "AFT",
	"MSK": "MSK",
	"IRST": "IRST",
	"FET": "FET",
	"EET": "EET",
	"CET": "CET",
	"UTC": "UTC",
	"GMT": "GMT",
	"CVT": "CVT",
	"GST": "GST",
	"BRT": "BRT",
	"NST": "NST",
	"AST": "AST",
	"EST": "EST",
	"CST": "CST",
	"MST": "MST",
	"PST": "PST",
	"AKST": "AKST",
	"MIT": "MIT",
	"HST": "HST",
	"SST": "SST",
	"BIT": "BIT",
	"CHADT": "CHADT",
	"NZDT": "NZDT",
	"AEDT": "AEDT",
	"ACDT": "ACDT",
	"AZST": "AZST",
	"IRDT": "IRDT",
	"EEST": "EEST",
	"CEST": "CEST",
	"BST": "BST",
	"PMDT": "PMDT",
	"ADT": "ADT",
	"NDT": "NDT",
	"EDT": "EDT",
	"CDT": "CDT",
	"MDT": "MDT",
	"PDT": "PDT",
	"AKDT": "AKDT",
	"HADT": "HADT"
};
<|endoftext|>