add javascripts files in HTML body
12242
def add_javascripts(self, *js_files):
        """"""
        # create the script tag if don't exists
        if self.main_soup.script is None:
            script_tag = self.main_soup.new_tag('script')
            self.main_soup.body.append(script_tag)

        for js_file in js_files:
            self.main_soup.script.append(self._text_file(js_file))
532310
function handleTpl(file) {
    var html2js = require('html2js');
    file.data = html2js(file.data, {wrap: true});
    file.path += '.js';
    file.fullPath += '.js';
    file.outputPath += '.js';
}
762775
def add_scripts(self):
        """"""
        common_script = self.node(self.defs, 'script', type='text/javascript')

        def get_js_dict():
            return dict(
                (k, getattr(self.graph.state, k))
                for k in dir(self.graph.config)
                if not k.startswith('_') and hasattr(self.graph.state, k)
                and not hasattr(getattr(self.graph.state, k), '__call__')
            )

        def json_default(o):
            if isinstance(o, (datetime, date)):
                return o.isoformat()
            if hasattr(o, 'to_dict'):
                return o.to_dict()
            return json.JSONEncoder().default(o)

        dct = get_js_dict()
        # Config adds
        dct['legends'] = [
            l.get('title') if isinstance(l, dict) else l
            for l in self.graph._legends + self.graph._secondary_legends
        ]

        common_js = 'window.pygal = window.pygal || {};'
        common_js += 'window.pygal.config = window.pygal.config || {};'
        if self.graph.no_prefix:
            common_js += 'window.pygal.config = '
        else:
            common_js += 'window.pygal.config[%r] = ' % self.graph.uuid

        common_script.text = common_js + json.dumps(dct, default=json_default)

        for js in self.graph.js:
            if js.startswith('file://'):
                script = self.node(self.defs, 'script', type='text/javascript')
                with io.open(js[len('file://'):], encoding='utf-8') as f:
                    script.text = f.read()
            else:
                if js.startswith('//') and self.graph.force_uri_protocol:
                    js = '%s:%s' % (self.graph.force_uri_protocol, js)
                self.node(self.defs, 'script', type='text/javascript', href=js)
