Get script object based on the `src` URL
330078
function getScriptFromUrl(url, eligibleScripts) {
  var i,
      script = null;

  eligibleScripts = eligibleScripts || scripts;

  if (typeof url === "string" && url) {
    for (i = eligibleScripts.length; i--; ) {
      if (eligibleScripts[i].src === url) {
        // NOTE: Could check if the same script URL is used by more than one `script` element
        // here... but let's not. That would yield less useful results in "loose" detection. ;)
        script = eligibleScripts[i];
        break;
      }
    }
  }
  return script;
}
410828
def load_script(self, source_name, timeoutMilliseconds=0):
        

        script_path = os.path.join(self.scripts_dir_path,
                                   self._source_to_script_name(source_name))

        if os.path.isfile(script_path):
            return ScriptHook(script_path, timeoutMilliseconds)
        return None
1060711
function loadScript(src, loadedCallback) {
    var script = document.createElement("script");
    script.setAttribute("type", "text/javascript");
    script.setAttribute("src", src);

    // Call the callback when the script is loaded.
    script.onload = loadedCallback;
    script.onreadystatechange = function () {
      if (this.readyState === "complete" || this.readyState === "loaded") {
        loadedCallback();
      }
    };

    head.appendChild(script);
  }
207457
def _get_scripts_resource(pe):
    """"""
    res = None
    for entry in pe.DIRECTORY_ENTRY_RESOURCE.entries:
        if entry.name and entry.name.string == b"PYTHONSCRIPT":
            res = entry.directory.entries[0].directory.entries[0]
            break
    return res
561843
function (evt) {
                var data = getScriptData(evt);
                if (!hasPathFallback(data.id)) {
                    return onError(makeError('scripterror', 'Script error', evt, [data.id]));
                }
            }
982500
function getExportScriptUrl( $type ) {

		$url = false;

		$dir = Container::get( 'Styles' )->getDir();
		if ( Container::get( 'Styles' )->isCurrentThemeCompatible( 2 ) && realpath( "$dir/assets/scripts/$type/script.js" ) ) {
			$url = apply_filters( 'pb_stylesheet_directory_uri', get_stylesheet_directory_uri() ) . "/assets/scripts/$type/script.js";
		} elseif ( realpath( "$dir/export/$type/script.js" ) ) {
			$url = apply_filters( 'pb_stylesheet_directory_uri', get_stylesheet_directory_uri() ) . "/export/$type/script.js";
		}
		if ( CustomCss::isCustomCss() && CustomCss::isRomanized() && 'prince' === $type ) {
			$url = get_stylesheet_directory_uri() . "/export/$type/script-romanize.js";
		}

		return $url;
	}
886432
def get_executable_info
      if not (@servers.empty? )
        if (@script != nil)
          # If script is an uri/url no need to "detect it"
          # https://my.rightscale.com/acct/9202/right_scripts/205347
          if @script =~ /\A#{URI::regexp}\z/
            if not @use_chimpd || !@prompt
              puts "=================================================="
              puts "WARNING! You will be running this script on all "
              puts "server matches! (Press enter to continue)"
              puts "=================================================="
              gets
            end

            script_number = File.basename(@script)

            s = Executable.new
            s.delay = @delay

            s.params['right_script']['href']="right_script_href=/api/right_scripts/"+script_number
            #Make an 1.5 call to extract name, by loading resource.
            Log.debug "[#{Chimp.get_job_uuid}] Making API 1.5 call : client.resource(#{s.params['right_script']['href'].scan(/=(.*)/).last.last})"
            begin
              tries ||= 3
              the_name = Connection.client.resource(s.params['right_script']['href'].scan(/=(.*)/).last.last).name
            rescue
              Log.error "[#{Chimp.get_job_uuid}] Failed to make 1.5 call for rightscript href (retrying)"
              sleep 30
              retry unless (tries -= 1).zero?
              Log.error "[#{Chimp.get_job_uuid}] Failed to make 1.5 call for rightscript href (giving up)"
            end
            s.params['right_script']['name'] = the_name
            @executable = s
          else
            # If its not an url, go ahead try to locate it in the ST"
            @executable = detect_right_script(@server_template, @script)
          end
        else
          # @script could be nil because we want to run ssh
          if @action == :action_ssh
            puts "Using SSH command: \"#{@ssh}\"" if @action == :action_ssh
          end
        end
      end
    end
843413
def _get_src(tree_base, source, saltenv='base'):
    '''
    
    '''
    parsed = _urlparse(source)
    sbase = os.path.basename(source)
    dest = os.path.join(tree_base, sbase)
    if parsed.scheme:
        __salt__['cp.get_url'](source, dest, saltenv=saltenv)
    else:
        shutil.copy(source, dest)
1314106
function _getScriptElements($typeLazy) {
        var scripts;
        var src = $typeLazy.attr("src");
        if (!src) {
            src = $typeLazy.data("src");
        }
        if ("js" === _getExtension(src).toLowerCase()) {
            return $typeLazy;
        } else {
            if (requirejs && typeof requirejs.toUrl === "function") {
                src = requirejs.toUrl(src);
            }
            $.ajax({
                url: src,
                method: "GET",
                async: false,
                dataType: "html",
                success: function (data){
                    scripts = data;
                },
                error: function (data, status) {
                    console.error(TAG + "lazyLoad() ajax request failed. [status: " + status + "][src: " + src + "]");
                }
            });
            return $(scripts).find("script");
        }
    }
