Skip to content

Commit

Permalink
transferred from gist
Browse files Browse the repository at this point in the history
  • Loading branch information
vincesp committed May 1, 2013
1 parent 3ba54a6 commit 848c74f
Show file tree
Hide file tree
Showing 12 changed files with 513 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
angular.module('connair', ['ngResource', 'ngCookies', 'http-auth-interceptor'])
.config(function ($routeProvider) {
var HOME = {templateUrl: 'parts/panelSelection.html'};
$routeProvider
.when('/', HOME)
.when('/login', {templateUrl: 'parts/login.html'})
.when('/:panelTitle', {templateUrl: 'parts/panel.html', controller: 'PanelCtrl'})
.otherwise(HOME);
})
.controller('MainCtrl', function($scope, $resource, $http, $location, $cookies) {
var HOME_TITLE = $scope.pageTitle = 'ConnAir Remote Touch';
var CONFIG_PATH = 'config/panel-config.json';
function convertShy(t) {
return t.replace(/­/g, '\u00AD');
}
function stripShy(t) {
return t.replace(/­/g, '');
}
$scope.$on('event:auth-loginRequired', function() {
$location.path('/login');
});
$scope.config = $resource(CONFIG_PATH).get(
function (config) {
var panelMap = {},
rows = [],
row = [];
angular.forEach(config.panels, function (panel) {
panelMap[stripShy(panel.title)] = panel;
panel.title = convertShy(panel.title);
row.push(panel);
if (row.length == 2) {
rows.push(row);
row = [];
}
});
if (row.length) rows.push(row);
$scope.rows = rows;
$scope.panelMap = panelMap;
},
function (error) {
$scope.configGetError = error;
}
);
$scope.setTitle = function (pageTitle) {
$scope.pageTitle = pageTitle || HOME_TITLE;
};
$scope.gotoPanel = function (panelTitle) {
var cleanTitle = stripShy(panelTitle);
$location.path(cleanTitle);
$scope.setTitle(cleanTitle);
};
$scope.getColorSchemeClass = function () {
if ($scope.config.colorScheme) return 'c' + $scope.config.colorScheme;
};
})
.controller('PanelCtrl', function ($scope, $routeParams) {
$scope.panel = $scope.panelMap[$routeParams.panelTitle];
$scope.setTitle($routeParams.panelTitle);
})
.controller('ActorCtrl', function ($scope, $http) {
$scope.toggle = function (action) {
$scope.toggleClasses = {};
$scope.toggleClasses[action] = 'actionRunning';
var actor = $scope.actor;
delete actor._lastError;
$http.get($scope.config.connAirPath, {params: {action: action, type: actor.type, id: actor.id}})
.success(function () {
$scope.toggleClasses[action] = 'actionSuccess';
})
.error(function (error) {
actor._lastError = error;
delete $scope.toggleClasses[action];
});
};
})
;
111 changes: 111 additions & 0 deletions src/config/panel-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"connAirPath": "/connair/",
"colorScheme": "2369",
"panels": [
{
"title": "Room & <1>",
"actors": [
{
"title": "Warm light",
"color": "#ff9",
"type": "device",
"id": 1
},
{
"title": "Warm heavy",
"color": "#ff3",
"type": "device",
"id": 2
},
{
"title": "Cool heavy",
"color": "#38c",
"type": "group",
"id": 3
},
{
"title": "Cool light",
"color": "#9cf",
"type": "group",
"id": 3
},
{
"title": "Neutral",
"color": "#766",
"type": "group",
"id": 3
}
]
},
{
"title": "Su&shy;per&shy;cal&shy;i&shy;fra&shy;gil&shy;istic&shy;ex&shy;pi&shy;al&shy;ido&shy;cious",
"actors": [
{
"title": "Warm light",
"color": "#bf9",
"type": "device",
"id": 1
},
{
"title": "Warm heavy",
"color": "#6f3",
"type": "device",
"id": 2
},
{
"title": "Cool heavy",
"color": "#33c",
"type": "group",
"id": 3
},
{
"title": "Cool light",
"color": "#99f",
"type": "group",
"id": 3
},
{
"title": "Neutral",
"color": "#765",
"type": "group",
"id": 3
}
]
},
{
"title": "Room 3",
"actors": [
{
"title": "Warm light",
"color": "#fd9",
"type": "device",
"id": 1
},
{
"title": "Warm heavy",
"color": "#fc3",
"type": "device",
"id": 2
},
{
"title": "Cool heavy",
"color": "#3c8",
"type": "group",
"id": 3
},
{
"title": "Cool light",
"color": "#9fd",
"type": "group",
"id": 3
},
{
"title": "Neutral",
"color": "#657",
"type": "group",
"id": 3
}
]
}
]
}
Binary file added src/css/Oswald-Light.ttf
Binary file not shown.
Binary file added src/css/Oswald-Light.woff
Binary file not shown.
Binary file added src/css/Oswald-Regular.ttf
Binary file not shown.
Binary file added src/css/Oswald-Regular.woff
Binary file not shown.
169 changes: 169 additions & 0 deletions src/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
@font-face {
font-family: 'Oswald';
font-style: normal;
font-weight: 300;
src: url(Oswald-Light.ttf), url(Oswald-Light.woff) format('woff');
}
@font-face {
font-family: 'Oswald';
font-style: normal;
font-weight: 400;
src: url(Oswald-Regular.ttf), url(Oswald-Regular.woff) format('woff');
}