1267822
function html(req, res) {
  fs.readFile(path.join(__dirname, 'index.html'), function read(err, file) {
    if (err) throw err;

    res.setHeader('Content-Length', file.length);
    res.writeHead(200, { 'Content-Type': 'text/html' });

    res.end(file);
  });
}
678181
function htmlToJsonController (fileContents, filePath, output, p) {

    var matches;
    var includePaths = false;

    while (matches = _DIRECTIVE_REGEX.exec(fileContents)) {

        var relPath     = path.dirname(filePath),
            fullPath    = path.join(relPath,  matches[3].replace(/['"]/g, '')).trim(),
            jsonVar     = matches[2],
            extension   = matches[3].split('.').pop();

        var fileMatches = [];

        if (p.includePaths) {

            if (typeof p.includePaths == "string") {
                // Arrayify the string
                includePaths = [params.includePaths];
            }else if (Array.isArray(p.includePaths)) {
                // Set this array to the includepaths
                includePaths = p.includePaths;
            }

            var includePath = '';

            for (var y = 0; y < includePaths.length; y++) {

                includePath = path.join(includePaths[y], matches[3].replace(/['"]/g, '')).trim();

                if (fs.existsSync(includePath)) {

                    var globResults = glob.sync(includePath, {mark: true});
                    fileMatches = fileMatches.concat(globResults);

                }

            }

        } else {

            var globResults = glob.sync(fullPath, {mark: true});
            fileMatches = fileMatches.concat(globResults);

        }

        try {

            fileMatches.forEach(function(value){

                var _inc = _parse(value);

                if (_inc.length > 0) {

                    var ind = (jsonVar.trim() == '*') ? indName(value) : jsonVar;
                    output[ind] = _inc;
                }
            })

        } catch (err) {
            console.log(err)
        }

    }
}
593113
protected function renderBodyBeginHtml()
    {
        $lines = [$this->body];
        if (!empty($this->jsFiles[self::POS_BEGIN])) {
            $lines[] = implode("\n", $this->jsFiles[self::POS_BEGIN]);
        }
        if (!empty($this->js[self::POS_BEGIN])) {
            $lines[] = Html::script(implode("\n", $this->js[self::POS_BEGIN]), ['type' => 'text/javascript']);
        }

        return empty($lines) ? '' : implode("\n", $lines);
    }
336875
function setupFileElement( editor, fileInput, filebrowser ) {
		var params = filebrowser.params || {};
		params.CKEditor = editor.name;
		params.CKEditorFuncNum = editor._.filebrowserFn;
		if ( !params.langCode )
			params.langCode = editor.langCode;

		fileInput.action = addQueryString( filebrowser.url, params );
		fileInput.filebrowser = filebrowser;
	}
8488
function loadScripts(scripts, loadedCallback) {
    var srcs = [], property, count, i, src,
        countDown = function () {
          count -= 1;
          if (!count) {
            loadedCallback();
          }
        };

    for (property in scripts) {
      if (!(property in window)) {
        srcs.push(scripts[property]);
      }
    }

    count = srcs.length;
    if (!count) {
      loadedCallback();
    }

    for (i = 0; i < srcs.length; i += 1) {
      src = srcs[i];
      loadScript(src, countDown);
    }
  }
1260483
function injectScriptTag(script) {
  // Get some kind of target to put the script in.
  // Only valid documents get body/head, so this is a nice way to ignore bad
  // ones. Try to insert as early as possible.
  var targetElement =
      document.documentElement || document.head || document.body;
  if (targetElement) {
    if (targetElement.firstElementChild) {
      targetElement.insertBefore(script, targetElement.firstElementChild);
    } else {
      targetElement.appendChild(script);
    }
    script.parentNode.removeChild(script);
  }
}
279670
protected void appendDirectEditOpenerScript(StringBuffer html) {

        html.append("<script type=\"text/javascript\">\n");
        html.append("function doOnload() {\n");

        // the window's name must be the same as in:
        // system/workplace/resources/commons/explorer.js
        html.append("window.name='preview';");
        html.append("window.location.replace('");
        html.append(link(m_directEditPath));
        html.append("');");

        html.append("}\n");
        html.append("</script>\n");
    }
495157
def add_to_js(self, name, var):
        """"""
        frame = self.page().mainFrame()
        frame.addToJavaScriptWindowObject(name, var)
264024
private function _addScripts()
    {
        $api = 'https://www.google.com/recaptcha/api.js';
        $base = AnService::get('com:application')->getRouter()->getBaseUrl();
        $recaptcha = $base.'/media/plg_recaptcha/js/';
        $recaptcha .= ANDEBUG ? 'recaptcha.js' : 'min/recaptcha.min.js';

        $document = AnService::get('anahita:document');
        $jsDeclaration = "
            var recaptcha = null;
            $(document).ready(function(){
                if( $('form.recaptcha').length ) {
                    recaptcha = $('form.recaptcha').recaptcha({
                        siteKey: \"%s\"
                    });
                }
            });
            function recaptchaCallback(token) {
                recaptcha.recaptcha('recaptchaCallback', token)
            }
        ";

        $document->addScriptDeclaration(sprintf($jsDeclaration, $this->_params->get('site-key')));
        $document->addScript($recaptcha);
        $document->addScript($api, 'text/javascript', array('async', 'defer'));
    }
1094305
private function replaceJavaScriptTags($html, array $javaScriptFiles)
    {
        foreach ($javaScriptFiles['links'] as $key => $file) {
            if (!$this->isExternalJavaScriptFile($file)) {
                $html = str_replace(
                    $javaScriptFiles['tags'][$key],
                    $this->getJavaScriptContent($file),
                    $html
                );
            }
        }

        return $html;
    }
816606
public void addBottom(Content body) {
        Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
        Content small = HtmlTree.SMALL(bottom);
        Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
        body.addContent(p);
    }
786380
public function addContentElementsJS ($strBuffer='', $objTemplate=null)
	{
		if ($GLOBALS['TL_CTB_JS'] == '')
		{
			return $strBuffer;
		}

		$strKey = substr(md5('js' . $GLOBALS['TL_CTB_JS']), 0, 12);
		$strPath = 'assets/js/' . $strKey . '.js';
		
		// Write to a temporary file in the assets folder
		if (!file_exists($strPath))
		{
			$objFile = new File($strPath, true);
			$objFile->write($GLOBALS['TL_CTB_JS']);
			$objFile->close();
		}
			
		$strPath .= '|static';
		
		// add file path to TL_JAVASCRIPT
		$GLOBALS['TL_JAVASCRIPT'][] = $strPath;

		return $strBuffer;
	}
1129946
function includeJscadSync(fn) {
// include the requested script via MemFs if possible
  if (typeof(gMemFs) == 'object') {
    for(var fs in gMemFs) {
      if (gMemFs[fs].name == fn) {
        eval(gMemFs[fs].source);
        return;
      }
    }
  }
// include the requested script via webserver access
  var xhr = new XMLHttpRequest();
  var url = relpath+fn;
  if (fn.match(/^(https:|http:)/i)) {
    url = fn;
  }
  xhr.open('GET',url,false);
  xhr.onload = function() {
    var src = this.responseText;
    eval(src);
  };
  xhr.onerror = function() {
  };
  xhr.send();
}
1138629
public function includeDefaultJavaScriptFiles()
    {
        if (ExtensionService::get()->isInDebugMode()) {
            $this->javaScriptFiles[] = 'Formz.Debug.js';
        }

        foreach ($this->javaScriptFiles as $file) {
            $filePath = StringService::get()->getExtensionRelativePath('Resources/Public/JavaScript/' . $file);

            $this->includeJsFile($filePath);
        }

        return $this;
    }