Commit 8bc1d507f2419e56b003e0290547bbf3be3be0a6

Authored by David Guilherme
1 parent 06dd693a
Exists in master

Implements notification system and a large refactoring

.gitignore
... ... @@ -2,10 +2,13 @@ chrome/app/player
2 2 firefox/data/player
3 3 safari.safariextension/app/player
4 4  
5   -webgl/Release
6   -webgl/vendors
7   -webplayer/vendors
  5 +player/webgl/Release
  6 +player/vendors
8 7  
9 8 node_modules
10 9  
11   -**/.DS_Store
12 10 \ No newline at end of file
  11 +**/.DS_Store
  12 +**/Thumbs.db
  13 +
  14 +**/*.crx
  15 +**/*.xpi
13 16 \ No newline at end of file
... ...
Gulpfile.js
... ... @@ -6,45 +6,55 @@ var playersPath = {
6 6 safari: 'safari.safariextension/app/player'
7 7 };
8 8  
9   -var webglOptions = {
10   - base: 'webgl',
11   - cwd: 'webgl'
12   -};
13   -
14 9 var webglFiles = [
15 10 'connect.js',
16 11 'load.js',
  12 + 'verify-compatibility.js',
17 13 'window.html',
18 14 'TemplateData/*',
19   - 'Release/*',
20   - 'vendors/**/*',
21   - 'js/*'
  15 + 'Release/*'
22 16 ];
23 17  
24   -var webplayerOptions = {
25   - base: 'webplayer',
26   - cwd: 'webplayer'
27   -};
28   -
29 18 var webplayerFiles = [
30 19 'window.html',
31 20 'player.js',
32   - 'WEBPLAYER.unity3d',
33   - 'vendors/**/*',
34   - 'TemplateData/*'
  21 + 'WEBPLAYER.unity3d'
35 22 ];
36 23  
  24 +var playerFiles = [
  25 + 'TemplateData/*',
  26 + 'js/*',
  27 + 'vendors/qdclient/qdclient.js',
  28 + 'vendors/offline/offline.js'
  29 +];
  30 +
  31 +var webglTask = function(dest) {
  32 + gulp.src(webglFiles, {base: 'player/webgl', cwd: 'player/webgl'})
  33 + .pipe(gulp.dest(dest));
  34 +
  35 + playerTask(dest);
  36 +};
  37 +
  38 +var webplayerTask = function(dest) {
  39 + gulp.src(webplayerFiles, {base: 'player/webplayer', cwd: 'player/webplayer'})
  40 + .pipe(gulp.dest(dest));
  41 +
  42 + playerTask(dest);
  43 +};
  44 +
  45 +var playerTask = function(dest) {
  46 + gulp.src(playerFiles, {base: 'player', cwd: 'player'})
  47 + .pipe(gulp.dest(dest));
  48 +};
  49 +
37 50 gulp.task('chrome', function() {
38   - gulp.src(webglFiles, webglOptions)
39   - .pipe(gulp.dest(playersPath.chrome));
  51 + webglTask(playersPath.chrome);
40 52 });
41 53  
42 54 gulp.task('firefox', function() {
43   - gulp.src(webglFiles, webglOptions)
44   - .pipe(gulp.dest(playersPath.firefox));
  55 + webglTask(playersPath.firefox);
45 56 });
46 57  
47 58 gulp.task('safari', function() {
48   - gulp.src(webplayerFiles, webplayerOptions)
49   - .pipe(gulp.dest(playersPath.safari));
  59 + webplayerTask(playersPath.safari);
50 60 });
51 61 \ No newline at end of file
... ...
chrome/app/main.js
... ... @@ -1,50 +0,0 @@
1   -var app = {
2   - chooser: null,
3   - glosa: undefined,
4   - loaded: false,
5   - lastReq: {
6   - url: null,
7   - millis: null,
8   - response: null
9   - }
10   -};
11   -
12   -function onLoadPlayer() {
13   - if ( app.glosa !== undefined )
14   - SendMessage('PlayerManager', 'catchGlosa', app.glosa);
15   -
16   - app.loaded = true;
17   -}
18   -
19   -chrome.runtime.onMessage.addListener(
20   - function(request, sender, sendResponse) {
21   - if (request.selectedText === undefined) return;
22   -
23   - request.selectedText = encodeURI(request.selectedText);
24   -
25   - app.chooser = app.chooser || new qdClient.Chooser();
26   -
27   - document.getElementById('loading-screen').style.display = 'block';
28   - app.chooser.choose(
29   - app.lastReq.url,
30   - app.lastReq.millis,
31   - app.lastReq.response,
32   - function (url) {
33   - var start = new Date().getTime();
34   - qdClient.request(url + '?texto=' + request.selectedText, "GET", {},
35   - function(status, response) {
36   - app.lastReq.response = status === 404 ? -1 : status;
37   - app.lastReq.millis = (new Date().getTime() - start);
38   - app.lastReq.url = url;
39   -
40   - app.glosa = response;
41   -
42   - if (app.loaded == true)
43   - SendMessage('PlayerManager', 'catchGlosa', app.glosa);
44   -
45   - document.getElementById('loading-screen').style.display = 'none';
46   - });
47   - });
48   - });
49   -
50   -chrome.runtime.sendMessage({ready: true});
chrome/app/middleware.js 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +window.addEventListener('load', function() {
  2 + chrome.runtime.onMessage.addListener(
  3 + function(request, sender, sendResponse) {
  4 + if (request.selectedText === undefined) return;
  5 +
  6 + VLibrasPlugin.translate(encodeURI(request.selectedText));
  7 + });
  8 +
  9 + chrome.runtime.sendMessage({ready: true});
  10 +});
