<commit_before>import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Icon from 'react-geomicons';
import {
  Overlay,
  Panel,
  PanelHeader,
  Text,
  Close,
  Space,
  Heading,
  Divider,
  ButtonCircle,
} from 'rebass';
import { Flex } from 'reflexbox';

import FadeInTransition from './FadeInTransition';
import FadeImage from './FadeImage';
import PlayPause from './PlayPause';
import { actions as appActions, selectors as appSelectors } from '../app';
import { selectors as mosaicSelectors } from '../mosaic';
import { selectors as recommendedSelectors } from '../recommended';
import { getAlbumArtUrlForTrack } from '../utils';

const styles = require('./FadeInTransition.css');

const TrackInfoModal = ({ isModalOpen, selectedTrack, windowWidth, actions }) => {
  const mapPitchClassToKey = (pitchClass) => {
    switch (pitchClass) {
      case 0:
        return 'C';
      case 1:
        return 'C♯/D♭';
      case 2:
        return 'D';
      case 3:
        return 'D♯/E♭';
      case 4:
        return 'E';
      case 5:
        return 'F';
      case 6:
        return 'F♯/G♭';
      case 7:
        return 'G';
      case 8:
        return 'G♯/A♭';
      case 9:
        return 'A';
      case 10:
        return 'A♯/B♭';
      case 11:
        return 'B';
      default:
        return 'UNKNOWN';
    }
  };

  const mapMode = mode => (mode === 1 ? 'major' : 'minor');

  return (
    selectedTrack ?
      <FadeInTransition>
        <Overlay key="modal" open={isModalOpen} onDismiss={() => actions.closeModal()} className={styles.overflowHidden}>
          <Panel>
            <PanelHeader>
              <Text>
                {`${selectedTrack.getIn(['artists', 0, 'name'])} - ${selectedTrack.get('name')}`}
              </Text>
              <Space auto />
              <Close onClick={() => actions.closeModal()} />
            </PanelHeader>
            <Flex
              flexColumn={windowWidth <= 480}
              style={{ marginTop: '-16px', marginRight: '-16px' }}
              align="center"
            >
              <FadeImage
                src={getAlbumArtUrlForTrack(selectedTrack)}
                style={{
                  width: '300px',
                  height: '300px',
                  marginRight: '16px',
                  marginTop: '16px',
                }}
              />
              <Flex mt={2} mr={2} wrap flexColumn style={{ width: '300px' }}>
                <Heading color="black" level={3}>
                  {selectedTrack.get('name')}
                </Heading>
                <Text
                  color="black"
                >
                  {selectedTrack.get('artists').map(a => a.get('name')).join(', ')}
                </Text>
                <Text color="black">
                  {selectedTrack.getIn(['album', 'name'])}
                </Text>
                <Divider ml={0} width={150} />
                <Flex flexColumn={windowWidth > 480} style={{ marginTop: '-16px' }}>
                  <Flex flexColumn mt={2}>
                    <Text color="black">
                      {`${Math.round(selectedTrack.get('tempo'))} bpm`}
                    </Text>
                    <Text color="black">
                      {
                        `${mapPitchClassToKey(selectedTrack.get('key'))}
                          ${mapMode(selectedTrack.get('mode'))}`
                      }
                    </Text>
                  </Flex>
                  <Space auto />
                  <Flex mt={2}>
                    <PlayPause
                      previewUrl={selectedTrack.get('preview_url')}
                    />
                    <ButtonCircle
                      ml={1}
                      size={48}
                      backgroundColor="green"
                      title="Open in Spotify"
                      href={selectedTrack.getIn(['external_urls', 'spotify'])}
                      target="_blank"
                    >
                      <Icon
                        fill="white"
                        height="32px"
                        name="external"
                        width="32px"
                      />
                    </ButtonCircle>
                  </Flex>
                </Flex>
              </Flex>
            </Flex>
          </Panel>
        </Overlay>
      </FadeInTransition>
      : null
  );
};

TrackInfoModal.propTypes = {
  actions: PropTypes.object.isRequired,
  isModalOpen: PropTypes.bool.isRequired,
  windowWidth: PropTypes.number.isRequired,
  selectedTrack: PropTypes.object,
};

