This will add a javascript view to $this->obj->script
Chainable

@param string $path
@param string $mode
@return string|false
968115
public function add_js(){
    $args = \func_get_args();
    $has_path = false;
    foreach ( $args as $i => $a ){
      if ( $new_data = $this->retrieve_var($a) ){
        $this->js_data($new_data);
      }
      else if ( \is_string($a) ){
        $has_path = 1;
      }
      else if ( \is_array($a) ){
        $this->js_data($a);
      }
    }
    if ( !$has_path ){
      array_unshift($args, $this->path);
    }
    $args[] = 'js';
    if ( $r = $this->get_view(...$args) ){
      $this->add_script($r);
    }
    return $this;
  }
274039
private function _getCurlHandler($path, $mode) 
    {
        $url = $this->_getJsonPath($path);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT, $this->_timeout);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->_timeout);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $mode);
        curl_setopt($ch, CURLOPT_HEADER, true);
        return $ch;
    }
845293
public function script($path, $options = array()) {
		$options = array_merge(array('block' => 'script'), $options);
		$this->_append('js', $path, $options);
	}
698458
protected function upload(string $path, $contents, string $mode)
    {
        $path = $this->applyPathPrefix($path);

        try {
            $object = $this->client->upload($path, $contents, $mode);
        } catch (BadRequest $e) {
            return false;
        }

        return $this->normalizeResponse($object);
    }
668047
private function javascript($path)
	{
		$response = Response::make(Asset::javascript($path), 200);

		$response->header('Content-Type', 'application/javascript');

		return $response;
	}
1370200
public function stream_open($path, $mode, $options, &$opened_path)
	{
		$this->path = $path;
		$this->resource = fopen($this->getLocalFilesystemPath($path), $mode);
		
		return is_resource($this->resource);
	}
944807
public function get_route($path, $mode, $root = null){
    return $this->router->route($path, $mode, $root);
  }
717145
public function writeFile($path, $content, $mode = 0666)
    {
        $this->getFilesystem()->dumpFile($path, $content, $mode);

        return $this;
    }
158619
public function stream_open($path, $mode, $options, &$opened_path)
    {
        if ($this->fileHandle !== null) {
            return false;
        }
        self::restore();
        $path = self::overlayPath($path);
        $this->fileHandle = fopen($path, $mode, (bool)($options & STREAM_USE_PATH));
        self::register();
        return $this->fileHandle !== false;
    }
934384
protected function getStream($path, $mode)
    {
        switch ($mode[0]) {
            case 'r':
                $this->needsCowCheck = true;

                return $this->getFilesystem()->readStream($path);

            case 'w':
                $this->needsFlush = true;

                return fopen('php://temp', 'w+b');

            case 'a':
                return $this->getAppendStream($path);

            case 'x':
                return $this->getXStream($path);

            case 'c':
                return $this->getWritableStream($path);
        }

        return false;
    }