1261342
function get(scriptModule, agent, msg, cb) {
    const filename = msg.filename;
    if (!filename) {
        cb('empty filename');
        return;
    }

    fs.readFile(path.join(scriptModule.root, filename), 'utf-8', (err, data) => {
        if (err) {
            logger.error(`fail to read script file:${filename}, ${err.stack}`);
            cb(`fail to read script with name:${filename}`);
        }

        cb(null, data);
    });
}
578844
function importScript(src) {
  // Scan all search paths in order, trying to find the file.
  //var relPath = path.join(path.dirname(process.argv[1]) + '/', src);
  var filePath = src;//path.relative(process.cwd(), relPath);
  for (var n = 0; n < SEARCH_PATHS.length; n++) {
    var searchPath = path.join(process.cwd(), SEARCH_PATHS[n]);
    var searchFilePath = path.join(searchPath, filePath);
    if (fileExistsSync(searchFilePath)) {
      var sourceCode = fs.readFileSync(searchFilePath, 'utf8');
      try {
        vm.runInThisContext(sourceCode, searchFilePath);
      } catch (e) {
        console.log('Error running script ' + src);
        throw e;
      }
      return true;
    }
  }

  // File not found.
  console.log('ERROR: could not find ' + src);
  return false;
}
1222594
function extractScriptNames() {
  console.log("Extracting script file names from index.html");

  var regexScriptName = /<script src="(.*?)"><\/script>/g;
  var scriptSection = regexScriptSection.exec(indexFile)[1];

  // extract script names
  var names = []; 
  var match;
  while ((match = regexScriptName.exec(scriptSection)) != null) {
    var script = match[1];
    names.push(script);
  }
    
  return names;
}
43403
def url(self, var, default=NOTSET, force=True):
        """"""
        return self._get(var, default=default, cast=urlparse.urlparse,
                         force=force)
212853
function getScript(url, async, cb) {
    if (typeof async === 'function') {
      cb = async;
      async = false;
    }

    var el = document.createElement('script');

    // Script attributes
    el.type = 'text/javascript';
    el.src = url;

    // Should the script be loaded asynchronously?
    if (async)
      el.async = true;

    // Defining callbacks
    el.onload = el.onreadystatechange = function() {
      if ((!this.readyState ||
            this.readyState == 'loaded' ||
            this.readyState == 'complete')) {
        el.onload = el.onreadystatechange = null;

        // Removing element from head
        artoo.mountNode.removeChild(el);

        if (typeof cb === 'function')
          cb();
      }
    };

    // Appending the script to head
    artoo.mountNode.appendChild(el);
  }
577006
private Object getScriptResult(String script, ScriptEngine engine) throws ScriptException {
        String scriptToExecute = script.substring(script.indexOf(":") + 1);
        return engine.eval(scriptToExecute);
    }
906302
function getSoleInlineScript(eligibleScripts) {
  var i, len,
      script = null;
  eligibleScripts = eligibleScripts || scripts;
  for (i = 0, len = eligibleScripts.length; i < len; i++) {
    if (!eligibleScripts[i].hasAttribute("src")) {
      if (script) {
        script = null;
        break;
      }
      script = eligibleScripts[i];
    }
  }
  return script;
}
1100332
protected Content getFramesJavaScript() {
        HtmlTree scriptTree = HtmlTree.SCRIPT();
        String scriptCode = "\n" +
                "    tmpTargetPage = \"\" + window.location.search;\n" +
                "    if (tmpTargetPage != \"\" && tmpTargetPage != \"undefined\")\n" +
                "        tmpTargetPage = tmpTargetPage.substring(1);\n" +
                "    if (tmpTargetPage.indexOf(\":\") != -1 || (tmpTargetPage != \"\" && !validURL(tmpTargetPage)))\n" +
                "        tmpTargetPage = \"undefined\";\n" +
                "    targetPage = tmpTargetPage;\n" +
                "    function validURL(url) {\n" +
                "        try {\n" +
                "            url = decodeURIComponent(url);\n" +
                "        }\n" +
                "        catch (error) {\n" +
                "            return false;\n" +
                "        }\n" +
                "        var pos = url.indexOf(\".html\");\n" +
                "        if (pos == -1 || pos != url.length - 5)\n" +
                "            return false;\n" +
                "        var allowNumber = false;\n" +
                "        var allowSep = false;\n" +
                "        var seenDot = false;\n" +
                "        for (var i = 0; i < url.length - 5; i++) {\n" +
                "            var ch = url.charAt(i);\n" +
                "            if ('a' <= ch && ch <= 'z' ||\n" +
                "                    'A' <= ch && ch <= 'Z' ||\n" +
                "                    ch == '$' ||\n" +
                "                    ch == '_' ||\n" +
                "                    ch.charCodeAt(0) > 127) {\n" +
                "                allowNumber = true;\n" +
                "                allowSep = true;\n" +
                "            } else if ('0' <= ch && ch <= '9'\n" +
                "                    || ch == '-') {\n" +
                "                if (!allowNumber)\n" +
                "                     return false;\n" +
                "            } else if (ch == '/' || ch == '.') {\n" +
                "                if (!allowSep)\n" +
                "                    return false;\n" +
                "                allowNumber = false;\n" +
                "                allowSep = false;\n" +
                "                if (ch == '.')\n" +
                "                     seenDot = true;\n" +
                "                if (ch == '/' && seenDot)\n" +
                "                     return false;\n" +
                "            } else {\n" +
                "                return false;\n" +
                "            }\n" +
                "        }\n" +
                "        return true;\n" +
                "    }\n" +
                "    function loadFrames() {\n" +
                "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
                "             top.classFrame.location = top.targetPage;\n" +
                "    }\n";
        RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL));
        scriptTree.addContent(scriptContent);
        return scriptTree;
    }