TrackInfoModal.defaultProps = {
  windowWidth: 0,
  selectedTrack: null,
};

const mapStateToProps = state => (
  {
    isModalOpen: appSelectors.getIsModalOpen(state),
    selectedTrack: mosaicSelectors.getTrack(state, appSelectors.getSelectedTrackId(state)) ||
      recommendedSelectors.getRecommendedTrack(state, appSelectors.getSelectedTrackId(state)),
  }
);

const mapDispatchToProps = dispatch => (
  {
    actions: bindActionCreators({ ...appActions }, dispatch),
  }
);

export default connect(mapStateToProps, mapDispatchToProps)(TrackInfoModal);
<commit_msg>Fix runtime issue<commit_after>import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Icon from 'react-geomicons';
import {
  Overlay,
  Panel,
  PanelHeader,
  Text,
  Close,
  Space,
  Heading,
  Divider,
  ButtonCircle,
} from 'rebass';
import { Flex } from 'reflexbox';

import FadeInTransition from './FadeInTransition';
import FadeImage from './FadeImage';
import PlayPause from './PlayPause';
import { actions as appActions, selectors as appSelectors } from '../app';
import { selectors as mosaicSelectors } from '../mosaic';
import { selectors as recommendedSelectors } from '../recommended';
import { getAlbumArtUrlForTrack } from '../utils';

const styles = require('./TrackInfoModal.css');

const TrackInfoModal = ({ isModalOpen, selectedTrack, windowWidth, actions }) => {
  const mapPitchClassToKey = (pitchClass) => {
    switch (pitchClass) {
      case 0:
        return 'C';
      case 1:
        return 'C♯/D♭';
      case 2:
        return 'D';
      case 3:
        return 'D♯/E♭';
      case 4:
        return 'E';
      case 5:
        return 'F';
      case 6:
        return 'F♯/G♭';
      case 7:
        return 'G';
      case 8:
        return 'G♯/A♭';
      case 9:
        return 'A';
      case 10:
        return 'A♯/B♭';
      case 11:
        return 'B';
      default:
        return 'UNKNOWN';
    }
  };

  const mapMode = mode => (mode === 1 ? 'major' : 'minor');

  return (
    selectedTrack ?
      <FadeInTransition>
        <Overlay key="modal" open={isModalOpen} onDismiss={() => actions.closeModal()} className={styles.overflowHidden}>
          <Panel>
            <PanelHeader>
              <Text>
                {`${selectedTrack.getIn(['artists', 0, 'name'])} - ${selectedTrack.get('name')}`}
              </Text>
              <Space auto />
              <Close onClick={() => actions.closeModal()} />
            </PanelHeader>
            <Flex
              flexColumn={windowWidth <= 480}
              style={{ marginTop: '-16px', marginRight: '-16px' }}
              align="center"
            >
              <FadeImage
                src={getAlbumArtUrlForTrack(selectedTrack)}
                style={{
                  width: '300px',
                  height: '300px',
                  marginRight: '16px',
                  marginTop: '16px',
                }}
              />
              <Flex mt={2} mr={2} wrap flexColumn style={{ width: '300px' }}>
                <Heading color="black" level={3}>
                  {selectedTrack.get('name')}
                </Heading>
                <Text
                  color="black"
                >
                  {selectedTrack.get('artists').map(a => a.get('name')).join(', ')}
                </Text>
                <Text color="black">
                  {selectedTrack.getIn(['album', 'name'])}
                </Text>
                <Divider ml={0} width={150} />
                <Flex flexColumn={windowWidth > 480} style={{ marginTop: '-16px' }}>
                  <Flex flexColumn mt={2}>
                    <Text color="black">
                      {`${Math.round(selectedTrack.get('tempo'))} bpm`}
                    </Text>
                    <Text color="black">
                      {
                        `${mapPitchClassToKey(selectedTrack.get('key'))}
                          ${mapMode(selectedTrack.get('mode'))}`
                      }
                    </Text>
                  </Flex>
                  <Space auto />
                  <Flex mt={2}>
                    <PlayPause
                      previewUrl={selectedTrack.get('preview_url')}
                    />
                    <ButtonCircle
                      ml={1}
                      size={48}
                      backgroundColor="green"
                      title="Open in Spotify"
                      href={selectedTrack.getIn(['external_urls', 'spotify'])}
                      target="_blank"
                    >
                      <Icon
                        fill="white"
                        height="32px"
                        name="external"
                        width="32px"
                      />
                    </ButtonCircle>
                  </Flex>
                </Flex>
              </Flex>
            </Flex>
          </Panel>
        </Overlay>
      </FadeInTransition>
      : null
  );
};

