How to use the global/window.location function in global

To help you get started, we’ve selected a few global examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github videojs / video.js / src / js / cdn.js View on Github external
var sendGaEvent = function(image) {
  const i = new window.Image();
  const w = window;
  const n = window.navigator;
  const l = window.location;
  const e = window.encodeURIComponent;

  // Google Analytics has a limit of 10 million hits per month for free accounts.
  // The Video.js CDN goes over this (by a lot) and they've asked us to stop.
  if (Math.random() > 0.01) {
    return;
  }

  // Setting the source of an image will load the URL even without adding to dom
  // Using //www, still seems to work for https even though ssl.google is used by google
  i.src='//www.google-analytics.com/__utm.gif'
    // Version
    +'?utmwv=5.4.2'
    // ID
    +'&utmac=UA-16505296-2'
    // Sessions
github videojs / video.js / test / unit / lib.js View on Github external
test('should parse the details of a url correctly', function(){
  equal(Lib.parseUrl('#').protocol, window.location.protocol, 'parsed relative url protocol');
  equal(Lib.parseUrl('#').host, window.location.host, 'parsed relative url host');

  equal(Lib.parseUrl('http://example.com').protocol, 'http:', 'parsed example url protocol');
  equal(Lib.parseUrl('http://example.com').hostname, 'example.com', 'parsed example url hostname');

  equal(Lib.parseUrl('http://example.com:1234').port, '1234', 'parsed example url port');
});
github rahatarmanahmed / nanopush / test / client / mainView.js View on Github external
test.before(() => {
  window.location = {
    origin: 'http://localhost:3000'
  }
})
github videojs / http-streaming / test / test-helpers.js View on Github external
export const absoluteUrl = function(relativeUrl) {
  return URLToolkit.buildAbsoluteURL(window.location.href, relativeUrl);
};
github videojs / videojs.com / _src-js / advanced.js View on Github external
player.on('loadstart', function() {
  const pl = player.playlist();
  const plitem = pl[player.playlist.currentItem()];

  window.location.hash = plitem.id;

  player.mux.emit('videochange', {
    video_id: plitem.id,
    video_title: plitem.name,
    video_duration: plitem.duration,
  });
});
github fathomlabs / open-retractions / bundle.js View on Github external
function createLocation () {
  var pathname = window.location.pathname.replace(/\/$/, '')
  var hash = window.location.hash.replace(/^#/, '/')
  return pathname + hash
}
github rahatarmanahmed / nanopush / client / app.js View on Github external
Try it out! Run this command to see if it works
        <p></p>
        <div class="code pa2 br2 bg-dark-green light-blue">
          curl '${window.location.href}${state.token}/notify?title=nanopush&amp;body=This%20is%20a%20test'
        </div>
      

      ${Divider(true)}

      <section class="mv4">
        <h2 class="f4 fw7 mb2 lh-title">
          API
        </h2>

        <h3 class="code f5 fw7 mt0 mb1 lh-copy">
          GET ${window.location.href}${state.token}/notify
        </h3>
        <p class="ml2 mv1">
          Takes parameters by query string.
        </p>

        <h3 class="code f5 fw7 mt2 mb1 lh-copy">
          POST ${window.location.href}${state.token}/notify
        </h3>
        <p class="ml2 mv1">
          Takes parameters by JSON body.
        </p>

        <h4 class="f5 fw7 mt3 mb1">
          Parameters
        </h4>
        <ul class="list mv1"></ul></section>
github mediaelement / mediaelement / src / js / renderers / youtube.js View on Github external
youtubeSettings = {
				id: youtube.id,
				containerId: youtubeContainer.id,
				videoId: videoId,
				height: height,
				width: width,
				playerVars: Object.assign({
					controls: 0,
					rel: 0,
					disablekb: 1,
					showinfo: 0,
					modestbranding: 0,
					html5: 1,
					iv_load_policy: 3
				}, youtube.options.youtube),
				origin: window.location.host,
				events: {
					onReady: (e) =&gt; {
						mediaElement.youTubeApi = youTubeApi = e.target;
						mediaElement.youTubeState = {
							paused: true,
							ended: false
						};

						if (apiStack.length) {
							for (let i = 0, total = apiStack.length; i &lt; total; i++) {

								const stackItem = apiStack[i];

								if (stackItem.type === 'set') {
									const
										propName = stackItem.propName,
github rahatarmanahmed / nanopush / client / mainView.js View on Github external
module.exports = (state, send) =&gt; {
  function resetToken (e) {
    e.preventDefault()
    if (window.confirm(`Are you sure you want to reset your token? This is permanent and can't be undone.`)) {
      send('resetToken')
    }
  }

  return yo`
    <div class="measure">
      <section class="mv4">
        <p class="lh-copy">
          Your push notification URL is:
        </p>
        <div class="code pa2 br2 bg-dark-green light-blue overflow-y-scroll nowrap">
          ${window.location.href}${state.token}/notify
        </div>

        <p class="lh-copy">
          You can receive notifications when you send a request to that URL, even when this page isn't open. This URL will stay the same (even if you refresh) until you clear your browser data. If you want a new token, <a class="link underline hover-light-blue pointer">click here</a>.
        </p>
      </section>

      ${Divider(false)}

      <section class="mv4">
        <p class="lh-copy">
          Try it out! Run this command to see if it works
        </p>
        <div class="code pa2 br2 bg-dark-green light-blue">
          curl '${window.location.href}${state.token}/notify?title=nanopush&amp;body=This%20is%20a%20test'
        </div></section></div>
github yoshuawuyts / sheet-router / href.js View on Github external
var node = (function traverse (node) {
      if (!node || node === root) return
      if (node.localName !== 'a') return traverse(node.parentNode)
      if (node.href === undefined) return traverse(node.parentNode)
      if (window.location.host !== node.host) return traverse(node.parentNode)
      return node
    })(e.target)