... ...
firefox/data/main.js
... ... @@ -1,47 +0,0 @@
1   -var app = {
2   - chooser: null,
3   - glosa: undefined,
4   - loaded: false,
5   - lastReq: {
6   - url: null,
7   - millis: null,
8   - response: null
9   - }
10   -};
11   -
12   -function onLoadPlayer() {
13   - if ( app.glosa !== undefined )
14   - SendMessage('PlayerManager', 'catchGlosa', app.glosa);
15   -
16   - app.loaded = true;
17   -}
18   -
19   -document.addEventListener('plugin:selectedText', function(e) {
20   - if (e.detail === undefined) return;
21   -
22   - e.detail = encodeURI(e.detail);
23   -
24   - app.chooser = app.chooser || new qdClient.Chooser();
25   -
26   - document.getElementById('loading-screen').style.display = 'block';
27   - app.chooser.choose(
28   - app.lastReq.url,
29   - app.lastReq.millis,
30   - app.lastReq.response,
31   - function (url) {
32   - var start = new Date().getTime();
33   -
34   - qdClient.request(url + '?texto=' + e.detail, "GET", {},
35   - function(status, response) {
36   - app.lastReq.response = status === 404 ? -1 : status;
37   - app.lastReq.millis = (new Date().getTime() - start);
38   - app.lastReq.url = url;
39   -
40   - app.glosa = response;
41   -
42   - document.getElementById('loading-screen').style.display = 'none';
43   - if (app.loaded == true)
44   - SendMessage('PlayerManager', 'catchGlosa', app.glosa);
45   - });
46   - });
47   -});
firefox/data/middleware.js 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +document.addEventListener('plugin:selectedText', function(e) {
  2 + if (e.detail === undefined) return;
  3 +
  4 + VLibrasPlugin.translate(encodeURI(e.detail));
  5 +});