TrackInfoModal.propTypes = {
  actions: PropTypes.object.isRequired,
  isModalOpen: PropTypes.bool.isRequired,
  windowWidth: PropTypes.number.isRequired,
  selectedTrack: PropTypes.object,
};

TrackInfoModal.defaultProps = {
  windowWidth: 0,
  selectedTrack: null,
};

const mapStateToProps = state => (
  {
    isModalOpen: appSelectors.getIsModalOpen(state),
    selectedTrack: mosaicSelectors.getTrack(state, appSelectors.getSelectedTrackId(state)) ||
      recommendedSelectors.getRecommendedTrack(state, appSelectors.getSelectedTrackId(state)),
  }
);

const mapDispatchToProps = dispatch => (
  {
    actions: bindActionCreators({ ...appActions }, dispatch),
  }
);

export default connect(mapStateToProps, mapDispatchToProps)(TrackInfoModal);
<|endoftext|>


<commit_before>const crypto = require('crypto')
const os = require('os')
const path = require('path')
const cp = require('child_process')
const fs = require('fs')

const _ = require('lodash/fp')

const logger = require('console-log-level')({level: 'info'})

module.exports = {
  es,
  writeSupervisorConfig,
  firewall,
  randomPass,
  fetchAndInstall,
  logger,
  isInstalledSoftware,
  writeFile
}

const BINARIES = {
  BTC: {
    url: 'https://bitcoincore.org/bin/bitcoin-core-0.21.1/bitcoin-0.21.1-x86_64-linux-gnu.tar.gz',
    dir: 'bitcoin-0.21.1/bin'
  },
  ETH: {
    url: 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.3-991384a7.tar.gz',
    dir: 'geth-linux-amd64-1.10.3-991384a7'
  },
  ZEC: {
    url: 'https://z.cash/downloads/zcash-4.4.0-linux64-debian-stretch.tar.gz',
    dir: 'zcash-4.4.0/bin'
  },
  DASH: {
    url: 'https://github.com/dashpay/dash/releases/download/v0.17.0.3/dashcore-0.17.0.3-x86_64-linux-gnu.tar.gz',
    dir: 'dashcore-0.17.0/bin'
  },
  LTC: {
    url: 'https://download.litecoin.org/litecoin-0.18.1/linux/litecoin-0.18.1-x86_64-linux-gnu.tar.gz',
    dir: 'litecoin-0.18.1/bin'
  },
  BCH: {
    url: 'https://github.com/bitcoin-cash-node/bitcoin-cash-node/releases/download/v23.0.0/bitcoin-cash-node-23.0.0-x86_64-linux-gnu.tar.gz',
    dir: 'bitcoin-cash-node-23.0.0/bin',
    files: [['bitcoind', 'bitcoincashd'], ['bitcoin-cli', 'bitcoincash-cli']]
  }
}

function firewall (ports) {
  if (!ports || ports.length === 0) throw new Error('No ports supplied')
  const portsString = ports.join(',')
  es(`sudo ufw allow ${portsString}`)
}

function randomPass () {
  return crypto.randomBytes(32).toString('hex')
}

function es (cmd) {
  const env = {HOME: os.userInfo().homedir}
  const options = {encoding: 'utf8', env}
  const res = cp.execSync(cmd, options)
  logger.debug(res)
  return res.toString()
}

