MathJax download cannot load in a local web page - mathjax

I downloaded the latest copy of MathJax through Git, installed it somewhere, and wrote the following document:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Notes - Wenke's Patterns in Prehistory</title>
<script id="MathJax-script" async src="../../../../MathJax/e5/tex-chtml.js">
</script>
</head>
<body>
$ e^i $
</body>
</html>
When I try to run it in a browser the console prints the message Loading failed for the <script> with source “file:///home/username/underconstruction/MathJax/e5/tex-chtml.js”..
I believe the README.md file that comes with the download indicated that tex-chtml.js was supposed to be the file to link in the HTML document. I've seen elsewhere reference to a MathJax.js file but that was not included in my download.

You specify the location ("../..") of the file "tex-chtml.js" relative to the location of the HTML-page containing $e^i$. The file is likely not there as the warning message indicates. If you specify a path relative to the current HTML-page be also sure that the relative path is the same on your localhost and on the server.
A simple method for using MathJax is given on https://www.mathjax.org.
You do not need to download MathJax from anywhere. Just include the following lines in your HTML-file:
<head>
<script>
MathJax = {tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]}};
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax#3/es5/tex-mml-chtml.js"></script>
</head>

Related

localhost sent an invalid response

Server for PixiJS not working, "localhost sent an invalid response" error when connecting for client side
When I try connecting to the server (http://127.0.0.1:8080) through my chrome browser, I get a page which has this written on it:
"This page isn’t working
localhost sent an invalid response.
ERR_INVALID_REDIRECT"
And it also downloads a file called "download" with it. I have no idea as to why this happens. This "download" file is almost the exact same as the code in my index.html file. The code is the following:
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing pixi.JS</title>
<!-- The <script> tag's src should be relative to your root directory where your webserver is running -->
<script src="pixi/pixi.min.js"></script>
</head>
<body>
<script type="text/javascript">
let type = "WebGL";
if(!PIXI.utils.isWebGLSupported()){
type = "canvas";
}
</script>
</body>
</html>
<!-- MY INDEX.HTML CODE -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Testing pixi.JS</title>
<!-- The <script> tag's src should be relative to your root directory where your webserver is running -->
<script src="./pixi.min.js"></script>
</head>
<body>
<h1>Hello there!</h1>
<script type="text/javascript">
let type = "WebGL";
if(!PIXI.utils.isWebGLSupported()){
type = "canvas";
}
</script>
</body>
</html>
CODE TYPED INTO CMD AFTER MOVING TO SAME FOLDER AS INDEX.HTML:
npm install http-server -g
http-server
I expected the page to load but it doesn't. I have no idea as to what to do.
If you navigate to the full path it seems to work: http://127.0.0.1:8080/index.html It seems to be some http-server bug.
There are many other local web servers. I suggest browsersync:
npm install -g browser-sync
browser-sync start --server --index index.html
There is a bug, it seems only affect to Windows. You should install a lower version of http-server, 0.9.0 works.
Run the following command
npm install -g http-server#0.9.0
for more info click here.
I tried to connect to a netgear D700 using opera and edge but got the same response. Eventually I used the old 32bit internet explorer and got into the router. Once the firmware was updated I was able to use opera to get into the router.

Node.js & amcharts4 - how to integrate and call core.js and charts.js correctly via 'Javascript'

I just downloaded the new amCharts4 into my node.js app via npm to test it. Wenn installed I find the files chore.js and charts.js in MyNodejsApp/node_modules/#amcharts/amcharts4 :
MyNodejsApp
_node_modules
|_#amcharts
|_amcharts4
|_charts.js
|_core.js
|_amcharts4-geodata
_public
|_css
|_styles.css
|_js
|_main.js
_views
|_partials
|_scripts.ejs
|_dashboard.ejs
|_index.ejs
app.js
As you can see I placed my css and js files in folder public. I'm also using ejs and call the files via views/index.ejs and dashboard.ejs. I'm then loading my js files via script.ejs.
script.ejs
<script type="text/javascript" src="/js/main.js"></script>
# this worked
<script type="text/javascript" src="//www.amcharts.com/lib/4/core.js"></script>
<script type="text/javascript" src="//www.amcharts.com/lib/4/charts.js"></script>
<script type="text/javascript" src="//www.amcharts.com/lib/4/themes/animated.js"></script>
# this did not work
<script type="text/javascript" src="/js/amcharts/core.js"></script>
<script type="text/javascript" src="/js/amcharts/charts.js"></script>
<script type="text/javascript" src="/js/amcharts/themes/animated.js"></script>
dashboard.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<% include partials/head %>
</head>
<body>
<div id="chartdiv"></div>
<% include partials/script %>
</body>
</html>
Where and how do I exactly integrate and call the charts.js and core.js file? I'm assuming also in my script.ejs ? But do I copy & paste charts.js and core.js files in my public/js folder (which didn't work under folder public/js/amcharts)? or how do I integrate and access them?
https://www.amcharts.com/docs/v4/getting-started/basics/