716842
public function stream_open($path, $mode, $options, &$openedPath)
    {
        $container = $this->getContainerFromContext($path);
        $path = $this->stripScheme($path);

        $mode = str_split(str_replace('b', '', $mode));

        $accessDeniedError = function () use ($path, $options) {
            if ($options & STREAM_REPORT_ERRORS) {
                trigger_error(sprintf('fopen(%s): failed to open stream: Permission denied', $path), E_USER_WARNING);
            }

            return false;
        };

        $appendMode = in_array('a', $mode);
        $readMode = in_array('r', $mode);
        $writeMode = in_array('w', $mode);
        $extended = in_array('+', $mode);

        if (!$container->hasNodeAt($path)) {
            if ($readMode || !$container->hasNodeAt(dirname($path))) {
                if ($options & STREAM_REPORT_ERRORS) {
                    trigger_error(sprintf('%s: failed to open stream.', $path), E_USER_WARNING);
                }

                return false;
            }
            $parent = $container->directoryAt(dirname($path));
            $permissionHelper = $container->getPermissionHelper($parent);
            if (!$permissionHelper->isWritable()) {
                return $accessDeniedError();
            }
            $parent->addFile($container->factory()->getFile(basename($path)));
        }

        $file = $container->nodeAt($path);

        if ($file instanceof Link) {
            $file = $file->getDestination();
        }

        if (($extended || $writeMode || $appendMode) && $file instanceof Directory) {
            if ($options & STREAM_REPORT_ERRORS) {
                trigger_error(sprintf('fopen(%s): failed to open stream: Is a directory', $path), E_USER_WARNING);
            }

            return false;
        }

        if ($file instanceof Directory) {
            $dir = $file;
            $file = $container->factory()->getFile('tmp');
            $file->chmod($dir->mode());
            $file->chown($dir->user());
            $file->chgrp($dir->group());
        }

        $permissionHelper = $container->getPermissionHelper($file);

        $this->currentlyOpenedFile = new FileHandler();
        $this->currentlyOpenedFile->setFile($file);

        if ($extended) {
            if (!$permissionHelper->isReadable() || !$permissionHelper->isWritable()) {
                return $accessDeniedError();
            }
            $this->currentlyOpenedFile->setReadWriteMode();
        } elseif ($readMode) {
            if (!$permissionHelper->isReadable()) {
                return $accessDeniedError();
            }
            $this->currentlyOpenedFile->setReadOnlyMode();
        } else { // a or w are for write only
            if (!$permissionHelper->isWritable()) {
                return $accessDeniedError();
            }
            $this->currentlyOpenedFile->setWriteOnlyMode();
        }

        if ($appendMode) {
            $this->currentlyOpenedFile->seekToEnd();
        } elseif ($writeMode) {
            $this->currentlyOpenedFile->truncate();
            clearstatcache();
        }

        $openedPath = $file->path();

        return true;
    }
1132470
public function script(String $path) : String
    {
        if( ! IS::url($path) )
        {
            $path = Request::getBaseURL(Base::suffix($path, '.js'));
        }

        $attributes['href'] = $path;
        $attributes['type'] = 'text/javascript';

        return $this->_singleElement(__FUNCTION__, $attributes);
    }
924968
public function filePermission($path, $mode = self::CHMOD_775)
    {
        $results = array();
        $success = 0;
        if(file_exists($path)) {
            if(!is_writable($path))
                chmod($path, $mode);

            if(!is_readable($path))
                chmod($path, $mode);

            if(is_readable($path) && is_writable($path))
                $status = 1;
        }

        $results = array(
            'path' => $path,
            'mode' => $mode,
            'success' => $success
        );

        return Json::encode($results);
    }
1182118
public static function addLink (string $linkPath) {
		if(preg_match("/\b.js\b/",$linkPath)) {
			$type = "js";
		}
		else if (preg_match("/\b.css\b/",$linkPath)) {
			$type = "css";
		}
		else if (preg_match("/(\b.(tiff|otf|ttf)\b)/",$linkPath)) {
			$type = "font";
		}

		preg_match("/\b(?!.*\/)\S*\.(tiff|otf|ttf|js|css)?\?*\b/",$linkPath,$matches);

		if (count($matches) == 0) {
			return false;

			if (kmd_debugMode)
				error_log(date("d-m-Y H:i:s")." - Controller did not find any match for the following path: ".$linkPath);
		}

		if (debug_backtrace()[1]["class"] == "PageController")
			Blender::$pageLinks[$type][$matches[0]] = $linkPath;
		else
			Blender::$sectionLinks[$type][$matches[0]] = $linkPath;
	}
1197410
public function script($src, $version=false){

        $list = [];

        foreach((array)$src as $script) {

            $type = 'text/javascript';
            $src  = $script;
            $load = '';

            if (is_array($script)) {
                extract($script);
            }

            $ispath = strpos($src, ':') !== false && !preg_match('#^(|http\:|https\:)//#', $src);
            $list[] = '<script src="'.($ispath ? $this->pathToUrl($src):$src).($version ? "?ver={$version}":"").'" type="'.$type.'" '.$load.'></script>';
        }

        return implode("\n", $list);
    }
1046515
function _mkdir($path, $mode = 0777)
    {
        $old = umask(0);
        $res = @mkdir($path, $mode);
        umask($old);

        return $res;
    }
1262354
public function include_script($path, $replace = false)
    {
        $this->last_selector = null;

        return $this->cmd(10, array(
            'j',
            $path,
            $replace
        ));
    }