function writeSupervisorConfig (coinRec, cmd) {
  if (isInstalledSoftware(coinRec)) return

  const blockchain = coinRec.code

  const supervisorConfig = `[program:${blockchain}]
command=nice ${cmd}
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/${blockchain}.err.log
stdout_logfile=/var/log/supervisor/${blockchain}.out.log
environment=HOME="/root"
`

  writeFile(`/etc/supervisor/conf.d/${coinRec.code}.conf`, supervisorConfig)
}

function isInstalledSoftware (coinRec) {
  return fs.existsSync(`/etc/supervisor/conf.d/${coinRec.code}.conf`)
}

function fetchAndInstall (coinRec) {
  if (isInstalledSoftware(coinRec)) return

  const binaries = BINARIES[coinRec.cryptoCode]
  if (!binaries) throw new Error(`No such coin: ${coinRec.code}`)

  const url = binaries.url
  const downloadFile = path.basename(url)
  const binDir = binaries.dir

  es(`wget -q ${url}`)
  es(`tar -xzf ${downloadFile}`)

  if (_.isEmpty(binaries.files)) {
    es(`sudo cp ${binDir}/* /usr/local/bin`)
    return
  }

  _.forEach(([source, target]) => {
    es(`sudo cp ${binDir}/${source} /usr/local/bin/${target}`)
  }, binaries.files)
}

function writeFile (path, content) {
  try {
    fs.writeFileSync(path, content)
  } catch (err) {
    if (err.code === 'EEXIST') {
      logger.info(`${path} exists, skipping.`)
      return
    }

    throw err
  }
}
<commit_msg>chore: update zec, geth nodes<commit_after>const crypto = require('crypto')
const os = require('os')
const path = require('path')
const cp = require('child_process')
const fs = require('fs')

const _ = require('lodash/fp')

const logger = require('console-log-level')({level: 'info'})

module.exports = {
  es,
  writeSupervisorConfig,
  firewall,
  randomPass,
  fetchAndInstall,
  logger,
  isInstalledSoftware,
  writeFile
}

const BINARIES = {
  BTC: {
    url: 'https://bitcoincore.org/bin/bitcoin-core-0.21.1/bitcoin-0.21.1-x86_64-linux-gnu.tar.gz',
    dir: 'bitcoin-0.21.1/bin'
  },
  ETH: {
    url: 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.4-aa637fd3.tar.gz',
    dir: 'geth-linux-amd64-1.10.4-aa637fd3'
  },
  ZEC: {
    url: 'https://z.cash/downloads/zcash-4.4.1-linux64-debian-stretch.tar.gz',
    dir: 'zcash-4.4.1/bin'
  },
  DASH: {
    url: 'https://github.com/dashpay/dash/releases/download/v0.17.0.3/dashcore-0.17.0.3-x86_64-linux-gnu.tar.gz',
    dir: 'dashcore-0.17.0/bin'
  },
  LTC: {
    url: 'https://download.litecoin.org/litecoin-0.18.1/linux/litecoin-0.18.1-x86_64-linux-gnu.tar.gz',
    dir: 'litecoin-0.18.1/bin'
  },
  BCH: {
    url: 'https://github.com/bitcoin-cash-node/bitcoin-cash-node/releases/download/v23.0.0/bitcoin-cash-node-23.0.0-x86_64-linux-gnu.tar.gz',
    dir: 'bitcoin-cash-node-23.0.0/bin',
    files: [['bitcoind', 'bitcoincashd'], ['bitcoin-cli', 'bitcoincash-cli']]
  }
}

function firewall (ports) {
  if (!ports || ports.length === 0) throw new Error('No ports supplied')
  const portsString = ports.join(',')
  es(`sudo ufw allow ${portsString}`)
}

function randomPass () {
  return crypto.randomBytes(32).toString('hex')
}

function es (cmd) {
  const env = {HOME: os.userInfo().homedir}
  const options = {encoding: 'utf8', env}
  const res = cp.execSync(cmd, options)
  logger.debug(res)
  return res.toString()
}