... ...
firefox/index.js
... ... @@ -48,7 +48,7 @@ cm.Item({
48 48 // Page mod
49 49 pm.PageMod({
50 50 include: self.data.url('player/window.html'),
51   - contentScriptWhen: 'ready',
  51 + contentScriptWhen: 'end',
52 52 contentScriptFile: self.data.url('delegator.js'),
53 53 onAttach: function(worker) {
54 54 app.worker = worker;
... ...
player/.bowerrc 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +{
  2 + "directory": "vendors"
  3 +}
... ...
player/TemplateData/default-cover.jpg 0 → 100644

51.6 KB

player/TemplateData/favicon.png 0 → 100644

18.4 KB

player/TemplateData/fullbar.png 0 → 100644

2.71 KB

player/TemplateData/loadingbar.png 0 → 100644

2.78 KB

player/TemplateData/progresslogo.png 0 → 100644

20.7 KB

player/TemplateData/style.css 0 → 100644
... ... @@ -0,0 +1,69 @@
  1 +html {
  2 + -ms-text-size-adjust: 100%;
  3 + -webkit-text-size-adjust: 100%;
  4 +}
  5 +
  6 +html, body, #canvas {
  7 + width: 100%;
  8 + height: 100%;
  9 + margin: 0;
  10 + overflow: hidden;
  11 + font-size: 70%;
  12 + line-height: 110%;
  13 + -moz-osx-font-smoothing: grayscale;
  14 + -webkit-font-smoothing: antialiased;
  15 +}
  16 +
  17 +#loading-screen {
  18 + position: absolute;
  19 + top: 0;
  20 + left: 0;
  21 + display: none;
  22 + width: 100%;
  23 + height: 100%;
  24 + z-index: 9999;
  25 +}
  26 +
  27 +.message-box {
  28 + position: fixed;
  29 + top: -5em;
  30 + left: 0;
  31 + width: 100%;
  32 + padding: 1em;
  33 + font-size: 2em;
  34 + word-wrap: break-word;
  35 + color: #000;
  36 + opacity: 0;
  37 + -moz-transition: all .15s ease .15s;
  38 + -webkit-transition: all .15s ease .15s;
  39 + transition: all .15s ease .15s;
  40 + -moz-box-shadow: 0px 2px 5px #888888;
  41 + -webkit-box-shadow: 0px 2px 5px #888888;
  42 + box-shadow: 0px 2px 5px #888888;
  43 + z-index: 9998;
  44 +}
  45 +
  46 +.message-box.info {
  47 + background-color: #3b8bba;
  48 + color: #ffffff;
  49 +}
  50 +
  51 +.message-box.warning {
  52 + background-color: #f8ecad;
  53 + color: #7c6d1f;
  54 +}
  55 +
  56 +.message-box.success {
  57 + background-color: #d6e9c6;
  58 + color: #468847;
  59 +}
  60 +
  61 +.message-box.default {
  62 + background-color: #e6e6e6;
  63 + color: #8c8c8c;
  64 +}
  65 +
  66 +.message-box.active {
  67 + top: 0;
  68 + opacity: 1;
  69 +}
0 70 \ No newline at end of file
... ...
player/bower.json 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +{
  2 + "name": "vlibras-player",
  3 + "version": "0.0.1",
  4 + "ignore": [
  5 + "**/.*",
  6 + "node_modules",
  7 + "bower_components",
  8 + "test",
  9 + "tests"
  10 + ],
  11 + "devDependencies": {
  12 + "qdclient": "git@git.lavid.ufpb.br:qdclient.git"
  13 + },
  14 + "dependencies": {}
  15 +}
... ...
player/js/loading.js 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +(function (window, document, Message) {
  2 +
  3 + function Loading(selector, messageSelector) {
  4 + this.element = document.querySelector(selector);
  5 + this.message = new Message(messageSelector);
  6 + }
  7 +
  8 + Loading.prototype.show = function(message) {
  9 + this.element.style.display = 'block';
  10 + this.message.show('info', message);
  11 + };
  12 +
  13 + Loading.prototype.hide = function() {
  14 + this.element.style.display = 'none';
  15 + this.message.hide();
  16 + };
  17 +
  18 + window.Loading = Loading;
  19 +})(window, document, window.Message);
0 20 \ No newline at end of file
... ...
player/js/message.js 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +(function(window, document) {
  2 +
  3 + function Message(selectors) {
  4 + this.element = document.querySelector(selectors);
  5 +
  6 + this.element.classList.add('message-box');
  7 +
  8 + var self = this;
  9 + var closeElement = this.element.querySelector('.close');
  10 +
  11 + if (closeElement) {
  12 + closeElement.addEventListener('click', function (e) {
  13 + self.hide();
  14 + });
  15 + }
  16 +
  17 + this.hide();
  18 + }
  19 +
  20 + Message.LEVELS = ['info', 'warning', 'success', 'default'];
  21 +
  22 + Message.prototype.hide = function() {
  23 + this.element.classList.remove('active');
  24 +
  25 + Message.LEVELS.forEach(function(level) {
  26 + this.element.classList.remove(level);
  27 + }, this);
  28 + };
  29 +
  30 + Message.prototype.show = function(level, message, time) {
  31 + var self = this;
  32 +
  33 + level = Message.LEVELS.indexOf(level) == -1 ? 'info' : level;
  34 +
  35 + this.hide();
  36 +
  37 + self.element.classList.add('active');
  38 + self.element.classList.add(level);
  39 + self.element.querySelector('.message').innerHTML = message;
  40 +
  41 + if (time) {
  42 + setTimeout(function () {
  43 + self.hide();
  44 + }, time + 1);
  45 + }
  46 + };
  47 +
  48 + // Expose
  49 + window.Message = Message;
  50 +})(window, document);
0 51 \ No newline at end of file
... ...
player/js/vlibras-plugin.js 0 → 100644
... ... @@ -0,0 +1,73 @@
  1 +(function(window, document, Loading, Message) {
  2 + function VLibrasPlugin() {
  3 + this.loaded = false;
  4 + this.chooser = new qdClient.Chooser();
  5 + this.glosa = undefined;
  6 + this.loading = new Loading('#loading-screen', '#message-box');
  7 + this.message = new Message('#message-box');
  8 + this.lastReq = {
  9 + url: null,
  10 + millis: null,
  11 + response: null
  12 + };
  13 + }
  14 +
  15 + VLibrasPlugin.prototype.sendGlosa = function(glosa) {
  16 + var glosa = glosa || this.glosa;
  17 +
  18 + if (glosa !== undefined && this.loaded === true) {
  19 + window.SendMessage('PlayerManager', 'catchGlosa', glosa);
  20 + }
  21 + };
  22 +
  23 + VLibrasPlugin.prototype.translate = function(text) {
  24 + var self = this;
  25 + self.loading.show('Traduzindo...');
  26 + self.chooser.choose(self.lastReq.url, self.lastReq.millis, self.lastReq.response,
  27 + function (url) {
  28 + var start = new Date().getTime();
  29 +
  30 + if (!url) {
  31 + self.loading.hide();
  32 + self.message.show('warning', 'Não foi possível se conectar ao servidor. Irei soletrar!', 3000);
  33 +
  34 + self.glosa = decodeURI(text).toUpperCase();
  35 + self.sendGlosa();
  36 + return;
  37 + }
  38 +
  39 + qdClient.request(url + '?texto=' + text, "GET", {},
  40 + function(status, response) {
  41 + self.lastReq.response = status !== 200 ? -1 : status;
  42 + self.lastReq.millis = (new Date().getTime() - start);
  43 + self.lastReq.url = url;
  44 +
  45 + self.loading.hide();
  46 + if (status !== 200)
  47 + self.message.show('warning', 'Não foi possível se conectar ao servidor. Irei soletrar!', 3000);
  48 +
  49 + self.glosa = response || decodeURI(text).toUpperCase();
  50 + self.sendGlosa();
  51 + });
  52 + });
  53 + };
  54 +
  55 + VLibrasPlugin.prototype.showMessage = function(level, message, time) {
  56 + this.message.show(level, message, time);
  57 + };
  58 +
  59 + VLibrasPlugin.prototype.hideMessage = function() {
  60 + this.message.hide();
  61 + };
  62 +
  63 + VLibrasPlugin.prototype.load = function() {
  64 + this.loaded = true;
  65 + this.sendGlosa();
  66 + };
  67 +
  68 + // Expose
  69 + window.VLibrasPlugin = new VLibrasPlugin();
  70 + window.onLoadPlayer = function() {
  71 + this.VLibrasPlugin.load();
  72 + };
  73 +})(window, document, Loading, Message);
... ...
player/webgl/TemplateData/UnityProgress.js 0 → 100644
... ... @@ -0,0 +1,97 @@
  1 +function UnityProgress (dom) {
  2 + this.progress = 0.0;
  3 + this.message = "";
  4 + this.dom = dom;
  5 +
  6 + var parent = dom.parentNode;
  7 +
  8 + var background = document.createElement("div");
  9 + background.style.background = "#FFFFFF";
  10 + background.style.position = "absolute";
  11 + parent.appendChild(background);
  12 + this.background = background;
  13 +
  14 + var logoImage = document.createElement("img");
  15 + logoImage.src = "TemplateData/progresslogo.png";
  16 + logoImage.style.position = "absolute";
  17 + parent.appendChild(logoImage);
  18 + this.logoImage = logoImage;
  19 +
  20 + var progressFrame = document.createElement("img");
  21 + progressFrame.src = "TemplateData/loadingbar.png";
  22 + progressFrame.style.position = "absolute";
  23 + parent.appendChild(progressFrame);
  24 + this.progressFrame = progressFrame;
  25 +
  26 + var progressBar = document.createElement("img");
  27 + progressBar.src = "TemplateData/fullbar.png";
  28 + progressBar.style.position = "absolute";
  29 + parent.appendChild(progressBar);
  30 + this.progressBar = progressBar;
  31 +
  32 + var messageArea = document.createElement("p");
  33 + messageArea.style.position = "absolute";
  34 + parent.appendChild(messageArea);
  35 + this.messageArea = messageArea;
  36 +
  37 +
  38 + this.SetProgress = function (progress) {
  39 + if (this.progress < progress)
  40 + this.progress = progress;
  41 + this.messageArea.style.display = "none";
  42 + this.progressFrame.style.display = "inline";
  43 + this.progressBar.style.display = "inline";
  44 + this.Update();
  45 + }
  46 +
  47 + this.SetMessage = function (message) {
  48 + this.message = message;
  49 + this.background.style.display = "inline";
  50 + this.logoImage.style.display = "inline";
  51 + this.progressFrame.style.display = "none";
  52 + this.progressBar.style.display = "none";
  53 + this.Update();
  54 + }
  55 +
  56 + this.Clear = function() {
  57 + this.background.style.display = "none";
  58 + this.logoImage.style.display = "none";
  59 + this.progressFrame.style.display = "none";
  60 + this.progressBar.style.display = "none";
  61 + }
  62 +
  63 + this.Update = function() {
  64 + this.background.style.top = this.dom.offsetTop + 'px';
  65 + this.background.style.left = this.dom.offsetLeft + 'px';
  66 + this.background.style.width = this.dom.offsetWidth + 'px';
  67 + this.background.style.height = this.dom.offsetHeight + 'px';
  68 +
  69 + var logoImg = new Image();
  70 + logoImg.src = this.logoImage.src;
  71 + var progressFrameImg = new Image();
  72 + progressFrameImg.src = this.progressFrame.src;
  73 +
  74 + this.logoImage.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 - logoImg.height * 0.5) + 'px';
  75 + this.logoImage.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - logoImg.width * 0.5) + 'px';
  76 + this.logoImage.style.width = logoImg.width+'px';
  77 + this.logoImage.style.height = logoImg.height+'px';
  78 +
  79 + this.progressFrame.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 + logoImg.height * 0.5 + 10) + 'px';
  80 + this.progressFrame.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - progressFrameImg.width * 0.5) + 'px';
  81 + this.progressFrame.width = progressFrameImg.width;
  82 + this.progressFrame.height = progressFrameImg.height;
  83 +
  84 + this.progressBar.style.top = this.progressFrame.style.top;
  85 + this.progressBar.style.left = this.progressFrame.style.left;
  86 + this.progressBar.width = progressFrameImg.width * Math.min(this.progress, 1);
  87 + this.progressBar.height = progressFrameImg.height;
  88 +
  89 + this.messageArea.style.top = this.progressFrame.style.top;
  90 + this.messageArea.style.left = 0;
  91 + this.messageArea.style.width = '100%';
  92 + this.messageArea.style.textAlign = 'center';
  93 + this.messageArea.innerHTML = this.message;
  94 + }
  95 +
  96 + this.Update ();
  97 +}