body {
font-family: 'Oswald', sans-serif;
font-size: 1cm;
background-color: #000;
padding: .15cm 0 0 0;
margin: 0;
}
html {
max-width: 12cm;
margin: 0 auto;
position: relative;
}
.panelTitle {
font-size: .3cm;
padding: .1cm .3cm .3cm .3cm;
letter-spacing: 0;
position: fixed;
bottom: -.2cm;
left: 0;
right: 0;
z-index: 2000;
cursor: pointer;
background-color: #000;
background-color: rgba(0,0,0,.85);
color: #b2b2b2;
text-align: center;
}
.panelContent {
margin-bottom: .7cm;
}
.panelTable {
border-spacing:.15cm;
}
.panel {
padding: .2cm;
height: 3cm;
cursor: pointer;
width: 50%;
vertical-align:top;
}
.panelBackIcon {
position: relative;
width: .6cm;
display: inline-block;
}
.panelBackIcon > div {
float: left;
width: .2cm;
height: .13cm;
margin: .03cm;
}
.configError {
color: #f00;
font-size: .4cm;
letter-spacing: .05em;
}
.toggleTitle, .panel {
letter-spacing: -.03em;
}
.toggle {
padding: .2cm;
border-radius: 1cm;
margin: .15cm 0;
min-height: 1.5cm;
text-align: center;
}
.toggleTitle {
position: relative;
padding: 0 1cm;
}
.toggleOn, .toggleOff {
width: 50%;
position: absolute;
}
.toggleOn {
left: 0;
text-align: left;
}
.toggleOff {
right: 0;
text-align: right;
}
.toggleOn > div, .toggleOff > div {
font-weight: 300;
font-size: .5cm;
height: 1.5cm;
cursor: pointer;
margin: 0 .2cm;
line-height: 1.5cm;
}
.toggleOn > div > div, .toggleOff > div > div {
position: relative;
z-index: 1000;
padding: 0 .2cm;
}
.toggleOn > div {
background: -moz-linear-gradient(left, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 80%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0.4)), color-stop(80%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* IE10+ */
background: linear-gradient(to right, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* W3C */
border-radius: .7cm 0 0 .7cm;
}
.toggleOff > div {
background: -moz-linear-gradient(right, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 80%); /* FF3.6+ */
background: -webkit-gradient(linear, right top, left top, color-stop(0%,rgba(255,255,255,0.4)), color-stop(80%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(right, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(right, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* Opera 11.10+ */
background: -ms-linear-gradient(right, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* IE10+ */
background: linear-gradient(to left, rgba(255,255,255,0.4) 0%,rgba(255,255,255,0) 80%); /* W3C */
border-radius: 0 .7cm .7cm 0;
}
.actionRunning {
background: #fff!important;
}
.actionSuccess {
transition: background 3s;
-webkit-transition: background 3s;
}
.toggleError {
font-size: .3cm;
}

/** colors **/
/* 2357 = default */
.panel, .panelBackIcon > div {
background-color: #36c;
}
.toggle {
background-color: #ff9;
}

/* 2369 */
.c2369 .panel, .c2369 .panelBackIcon > div {
background-color: #99f;
}
.c2369 .toggle {
background-color: #fc6;
}

/* 2375 */
.c2375 .panel, .c2375 .panelBackIcon > div {
background-color: #68c;
}
.c2375 .toggle {
background-color: #e95;
}

/* 2379 */
.c2379 .panel, .c2379 .panelBackIcon > div {
background-color: #36f;
}
.c2379 .toggle {
background-color: #ba5;
}
19 changes: 19 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html ng-app="connair" ng-controller="MainCtrl" >
<head lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>{{pageTitle}}</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular-resource.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular-cookies.js"></script>
<script src="lib/http-auth-interceptor.js"></script>
<link rel="stylesheet" href="css/style.css">
<script src="app/app.js"></script>
</head>
<body ng-class="getColorSchemeClass()">
<div ng-view></div>
</body>
</html>
Loading

0 comments on commit 848c74f

Please sign in to comment.