function writeSupervisorConfig (coinRec, cmd) {
  if (isInstalledSoftware(coinRec)) return

  const blockchain = coinRec.code

  const supervisorConfig = `[program:${blockchain}]
command=nice ${cmd}
autostart=true
autorestart=true
stderr_logfile=/var/log/supervisor/${blockchain}.err.log
stdout_logfile=/var/log/supervisor/${blockchain}.out.log
environment=HOME="/root"
`

  writeFile(`/etc/supervisor/conf.d/${coinRec.code}.conf`, supervisorConfig)
}

function isInstalledSoftware (coinRec) {
  return fs.existsSync(`/etc/supervisor/conf.d/${coinRec.code}.conf`)
}

function fetchAndInstall (coinRec) {
  if (isInstalledSoftware(coinRec)) return

  const binaries = BINARIES[coinRec.cryptoCode]
  if (!binaries) throw new Error(`No such coin: ${coinRec.code}`)

  const url = binaries.url
  const downloadFile = path.basename(url)
  const binDir = binaries.dir

  es(`wget -q ${url}`)
  es(`tar -xzf ${downloadFile}`)

  if (_.isEmpty(binaries.files)) {
    es(`sudo cp ${binDir}/* /usr/local/bin`)
    return
  }

  _.forEach(([source, target]) => {
    es(`sudo cp ${binDir}/${source} /usr/local/bin/${target}`)
  }, binaries.files)
}

function writeFile (path, content) {
  try {
    fs.writeFileSync(path, content)
  } catch (err) {
    if (err.code === 'EEXIST') {
      logger.info(`${path} exists, skipping.`)
      return
    }

    throw err
  }
}
<|endoftext|>


<commit_before>(function(){

  var tags = $("div.google-dfp");

  if(tags.length == 0)
    return; // nothing to do

  // initialize googletag-variable
  window.googletag = window.googletag || {};
  var googletag = window.googletag;
  googletag.cmd = [];

  // Load script
  $.getScript( document.location.protocol + '//www.googletagservices.com/tag/js/gpt.js');

  // async commands
  googletag.cmd.push(function() {

    // define slots
    tags.each(function(){
      var $this = $(this);
      googletag.defineSlot( $this.data('unit'), [$this.width(), $this.height()], this.id).addService(googletag.pubads());
    })

    // enable services
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();

    // display ads
    tags.each(function(){
      googletag.display(this.id);
    })
  });

})();
<commit_msg>Caching enabled<commit_after>(function(){

  var tags = $("div.google-dfp");

  if(tags.length == 0)
    return; // nothing to do

  // initialize googletag-variable
  window.googletag = window.googletag || {};
  var googletag = window.googletag;
  googletag.cmd = [];

  // Load script
  $.ajax({
    dataType: "script",
    cache: true,
    url: '//www.googletagservices.com/tag/js/gpt.js'
  });

  // async commands
  googletag.cmd.push(function() {

    // define slots
    tags.each(function(){
      var $this = $(this);
      googletag.defineSlot( $this.data('unit'), [$this.width(), $this.height()], this.id).addService(googletag.pubads());
    })

    // enable services
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();

    // display ads
    tags.each(function(){
      googletag.display(this.id);
    })
  });

})();
<|endoftext|>


<commit_before>import PropTypes from 'prop-types';
import { pick } from 'ramda';

/* eslint-disable padding-line-between-statements, newline-after-var */
export const EDIT_SHORT_URL_TAGS_START = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_START';
export const EDIT_SHORT_URL_TAGS_ERROR = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_ERROR';
export const EDIT_SHORT_URL_TAGS = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS';
export const RESET_EDIT_SHORT_URL_TAGS = 'shlink/shortUrlTags/RESET_EDIT_SHORT_URL_TAGS';
export const SHORT_URL_TAGS_EDITED = 'shlink/shortUrlTags/SHORT_URL_TAGS_EDITED';
/* eslint-enable padding-line-between-statements, newline-after-var */

export const shortUrlTagsType = PropTypes.shape({
  shortCode: PropTypes.string,
  tags: PropTypes.arrayOf(PropTypes.string).isRequired,
  saving: PropTypes.bool.isRequired,
  error: PropTypes.bool.isRequired,
});

const defaultState = {
  shortCode: null,
  tags: [],
  saving: false,
  error: false,
};