0 98 \ No newline at end of file
... ...
player/webgl/connect.js 0 → 100644
... ... @@ -0,0 +1,40 @@
  1 +// connect to canvas
  2 + var Module = {
  3 + TOTAL_MEMORY: 268435456,
  4 + filePackagePrefixURL: "Release/",
  5 + memoryInitializerPrefixURL: "Release/",
  6 + preRun: [],
  7 + postRun: [],
  8 + print: (function() {
  9 + return function(text) {
  10 + console.log (text);
  11 + };
  12 + })(),
  13 + printErr: function(text) {
  14 + console.error (text);
  15 + },
  16 + canvas: document.getElementById('canvas'),
  17 + progress: null,
  18 + setStatus: function(text) {
  19 + if (this.progress == null)
  20 + {
  21 + if (typeof UnityProgress != 'function')
  22 + return;
  23 + this.progress = new UnityProgress (canvas);
  24 + }
  25 + if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
  26 + if (text === Module.setStatus.text) return;
  27 + this.progress.SetMessage (text);
  28 + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
  29 + if (m)
  30 + this.progress.SetProgress (parseInt(m[2])/parseInt(m[4]));
  31 + if (text === "")
  32 + this.progress.Clear()
  33 + },
  34 + totalDependencies: 0,
  35 + monitorRunDependencies: function(left) {
  36 + this.totalDependencies = Math.max(this.totalDependencies, left);
  37 + Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
  38 + }
  39 + };
  40 + Module.setStatus('Downloading (0.0/1)');
