diff --git a/.gitignore b/.gitignore index a452248..ca6f01c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,11 @@ chrome/app/player firefox/data/player +safari.safariextension/app/player -player/Release +webgl/Release +webgl/vendors +webplayer/vendors node_modules + +**/.DS_Store \ No newline at end of file diff --git a/Gulpfile.js b/Gulpfile.js index ce683f4..d4de1c6 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -1,6 +1,17 @@ var gulp = require('gulp'); -var playerFiles = [ +var playersPath = { + chrome: 'chrome/app/player', + firefox: 'firefox/data/player', + safari: 'safari.safariextension/app/player' +}; + +var webglOptions = { + base: 'webgl', + cwd: 'webgl' +}; + +var webglFiles = [ 'connect.js', 'load.js', 'window.html', @@ -9,12 +20,29 @@ var playerFiles = [ 'vendors/**/*' ]; +var webplayerOptions = { + base: 'webplayer', + cwd: 'webplayer' +}; + +var webplayerFiles = [ + 'window.html', + 'player.js', + 'WEBPLAYER.unity3d', + 'vendors/**/*' +]; + gulp.task('chrome', function() { - gulp.src(playerFiles, { base: '.', cwd: 'player/' }) - .pipe(gulp.dest('chrome/app')); + gulp.src(webglFiles, webglOptions) + .pipe(gulp.dest(playersPath.chrome)); }); gulp.task('firefox', function() { - gulp.src(playerFiles, { base: '.', cwd: 'player/' }) - .pipe(gulp.dest('firefox/data')); + gulp.src(webglFiles, webglOptions) + .pipe(gulp.dest(playersPath.firefox)); }); + +gulp.task('safari', function() { + gulp.src(webplayerFiles, webplayerOptions) + .pipe(gulp.dest(playersPath.safari)); +}); \ No newline at end of file diff --git a/chrome/background.js b/chrome/background.js index b0717ea..58a7fde 100644 --- a/chrome/background.js +++ b/chrome/background.js @@ -12,6 +12,8 @@ chrome.contextMenus.create({ // Listening the event click chrome.contextMenus.onClicked.addListener( function (info) { + selectedText = info.selectionText; + // Creates the window if it exists if ( popup === undefined ) { chrome.windows.create({ @@ -23,12 +25,11 @@ chrome.contextMenus.onClicked.addListener( function (info) { type: "popup" }, function (w) { popup = w; - - selectedText = info.selectionText; }); } else { chrome.windows.update(popup.id, {focused: true}, function () { - chrome.runtime.sendMessage({selectedText: info.selectionText}); + chrome.runtime.sendMessage({selectedText: selectedText}); + selectedText = undefined; }); } }); diff --git a/keys/vlibrasplugin-chrome.pem b/keys/vlibrasplugin-chrome.pem new file mode 100644 index 0000000..f287079 --- /dev/null +++ b/keys/vlibrasplugin-chrome.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8UI+z9pRhF8Kv +WC3Y2eI41b4AJeROjrO3rVeBG+FYjMuOB0r1byFUlebGP/Nep7nZ9eEUZ4E71lkp +WDyYLfZTb+gum6MQAeh8Wd7aBh9qSa4ru08ieu/8HxmHdfUFpWph3yPMV0TdAXVh +sbMLWcvzu+AmEkPM09KtXENyAOkR63ncll7HtmGFdxicTzNWuIhrvrhsd1xtuS1c +g4vk1XEJ5mcSnVLVGojAI8uwY4QEAGC2bUMzmD6mtZxySHu5XxNnk1xFdTxebd1K +4u0HyDgpY7epRsnkYHQq9HZ7Smet2JW4tHmd/5nPMZXFztZ/bUSuOqAmXvmLXvmw +JSpVnEENAgMBAAECggEAVCmFMB8iDYq6/fbg9qvaSSBt/E7zDJEGjS6xjwhQ3GyA +hQeJXsu+D7m3HB90u3cmvtz/LUldHssbqji/TBwunPfEwx/X7s2LhBf+W16lJ7Gq +X+0k3vomy31ywXHcght9wiQiMa9HHacLORBcPtRxLItpEFrVZnO9ErHLiuYRRGo+ +EKP79o1dVZ5kldJ7toB4ok+KIDu2PJJShj4nXj7mKNlGZPH2hYn+NG7ZLFOjUp09 +AKjTIE5WADt5bOKN9Wo2HiCG63zLZsaJmeYh2v3TxnpAj+W/TMxV/y0kIe7gzqw1 +2qxdBmLBILNM8AkwadpbJRuC6aynd41sqejix3uemQKBgQDzONGl0Yf8fg5EyX3r +w/OldzZv/Comy6Ka/aq8I88clFBlEoD2os+lF6IDAgMj102awjiI+fxOe81C7Pza +a5eGHeq3qaE0E7v7ggcW7YXlFs9YC6RikKEkGCFnnaxeBf+/iXICcf32GzZkSow2 +JTedIJIbu/oca2UFpVsK4inkHwKBgQDGNUZMmJ1ca4WdpmP6mUCwqEgOZ+UcG/3K +4Sy0BtJOB1wVoQOzM1q2FUurCqps81cghUbtJyeRk4y4eI1rOEbz8m0UB0hWyEq1 +pJJiz0nei7ficAIHO5e2elDV2lJ7KNxYeb3YN2NXbGmwmsI/IoudPp+wghnl4Xns +2JcBFZdVUwKBgQCBDcb/6xvyt5gum5M7BDBFvemepfhfuXFAOBTd20pL6c52ssjH +FUCEYvPOEMVFwTomQaPp2msr4bjaKBFKfAhcW4dtiI5Gqan3G9lTKxj+o4nFN/gz +bHZ0RnGDH0CUay52nSFndsDAU1QbBws6t6i4sM2V9boSVlG2GzUhozuDFQKBgG2P +kTZRvdoSTR9hlC43fDyqKHpeD5TEHDuC0HUKuEENbGdAQ41Qu7med98p3B6xO93s +DdKVLBgaGVT2viUgTIgX3xeNFv1xZWqWd5xKvKhZTuHJzDU3SZtCbWBod+NAKNx3 +HutfYng2ow1N3kWL0OSwcxDcOXiKdBzpdD7TMn2lAoGAH3xcQ9pI1aCeNxrnyvsJ +1EFlSX+3HQvjd9JOVemiVd6jP5SbrM6DplzimYPVmJhlAcq+wi8/dHyOGMRCb7ZV +Yv44hSheny/RhfMcePwubLBhVULRrdg2LWOEnSgrLIWNe2CCJ+xzgr2mEM+vGazI +zVWbI5s+shUi96/ZSZMjxGo= +-----END PRIVATE KEY----- diff --git a/player/.bowerrc b/player/.bowerrc deleted file mode 100644 index b4eb29f..0000000 --- a/player/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "vendors" -} diff --git a/player/TemplateData/UnityProgress.js b/player/TemplateData/UnityProgress.js deleted file mode 100644 index 0ed2beb..0000000 --- a/player/TemplateData/UnityProgress.js +++ /dev/null @@ -1,97 +0,0 @@ -function UnityProgress (dom) { - this.progress = 0.0; - this.message = ""; - this.dom = dom; - - var parent = dom.parentNode; - - var background = document.createElement("div"); - background.style.background = "#FFFFFF"; - background.style.position = "absolute"; - parent.appendChild(background); - this.background = background; - - var logoImage = document.createElement("img"); - logoImage.src = "TemplateData/progresslogo.png"; - logoImage.style.position = "absolute"; - parent.appendChild(logoImage); - this.logoImage = logoImage; - - var progressFrame = document.createElement("img"); - progressFrame.src = "TemplateData/loadingbar.png"; - progressFrame.style.position = "absolute"; - parent.appendChild(progressFrame); - this.progressFrame = progressFrame; - - var progressBar = document.createElement("img"); - progressBar.src = "TemplateData/fullbar.png"; - progressBar.style.position = "absolute"; - parent.appendChild(progressBar); - this.progressBar = progressBar; - - var messageArea = document.createElement("p"); - messageArea.style.position = "absolute"; - parent.appendChild(messageArea); - this.messageArea = messageArea; - - - this.SetProgress = function (progress) { - if (this.progress < progress) - this.progress = progress; - this.messageArea.style.display = "none"; - this.progressFrame.style.display = "inline"; - this.progressBar.style.display = "inline"; - this.Update(); - } - - this.SetMessage = function (message) { - this.message = message; - this.background.style.display = "inline"; - this.logoImage.style.display = "inline"; - this.progressFrame.style.display = "none"; - this.progressBar.style.display = "none"; - this.Update(); - } - - this.Clear = function() { - this.background.style.display = "none"; - this.logoImage.style.display = "none"; - this.progressFrame.style.display = "none"; - this.progressBar.style.display = "none"; - } - - this.Update = function() { - this.background.style.top = this.dom.offsetTop + 'px'; - this.background.style.left = this.dom.offsetLeft + 'px'; - this.background.style.width = this.dom.offsetWidth + 'px'; - this.background.style.height = this.dom.offsetHeight + 'px'; - - var logoImg = new Image(); - logoImg.src = this.logoImage.src; - var progressFrameImg = new Image(); - progressFrameImg.src = this.progressFrame.src; - - this.logoImage.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 - logoImg.height * 0.5) + 'px'; - this.logoImage.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - logoImg.width * 0.5) + 'px'; - this.logoImage.style.width = logoImg.width+'px'; - this.logoImage.style.height = logoImg.height+'px'; - - this.progressFrame.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 + logoImg.height * 0.5 + 10) + 'px'; - this.progressFrame.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - progressFrameImg.width * 0.5) + 'px'; - this.progressFrame.width = progressFrameImg.width; - this.progressFrame.height = progressFrameImg.height; - - this.progressBar.style.top = this.progressFrame.style.top; - this.progressBar.style.left = this.progressFrame.style.left; - this.progressBar.width = progressFrameImg.width * Math.min(this.progress, 1); - this.progressBar.height = progressFrameImg.height; - - this.messageArea.style.top = this.progressFrame.style.top; - this.messageArea.style.left = 0; - this.messageArea.style.width = '100%'; - this.messageArea.style.textAlign = 'center'; - this.messageArea.innerHTML = this.message; - } - - this.Update (); -} \ No newline at end of file diff --git a/player/TemplateData/default-cover.jpg b/player/TemplateData/default-cover.jpg deleted file mode 100644 index 86f23ce..0000000 Binary files a/player/TemplateData/default-cover.jpg and /dev/null differ diff --git a/player/TemplateData/favicon.png b/player/TemplateData/favicon.png deleted file mode 100644 index f6c7194..0000000 Binary files a/player/TemplateData/favicon.png and /dev/null differ diff --git a/player/TemplateData/fullbar.png b/player/TemplateData/fullbar.png deleted file mode 100644 index 4ee0a14..0000000 Binary files a/player/TemplateData/fullbar.png and /dev/null differ diff --git a/player/TemplateData/loadingbar.png b/player/TemplateData/loadingbar.png deleted file mode 100644 index 98e0d96..0000000 Binary files a/player/TemplateData/loadingbar.png and /dev/null differ diff --git a/player/TemplateData/progresslogo.png b/player/TemplateData/progresslogo.png deleted file mode 100644 index a568710..0000000 Binary files a/player/TemplateData/progresslogo.png and /dev/null differ diff --git a/player/TemplateData/style.css b/player/TemplateData/style.css deleted file mode 100644 index 94c4232..0000000 --- a/player/TemplateData/style.css +++ /dev/null @@ -1,28 +0,0 @@ - -/**************************************** - ==== RESETS -****************************************/ - -html,body,div,canvas { margin: 0; padding: 0; } -::-moz-selection { color: #333; text-shadow: none; } -::selection { color: #333; text-shadow: none; } -.clear:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; } -.clear { display: inline-table; clear: both; } -/* Hides from IE-mac \*/ * html .clear { height: 1%; } .clear { display: block; } /* End hide from IE-mac */ - -/**************************************** - ==== LAYOUT -****************************************/ - -html, body { width: 100%; height: 100%; font-family: Helvetica, Verdana, Arial, sans-serif; } -body { } -p.header, p.footer { display: none; } -div.logo { width: 196px; height: 38px; float: left; background: url(logo.png) 0 0 no-repeat; position: relative; z-index: 10; } -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; } -.template-wrap { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } -.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); } -.fullscreen { float: right; position: relative; z-index: 10; } - -body.template { } -.template .template-wrap { } -.template .template-wrap canvas { } diff --git a/player/bower.json b/player/bower.json deleted file mode 100644 index 0b34d2b..0000000 --- a/player/bower.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "vlibras-player", - "version": "0.0.1", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ], - "devDependencies": { - "qdclient": "git@git.lavid.ufpb.br:qdclient.git" - } -} diff --git a/player/connect.js b/player/connect.js deleted file mode 100644 index e332844..0000000 --- a/player/connect.js +++ /dev/null @@ -1,40 +0,0 @@ -// connect to canvas - var Module = { - TOTAL_MEMORY: 268435456, - filePackagePrefixURL: "Release/", - memoryInitializerPrefixURL: "Release/", - preRun: [], - postRun: [], - print: (function() { - return function(text) { - console.log (text); - }; - })(), - printErr: function(text) { - console.error (text); - }, - canvas: document.getElementById('canvas'), - progress: null, - setStatus: function(text) { - if (this.progress == null) - { - if (typeof UnityProgress != 'function') - return; - this.progress = new UnityProgress (canvas); - } - if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; - if (text === Module.setStatus.text) return; - this.progress.SetMessage (text); - var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); - if (m) - this.progress.SetProgress (parseInt(m[2])/parseInt(m[4])); - if (text === "") - this.progress.Clear() - }, - totalDependencies: 0, - monitorRunDependencies: function(left) { - this.totalDependencies = Math.max(this.totalDependencies, left); - Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); - } - }; - Module.setStatus('Downloading (0.0/1)'); diff --git a/player/load.js b/player/load.js deleted file mode 100644 index 53ce991..0000000 --- a/player/load.js +++ /dev/null @@ -1,39 +0,0 @@ -if (!(!Math.fround)) { - var script = document.createElement('script'); - script.src = "Release/WEBGL.js"; - document.body.appendChild(script); -} else { - var codeXHR = new XMLHttpRequest(); - codeXHR.open('GET', 'Release/WEBGL.js', true); - codeXHR.onload = function() { - var code = codeXHR.responseText; - if (!Math.fround) { -try { - console.log('optimizing out Math.fround calls'); - var m = /var ([^=]+)=global\.Math\.fround;/.exec(code); - var minified = m[1]; - if (!minified) throw 'fail'; - var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS'); - var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS'); - var asm = code.substring(startAsm, endAsm); - do { - var moar = false; // we need to re-do, as x(x( will not be fixed - asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' }); - } while (moar); - code = code.substring(0, startAsm) + asm + code.substring(endAsm); - code = code.replace("'use asm'", "'almost asm'"); -} catch(e) { console.log('failed to optimize out Math.fround calls ' + e) } - } - - var blob = new Blob([code], { type: 'text/javascript' }); - codeXHR = null; - var src = URL.createObjectURL(blob); - var script = document.createElement('script'); - script.src = URL.createObjectURL(blob); - script.onload = function() { - URL.revokeObjectURL(script.src); - }; - document.body.appendChild(script); - }; - codeXHR.send(null); -} diff --git a/player/vendors/qdclient/.bower.json b/player/vendors/qdclient/.bower.json deleted file mode 100644 index 6dd3e23..0000000 --- a/player/vendors/qdclient/.bower.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "qdclient", - "main": [ - "qdclient.js" - ], - "ignore": [ - "**/.*", - "Gulpfile.js", - "demo", - "node_modules", - "vendor", - "tests" - ], - "devDependencies": { - "mocha": "~2.2.5", - "chai": "~3.0.0" - }, - "_release": "2b32d629d0", - "_resolution": { - "type": "branch", - "branch": "master", - "commit": "2b32d629d0a6c4818ad5dd53c22bd000d37a7893" - }, - "_source": "git@git.lavid.ufpb.br:qdclient.git", - "_target": "*", - "_originalSource": "git@git.lavid.ufpb.br:qdclient.git" -} \ No newline at end of file diff --git a/player/vendors/qdclient/README b/player/vendors/qdclient/README deleted file mode 100644 index 15eab8e..0000000 --- a/player/vendors/qdclient/README +++ /dev/null @@ -1,32 +0,0 @@ -qdClient -========= - -1. Tools ----------------- - -1. NodeJS -2. NPM - Node Package Manager -3. Bower - Frontend dependencies -4. Gulp - Build tools - -2. Installing dependencies ----------------- - -```bash -$ npm install -$ bower install -``` - -3. Demo ----------------- -```bash -$ gulp demo -``` - -4. Building ----------------- -```bash -$ gulp build -``` - -**Enjoy** diff --git a/player/vendors/qdclient/bower.json b/player/vendors/qdclient/bower.json deleted file mode 100644 index 98c58ce..0000000 --- a/player/vendors/qdclient/bower.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "qdclient", - "version": "0.0.1", - "main": [ - "qdclient.js" - ], - "ignore": [ - "**/.*", - "Gulpfile.js", - "demo", - "node_modules", - "vendor", - "tests" - ], - "devDependencies": { - "mocha": "~2.2.5", - "chai": "~3.0.0" - } -} diff --git a/player/vendors/qdclient/lib/chooser.js b/player/vendors/qdclient/lib/chooser.js deleted file mode 100644 index 2e36aa1..0000000 --- a/player/vendors/qdclient/lib/chooser.js +++ /dev/null @@ -1,222 +0,0 @@ -(function(window, localStorage, undefined) { - 'use strict'; - - function Chooser() { - this.server = 'http://150.165.204.39/vlibras-cloud/get_servers.php'; - - this.options = { - THRESHOLDSLOW: 2000, - SLOWLIMITTRIES: 5, - NBESTHEURISTIC1: 2, - QUANTITYPREVIOUSTIMESSTORED: 10 - }; - - this.mirrors = []; - - this.heuristics = { - FIRSTHEURISTIC: { - FIRSTRANDOM : {value: 0, name: "Random"}, - FIRSTRANDOMNBEST: {value: 1, name: "Random Among N Best"}, - FIRSTBEST : {value: 2, name: "Best"} - }, - SECONDHEURISTIC: { - SECONDRANDOM : {value: 0, name: "Random"}, - SECONDCLOSEST: {value: 1, name: "Closest"} - }, - THIRDHEURISTIC: { - THIRDSIMPLEAVERAGE : {value: 0, name: "Simple Average"}, - THIRDWEIGHTEDAVERAGE: {value: 1, name: "Weighted Average"} - } - }; - } - - // Exports - qdClient.Chooser = Chooser; - - Chooser.prototype.choose = function(urlLast, millisLast, response, callback) { - var $this = this; - - this.loadMirrors_(function() { - $this.chooseServer_(urlLast, millisLast, response, callback); - }); - }; - - Chooser.prototype.chooseServer_ = function(urlLast, millisLast, response, callback) { - var firstHeuristic = this.heuristics.FIRSTHEURISTIC.FIRSTBEST; - var secondHeuristic = this.heuristics.SECONDHEURISTIC.SECONDRANDOM; - var thirdHeuristic = this.heuristics.THIRDHEURISTIC.THIRDWEIGHTEDAVERAGE; - - var j = 0, i = 0; /* Fix JSHint */ - - var sizeBest = this.options.NBESTHEURISTIC1; - if (firstHeuristic == this.heuristics.FIRSTHEURISTIC.FIRSTBEST) { - sizeBest = 1; - } - - if (urlLast && urlLast.length > 0) { - for (i = 0; i < this.mirrors.length; i++) { - if (this.mirrors[i].url.toLowerCase() == urlLast.toLowerCase()) { - if (this.mirrors[i].previousTimes.length < this.options.QUANTITYPREVIOUSTIMESSTORED) { - this.mirrors[i].previousTimes[this.mirrors[i].previousTimes.length] = millisLast; - } else { - for (j = this.options.QUANTITYPREVIOUSTIMESSTORED-1; j > 0; j--) { - this.mirrors[i].previousTimes[j-1] = this.mirrors[i].previousTimes[j]; - } - - this.mirrors[i].previousTimes[this.options.QUANTITYPREVIOUSTIMESSTORED-1] = millisLast; - } - - if (thirdHeuristic == this.heuristics.THIRDHEURISTIC.THIRDSIMPLEAVERAGE) { - var totalMillis = 0; - for (j = 0; j < this.mirrors[i].previousTimes.length; j++) { - totalMillis += this.mirrors[i].previousTimes[j]; - } - - this.mirrors[i].averageTime = totalMillis/this.mirrors[i].previousTimes.length; - } else if (thirdHeuristic == this.heuristics.THIRDHEURISTIC.THIRDWEIGHTEDAVERAGE) { - var totalMillisAndWeights = 0; - var totalWeights = 0; - for (j = 0; j < this.mirrors[i].previousTimes.length; j++) { - totalMillisAndWeights += this.mirrors[i].previousTimes[j]*(j+1); - totalWeights += (j+1); - } - - this.mirrors[i].averageTime = totalMillisAndWeights/totalWeights; - } - - if (millisLast > this.options.THRESHOLDSLOW || response == -1) { - this.mirrors[i].isSlow = true; - this.mirrors[i].remainingSlow = this.options.SLOWLIMITTRIES; - } - - localStorage.setItem("servers", JSON.stringify(this.mirrors)); - break; - } - - } - - } - - var position = Math.floor((Math.random() * this.mirrors.length)); - var closestPosition; - - if (firstHeuristic != this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM) { - position = -1; - closestPosition = -1; - } - - var vectorBest = []; - var k = 0, z = 0; /* JSHint Fix */ - - for (j = 0; j < this.mirrors.length; j++) { - if (this.mirrors[j].remainingSlow > 0) { - this.mirrors[j].remainingSlow = this.mirrors[j].remainingSlow - 1; - } - - if (this.mirrors[j].remainingSlow === 0) { - this.mirrors[j].isSlow = false; - } - - if (firstHeuristic != this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM && this.mirrors[j].isSlow === false) { - if (closestPosition == -1) { - closestPosition = j; - } - - var added = false; - - for (k = 0; k < vectorBest.length; k++) { - if (this.mirrors[j].averageTime < vectorBest[k].averageTime || (this.mirrors[j].averageTime == vectorBest[k].averageTime && (Math.floor(Math.random()) < 0.5) )) { - - added = true; - - if (vectorBest.length < sizeBest) { - for (z = vectorBest.length-1; z >= k; z--) { - vectorBest[z+1] = vectorBest[z]; - } - } else { - for (z = vectorBest.length-2; z >= k; z--) { - vectorBest[z+1] = vectorBest[z]; - } - } - - vectorBest[k] = this.mirrors[j]; - - break; - } - } - - if (added === false && vectorBest.length < sizeBest) { - vectorBest[vectorBest.length] = this.mirrors[j]; - } - - } - - } - - // pega aleatorio entre as N posicoes dos melhores (se for guloso, tera apenas um elemento no vetor) - if (firstHeuristic != this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM && vectorBest.length > 0) { - position = Math.floor((Math.random() * vectorBest.length)); - } - - if (position == -1) { - if (secondHeuristic == this.heuristics.SECONDHEURISTIC.SECONDCLOSEST) { - // escolhendo o mais proximo, no caso, o vetor já está ordenado - if (closestPosition != -1) { - position = closestPosition; - } else { - // se nao marcou nenhum como closest, todos devem estar como slow, nesse caso seleciona o primeiro que é o mais próximo - position = 0; - } - - } else { - position = Math.floor((Math.random() * this.mirrors.length)); - } - } - - callback(this.mirrors[position].url); - }; - - Chooser.prototype.loadMirrors_ = function(callback) { - if (this.mirrors.length > 0) { - if (callback instanceof Function) callback(); - - return; - } - - var $this = this; - - var localServers = JSON.parse(localStorage.getItem("servers")) || []; - - qdClient.getJSON(this.server, function (status, response) { - var servers = status === 200 ? response : []; - - for (var i = 0; i < servers.length; i++){ - var mirror = { - name: servers[i].nome, - url: servers[i].url, - averageTime: 99999999, - isSlow: false, - previousTimes: [], - remainingSlow: 0, - type: servers[i].type - }; - - for (var localServer in localServers) { - if (mirror.url == localServer.url) { - mirror.averageTime = localServer.averageTime; - mirror.isSlow = localServer.isSlow; - mirror.previousTimes = localServer.previousTimes; - mirror.remainingSlow = localServer.remainingSlow; - - break; - } - } - - $this.mirrors.push(mirror); - } - - if (callback instanceof Function) callback(); - }); - }; - -}(window, localStorage)); diff --git a/player/vendors/qdclient/lib/qdclient.js b/player/vendors/qdclient/lib/qdclient.js deleted file mode 100644 index 086d549..0000000 --- a/player/vendors/qdclient/lib/qdclient.js +++ /dev/null @@ -1,34 +0,0 @@ -(function(window, undefined) { - 'use strict'; - - window.qdClient = window.qdClient || {}; - - qdClient.request = function request(url, method, params, callback) { - var xhr = new XMLHttpRequest(); - var raw_params = ""; - - xhr.open(method, url, true); - - xhr.onload = function() { - callback(xhr.status, xhr.responseText); - }; - - if (method == "POST" && params instanceof Object) { - - for(var param in params) { - raw_params += param + '=' + params[param] + '&'; - } - - if (params.length > 1) raw_params.slice(0, -1); - } - - xhr.send(raw_params); - }; - - qdClient.getJSON = function getJSON(url, callback) { - qdClient.request(url, "GET", {}, function(status, response) { - callback(status, JSON.parse(response)); - }); - }; - -}(window)); diff --git a/player/vendors/qdclient/package.json b/player/vendors/qdclient/package.json deleted file mode 100644 index b1fdf95..0000000 --- a/player/vendors/qdclient/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "qdclient", - "version": "0.0.1", - "description": "", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "devDependencies": { - "browser-sync": "^2.7.13", - "gulp": "^3.9.0", - "gulp-concat": "^2.6.0", - "gulp-jshint": "^1.11.2", - "gulp-rename": "^1.2.2", - "gulp-rimraf": "^0.1.1", - "gulp-uglify": "^1.2.0", - "run-sequence": "^1.1.1" - } -} diff --git a/player/vendors/qdclient/qdclient.js b/player/vendors/qdclient/qdclient.js deleted file mode 100644 index e054abe..0000000 --- a/player/vendors/qdclient/qdclient.js +++ /dev/null @@ -1,257 +0,0 @@ -(function(window, undefined) { - 'use strict'; - - window.qdClient = window.qdClient || {}; - - qdClient.request = function request(url, method, params, callback) { - var xhr = new XMLHttpRequest(); - var raw_params = ""; - - xhr.open(method, url, true); - - xhr.onload = function() { - callback(xhr.status, xhr.responseText); - }; - - if (method == "POST" && params instanceof Object) { - - for(var param in params) { - raw_params += param + '=' + params[param] + '&'; - } - - if (params.length > 1) raw_params.slice(0, -1); - } - - xhr.send(raw_params); - }; - - qdClient.getJSON = function getJSON(url, callback) { - qdClient.request(url, "GET", {}, function(status, response) { - callback(status, JSON.parse(response)); - }); - }; - -}(window)); - -(function(window, localStorage, undefined) { - 'use strict'; - - function Chooser() { - this.server = 'http://150.165.204.39/vlibras-cloud/get_servers.php'; - - this.options = { - THRESHOLDSLOW: 2000, - SLOWLIMITTRIES: 5, - NBESTHEURISTIC1: 2, - QUANTITYPREVIOUSTIMESSTORED: 10 - }; - - this.mirrors = []; - - this.heuristics = { - FIRSTHEURISTIC: { - FIRSTRANDOM : {value: 0, name: "Random"}, - FIRSTRANDOMNBEST: {value: 1, name: "Random Among N Best"}, - FIRSTBEST : {value: 2, name: "Best"} - }, - SECONDHEURISTIC: { - SECONDRANDOM : {value: 0, name: "Random"}, - SECONDCLOSEST: {value: 1, name: "Closest"} - }, - THIRDHEURISTIC: { - THIRDSIMPLEAVERAGE : {value: 0, name: "Simple Average"}, - THIRDWEIGHTEDAVERAGE: {value: 1, name: "Weighted Average"} - } - }; - } - - // Exports - qdClient.Chooser = Chooser; - - Chooser.prototype.choose = function(urlLast, millisLast, response, callback) { - var $this = this; - - this.loadMirrors_(function() { - $this.chooseServer_(urlLast, millisLast, response, callback); - }); - }; - - Chooser.prototype.chooseServer_ = function(urlLast, millisLast, response, callback) { - var firstHeuristic = this.heuristics.FIRSTHEURISTIC.FIRSTBEST; - var secondHeuristic = this.heuristics.SECONDHEURISTIC.SECONDRANDOM; - var thirdHeuristic = this.heuristics.THIRDHEURISTIC.THIRDWEIGHTEDAVERAGE; - - var j = 0, i = 0; /* Fix JSHint */ - - var sizeBest = this.options.NBESTHEURISTIC1; - if (firstHeuristic == this.heuristics.FIRSTHEURISTIC.FIRSTBEST) { - sizeBest = 1; - } - - if (urlLast && urlLast.length > 0) { - for (i = 0; i < this.mirrors.length; i++) { - if (this.mirrors[i].url.toLowerCase() == urlLast.toLowerCase()) { - if (this.mirrors[i].previousTimes.length < this.options.QUANTITYPREVIOUSTIMESSTORED) { - this.mirrors[i].previousTimes[this.mirrors[i].previousTimes.length] = millisLast; - } else { - for (j = this.options.QUANTITYPREVIOUSTIMESSTORED-1; j > 0; j--) { - this.mirrors[i].previousTimes[j-1] = this.mirrors[i].previousTimes[j]; - } - - this.mirrors[i].previousTimes[this.options.QUANTITYPREVIOUSTIMESSTORED-1] = millisLast; - } - - if (thirdHeuristic == this.heuristics.THIRDHEURISTIC.THIRDSIMPLEAVERAGE) { - var totalMillis = 0; - for (j = 0; j < this.mirrors[i].previousTimes.length; j++) { - totalMillis += this.mirrors[i].previousTimes[j]; - } - - this.mirrors[i].averageTime = totalMillis/this.mirrors[i].previousTimes.length; - } else if (thirdHeuristic == this.heuristics.THIRDHEURISTIC.THIRDWEIGHTEDAVERAGE) { - var totalMillisAndWeights = 0; - var totalWeights = 0; - for (j = 0; j < this.mirrors[i].previousTimes.length; j++) { - totalMillisAndWeights += this.mirrors[i].previousTimes[j]*(j+1); - totalWeights += (j+1); - } - - this.mirrors[i].averageTime = totalMillisAndWeights/totalWeights; - } - - if (millisLast > this.options.THRESHOLDSLOW || response == -1) { - this.mirrors[i].isSlow = true; - this.mirrors[i].remainingSlow = this.options.SLOWLIMITTRIES; - } - - localStorage.setItem("servers", JSON.stringify(this.mirrors)); - break; - } - - } - - } - - var position = Math.floor((Math.random() * this.mirrors.length)); - var closestPosition; - - if (firstHeuristic != this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM) { - position = -1; - closestPosition = -1; - } - - var vectorBest = []; - var k = 0, z = 0; /* JSHint Fix */ - - for (j = 0; j < this.mirrors.length; j++) { - if (this.mirrors[j].remainingSlow > 0) { - this.mirrors[j].remainingSlow = this.mirrors[j].remainingSlow - 1; - } - - if (this.mirrors[j].remainingSlow === 0) { - this.mirrors[j].isSlow = false; - } - - if (firstHeuristic != this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM && this.mirrors[j].isSlow === false) { - if (closestPosition == -1) { - closestPosition = j; - } - - var added = false; - - for (k = 0; k < vectorBest.length; k++) { - if (this.mirrors[j].averageTime < vectorBest[k].averageTime || (this.mirrors[j].averageTime == vectorBest[k].averageTime && (Math.floor(Math.random()) < 0.5) )) { - - added = true; - - if (vectorBest.length < sizeBest) { - for (z = vectorBest.length-1; z >= k; z--) { - vectorBest[z+1] = vectorBest[z]; - } - } else { - for (z = vectorBest.length-2; z >= k; z--) { - vectorBest[z+1] = vectorBest[z]; - } - } - - vectorBest[k] = this.mirrors[j]; - - break; - } - } - - if (added === false && vectorBest.length < sizeBest) { - vectorBest[vectorBest.length] = this.mirrors[j]; - } - - } - - } - - // pega aleatorio entre as N posicoes dos melhores (se for guloso, tera apenas um elemento no vetor) - if (firstHeuristic != this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM && vectorBest.length > 0) { - position = Math.floor((Math.random() * vectorBest.length)); - } - - if (position == -1) { - if (secondHeuristic == this.heuristics.SECONDHEURISTIC.SECONDCLOSEST) { - // escolhendo o mais proximo, no caso, o vetor já está ordenado - if (closestPosition != -1) { - position = closestPosition; - } else { - // se nao marcou nenhum como closest, todos devem estar como slow, nesse caso seleciona o primeiro que é o mais próximo - position = 0; - } - - } else { - position = Math.floor((Math.random() * this.mirrors.length)); - } - } - - callback(this.mirrors[position].url); - }; - - Chooser.prototype.loadMirrors_ = function(callback) { - if (this.mirrors.length > 0) { - if (callback instanceof Function) callback(); - - return; - } - - var $this = this; - - var localServers = JSON.parse(localStorage.getItem("servers")) || []; - - qdClient.getJSON(this.server, function (status, response) { - var servers = status === 200 ? response : []; - - for (var i = 0; i < servers.length; i++){ - var mirror = { - name: servers[i].nome, - url: servers[i].url, - averageTime: 99999999, - isSlow: false, - previousTimes: [], - remainingSlow: 0, - type: servers[i].type - }; - - for (var localServer in localServers) { - if (mirror.url == localServer.url) { - mirror.averageTime = localServer.averageTime; - mirror.isSlow = localServer.isSlow; - mirror.previousTimes = localServer.previousTimes; - mirror.remainingSlow = localServer.remainingSlow; - - break; - } - } - - $this.mirrors.push(mirror); - } - - if (callback instanceof Function) callback(); - }); - }; - -}(window, localStorage)); diff --git a/player/vendors/qdclient/qdclient.min.js b/player/vendors/qdclient/qdclient.min.js deleted file mode 100644 index d5273b7..0000000 --- a/player/vendors/qdclient/qdclient.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(i,r){"use strict";i.qdClient=i.qdClient||{},qdClient.request=function(i,r,s,e){var t=new XMLHttpRequest,o="";if(t.open(r,i,!0),t.onload=function(){e(t.status,t.responseText)},"POST"==r&&s instanceof Object){for(var n in s)o+=n+"="+s[n]+"&";s.length>1&&o.slice(0,-1)}t.send(o)},qdClient.getJSON=function(i,r){qdClient.request(i,"GET",{},function(i,s){r(i,JSON.parse(s))})}}(window),function(i,r,s){"use strict";function e(){this.server="http://150.165.204.39/vlibras-cloud/get_servers.php",this.options={THRESHOLDSLOW:2e3,SLOWLIMITTRIES:5,NBESTHEURISTIC1:2,QUANTITYPREVIOUSTIMESSTORED:10},this.mirrors=[],this.heuristics={FIRSTHEURISTIC:{FIRSTRANDOM:{value:0,name:"Random"},FIRSTRANDOMNBEST:{value:1,name:"Random Among N Best"},FIRSTBEST:{value:2,name:"Best"}},SECONDHEURISTIC:{SECONDRANDOM:{value:0,name:"Random"},SECONDCLOSEST:{value:1,name:"Closest"}},THIRDHEURISTIC:{THIRDSIMPLEAVERAGE:{value:0,name:"Simple Average"},THIRDWEIGHTEDAVERAGE:{value:1,name:"Weighted Average"}}}}qdClient.Chooser=e,e.prototype.choose=function(i,r,s,e){var t=this;this.loadMirrors_(function(){t.chooseServer_(i,r,s,e)})},e.prototype.chooseServer_=function(i,s,e,t){var o=this.heuristics.FIRSTHEURISTIC.FIRSTBEST,n=this.heuristics.SECONDHEURISTIC.SECONDRANDOM,h=this.heuristics.THIRDHEURISTIC.THIRDWEIGHTEDAVERAGE,T=0,S=0,a=this.options.NBESTHEURISTIC1;if(o==this.heuristics.FIRSTHEURISTIC.FIRSTBEST&&(a=1),i&&i.length>0)for(S=0;S0;T--)this.mirrors[S].previousTimes[T-1]=this.mirrors[S].previousTimes[T];this.mirrors[S].previousTimes[this.options.QUANTITYPREVIOUSTIMESSTORED-1]=s}if(h==this.heuristics.THIRDHEURISTIC.THIRDSIMPLEAVERAGE){var m=0;for(T=0;Tthis.options.THRESHOLDSLOW||-1==e)&&(this.mirrors[S].isSlow=!0,this.mirrors[S].remainingSlow=this.options.SLOWLIMITTRIES),r.setItem("servers",JSON.stringify(this.mirrors));break}var R,E=Math.floor(Math.random()*this.mirrors.length);o!=this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM&&(E=-1,R=-1);var u=[],v=0,g=0;for(T=0;T0&&(this.mirrors[T].remainingSlow=this.mirrors[T].remainingSlow-1),0===this.mirrors[T].remainingSlow&&(this.mirrors[T].isSlow=!1),o!=this.heuristics.FIRSTHEURISTIC.FIRSTRANDOM&&this.mirrors[T].isSlow===!1){-1==R&&(R=T);var f=!1;for(v=0;v=v;g--)u[g+1]=u[g];else for(g=u.length-2;g>=v;g--)u[g+1]=u[g];u[v]=this.mirrors[T];break}f===!1&&u.length0&&(E=Math.floor(Math.random()*u.length)),-1==E&&(E=n==this.heuristics.SECONDHEURISTIC.SECONDCLOSEST?-1!=R?R:0:Math.floor(Math.random()*this.mirrors.length)),t(this.mirrors[E].url)},e.prototype.loadMirrors_=function(i){if(this.mirrors.length>0)return void(i instanceof Function&&i());var s=this,e=JSON.parse(r.getItem("servers"))||[];qdClient.getJSON(this.server,function(r,t){for(var o=200===r?t:[],n=0;n - - - - - VLibras Plugin - - - - - - - - - - -
Carregando...
-
- -
- - - - - - diff --git a/safari.safariextension/Info.plist b/safari.safariextension/Info.plist new file mode 100644 index 0000000..afd7c2e --- /dev/null +++ b/safari.safariextension/Info.plist @@ -0,0 +1,57 @@ + + + + + Author + LAViD + Builder Version + 10600.6.3 + CFBundleDisplayName + VLibras Plugin + CFBundleIdentifier + br.ufpb.lavid.vlibras + CFBundleInfoDictionaryVersion + 6.0 + CFBundleShortVersionString + 0.1 + CFBundleVersion + 1 + Chrome + + Database Quota + 5242880 + Global Page + global.html + + Content + + Scripts + + End + + scripts/delegator.js + + Start + + scripts/contextmenu.js + + + + Description + Um tradutor de portugues para LIBRAS + DeveloperIdentifier + 3PTX2S8KDQ + ExtensionInfoDictionaryVersion + 1.0 + Permissions + + Website Access + + Include Secure Pages + + Level + All + + + + diff --git a/safari.safariextension/app/main.js b/safari.safariextension/app/main.js new file mode 100644 index 0000000..d6b87f0 --- /dev/null +++ b/safari.safariextension/app/main.js @@ -0,0 +1,56 @@ +window.resizeTo(535, 500); + +var app = { + chooser: null, + glosa: undefined, + loaded: false, + lastReq: { + url: null, + millis: null, + response: null + } +}; + +function onLoadPlayer() { + if ( app.glosa !== undefined ) + SendMessage('PlayerManager', 'catchGlosa', app.glosa); + + app.loaded = true; +} + +safari.self.addEventListener('message', function (request) { + if (request.name !== 'plugin:selectedText' && request.message === undefined) return; + var selectedText = encodeURI(request.message); + + app.chooser = app.chooser || new qdClient.Chooser(); + + document.getElementById('loading-screen').style.display = 'block'; + app.chooser.choose( + app.lastReq.url, + app.lastReq.millis, + app.lastReq.response, + function (url) { + var start = new Date().getTime(); + + if (!url) { + document.getElementById('loading-screen').style.display = 'none'; + return; + } + + qdClient.request(url + '?texto=' + selectedText, "GET", {}, + function(status, response) { + app.lastReq.response = status === 200 ? status : -1; + app.lastReq.millis = (new Date().getTime() - start); + app.lastReq.url = url; + + document.getElementById('loading-screen').style.display = 'none'; + if (status !== 200) return; + + app.glosa = response; + if (app.loaded == true) + SendMessage('PlayerManager', 'catchGlosa', app.glosa); + }); + }); +}); + +safari.self.tab.dispatchMessage('page:ready', true); diff --git a/safari.safariextension/background.js b/safari.safariextension/background.js new file mode 100644 index 0000000..b3466c0 --- /dev/null +++ b/safari.safariextension/background.js @@ -0,0 +1,46 @@ +var popup = null; +var selectedText = undefined; + +safari.application.addEventListener('contextmenu', function (event){ + var selectedText = event.userInfo; + + if (!selectedText) return; + + if (selectedText.length > 20) { + selectedText = selectedText.substr(0, 20) + '...'; + } + + if (selectedText !== '') { + event.contextMenu.appendContextMenuItem('translateLibras', 'Traduzir ' + selectedText + ' para LIBRAS'); + } +}, false); + +safari.application.addEventListener('command', function (event){ + if (event.command === 'translateLibras') { + selectedText = event.userInfo; + + if (popup === null) { + popup = safari.application.openBrowserWindow().activeTab; + popup.url = safari.extension.baseURI + 'app/player/window.html'; + + popup.addEventListener('close', function () { + popup = null; + }); + + popup.addEventListener('navigate', function () { + popup = null; + }); + + popup.addEventListener('message', function (request) { + if (selectedText !== undefined && request.name === 'page:ready' && request.message == true) { + popup.page.dispatchMessage('plugin:selectedText', selectedText); + selectedText = undefined; + }; + }); + } else { + popup.browserWindow.activate(); + popup.page.dispatchMessage('plugin:selectedText', selectedText); + selectedText = undefined; + } + } +}, false); \ No newline at end of file diff --git a/safari.safariextension/global.html b/safari.safariextension/global.html new file mode 100644 index 0000000..2d91fdb --- /dev/null +++ b/safari.safariextension/global.html @@ -0,0 +1,8 @@ + + + VLibras Plugin + + + + + \ No newline at end of file diff --git a/safari.safariextension/scripts/contextmenu.js b/safari.safariextension/scripts/contextmenu.js new file mode 100644 index 0000000..ef99c7e --- /dev/null +++ b/safari.safariextension/scripts/contextmenu.js @@ -0,0 +1,3 @@ +document.addEventListener('contextmenu', function (event){ + safari.self.tab.setContextMenuEventUserInfo(event, window.getSelection().toString()); +}, false); \ No newline at end of file diff --git a/safari.safariextension/vlibras48.png b/safari.safariextension/vlibras48.png new file mode 100644 index 0000000..f6c7194 Binary files /dev/null and b/safari.safariextension/vlibras48.png differ diff --git a/vlibrasplugin-chrome.pem b/vlibrasplugin-chrome.pem deleted file mode 100644 index f287079..0000000 --- a/vlibrasplugin-chrome.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC8UI+z9pRhF8Kv -WC3Y2eI41b4AJeROjrO3rVeBG+FYjMuOB0r1byFUlebGP/Nep7nZ9eEUZ4E71lkp -WDyYLfZTb+gum6MQAeh8Wd7aBh9qSa4ru08ieu/8HxmHdfUFpWph3yPMV0TdAXVh -sbMLWcvzu+AmEkPM09KtXENyAOkR63ncll7HtmGFdxicTzNWuIhrvrhsd1xtuS1c -g4vk1XEJ5mcSnVLVGojAI8uwY4QEAGC2bUMzmD6mtZxySHu5XxNnk1xFdTxebd1K -4u0HyDgpY7epRsnkYHQq9HZ7Smet2JW4tHmd/5nPMZXFztZ/bUSuOqAmXvmLXvmw -JSpVnEENAgMBAAECggEAVCmFMB8iDYq6/fbg9qvaSSBt/E7zDJEGjS6xjwhQ3GyA -hQeJXsu+D7m3HB90u3cmvtz/LUldHssbqji/TBwunPfEwx/X7s2LhBf+W16lJ7Gq -X+0k3vomy31ywXHcght9wiQiMa9HHacLORBcPtRxLItpEFrVZnO9ErHLiuYRRGo+ -EKP79o1dVZ5kldJ7toB4ok+KIDu2PJJShj4nXj7mKNlGZPH2hYn+NG7ZLFOjUp09 -AKjTIE5WADt5bOKN9Wo2HiCG63zLZsaJmeYh2v3TxnpAj+W/TMxV/y0kIe7gzqw1 -2qxdBmLBILNM8AkwadpbJRuC6aynd41sqejix3uemQKBgQDzONGl0Yf8fg5EyX3r -w/OldzZv/Comy6Ka/aq8I88clFBlEoD2os+lF6IDAgMj102awjiI+fxOe81C7Pza -a5eGHeq3qaE0E7v7ggcW7YXlFs9YC6RikKEkGCFnnaxeBf+/iXICcf32GzZkSow2 -JTedIJIbu/oca2UFpVsK4inkHwKBgQDGNUZMmJ1ca4WdpmP6mUCwqEgOZ+UcG/3K -4Sy0BtJOB1wVoQOzM1q2FUurCqps81cghUbtJyeRk4y4eI1rOEbz8m0UB0hWyEq1 -pJJiz0nei7ficAIHO5e2elDV2lJ7KNxYeb3YN2NXbGmwmsI/IoudPp+wghnl4Xns -2JcBFZdVUwKBgQCBDcb/6xvyt5gum5M7BDBFvemepfhfuXFAOBTd20pL6c52ssjH -FUCEYvPOEMVFwTomQaPp2msr4bjaKBFKfAhcW4dtiI5Gqan3G9lTKxj+o4nFN/gz -bHZ0RnGDH0CUay52nSFndsDAU1QbBws6t6i4sM2V9boSVlG2GzUhozuDFQKBgG2P -kTZRvdoSTR9hlC43fDyqKHpeD5TEHDuC0HUKuEENbGdAQ41Qu7med98p3B6xO93s -DdKVLBgaGVT2viUgTIgX3xeNFv1xZWqWd5xKvKhZTuHJzDU3SZtCbWBod+NAKNx3 -HutfYng2ow1N3kWL0OSwcxDcOXiKdBzpdD7TMn2lAoGAH3xcQ9pI1aCeNxrnyvsJ -1EFlSX+3HQvjd9JOVemiVd6jP5SbrM6DplzimYPVmJhlAcq+wi8/dHyOGMRCb7ZV -Yv44hSheny/RhfMcePwubLBhVULRrdg2LWOEnSgrLIWNe2CCJ+xzgr2mEM+vGazI -zVWbI5s+shUi96/ZSZMjxGo= ------END PRIVATE KEY----- diff --git a/webgl/.bowerrc b/webgl/.bowerrc new file mode 100644 index 0000000..b4eb29f --- /dev/null +++ b/webgl/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "vendors" +} diff --git a/webgl/TemplateData/UnityProgress.js b/webgl/TemplateData/UnityProgress.js new file mode 100644 index 0000000..0ed2beb --- /dev/null +++ b/webgl/TemplateData/UnityProgress.js @@ -0,0 +1,97 @@ +function UnityProgress (dom) { + this.progress = 0.0; + this.message = ""; + this.dom = dom; + + var parent = dom.parentNode; + + var background = document.createElement("div"); + background.style.background = "#FFFFFF"; + background.style.position = "absolute"; + parent.appendChild(background); + this.background = background; + + var logoImage = document.createElement("img"); + logoImage.src = "TemplateData/progresslogo.png"; + logoImage.style.position = "absolute"; + parent.appendChild(logoImage); + this.logoImage = logoImage; + + var progressFrame = document.createElement("img"); + progressFrame.src = "TemplateData/loadingbar.png"; + progressFrame.style.position = "absolute"; + parent.appendChild(progressFrame); + this.progressFrame = progressFrame; + + var progressBar = document.createElement("img"); + progressBar.src = "TemplateData/fullbar.png"; + progressBar.style.position = "absolute"; + parent.appendChild(progressBar); + this.progressBar = progressBar; + + var messageArea = document.createElement("p"); + messageArea.style.position = "absolute"; + parent.appendChild(messageArea); + this.messageArea = messageArea; + + + this.SetProgress = function (progress) { + if (this.progress < progress) + this.progress = progress; + this.messageArea.style.display = "none"; + this.progressFrame.style.display = "inline"; + this.progressBar.style.display = "inline"; + this.Update(); + } + + this.SetMessage = function (message) { + this.message = message; + this.background.style.display = "inline"; + this.logoImage.style.display = "inline"; + this.progressFrame.style.display = "none"; + this.progressBar.style.display = "none"; + this.Update(); + } + + this.Clear = function() { + this.background.style.display = "none"; + this.logoImage.style.display = "none"; + this.progressFrame.style.display = "none"; + this.progressBar.style.display = "none"; + } + + this.Update = function() { + this.background.style.top = this.dom.offsetTop + 'px'; + this.background.style.left = this.dom.offsetLeft + 'px'; + this.background.style.width = this.dom.offsetWidth + 'px'; + this.background.style.height = this.dom.offsetHeight + 'px'; + + var logoImg = new Image(); + logoImg.src = this.logoImage.src; + var progressFrameImg = new Image(); + progressFrameImg.src = this.progressFrame.src; + + this.logoImage.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 - logoImg.height * 0.5) + 'px'; + this.logoImage.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - logoImg.width * 0.5) + 'px'; + this.logoImage.style.width = logoImg.width+'px'; + this.logoImage.style.height = logoImg.height+'px'; + + this.progressFrame.style.top = this.dom.offsetTop + (this.dom.offsetHeight * 0.5 + logoImg.height * 0.5 + 10) + 'px'; + this.progressFrame.style.left = this.dom.offsetLeft + (this.dom.offsetWidth * 0.5 - progressFrameImg.width * 0.5) + 'px'; + this.progressFrame.width = progressFrameImg.width; + this.progressFrame.height = progressFrameImg.height; + + this.progressBar.style.top = this.progressFrame.style.top; + this.progressBar.style.left = this.progressFrame.style.left; + this.progressBar.width = progressFrameImg.width * Math.min(this.progress, 1); + this.progressBar.height = progressFrameImg.height; + + this.messageArea.style.top = this.progressFrame.style.top; + this.messageArea.style.left = 0; + this.messageArea.style.width = '100%'; + this.messageArea.style.textAlign = 'center'; + this.messageArea.innerHTML = this.message; + } + + this.Update (); +} \ No newline at end of file diff --git a/webgl/TemplateData/default-cover.jpg b/webgl/TemplateData/default-cover.jpg new file mode 100644 index 0000000..86f23ce Binary files /dev/null and b/webgl/TemplateData/default-cover.jpg differ diff --git a/webgl/TemplateData/favicon.png b/webgl/TemplateData/favicon.png new file mode 100644 index 0000000..f6c7194 Binary files /dev/null and b/webgl/TemplateData/favicon.png differ diff --git a/webgl/TemplateData/fullbar.png b/webgl/TemplateData/fullbar.png new file mode 100644 index 0000000..4ee0a14 Binary files /dev/null and b/webgl/TemplateData/fullbar.png differ diff --git a/webgl/TemplateData/loadingbar.png b/webgl/TemplateData/loadingbar.png new file mode 100644 index 0000000..98e0d96 Binary files /dev/null and b/webgl/TemplateData/loadingbar.png differ diff --git a/webgl/TemplateData/progresslogo.png b/webgl/TemplateData/progresslogo.png new file mode 100644 index 0000000..a568710 Binary files /dev/null and b/webgl/TemplateData/progresslogo.png differ diff --git a/webgl/TemplateData/style.css b/webgl/TemplateData/style.css new file mode 100644 index 0000000..94c4232 --- /dev/null +++ b/webgl/TemplateData/style.css @@ -0,0 +1,28 @@ + +/**************************************** + ==== RESETS +****************************************/ + +html,body,div,canvas { margin: 0; padding: 0; } +::-moz-selection { color: #333; text-shadow: none; } +::selection { color: #333; text-shadow: none; } +.clear:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; } +.clear { display: inline-table; clear: both; } +/* Hides from IE-mac \*/ * html .clear { height: 1%; } .clear { display: block; } /* End hide from IE-mac */ + +/**************************************** + ==== LAYOUT +****************************************/ + +html, body { width: 100%; height: 100%; font-family: Helvetica, Verdana, Arial, sans-serif; } +body { } +p.header, p.footer { display: none; } +div.logo { width: 196px; height: 38px; float: left; background: url(logo.png) 0 0 no-repeat; position: relative; z-index: 10; } +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; } +.template-wrap { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } +.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); } +.fullscreen { float: right; position: relative; z-index: 10; } + +body.template { } +.template .template-wrap { } +.template .template-wrap canvas { } diff --git a/webgl/bower.json b/webgl/bower.json new file mode 100644 index 0000000..0b34d2b --- /dev/null +++ b/webgl/bower.json @@ -0,0 +1,14 @@ +{ + "name": "vlibras-player", + "version": "0.0.1", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "devDependencies": { + "qdclient": "git@git.lavid.ufpb.br:qdclient.git" + } +} diff --git a/webgl/connect.js b/webgl/connect.js new file mode 100644 index 0000000..e332844 --- /dev/null +++ b/webgl/connect.js @@ -0,0 +1,40 @@ +// connect to canvas + var Module = { + TOTAL_MEMORY: 268435456, + filePackagePrefixURL: "Release/", + memoryInitializerPrefixURL: "Release/", + preRun: [], + postRun: [], + print: (function() { + return function(text) { + console.log (text); + }; + })(), + printErr: function(text) { + console.error (text); + }, + canvas: document.getElementById('canvas'), + progress: null, + setStatus: function(text) { + if (this.progress == null) + { + if (typeof UnityProgress != 'function') + return; + this.progress = new UnityProgress (canvas); + } + if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; + if (text === Module.setStatus.text) return; + this.progress.SetMessage (text); + var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); + if (m) + this.progress.SetProgress (parseInt(m[2])/parseInt(m[4])); + if (text === "") + this.progress.Clear() + }, + totalDependencies: 0, + monitorRunDependencies: function(left) { + this.totalDependencies = Math.max(this.totalDependencies, left); + Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); + } + }; + Module.setStatus('Downloading (0.0/1)'); diff --git a/webgl/load.js b/webgl/load.js new file mode 100644 index 0000000..53ce991 --- /dev/null +++ b/webgl/load.js @@ -0,0 +1,39 @@ +if (!(!Math.fround)) { + var script = document.createElement('script'); + script.src = "Release/WEBGL.js"; + document.body.appendChild(script); +} else { + var codeXHR = new XMLHttpRequest(); + codeXHR.open('GET', 'Release/WEBGL.js', true); + codeXHR.onload = function() { + var code = codeXHR.responseText; + if (!Math.fround) { +try { + console.log('optimizing out Math.fround calls'); + var m = /var ([^=]+)=global\.Math\.fround;/.exec(code); + var minified = m[1]; + if (!minified) throw 'fail'; + var startAsm = code.indexOf('// EMSCRIPTEN_START_FUNCS'); + var endAsm = code.indexOf('// EMSCRIPTEN_END_FUNCS'); + var asm = code.substring(startAsm, endAsm); + do { + var moar = false; // we need to re-do, as x(x( will not be fixed + asm = asm.replace(new RegExp('[^a-zA-Z0-9\\$\\_]' + minified + '\\(', 'g'), function(s) { moar = true; return s[0] + '(' }); + } while (moar); + code = code.substring(0, startAsm) + asm + code.substring(endAsm); + code = code.replace("'use asm'", "'almost asm'"); +} catch(e) { console.log('failed to optimize out Math.fround calls ' + e) } + } + + var blob = new Blob([code], { type: 'text/javascript' }); + codeXHR = null; + var src = URL.createObjectURL(blob); + var script = document.createElement('script'); + script.src = URL.createObjectURL(blob); + script.onload = function() { + URL.revokeObjectURL(script.src); + }; + document.body.appendChild(script); + }; + codeXHR.send(null); +} diff --git a/webgl/window.html b/webgl/window.html new file mode 100644 index 0000000..f3df4f5 --- /dev/null +++ b/webgl/window.html @@ -0,0 +1,57 @@ + + + + + + VLibras Plugin + + + + + + + + + + +
Carregando...
+
+ +
+ + + + + + diff --git a/webplayer/.bowerrc b/webplayer/.bowerrc new file mode 100644 index 0000000..368b332 --- /dev/null +++ b/webplayer/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "vendors" +} \ No newline at end of file diff --git a/webplayer/WEBPLAYER.unity3d b/webplayer/WEBPLAYER.unity3d new file mode 100644 index 0000000..b90fcb4 Binary files /dev/null and b/webplayer/WEBPLAYER.unity3d differ diff --git a/webplayer/bower.json b/webplayer/bower.json new file mode 100644 index 0000000..c088249 --- /dev/null +++ b/webplayer/bower.json @@ -0,0 +1,17 @@ +{ + "name": "vlibras-player", + "version": "0.0.1", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "devDependencies": { + "qdclient": "git@git.lavid.ufpb.br:qdclient.git" + }, + "dependencies": { + "jquery": "~2.1.4" + } +} diff --git a/webplayer/player.js b/webplayer/player.js new file mode 100644 index 0000000..2f64c0e --- /dev/null +++ b/webplayer/player.js @@ -0,0 +1,7 @@ +var Player = new UnityObject2(); +Player.initPlugin(document.getElementById('player'), 'WEBPLAYER.unity3d'); + +function SendMessage(object, method, params) { + console.log('SendMessage trigger'); + Player.getUnity().SendMessage(object, method, params); +} \ No newline at end of file diff --git a/webplayer/window.html b/webplayer/window.html new file mode 100644 index 0000000..01c9368 --- /dev/null +++ b/webplayer/window.html @@ -0,0 +1,58 @@ + + + + + + VLibras Plugin + + + + +
Carregando...
+
+
+ + Unity Web Player. Install now! + +
+
+ + + + + + + + + \ No newline at end of file -- libgit2 0.21.2