Grunt: How to correctly setup .html file for mocha testing?

I am new to grunt and tests and currently I have setup like this:
Grunt running tasks after which I have build folder where I have my compiled index.html and all his resources (css, js, images)
Now I want to run tests using grunt-mocha-phantomjs and it needs additions to my index.html like:
<link href="../node_modules/mocha/mocha.css" media="screen" rel="stylesheet" type="text/css" />
Inside head tag and:
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js" type="text/javascript" charset="utf-8"></script>
<script src="../node_modules/chai/chai.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
mocha.ui('bdd');
expect = chai.expect;
</script>
<script src="test.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
mocha.run();
</script>
Inside body tag.
I want to be able to open that modified index.html in web-browser too. (I have setup apache for it and example test works great both in grunt and web-browser)
So I am planning using task grunt-contrib-copy to copy all files from my build directory to test directory and add those lines to index.html and then launch mocha_phantomjs task.
Is this correct way to do it?
Which NpmTask can do it?
Not sure about "Is this correct way to do it?" part but I solved it.
I used grunt-html-build and its Removing parts feature.
Removing phantom's code for build folder, and keep it for testing folder.
It works great.

LESS, Dotless and Visualstudio

I started today with LESS. It looks awesome to work with and I will need it on my internship soon.
My less code:
#color: #4D926F;
body {
background-color: #color;
}
Not anything special.
My html:
<!Doctype HTML>
<html>
<head>
<title>#ViewBag.Title</title>
<link href="#Url.Content("~/Content/style.less")" type="stylesheet" rel="stylesheet/less" />
<script src="#Url.Content("~/Scripts/less-1.4.1.min.js")" type="text/javascript"></script>
</head>
<body>
#RenderBody()
</body>
</html>
The Less script file is downloaded from http://lesscss.org/
My file structure:
The result:
FileError: 'http://localhost:58123/Content/style.less' wasn't found (404)
in style.less
Index
When I install dotless via Package Manager everything works perfect.
My question is what do I need to runn it without Dotles? I dont have problems installing Dotless or using it. I just want to know whats the missing link why the LESS gives that error. Why do I get a 404 error when the file is there?
Dotless compiles the .less to .css. So you would need to add a reference to the resulting .css that Dotless compiles. Also you would want to remove this line from your code.
<link href="#Url.Content("~/Content/style.less")" type="stylesheet" rel="stylesheet/less" />

Getting TypeError: App.Router is undefined after building ember.js

Posting here as requested original post can be found here
Hello, I would like to build ember.js using Ubuntu 13.
I have cloned the official Github project, cd into the project and as described in the readme file I did:
bundle install
rake dist
no error is shown on screen and as a result I get a directory shown in the image
I would like to use ember and ember-data, so I include
ember.js
ember-data-deps.js
files in my test project.
The problem is that I am getting a TypeError: App.Router is undefined
I am using this at my client.js file to init ember
this.App = Ember.Application.create();
App.Router.map(function() {
this.route('contributors');
this.route('contributor', {path: '/contributors/:contributor_id'});
});
Am I doing something wrong in the build process?
Should I include some other js files in my project?
Thank you in advanced.
The TypeError: App.Router is undefined error is because ember.js is not loaded correctly or in the correct order.
To get ember-data (that is separate from ember.js) you have to clone this repo (https://github.com/emberjs/data) and follow the build instructions in the readme file, it's straight forward, and once you have the dist directory from the ember-data build process get the file ember-data.js development version or ember-data.min.js for production (well, production... ember-data is still considered unstable for production environments).
here is a simple ember project setup using ember-data:
index.html
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>ember app</title>
</head>
<body>
<script type="text/x-handlebars">
hello world!
</script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" src="http://builds.emberjs.com.s3.amazonaws.com/handlebars-1.0.0-rc.3.js"></script>
<script type="text/javascript" src="http://builds.emberjs.com.s3.amazonaws.com/ember-latest.js"></script>
<script type="text/javascript" src="http://builds.emberjs.com.s3.amazonaws.com/ember-data-latest.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
app.js
var App = Ember.Application.create({
ready: function () {
console.log("app started...");
}
});
hope it helps

Resources