Getting started with Javascript and tramontana::


To get started with tramontana for Javascript you need to first import jquery:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>


And then import the tramontan library:

<script src="../lib/tramontana_min.js"></script>


Now you can create a new tramontana object that links to your device (or node).

<script>   var device = new tramontana();  </script>


Open the tramontana app on your phone and check the ip address of your device:

device.start(“192.168.2.19”)


Now you are ready to send your first command to your device:

device.makeVibrate();


This is the html page for the full example:


<html>

<head>

<!-- import css-->

<link rel="stylesheet" type="text/css" href="./stylesheet.css">

<!-- import jquery-->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

<!-- import tramontana-->

<script src="../lib/tramontana_min.js"></script>

<!-- create a global variable-->

<script>

 var device = new tramontana();

</script>

</head>

<body>

<!--Link to tramontana the app!-->

<div>

<h4>To get started download the Tramontana App on your iOS device from <a href="https://itunes.apple.com/us/app/tramontana/id1121069555?mt=8">here</a> or on your Android device from <a href="https://itunes.apple.com/us/app/tramontana/id1121069555?mt=8">here</a>.</h4>

<p>

 1. Insert the IP Address of your device and press start.

</p>

<p>

 2. Press change color to change the color of the screen of your device.

</p>

</div>

<!-- OPEN SOCKET -->

<label>IPAddress:</label>

<input type="text" id="ipInput" placeholder="192.168.1.1"><br/>

<button onclick="device.start($('#ipInput').val())">start</button>

<!-- CHANGE device COLOR -->

<button onclick="console.log('change color');device.setColor(Math.random(0,255),Math.random(0,255),Math.random(0,255),255

);">change color</button>

</p>

</body>

</html>


You can check more examples here: