Add remote javascript file

@param string $url
@return AbstractCompiler
@throws Exception\InvalidArgumentException
339167
public function addRemoteFile($url)
    {
        if (!filter_var($url, FILTER_VALIDATE_URL)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'The url "%s" is not valid.',
                $url
            ));
        }

        $this->files[] = (string) $url;

        return $this;
    }
176184
public function addFooterScript($url)
    {
        $url = self::resolveUrl($url);
        if ($url) {
            $this->footerScripts[self::hashResource($url)] = $url;
        }
    }
802710
public function setButtonExport(string $url = null): ButtonInterface
    {
        $addUrl = 'export=1';
        if (!$url) {
            $url = url()->current();
        }
        if ($array = request()->except('export')) {
            $url .= '?' . http_build_query($array);
        }
        $addUrl = \Illuminate\Support\Str::is('*?*', $url) ? '&' . $addUrl : '?' . $addUrl;
        $text = GridView::trans('grid.export');

        return $this->setActionCustom($url . $addUrl, $text, 'btn btn-default btn-outline-primary', 'fa fa-download')
            ->setAction(self::TYPE_ACTION_EXPORT)
            ->setId('js_amiExportButton');
    }
1095078
public function addJsUrl($url, $defer = false, $async = false)
    {
        if (!in_array($url, $this->js_urls)) {
            $this->js_urls[++$this->js_sequence] = $url;
            if ($defer) {
                $this->deferred_scripts[$this->js_sequence] = $this->js_sequence;
            }
            if ($async) {
                $this->async_scripts[$this->js_sequence] = $this->js_sequence;
            }
        }

        return $this;
    }
183986
public function add($name, $url, $options = array())
    {
        $subcmd = new AddSubCommand();
        $subcmd->prepare($name, $url, $options);

        return $this->remote($subcmd);
    }
480779
public function setUrl(?string $url): void
	{
		if ($this->locale === null) {
			throw new InvalidArgumentException('Locale must be set before calling setUrl');
		}
		if ($this->isLink === null) {
			throw new InvalidArgumentException("'isLink' must be set before calling setUrl");
		}
		if (!$this->isLink && Strings::match($url, '/[^A-Za-z0-9_-]/')) {
			throw new InvalidArgumentException('URL contains invalid characters');
		}

		$completeUrl = !$this->isLink && $this->parent && $url !== null ?
			$this->parent->completeUrl . '/' . $url
			: $url;

		/* @var $repository PagesRepository */
		$repository = $this->getRepository();
		$page = $repository->getByUrl($completeUrl, $this->locale->name);
		if ($page !== null && $page !== $this) {
			throw new UniqueConstraintViolationException("Page with '$url' exists");
		}
		$this->url = $url;
	}
1130246
public function addAsyncJs($relativeUrl, string $moduleNamespace = null, $prepend = false) {
		if ($moduleNamespace === null) {
			$moduleNamespace = $this->view->getModuleNamespace();
		}
		
		$this->addAsyncJsUrl($this->view->getHttpContext()->getAssetsUrl($moduleNamespace)->ext($relativeUrl), (boolean) $prepend);
		
		return $this;
	}
762015
public function &file($url, $defer = false, $is_external = false)
    {
        // Do not add files already added
        if (in_array($url, $this->files_used)) {
            Throw new PageException(sprintf('Url "%s" is already set as included js file.', $url));
        }

        $dt = debug_backtrace();

        $this->files_used[$this->filecounter . '-' . $dt[1]['function']] = $url;
        $this->filecounter ++;

        $script = new JavascriptObject();

        $script->setType('file');
        $script->setScript($url);
        $script->setIsExternal($is_external);
        $script->setDefer($defer);

        $this->add($script);

        return $script;
    }
688736
protected function _locate($url)
    {
        if(!isset($this->_locations[$url]))
        {
            //Locate the template
            if (!$file = $this->getObject('template.locator.factory')->locate($url)) {
                throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url));
            }

            $this->_locations[$url] = $file;
        }

        return $this->_locations[$url];
    }
158060
public function add(FileAssetInterface $asset)
    {
        if (!$asset->getPackageName()) {
            // Deprecated.
            $asset->setPackageName('extensions');
        }

        $key = $asset->getPackageName()."/".$asset->getPath();

        if ($asset->getType() === 'javascript') {
            $this->javascript[$key] = $asset;
        } elseif ($asset->getType() === 'stylesheet') {
            $this->stylesheet[$key] = $asset;
        } else {
            throw new \InvalidArgumentException(sprintf('Requested asset type %s is not valid.', $asset->getType()));
        }
    }
696375
public function setUrl($url)
    {
        if (strlen($url) == 0) {
            throw new \InvalidArgumentException(sprintf('Enclosure URL should not be empty'));
        }

        $this->url = $url;

        return $this;
    }
230008
public function setVersionUrl($url)
    {
        if (!$this->validateAllowedUrl($url)) {
            throw new InvalidArgumentException(
                sprintf('Invalid url passed as argument: %s.', $url)
            );
        }
        $this->versionUrl = $url;
    }
83546
protected function generateCallback($url = [])
    {
        if (empty($url)) {
            $url = $this->authChoice->createClientUrl($this->client);
        } else {
            $url = Url::to($url);
        }
        if (strpos($url, '?') === false) {
            $url .= '?';
        } else {
            $url .= '&';
        }

        $callbackName = 'googleSignInCallback' . md5($this->id);
        $js = <<<JS
function $callbackName(authResult) {
    var urlParams = [];

    if (authResult['code']) {
        urlParams.push('code=' + encodeURIComponent(authResult['code']));
    } else if (authResult['error']) {
        if (authResult['error'] == 'immediate_failed') {
            return;
        }
        urlParams.push('error=' + encodeURIComponent(authResult['error']));
        urlParams.push('error_description=' + encodeURIComponent(authResult['error_description']));
    } else {
        for (var propName in authResult) {
            var propValue = authResult[propName];
            if (typeof propValue != 'object') {
                urlParams.push(encodeURIComponent(propName) + '=' + encodeURIComponent(propValue));
            }
        }
    }

    window.location = '$url' + urlParams.join('&');
}
JS;
        $this->view->registerJs($js, View::POS_END, __CLASS__ . '#' . $this->id);

        return $callbackName;
    }
1298011
public function setButtonCreate(string $url): ButtonInterface
    {
        $text = GridView::trans('grid.create');

        return $this->setActionCustom($url, $text, 'btn btn-primary btn-outline-primary', 'fa fa-plus')
            ->setAction(self::TYPE_ACTION_CREATE);
    }
355327
public function setUrl($url)
    {
      if(!is_string($url) && strlen(trim($url)) == 0)
        throw new InvalidArgumentException(__METHOD__ . '; Invalid url, must be a non empty string');

      $this->url = $url;
    }
167051
public function addScript($url, $type="text/javascript", $attribs = array()) {
		$this->_scripts[$url]['type'] = $type;
		$this->_scripts[$url]['attribs'] = $attribs;
	}
1005892
public function addJsUrl(string $url): PageHead
    {
        if (!in_array($url, $this->js_urls, true)) {
            $this->js_urls[++$this->js_sequence] = $url;
        }

        return $this;
    }