{"size": 1844, "ext": "js", "max_stars_repo_path": "spot-oa/ui/js/actions/SpotActions.js", "max_stars_repo_name": "maduhu/Apache-Spot-Incubator", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "spot-oa/ui/js/actions/SpotActions.js", "max_issues_repo_name": "maduhu/Apache-Spot-Incubator", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "spot-oa/ui/js/actions/SpotActions.js", "max_forks_repo_name": "maduhu/Apache-Spot-Incubator", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.9393939394, "max_line_length": 151, "alphanum_fraction": 0.5542299349}
// Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0.

var $ = require('jquery');

var SpotDispatcher = require('../dispatchers/SpotDispatcher');
var SpotConstants = require('../constants/SpotConstants');
var SpotUtils = require('../utils/SpotUtils');

var SpotActions = {
    setDate: function (date, name) {
        var regex;

        name = name || 'date';
        SpotUtils.setUrlParam(name, date);

        // Update links to match date

        regex = new RegExp('\\${(?:[^}]+\\|)?' + name + '(?:\\|[^}]+)?}', 'g');
        $('a[data-href]').each(function () {
            var link = $(this);

            if (regex.test(link.data('href'))) {
                link.attr('href', link.data('href').replace(regex, date));
            }
        });

        SpotDispatcher.dispatch({
            actionType: SpotConstants.UPDATE_FILTER,
            filter: ''
        });

        SpotDispatcher.dispatch({
            actionType: SpotConstants.UPDATE_DATE,
            date: date,
            name: name
        });
    },
    setPipeline(pipeline) {
       SpotDispatcher.dispatch({
           actionType: SpotConstants.UPDATE_PIPELINE,
           pipeline
       });
   },
    expandPanel: function (panel) {
        SpotDispatcher.dispatch({
            actionType: SpotConstants.EXPAND_PANEL,
            panel: panel
        });
    },
    restorePanel: function (panel) {
        SpotDispatcher.dispatch({
            actionType: SpotConstants.RESTORE_PANEL,
            panel: panel
        });
    },
    toggleMode: function (panel, mode) {
        SpotDispatcher.dispatch({
            actionType: SpotConstants.TOGGLE_MODE_PANEL,
            panel: panel,
            mode: mode
        });
    }
};

module.exports = SpotActions;
