src/Ease/WebPage.php
public function addToScriptsStack($code, $position = null)
    {
        $javaScripts = &$this->easeShared->javaScripts;
        if (is_null($position)) {
            if (is_array($javaScripts)) {
                $scriptFound = array_search($code, $javaScripts);
                if (!$scriptFound && ($javaScripts[0] != $code)) {
                    $javaScripts[] = $code;

                    return key($javaScripts);
                } else {
                    return $scriptFound;
                }
            } else {
                $javaScripts[] = $code;

                return 0;
            }
        } else { //Pozice urcena
            if (isset($javaScripts[$position])) { //Uz je obsazeno
                if ($javaScripts[$position] == $code) {
                    return $position;
                }

                $scriptFound = array_search($code, $javaScripts);
                if ($scriptFound) {
                    unset($javaScripts[$scriptFound]);
                }

                $backup                 = array_slice($javaScripts, $position);
                $javaScripts[$position] = $code;
                $nextFreeID             = $position + 1;
                foreach ($backup as $code) {
                    $javaScripts[$nextFreeID++] = $code;
                }

                return $position;
            } else { //Jeste je pozice volna
                $javaScripts[] = $code;

                return key($javaScripts);
            }
        }

        return $position;
    }
public function addToScriptsStack($code, $position = null)
    {
        $javaScripts = &$this->easeShared->javaScripts;
        if (is_null($position)) {
            if (is_array($javaScripts)) {
                $scriptFound = array_search($code, $javaScripts);
                if (!$scriptFound && ($javaScripts[0] != $code)) {
                    $javaScripts[] = $code;

                    return key($javaScripts);
                } else {
                    return $scriptFound;
                }
            } else {
                $javaScripts[] = $code;

                return 0;
            }
        } else { //Pozice urcena
            if (isset($javaScripts[$position])) { //Uz je obsazeno
                if ($javaScripts[$position] == $code) {
                    return $position;
                }

                $scriptFound = array_search($code, $javaScripts);
                if ($scriptFound) {
                    unset($javaScripts[$scriptFound]);
                }

                $backup                 = array_slice($javaScripts, $position);
                $javaScripts[$position] = $code;
                $nextFreeID             = $position + 1;
                foreach ($backup as $code) {
                    $javaScripts[$nextFreeID++] = $code;
                }

                return $position;
            } else { //Jeste je pozice volna
                $javaScripts[] = $code;

                return key($javaScripts);
            }
        }

        return $position;
    }
Vloží javascript do zasobniku skriptu stránky.

@param string $code     JS code
@param string $position končná pozice: '+','-','0','--',...

@return int