-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
172 lines (163 loc) · 7.11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!doctype html>
<html ng-app="flatPizza">
<head>
<meta charset="utf-8">
<title>Generate a sheet music from your Groove Pizza - Flat</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link href="//cdn.muicss.com/mui-0.9.16/css/mui.min.css" rel="stylesheet">
<link href="assets/styles.css" rel="stylesheet">
</head>
<body ng-controller="FlatPizzaCtrl">
<div class="score-container" ng-if="musedid" ng-cloak>
<div class="loading" ng-if="loading"><span>Loading...</span></div>
<div class="actions" ng-if="!loading">
<button class="mui-btn mui-btn--primary print" ng-click="print()"><img src="assets/img/print.svg"> Print</button>
<button class="mui-btn mui-btn--primary upload" ng-click="upload()" ng-if="!uploading"><img src="assets/img/logo-f-white.svg"> Edit with Flat</button>
<button class="mui-btn mui-btn--primary upload" ng-if="uploading" disabled><img src="assets/img/logo-f-white.svg"> Uploading...</button>
</div>
<div id="embed-container"></div>
<div class="error" ng-if="error" ng-bind="error"></div>
</div>
<div class="intro-horizontal" ng-if="!musedid" ng-cloak>
<div class="logo-gp">
<a href="https://apps.musedlab.org/groovepizza"><img src="assets/img/groove-pizza.svg" target="_blank" width="200"></a>
</div>
<form class="pizza-input" ng-if="!museid" ng-submit="loadPizzaUrl(url)">
<p class="help-input">Paste the URL of your <a href="https://apps.musedlab.org/groovepizza" target="_blank">Groove Pizza</a> to generate your sheet music:</p>
<div class="mui-textfield">
<input type="text" ng-model="url" placeholder="URL">
</div>
<div class="error" ng-if="error" ng-bind="error"></div>
<input type="submit" value="Generate" class="mui-btn mui-btn--raised">
</form>
</div>
<div class="footer" ng-cloak>
This sheet music generator is an <a href="https://github.com/FlatIO/experiment-groovepizza">Open-Source experiment</a>
by <a href="https://flat.io">Flat</a> built on the top of the <a href="https://apps.musedlab.org/groovepizza">Groove Pizza App</a>.<br>
<a href="mailto:[email protected]">Let us know if you have any feedback</a>!
<a class="logo-flat" href="https://flat.io"><img src="assets/img/flat.svg" alt="Flat"></a>
</div>
<script>Raven.config('https://[email protected]/35').install();</script>
<script src="lib/PizzaToFlat.js"></script>
<script>
angular.module('flatPizza', [])
.config(['$locationProvider', function ($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
}])
.controller('FlatPizzaCtrl', ['$http', '$q', '$log', '$timeout', '$location', '$scope', function ($http, $q, $log, $timeout, $location, $scope) {
// Instance Flat embed
$scope.flatAppId = '590606105cce794333bed42d';
$scope.loadEmbed = function () {
$scope.embed = new Flat.Embed('embed-container', {
embedParams: {
appId: $scope.flatAppId,
branding: false,
controlsPosition: 'top',
controlsPanel: false,
themeControlsBackground: '#4d38a0',
themeIconsPrimary: '#3d2e7f',
themeCursorV0: '#3d2e7f',
themeSlider: '#3d2e7f'
}
});
return $scope.embed;
}
$scope.displayErrors = function (err) {
if (err.data) {
err = err.data;
}
$scope.error = err.description || err.message || err;
if (!$scope.$$phase) {
$scope.$apply();
}
};
$scope.print = function () {
if ($scope.embed) {
$scope.embed.print();
}
};
$scope.upload = function () {
$scope.uploading = true;
$http.post('https://extendsclass.com/api/json-storage/bin', JSON.stringify($scope.score))
.then(function (response) {
window.location = 'https://flat.io/score/import-url?title=My%20Groove%20Pizza&app=' + $scope.flatAppId +
'&url=' + encodeURI(response.data.uri);
})
.catch(function (err) {
$scope.uploading = false;
$scope.displayErrors(err);
});
};
$scope.loadPizza = function (id) {
return $q(function (resolve, reject) {
$scope.loading = true;
// Load Pizza
$http.get('https://api.flat.io/groovepizza/' + encodeURI(id))
// Convert
.then(function (response) {
var pizza = response.data;
if (!pizza.groove) {
return reject(new Error('Groove pizza not found'));
}
$scope.score = new PizzaToFlat(pizza.groove).convert();
$log.debug('Score:', $scope.score);
return $scope.loadEmbed();
})
// Display
.then(function (embed) {
return embed.loadJSON($scope.score);
})
.then(function () {
$scope.loading = false;
resolve();
})
.catch(function (err) {
$scope.loading = false;
reject(err);
});
});
};
// Load Pizza by URL (form)
$scope.loadPizzaUrl = function (url) {
$scope.error = null;
if (url) {
$scope.musedid = new URL(url).searchParams.get('museid');
if (!$scope.musedid) {
$scope.error = 'Invalid Pizza URL';
}
$scope
.loadPizza($scope.musedid)
.then(function () {
$location.search('museid', $scope.musedid);
})
.catch(function (err) {
$scope.musedid = null;
$scope.displayErrors(err);
});
}
else {
$scope.error = 'Invalid Pizza URL';
}
};
// Load ?musedi=<x>
$scope.musedid = $location.search().museid;
if ($scope.musedid) {
$scope.loadPizza($scope.musedid).catch($scope.displayErrors);
}
}]);
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-35889059-12', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>