Commit 1acd0be3 by Alexander Bazo

Initial commit

parents
{
"parserOptions": {
"sourceType": "module"
},
"rules":
{
"block-scoped-var": "error",
"camelcase": "warn",
"comma-dangle": ["error", "always-multiline"],
"consistent-return": "error",
"curly": "error",
"default-case": "error",
"eqeqeq": "error",
"guard-for-in": "error",
"no-alert": "error",
"no-console": "warn",
"no-else-return": "error",
"no-empty-function": "error",
"no-eval": "error",
"no-eq-null": "error",
"no-extend-native": "warn",
"no-extra-bind": "error",
"no-loop-func": "error",
"no-magic-numbers": ["warn", {"ignore": [0, 1, -1], "ignoreArrayIndexes": true}],
"no-multiple-empty-lines": ["warn", {"max": 1}],
"no-multi-spaces": "warn",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-unused-expressions": "error",
"no-useless-concat": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-param-reassign": "error",
"no-self-compare": "error",
"no-void": "error",
"no-with": "error",
"one-var": "error",
"quotes": ["warn", "double"],
"semi": "error",
"strict": "error",
"vars-on-top": "error",
"yoda": "error"
},
"env":
{
"es6": true,
"browser": true
},
"extends": "eslint:recommended"
}
\ No newline at end of file
# node
node_modules
\ No newline at end of file
{
// Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options
"js": {
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
"brace_style": "collapse-preserve-inline",
"break_chained_methods": false,
"e4x": false,
"eol": "\n",
"end_with_newline": false,
"indent_char": " ",
"indent_level": 0,
"indent_size": 2,
"indent_with_tabs": false,
"jslint_happy": false,
"keep_array_indentation": false,
"keep_function_indentation": false,
"max_preserve_newlines": 0,
"preserve_newlines": true,
"space_after_anon_function": false,
"space_before_conditional": true,
"space_in_empty_paren": false,
"space_in_paren": false,
"unescape_strings": false,
"wrap_line_length": 80
}
}
\ No newline at end of file
# GazeClient
A javascript library to subscribe to local gaze data streams in the OTH/UR Eyetracking Classroom.
## Usage
Add the library:
```
<script type="application/javascript" src="gazeclient.js"></script>
```
Connect to a running *GazeServer*:
```
var gclient = new GazeClient();
gclient.connect("ws://localhost:8001/gaze");
```
## Build
**Prerequisite**
- node.js
To build a current version of this library run `npm install` and `npm run build`. The client library is packed with [rollup](https://rollupjs.org/guide/en/) and copied to `build/` and `demo/`.
\ No newline at end of file
(function () {
'use strict';
/* eslint-env browser */
function onOpen(event) {
this.callback("Connection open");
}
function onMessage(event) {
console.log(event);
}
class WebSocketClient {
constructor(url, callback) {
this.callback = callback;
this.ws = new WebSocket(url);
this.ws.onopen = onOpen.bind(this);
this.ws.onmessage = onMessage.bind(this);
}
send(msg) {
this.ws.send(msg);
}
}
/* eslint-env browser */
class GazeClient {
connect(url) {
this.url = url;
this.client = new WebSocketClient(url, this.onOpen.bind(this));
}
onOpen() {
this.client.send("hello server");
}
}
window.GazeClient = GazeClient;
}());
(function () {
'use strict';
/* eslint-env browser */
function onOpen(event) {
this.callback("Connection open");
}
function onMessage(event) {
console.log(event);
}
class WebSocketClient {
constructor(url, callback) {
this.callback = callback;
this.ws = new WebSocket(url);
this.ws.onopen = onOpen.bind(this);
this.ws.onmessage = onMessage.bind(this);
}
send(msg) {
this.ws.send(msg);
}
}
/* eslint-env browser */
class GazeClient {
connect(url) {
this.url = url;
this.client = new WebSocketClient(url, this.onOpen.bind(this));
}
onOpen() {
this.client.send("hello server");
}
}
window.GazeClient = GazeClient;
}());
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GazeClient</title>
<link rel="stylesheet" href="resources/css/default.css">
</head>
<body>
<header>
<h1>GazeClient</h1>
</header>
<content>
</content>
<script type="application/javascript" src="gazeclient.js"></script>
<script type="module" src="resources/js/index.js"></script>
</body>
</html>
/* eslint-env browser */
/* global GazeClient */
var gclient = new GazeClient();
gclient.connect("ws://localhost:8001/gaze");
// gclient.send("Hello World");
\ No newline at end of file
/* eslint-env browser */
function onOpen(event) {
this.callback("Connection open");
}
function onMessage(event) {
console.log(event);
}
class WebSocketClient {
constructor(url, callback) {
this.callback = callback;
this.ws = new WebSocket(url);
this.ws.onopen = onOpen.bind(this);
this.ws.onmessage = onMessage.bind(this);
}
send(msg) {
this.ws.send(msg);
}
}
export default WebSocketClient;
\ No newline at end of file
/* eslint-env browser */
import WebSocketClient from "./WebSocketClient.js";
class GazeClient {
connect(url) {
this.url = url;
this.client = new WebSocketClient(url, this.onOpen.bind(this));
}
onOpen() {
this.client.send("hello server");
}
}
window.GazeClient = GazeClient;
\ No newline at end of file
{
"name": "gazeclient",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/estree": {
"version": "0.0.39",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
"dev": true
},
"@types/node": {
"version": "12.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.2.tgz",
"integrity": "sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg==",
"dev": true
},
"acorn": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz",
"integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==",
"dev": true
},
"rollup": {
"version": "1.19.4",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.19.4.tgz",
"integrity": "sha512-G24w409GNj7i/Yam2cQla6qV2k6Nug8bD2DZg9v63QX/cH/dEdbNJg8H4lUm5M1bRpPKRUC465Rm9H51JTKOfQ==",
"dev": true,
"requires": {
"@types/estree": "0.0.39",
"@types/node": "^12.6.9",
"acorn": "^6.2.1"
}
}
}
}
{
"name": "gazeclient",
"version": "1.0.0",
"description": "A javascript client to subscribe to gaze data streams over websocket",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup lib/index.js --format iife --name \"gazeclient\" --file build/gazeclient.js",
"postbuild": "cp build/gazeclient.js demo/gazeclient.js"
},
"author": "Alexander Bazo <alexanderbazo@googlemail.com>",
"license": "MIT",
"devDependencies": {
"rollup": "^1.19.4"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment