initial commit

main
Gerardo Marx 23 hours ago
commit a88da118db

@ -0,0 +1,68 @@
# Basic procedure to init a JS proyect
This basic repository shows how to prepare basic JS apps to run and test in Unix like OS. The guide use the `serve` node package installed globally; alternally you can use `live server` extension in visual studio code to mount a basic server for testing.
## 1. Create the project directory
```sh
mkdir my-js-project
cd my-js-project
```
## 2. Create the basic files
```sh
touch index.html
touch script.js
```
**index.html**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test JS</title>
</head>
<body>
<h1>Hello Blink!</h1>
<button onclick="sayHello()">Click me</button>
<script src="script.js"></script>
</body>
</html>
```
**script.js**
```js
function sayHello() {
alert("Hello from JS!");
console.log("Hello from script.js!");
}
```
## 3. Install a simple static server
If you want to serve this app via a web browser use:
```sh
npm install -g serve
```
This will install globally, if you already do not have installed, and then you can use later for this or further js projects:
```sh
serve .
```
By default it serves on `http://localhost:3000`
## 4. Access it in the web browser
Once you execute the `serve` commmand a prompt will let you know where your server is serving:
```sh
Serving! ││ ││ - Local: http://localhost:3000 ││ - Network: http://172.18.0.2:3000
```
thus, you can visit it locally or in other device with the `network` address.
**Note: if you are using Blink Shell app for iPad** you must open other Blink terminal and forward the the exposed port:
```sh
Blink> build port add htools 3000 3000
```
after that you will be able to open the app only directly from your iPad if you did it by `Blink Build`. Otherwise, the app will be abaileble at the provided URL.

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test JS</title>
</head>
<body>
<h1>Hello Blink!</h1>
<button onclick="sayHello()">Click me</button>
<script src="script.js"></script>
</body>
</html>

@ -0,0 +1,4 @@
function sayHello() {
alert("Hello from JS!");
console.log("Hello from script.js!");
}
Loading…
Cancel
Save