... ...
player/webgl/load.js 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +if (!(!Math.fround)) {
  2 + var script = document.createElement('script');
  3 + script.src = "Release/WEBGL.js";
  4 + document.body.appendChild(script);
  5 +} else {
  6 + var codeXHR = new XMLHttpRequest();
  7 + codeXHR.open('GET', 'Release/WEBGL.js', true);
  8 + codeXHR.onload = function() {
  9 + var code = codeXHR.responseText;
  10 + if (!Math.fround) {
  11 +try {
  12 + console.log('optimizing out Math.fround calls');
  13 + var m = /var ([^=]+)=global\.Math\.fround;/.exec(code);
  14 + var minified = m[1];
  15 + if (!minified) throw 'fail';
  16 + var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS');
  17 + var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS');
  18 + var asm = code.substring(startAsm, endAsm);
  19 + do {
  20 + var moar = false; // we need to re-do, as x(x( will not be fixed
  21 + asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' });
  22 + } while (moar);
  23 + code = code.substring(0, startAsm) + asm + code.substring(endAsm);
  24 + code = code.replace("'use asm'", "'almost asm'");
  25 +} catch(e) { console.log('failed to optimize out Math.fround calls ' + e) }
  26 + }
  27 +
  28 + var blob = new Blob([code], { type: 'text/javascript' });
  29 + codeXHR = null;
  30 + var src = URL.createObjectURL(blob);
  31 + var script = document.createElement('script');
  32 + script.src = URL.createObjectURL(blob);
  33 + script.onload = function() {
  34 + URL.revokeObjectURL(script.src);
  35 + };
  36 + document.body.appendChild(script);
  37 + };
  38 + codeXHR.send(null);
  39 +}
... ...
player/webgl/verify-compatibility.js 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +(function() {
  2 + var checkWebGLCompability = function() {
  3 + var canvas = document.createElement('canvas');
  4 + var gl = canvas.getContext("webgl");
  5 + if (!gl) {
  6 + gl = canvas.getContext("experimental-webgl");
  7 + if (!gl) return false;
  8 + }
  9 +
  10 + return true;
  11 + };
  12 +
  13 + if (!checkWebGLCompability()) {
  14 + VLibrasPlugin.showMessage('warning', 'O seu computador não suporta o WebGL. Porfavor atualizar os drivers de vídeo.');
  15 + window.stop();
  16 + };
  17 +})();
0 18 \ No newline at end of file
... ...
player/webgl/window.html 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +<!doctype html>
  2 +<html lang="en-us">
  3 + <head>
  4 + <meta charset="utf-8">
  5 + <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6 + <title>VLibras Plugin</title>
  7 + <link rel="stylesheet" href="TemplateData/style.css">
  8 + <link rel="shortcut icon" href="TemplateData/favicon.png" />
  9 + <script src="TemplateData/UnityProgress.js"></script>
  10 + </head>
  11 + <body class="template">
  12 + <div id="loading-screen"></div>
  13 + <div id="message-box">
  14 + <span class="message"></span>
  15 + </div>
  16 +
  17 + <canvas class="emscripten" id="canvas"></canvas>
  18 +
  19 + <!-- VLibrasPlugin -->
  20 + <script src="vendors/qdclient/qdclient.js"></script>
  21 + <script src="js/message.js"></script>
  22 + <script src="js/loading.js"></script>
  23 + <script src="js/vlibras-plugin.js"></script>
  24 +
  25 + <!-- Verify Compatibilty -->
  26 + <script src="verify-compatibility.js"></script>
  27 +
  28 + <!-- Browser Middleware -->
  29 + <script src="../middleware.js"></script>
  30 +
  31 + <!-- Unity Player Setup -->
  32 + <script src="connect.js"></script>
  33 + <script src="Release/fileloader.js"></script>
  34 + <script src="load.js"></script>
  35 + </body>
  36 +</html>
... ...
player/webplayer/WEBPLAYER.unity3d 0 → 100644
No preview for this file type
player/webplayer/player.js 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +(function(window, UnityObject2) {
  2 + var params = {
  3 + logoimage: 'TemplateData/progresslogo.png',
  4 + progressbarimage: 'TemplateData/fullbar.png',
  5 + progressframeimage: 'TemplateData/loadingbar.png'
  6 + };
  7 +
  8 + var Player = new UnityObject2({ params: params });
  9 + Player.initPlugin(document.getElementById('player'), 'WEBPLAYER.unity3d');
  10 +
  11 + window.SendMessage = function(object, method, params) {
  12 + Player.getUnity().SendMessage(object, method, params);
  13 + };
  14 +
  15 +})(window, UnityObject2);