export default function reducer(state = defaultState, action) {
  switch (action.type) {
    case EDIT_SHORT_URL_TAGS_START:
      return {
        ...state,
        saving: true,
        error: false,
      };
    case EDIT_SHORT_URL_TAGS_ERROR:
      return {
        ...state,
        saving: false,
        error: true,
      };
    case EDIT_SHORT_URL_TAGS:
      return {
        ...pick([ 'shortCode', 'tags' ], action),
        saving: false,
        error: false,
      };
    case RESET_EDIT_SHORT_URL_TAGS:
      return defaultState;
    default:
      return state;
  }
}

export const editShortUrlTags = (buildShlinkApiClient) => (shortCode, tags) => async (dispatch, getState) => {
  dispatch({ type: EDIT_SHORT_URL_TAGS_START });
  const { selectedServer } = getState();
  const shlinkApiClient = buildShlinkApiClient(selectedServer);

  try {
    const normalizedTags = await shlinkApiClient.updateShortUrlTags(shortCode, tags);

    dispatch({ tags: normalizedTags, shortCode, type: EDIT_SHORT_URL_TAGS });
  } catch (e) {
    dispatch({ type: EDIT_SHORT_URL_TAGS_ERROR });

    throw e;
  }
};

export const resetShortUrlsTags = () => ({ type: RESET_EDIT_SHORT_URL_TAGS });

export const shortUrlTagsEdited = (shortCode, tags) => ({
  tags,
  shortCode,
  type: SHORT_URL_TAGS_EDITED,
});
<commit_msg>Refactored shortUrlTags reducer to take advantage of redux-actions<commit_after>import { createAction, handleActions } from 'redux-actions';
import PropTypes from 'prop-types';
import { pick } from 'ramda';

/* eslint-disable padding-line-between-statements */
export const EDIT_SHORT_URL_TAGS_START = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_START';
export const EDIT_SHORT_URL_TAGS_ERROR = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_ERROR';
export const EDIT_SHORT_URL_TAGS = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS';
export const RESET_EDIT_SHORT_URL_TAGS = 'shlink/shortUrlTags/RESET_EDIT_SHORT_URL_TAGS';
export const SHORT_URL_TAGS_EDITED = 'shlink/shortUrlTags/SHORT_URL_TAGS_EDITED';
/* eslint-enable padding-line-between-statements */

export const shortUrlTagsType = PropTypes.shape({
  shortCode: PropTypes.string,
  tags: PropTypes.arrayOf(PropTypes.string).isRequired,
  saving: PropTypes.bool.isRequired,
  error: PropTypes.bool.isRequired,
});

const defaultState = {
  shortCode: null,
  tags: [],
  saving: false,
  error: false,
};

export default handleActions({
  [EDIT_SHORT_URL_TAGS_START]: (state) => ({ ...state, saving: true, error: false }),
  [EDIT_SHORT_URL_TAGS_ERROR]: (state) => ({ ...state, saving: false, error: true }),
  [EDIT_SHORT_URL_TAGS]: (state, action) => ({ ...pick([ 'shortCode', 'tags' ], action), saving: false, error: false }),
  [RESET_EDIT_SHORT_URL_TAGS]: () => defaultState,
}, defaultState);

export const editShortUrlTags = (buildShlinkApiClient) => (shortCode, tags) => async (dispatch, getState) => {
  dispatch({ type: EDIT_SHORT_URL_TAGS_START });
  const { selectedServer } = getState();
  const shlinkApiClient = buildShlinkApiClient(selectedServer);

  try {
    const normalizedTags = await shlinkApiClient.updateShortUrlTags(shortCode, tags);

    dispatch({ tags: normalizedTags, shortCode, type: EDIT_SHORT_URL_TAGS });
  } catch (e) {
    dispatch({ type: EDIT_SHORT_URL_TAGS_ERROR });

    throw e;
  }
};

export const resetShortUrlsTags = createAction(RESET_EDIT_SHORT_URL_TAGS);

export const shortUrlTagsEdited = (shortCode, tags) => ({
  tags,
  shortCode,
  type: SHORT_URL_TAGS_EDITED,
});
<|endoftext|>


