Scripting tutorial #1 - Creating and authorizing a local HTML page

Disclaimer

When purchasing a DreamLover Labs device, you are purchasing a hardware device, and not software development services, or a guarantee that such services will be extended, or a commitment to extend such services at a specific price. There is no guarantee, either implicit or explicit, that you will be able to implement a specific new feature using the Javascript API, to extend functionality beyond what is described in the User's Guide. DreamLover Labs are under no obligation to provide any programming assistance beyond the tutorials on this site. In particular, we are unable to offer assistance to non-programmers trying to create their own scripts. Do not expect to be able to use the API if you have never programmed in Javascript. Programmers trying to code scripts are normally aided by pointing them to the relevant functions if the need arises. We do not normally take on programming/software development tasks on behalf of our users. If a quote for such a project is ever given on an exceptional basis, it will likely be substantially higher than market rates, due to this kind of service being outside of our line of business. If your choice to own a device is conditional to the possibility of realizing a specific feature, please consult with us first. Please understand that while we can tell you whether a specific new mode of operation is possible or not with our API, we absolutely cannot guarantee that you will be able to accomplish the relative programming tasks. Additionally, should you have difficulties in the attempt, we will not be able to come to the rescue and do the programming work necessary. Therefore by purchasing a device you agree to being entirely responsible for carrying out or outsourcing the programming work relative to whatever new features you will wish to create. We do not accept returns past the review period stated on the terms of sale, and your inability to program or hire someone to program some vital feature that makes the device useful to you does not constitute an exception to this rule.

This is the first of a series of tutorials on scripting the DreamLover Labs products.
No programming experience is assumed (though it will obviously help). The only prerequisites are:

  • to have installed the DL Uplink application (available on the Downloads page).
  • to have assigned a device owner for the device and be able to log in as device owner (optional - only if you will be testing on an actual DreamLover device)

Introduction

You can script DreamLover 2000 and ChronoVault behavior by running a Javascript script inside the DL Browser. The DL Browser is the browser included with the DL Uplink application. To run a script, you simply open an HTML page which contains the script. The HTML file can be somewhere on the web, or stored on your PC.

This is made only slightly more complex by the fact that, in order to prevent tampering, the DL Browser has a security mechanism to prevent access to "rogue" pages (pages which could, for instance, immediately open the ChronoVault, or reset its timer, or switch off any DreamLover 2000 mode such as Leash Mode, and more).

Therefore to open a page, that page must first be added to the list of "authorized" pages for a particular device. As a programmer, you must authorize the page you are testing or developing. If you choose to share your creation and put it somewhere on the web, your users will also need to authorize the script's web location (also known as URL) in order to utilize it.

Create a test script

Let's create a simple HTML page so we can add its location to the authorized list and begin working on the script. An HTML page can be created by opening Notepad, adding the following code, and saving the file.



After entering the code above, click the File menu and select "Save As". Navigate to your desktop and name the file test.html.

Find the page's full path

We want to authorize this script so that the DL Browser will allow us to load it and execute whatever commands we will decide to add. To do that, we must first find out the complete file name, including its path on your hard drive. The easiest way to get this is by opening a regular browser (not the DL Browser, but any other browser, like Explorer or Firefox) and dragging and dropping our test script on the browser window.



Supposing you've saved the HTML file right on your desktop, your complete file name will look like the one above, where "Something" actually is your Windows log in username. Copy the file name to the clipboard by right clicking the text (after selecting it) and choosing "Copy" (or easier, click on the text and press CTRL-A to select all, then CTRL-C to copy).

Authorize the test script

These instructions are for DreamLover Labs device owners only. If you wish to practice scripting for our products but you do not own a device (or you don't have it on hand right now), skip to the bottom of the page (the heading "Testing without a connected device").

With the file name on hand, we now go to the DL Lounge, at http://www.dreamloverlabs.com/link/ and log in with the username/password of the device owner.



The left menu now has a link named "Device permissions". Click it.



You will see a list of owned devices on the right side. If nothing is visible, you have not selected an owner for your DreamLover device! Just go to the Uplink application, and under the owner menu, choose to select an owner for your device.



Once a device appears, click "Edit allowed DL Browser URLs". Paste the file's location in the text box and click "Update".

Test the script in the DL Browser

The HTML file has been authorized, so your DL Browser is now able to open it. Let's try it. Open the DL Uplink, and click on "DL Browser".



The device must be plugged in when the DL Browser is opened. If so, it will query and retrieve the list of allowed URLs. That means you will be able to click on the select box at the top and find your file's location. Click the file's location, then click "Open" to display the page.



The page should be displayed. From this point on, any changes you make to the test.html file by editing it in Notepad and saving it, will be immediately visible in the DL Browser by clicking the refresh button.



Testing without a connected device

It is possible to open the test page without any connected devices. The advantage is that any URL can be opened without authorizing it first. However, any commands executed by the script will not be delivered. This is the DL Browser's "demo mode". Demo mode is useful for developers, because although no hardware interaction is possible, commands are still displayed as they are executed.



To enter DL Browser demo mode, start the DL Browser without any connected DreamLover devices. When the following screen is displayed, click "enter demo mode".



The DL Browser's URL select box will become a text box, and at this point the DL Browser will behave like any regular browser, allowing you to just type your desired URL.



Paste your test page's location in the text box, and click "Open" to display the page.



In this case, don't mind the fact that the URL format changed a bit after you clicked "open". The page is now visible.

 
DreamLover 2000

Overview
Infomercial
Features
Pro vs Lite
Part list
Technology
Reviews

Pulse

Pulse design
Pulse strength
Effectiveness
Customization
Electrodes

Safety

Electrical
Chemical
Usage safety
Lab testing
Fail-safe design

Compatibility

Compatibility
Notes and Mounting

PC interface

DL2K-LINK
Screenshots
Demo

Others

Mobile App
R&D Museum
Courses

Support

Downloads
Contact
Ordering

Pricing and order terms
Product contents
Plans/Upgrades
Pricing
Price comparisons
Warranty
Returns
Privacy
Shipping
Security
Place an order
 

Contact us | General terms | Refund/return policy | Warranty | Privacy | Security | Shipping | Fraud policy | Fraudulent disputes and chargeback policy


(C) 2008-2023 DreamLover Laboratories - all rights reserved