0 16 \ No newline at end of file
... ...
player/webplayer/window.html 0 → 100644
... ... @@ -0,0 +1,58 @@
  1 +<!doctype html>
  2 +<html lang="en-us">
  3 + <head>
  4 + <meta charset="utf-8">
  5 + <title>VLibras Plugin</title>
  6 +
  7 + <link rel="shortcut icon" href="TemplateData/favicon.png" />
  8 + <style type="text/css">
  9 + html, body, #player {
  10 + width: 100%;
  11 + height: 100%;
  12 + margin: 0;
  13 + overflow: hidden;
  14 + }
  15 +
  16 + #loading-screen span {
  17 + position: absolute;
  18 + top: 5px;
  19 + right: 40px;
  20 + padding: 15px 10px;
  21 + background: #000;
  22 + color: #FFF;
  23 +
  24 + font-size: 1.2em;
  25 + -webkit-border-radius: 20px;
  26 + -moz-border-radius: 20px;
  27 + border-radius: 20px;
  28 + }
  29 +
  30 + #loading-screen {
  31 + position: absolute;
  32 + top: 0;
  33 + left: 0;
  34 + display: none;
  35 + width: 100%;
  36 + height: 100%;
  37 + z-index: 9999;
  38 + }
  39 + </style>
  40 + </head>
  41 + <body>
  42 + <div id="loading-screen"><span>Carregando...</span></div>
  43 + <div id="player">
  44 + <div class="missing">
  45 + <a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
  46 + <img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
  47 + </a>
  48 + </div>
  49 + </div>
  50 +
  51 + <script src="vendors/jquery/dist/jquery.min.js"></script>
  52 + <script src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"></script>
  53 + <script src="vendors/qdclient/qdclient.js"></script>
  54 + <script src="player.js"></script>
  55 +
  56 + <script src="../main.js"></script>
  57 + </body>
  58 +</html>
0 59 \ No newline at end of file
... ...
webgl/.bowerrc
... ... @@ -1,3 +0,0 @@
1   -{
2   - "directory": "vendors"
3   -}
webgl/TemplateData/UnityProgress.js
... ... @@ -1,97 +0,0 @@
1   -function UnityProgress (dom) {
2   - this.progress = 0.0;
3   - this.message = "";
4   - this.dom = dom;
5   -
6   - var parent = dom.parentNode;
7   -
8   - var background = document.createElement("div");
9   - background.style.background = "#FFFFFF";
10   - background.style.position = "absolute";
11   - parent.appendChild(background);
12   - this.background = background;
13   -
14   - var logoImage = document.createElement("img");
15   - logoImage.src = "TemplateData/progresslogo.png";
16   - logoImage.style.position = "absolute";
17   - parent.appendChild(logoImage);
18   - this.logoImage = logoImage;
19   -
20   - var progressFrame = document.createElement("img");
21   - progressFrame.src = "TemplateData/loadingbar.png";
22   - progressFrame.style.position = "absolute";
23   - parent.appendChild(progressFrame);
24   - this.progressFrame = progressFrame;
25   -
26   - var progressBar = document.createElement("img");
27   - progressBar.src = "TemplateData/fullbar.png";
28   - progressBar.style.position = "absolute";
29   - parent.appendChild(progressBar);
30   - this.progressBar = progressBar;
31   -
32   - var messageArea = document.createElement("p");
33   - messageArea.style.position = "absolute";
34   - parent.appendChild(messageArea);
35   - this.messageArea = messageArea;
36   -
37   -
38   - this.SetProgress = function (progress) {
39   - if (this.progress < progress)
40   - this.progress = progress;
41   - this.messageArea.style.display = "none";
42   - this.progressFrame.style.display = "inline";
43   - this.progressBar.style.display = "inline";
44   - this.Update();
45   - }
46   -
47   - this.SetMessage = function (message) {
48   - this.message = message;
49   - this.background.style.display = "inline";
50   - this.logoImage.style.display = "inline";
51   - this.progressFrame.style.display = "none";
52   - this.progressBar.style.display = "none";
53   - this.Update();
54   - }
55   -
56   - this.Clear = function() {
57   - this.background.style.display = "none";
58   - this.logoImage.style.display = "none";
59   - this.progressFrame.style.display = "none";
60   - this.progressBar.style.display = "none";
61   - }
62   -
63   - this.Update = function() {
64   - this.background.style.top = this.dom.offsetTop + 'px';
65   - this.background.style.left = this.dom.offsetLeft + 'px';
66   - this.background.style.width = this.dom.offsetWidth + 'px';
67   - this.background.style.height = this.dom.offsetHeight + 'px';
68   -
69   - var logoImg = new Image();
70   - logoImg.src = this.logoImage.src;
71   - var progressFrameImg = new Image();
72   - progressFrameImg.src = this.progressFrame.src;
73   -
74   - this.logoImage.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 - logoImg.height * 0.5) + 'px';
75   - this.logoImage.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - logoImg.width * 0.5) + 'px';
76   - this.logoImage.style.width = logoImg.width+'px';
77   - this.logoImage.style.height = logoImg.height+'px';
78   -
79   - this.progressFrame.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 + logoImg.height * 0.5 + 10) + 'px';
80   - this.progressFrame.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - progressFrameImg.width * 0.5) + 'px';
81   - this.progressFrame.width = progressFrameImg.width;
82   - this.progressFrame.height = progressFrameImg.height;
83   -
84   - this.progressBar.style.top = this.progressFrame.style.top;
85   - this.progressBar.style.left = this.progressFrame.style.left;
86   - this.progressBar.width = progressFrameImg.width * Math.min(this.progress, 1);
87   - this.progressBar.height = progressFrameImg.height;
88   -
89   - this.messageArea.style.top = this.progressFrame.style.top;
90   - this.messageArea.style.left = 0;
91   - this.messageArea.style.width = '100%';
92   - this.messageArea.style.textAlign = 'center';
93   - this.messageArea.innerHTML = this.message;
94   - }
95   -
96   - this.Update ();
97   -}
98 0 \ No newline at end of file
webgl/TemplateData/default-cover.jpg