<commit_before>function processAxeCheckResults(error, results) {
  if (error) {
    console.log('Error executing the Axe check!');
    console.log(error);
    return;
  } else if (results.violations.length === 0) {
    return;
  }

  var bannerEl = document.createElement('div');

  var details = '';
  details += '
There are (' + results.violations.length + ') accessibility issues on this page.
';

  var violationsList = '
';

  results.violations.forEach(function(violation) {
    var violationEl = '
';

    violationEl += '';
    violationEl += '' + violation.help + '';
    violationEl += '
';

    violationEl += '
Description: ' + violation.description + '
';
    violationEl += '
Impact: ' + violation.impact + '
';
    violationEl += '
Tags: ' + violation.tags.join(', ') + '
';
    violationEl += '
Help: ' + violation.helpUrl + '
';

    var nodeList = '
HTML:';
    nodeList += '
';

    violation.nodes.forEach(function(node) {
      var nodeEl = '
';
      var code = document.createElement('code');

      code.innerText = node.html;
      nodeEl += code.outerHTML + '
';

      nodeList += nodeEl;
    });

    nodeList += '

';
    violationEl += nodeList;

    violationEl += '
';
    violationEl += '';
    violationEl += '
';

    violationsList += violationEl;
  });

  violationsList += '
';

  details += violationsList;
  details += '';

  bannerEl.innerHTML = details;

  const header = document.querySelector('header');

  header.prepend(bannerEl, header.firstChild);
}

(function executeAxeCheck() {
  axe.run(
    'main',
    {
      iframes: false,
      runOnly: {
        type: 'tag',
        values: ['section508', 'wcag2a', 'wcag2aa', 'best-practice'],
        resultTypes: ['violations'],
      },
      rules: {
        'color-contrast': { enabled: false },
      },
    }, processAxeCheckResults);
})();
<commit_msg>Adding regex to remove violation.help brackets for better rendering. (#11285)<commit_after>function sanitizeString(dirtyString, elem) {
  var sanitizedString = document.createElement(elem);
  sanitizedString.innerText = dirtyString;

  return sanitizedString.outerHTML;
}

function processAxeCheckResults(error, results) {
  if (error) {
    console.log('Error executing the Axe check!');
    console.log(error);
    return;
  } else if (results.violations.length === 0) {
    return;
  }

  var bannerEl = document.createElement('div');

  var details = '';
  details += '
There are (' + results.violations.length + ') accessibility issues on this page.
';

  var violationsList = '
';

  results.violations.forEach(function(violation) {
    var violationEl = '
';

    violationEl += '';
    violationEl += '' + sanitizeString(violation.help, 'strong') + '';
    violationEl += '
';

    violationEl += '
Description: ' + sanitizeString(violation.description, 'span') + '
';
    violationEl += '
Impact: ' + sanitizeString(violation.impact, 'span') + '
';
    violationEl += '
Tags: ' + sanitizeString(violation.tags.join(', '), 'span') + '
';
    violationEl += '
Help: ' + sanitizeString(violation.helpUrl, 'span') + '
';

    var nodeList = '
HTML:';
    nodeList += '
';

    violation.nodes.forEach(function(node) {
      var nodeEl = '
';
      nodeEl += sanitizeString(node.html, 'code');
      nodeList += nodeEl;
    });

    nodeList += '

';
    violationEl += nodeList;

    violationEl += '
';
    violationEl += '';
    violationEl += '
';

    violationsList += violationEl;
  });

  violationsList += '
';

  details += violationsList;
  details += '';

  bannerEl.innerHTML = details;

  const header = document.querySelector('header');

  header.prepend(bannerEl, header.firstChild);
}

(function executeAxeCheck() {
  axe.run(
    'main',
    {
      iframes: false,
      runOnly: {
        type: 'tag',
        values: ['section508', 'wcag2a', 'wcag2aa', 'best-practice'],
        resultTypes: ['violations'],
      },
      rules: {
        'color-contrast': { enabled: false },
      },
    }, processAxeCheckResults);
})();
<|endoftext|>