aboutsummaryrefslogtreecommitdiff
path: root/point/point.js
diff options
context:
space:
mode:
Diffstat (limited to 'point/point.js')
-rw-r--r--point/point.js135
1 files changed, 135 insertions, 0 deletions
diff --git a/point/point.js b/point/point.js
new file mode 100644
index 0000000..85dbfb3
--- /dev/null
+++ b/point/point.js
@@ -0,0 +1,135 @@
1/*
2 * This file is part of "What's The Point" <https://github.com/Pacien/WhatsThePoint>
3 * Copyright (C) 2014 Pacien TRAN-GIRARD
4 *
5 * "What's The Point" is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * "What's The Point" is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19requirejs.config({
20 baseUrl: "point",
21 paths: {
22
23 /* file loaders */
24 "text": "libs/text/text",
25 "css": "libs/require-css/css.min",
26
27 /* parsers and compilers */
28 "js-yaml": "libs/js-yaml/js-yaml.min",
29
30 },
31});
32
33var parameters = {
34 configFile: "../point.yml",
35 slides: true,
36};
37
38// parse url parameters
39location.search.substring(1).split("&").forEach(function (kv) {
40 var kvp = kv.split("=");
41 parameters[kvp[0]] = kvp[1] === undefined ? true : kvp[1];
42});
43
44// parse configuration file
45require([ "js-yaml", "text!" + parameters.configFile, "view/view", "control/control" ], function (jsyaml, config, view, control) {
46 var settings = jsyaml.safeLoad(config);
47
48 for (var k in view.VIEW) {
49 var v = view.VIEW[k];
50 if (parameters[v]) {
51 settings.view = v;
52 break;
53 }
54 }
55
56 settings.key = parameters.key;
57 if (settings.control == "local") {
58 settings.mode = control.MODE.FREE;
59 } else {
60 if (settings.key === undefined) {
61 settings.mode = control.MODE.SLAVE;
62 } else {
63 settings.mode = control.MODE.MASTER;
64 }
65 }
66
67 // load theme and view
68 if (settings.data.type !== "pdf") {
69 require([ "css!theme/" + settings.theme ]);
70 }
71 require([ "css!view/" + settings.view ]);
72
73 // apply slide dimension
74 var screen = document.getElementsByTagName("p-screen")[0];
75 screen.style.width = settings.dimension.width + "px";
76 screen.style.height = settings.dimension.height + "px";
77
78 require([ "data/renderSlide", "data/" + settings.data.type, "text!" + settings.data.file ], function (renderer, parser, data) {
79
80 var exec = function (object) {
81 object.init(settings);
82 };
83
84 exec(parser);
85 exec(renderer);
86
87 parser.parse(data, function (slidesData) {
88 renderer.render(slidesData, function (renderedSlides) {
89
90 document.getElementsByTagName("p-screen")[0].appendChild(renderedSlides);
91 document.body.removeChild(document.getElementById("loadingclock"));
92
93 // control
94 var controls = [ "slide", "fullscreen" ];
95 if (settings.mode !== control.MODE.SLAVE) {
96 controls = controls.concat([ "layout" ]);
97 }
98 if (settings.mode === control.MODE.MASTER) {
99 controls = controls.concat([ "network" ]);
100 }
101 for (var i = 0; i < controls.length; i++) {
102 require([ "control/" + controls[i] ], exec);
103 }
104
105 // binding
106 var bindings = [];
107
108 if (settings.control.remote !== undefined) {
109 bindings = bindings.concat([ "network" ]);
110 }
111
112 if (settings.mode !== control.MODE.SLAVE) {
113 bindings = bindings.concat(settings.binding);
114 }
115
116 if (bindings !== undefined) {
117 for (var i = 0; i < bindings.length; i++) {
118 require([ "binding/" + bindings[i] ], exec);
119 }
120 }
121
122 // load plug-ins
123 if (settings.plugins !== undefined) {
124 for (var i = 0; i < settings.plugins.length; i++) {
125 require([ "plugins/" + settings.plugins[i] + "/" + settings.plugins[i] ], exec);
126 }
127 }
128
129 });
130
131 });
132
133 });
134
135});