51.6 KB

webgl/TemplateData/favicon.png

18.4 KB

webgl/TemplateData/fullbar.png

2.71 KB

webgl/TemplateData/loadingbar.png

2.78 KB

webgl/TemplateData/progresslogo.png

20.7 KB

webgl/TemplateData/style.css
... ... @@ -1,64 +0,0 @@
1   -
2   -/****************************************
3   - ==== Player Styling
4   -****************************************/
5   -
6   -html,body,div,canvas { margin: 0; padding: 0; }
7   -::-moz-selection { color: #333; text-shadow: none; }
8   -::selection { color: #333; text-shadow: none; }
9   -.clear:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
10   -.clear { display: inline-table; clear: both; }
11   -/* Hides from IE-mac \*/ * html .clear { height: 1%; } .clear { display: block; } /* End hide from IE-mac */
12   -
13   -html, body { width: 100%; height: 100%; font-family: Helvetica, Verdana, Arial, sans-serif; }
14   -body { }
15   -p.header, p.footer { display: none; }
16   -div.logo { width: 196px; height: 38px; float: left; background: url(logo.png) 0 0 no-repeat; position: relative; z-index: 10; }
17   -div.title { height: 38px; line-height: 38px; padding: 0 10px; margin: 0 1px 0 0; float: right; color: #333; text-align: right; font-size: 18px; position: relative; z-index: 10; }
18   -.template-wrap { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
19   -.template-wrap canvas { margin: 0 0 10px 0; position: relative; z-index: 9; box-shadow: 0 10px 30px rgba(0,0,0,0.2); -moz-box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
20   -.fullscreen { float: right; position: relative; z-index: 10; }
21   -
22   -body.template { }
23   -.template .template-wrap { }
24   -.template .template-wrap canvas { }
25   -
26   -/****************************************
27   - ==== Overriding
28   -****************************************/
29   -html, #canvas, .template, .template-wrap {
30   - width: 100%;
31   - height: 100%;
32   - margin: 0;
33   - overflow: hidden;
34   -}
35   -
36   -#loading-screen {
37   - position: absolute;
38   - top: 0;
39   - left: 0;
40   - display: none;
41   - width: 100%;
42   - height: 100%;
43   - z-index: 9999;
44   -}
45   -
46   -.message {
47   - position: fixed;
48   - top: 0;
49   - left: 0;
50   - width: 100%;
51   - padding: 1em 0.5em;
52   -}
53   -
54   -.message .info {
55   - background-color: #3b8bba;
56   -}
57   -
58   -.message .hidden {
59   - display: none;
60   -}
61   -
62   -.message .warning {
63   - background-color: #f08a24;
64   -}
65 0 \ No newline at end of file
webgl/bower.json
... ... @@ -1,14 +0,0 @@
1   -{
2   - "name": "vlibras-player",
3   - "version": "0.0.1",
4   - "ignore": [
5   - "**/.*",
6   - "node_modules",
7   - "bower_components",
8   - "test",
9   - "tests"
10   - ],
11   - "devDependencies": {
12   - "qdclient": "git@git.lavid.ufpb.br:qdclient.git"
13   - }
14   -}
webgl/connect.js
... ... @@ -1,40 +0,0 @@
1   -// connect to canvas
2   - var Module = {
3   - TOTAL_MEMORY: 268435456,
4   - filePackagePrefixURL: "Release/",
5   - memoryInitializerPrefixURL: "Release/",
6   - preRun: [],
7   - postRun: [],
8   - print: (function() {
9   - return function(text) {
10   - console.log (text);
11   - };
12   - })(),
13   - printErr: function(text) {
14   - console.error (text);
15   - },
16   - canvas: document.getElementById('canvas'),
17   - progress: null,
18   - setStatus: function(text) {
19   - if (this.progress == null)
20   - {
21   - if (typeof UnityProgress != 'function')
22   - return;
23   - this.progress = new UnityProgress (canvas);
24   - }
25   - if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
26   - if (text === Module.setStatus.text) return;
27   - this.progress.SetMessage (text);
28   - var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
29   - if (m)
30   - this.progress.SetProgress (parseInt(m[2])/parseInt(m[4]));
31   - if (text === "")
32   - this.progress.Clear()
33   - },
34   - totalDependencies: 0,
35   - monitorRunDependencies: function(left) {
36   - this.totalDependencies = Math.max(this.totalDependencies, left);
37   - Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
38   - }
39   - };
40   - Module.setStatus('Downloading (0.0/1)');
webgl/load.js
... ... @@ -1,39 +0,0 @@
1   -if (!(!Math.fround)) {
2   - var script = document.createElement('script');
3   - script.src = "Release/WEBGL.js";
4   - document.body.appendChild(script);
5   -} else {
6   - var codeXHR = new XMLHttpRequest();
7   - codeXHR.open('GET', 'Release/WEBGL.js', true);
8   - codeXHR.onload = function() {
9   - var code = codeXHR.responseText;
10   - if (!Math.fround) {
11   -try {
12   - console.log('optimizing out Math.fround calls');
13   - var m = /var ([^=]+)=global\.Math\.fround;/.exec(code);
14   - var minified = m[1];
15   - if (!minified) throw 'fail';
16   - var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS');
17   - var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS');
18   - var asm = code.substring(startAsm, endAsm);
19   - do {
20   - var moar = false; // we need to re-do, as x(x( will not be fixed
21   - asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' });
22   - } while (moar);
23   - code = code.substring(0, startAsm) + asm + code.substring(endAsm);
24   - code = code.replace("'use asm'", "'almost asm'");
25   -} catch(e) { console.log('failed to optimize out Math.fround calls ' + e) }
26   - }
27   -
28   - var blob = new Blob([code], { type: 'text/javascript' });
29   - codeXHR = null;
30   - var src = URL.createObjectURL(blob);
31   - var script = document.createElement('script');
32   - script.src = URL.createObjectURL(blob);
33   - script.onload = function() {
34   - URL.revokeObjectURL(script.src);
35   - };
36   - document.body.appendChild(script);
37   - };
38   - codeXHR.send(null);
39   -}
webgl/window.html
... ... @@ -1,28 +0,0 @@
1   -<!doctype html>
2   -<html lang="en-us">
3   - <head>
4   - <meta charset="utf-8">
5   - <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6   - <title>VLibras Plugin</title>
7   - <link rel="stylesheet" href="TemplateData/style.css">
8   - <link rel="shortcut icon" href="TemplateData/favicon.png" />
9   - <script src="TemplateData/UnityProgress.js"></script>
10   -
11   - <script src="vendors/qdclient/qdclient.js"></script>
12   - <script src="js/message.js"></script>
13   - <script src="js/loading.js"></script>
14   -
15   - <script src="../main.js"></script>
16   - </head>
17   - <body class="template">
18   - <div id="message"></div>
19   - <div id="loading-screen"></div>
20   - <div class="template-wrap clear">
21   - <canvas class="emscripten" id="canvas"></canvas>
22   - </div>
23   - <script src="connect.js"></script>
24   - <script src="Release/UnityConfig.js"></script>
25   - <script src="Release/fileloader.js"></script>
26   - <script src="load.js"></script>
27   - </body>
28   -</html>
webplayer/.bowerrc
... ... @@ -1,3 +0,0 @@
1   -{
2   - "directory": "vendors"
3   -}
4 0 \ No newline at end of file
webplayer/TemplateData/favicon.png

18.4 KB

webplayer/TemplateData/fullbar.png

1.16 KB

webplayer/TemplateData/loadingbar.png

2.78 KB

webplayer/TemplateData/progresslogo.png

20.7 KB

webplayer/WEBPLAYER.unity3d
No preview for this file type
webplayer/bower.json
... ... @@ -1,17 +0,0 @@
1   -{
2   - "name": "vlibras-player",
3   - "version": "0.0.1",
4   - "ignore": [
5   - "**/.*",
6   - "node_modules",
7   - "bower_components",
8   - "test",
9   - "tests"
10   - ],
11   - "devDependencies": {
12   - "qdclient": "git@git.lavid.ufpb.br:qdclient.git"
13   - },
14   - "dependencies": {
15   - "jquery": "~2.1.4"
16   - }
17   -}
webplayer/player.js
... ... @@ -1,15 +0,0 @@
1   -(function(window, UnityObject2) {
2   - var params = {
3   - logoimage: 'TemplateData/progresslogo.png',
4   - progressbarimage: 'TemplateData/fullbar.png',
5   - progressframeimage: 'TemplateData/loadingbar.png'
6   - };
7   -
8   - var Player = new UnityObject2({ params: params });
9   - Player.initPlugin(document.getElementById('player'), 'WEBPLAYER.unity3d');
10   -
11   - window.SendMessage = function(object, method, params) {
12   - Player.getUnity().SendMessage(object, method, params);
13   - };
14   -
15   -})(window, UnityObject2);
16 0 \ No newline at end of file
webplayer/window.html
... ... @@ -1,58 +0,0 @@
1   -<!doctype html>
2   -<html lang="en-us">
3   - <head>
4   - <meta charset="utf-8">
5   - <title>VLibras Plugin</title>
6   -
7   - <link rel="shortcut icon" href="TemplateData/favicon.png" />
8   - <style type="text/css">
9   - html, body, #player {
10   - width: 100%;
11   - height: 100%;
12   - margin: 0;
13   - overflow: hidden;
14   - }
15   -
16   - #loading-screen span {
17   - position: absolute;
18   - top: 5px;
19   - right: 40px;
20   - padding: 15px 10px;
21   - background: #000;
22   - color: #FFF;
23   -
24   - font-size: 1.2em;
25   - -webkit-border-radius: 20px;
26   - -moz-border-radius: 20px;
27   - border-radius: 20px;
28   - }
29   -
30   - #loading-screen {
31   - position: absolute;
32   - top: 0;
33   - left: 0;
34   - display: none;
35   - width: 100%;
36   - height: 100%;
37   - z-index: 9999;
38   - }
39   - </style>
40   - </head>
41   - <body>
42   - <div id="loading-screen"><span>Carregando...</span></div>
43   - <div id="player">
44   - <div class="missing">
45   - <a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
46   - <img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
47   - </a>
48   - </div>
49   - </div>
50   -
51   - <script src="vendors/jquery/dist/jquery.min.js"></script>
52   - <script src="http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js"></script>
53   - <script src="vendors/qdclient/qdclient.js"></script>
54   - <script src="player.js"></script>
55   -
56   - <script src="../main.js"></script>
57   - </body>
58   -</html>
59 0 \ No newline at end of file