From 3924ac1d3bb0a3292493a960b8b1daa4187a13b1 Mon Sep 17 00:00:00 2001 From: zodern Date: Tue, 2 Dec 2014 15:07:18 -0600 Subject: [PATCH 01/36] App Menu --- apps/fileExplorer/public/logo.png | Bin 9344 -> 9344 bytes apps/textEditor/public/logo.png | Bin 9344 -> 9344 bytes core/public/css/main.css | 77 +++++++++++++++++++++++---- core/public/img/Close-48.png | Bin 0 -> 9344 bytes core/public/img/menu.png | Bin 0 -> 9344 bytes core/public/js/load.js | 2 +- core/public/js/windowManager.js | 84 ++++++++++++++++++++++++++++++ index.html | 17 +++--- 8 files changed, 160 insertions(+), 20 deletions(-) create mode 100644 core/public/img/Close-48.png create mode 100644 core/public/img/menu.png diff --git a/apps/fileExplorer/public/logo.png b/apps/fileExplorer/public/logo.png index ead7954d172834606d1dd8e30d882789d2b0a2a6..ecb90539fc07a5e590d3aa163440b0dd872eb711 100644 GIT binary patch literal 9344 zcmeI2PfG$p7>6gZ5J5jcUPAl;p1S0r!pO~9O_%=B!K6Ssbm-WjLzk%VPCH z5jwa#yHXMgNhaKrj2G>vu4~xd7-iU}|y*=bcAt>MHw7 z$S`sa92bv3m~(at6rX>sfvUC@c_?hy7HV-Oj5Tlz?b`DCdJab0)Bp&^uKPO4FXUi( zHF^LenY9Z5>9H$nfQG)3vJ1e(@~8pO{btZE04y&}4Nxqexe%PUZqB%GWb-aHP7PrF z0D^LfI{@xLmGZHd4S=4w;0?f}0}*;tSN3@WAU#gsfd~M)U5j%EV9|jHz+-7Qfd6UW zx``VGgAPOhtcu{mE6-J6)`18Fz9w(D0l;XhQaNGMfe3&J7xTOTn06onfQm~yya1To z1Cfc7T2<5jdLg;ZBTxGJBpFv!VL%w*YM`~J%mLt>u$~3rIB5DvWdyiJ;Y*qM^N|p+y=TqOCqc(ALn<2WU!^ zXvnQ0c<@}FD9@+9{ujE7yy4ZooTqUP953%8@7&-2-23+l@2XnaOC>W&Aw;TND(+*< z%SPM) zsJdX(ffNJ|)e9lO*q8$;0PM*-DgdJnqyXSVXM_Oe97qA+KS34;>y#q#__C$y^2iFX t0;CEY-PTuxh;Pbw0Z0pTF;;*T_zwzX*3KJm%d5|lrMz1yKJ3&kzX4lei!lHI diff --git a/apps/textEditor/public/logo.png b/apps/textEditor/public/logo.png index 2806ab6d464a4561a269cf2505249fa86e80fbc6..e86ee36645da29bd0152894fbe721aed075fa530 100644 GIT binary patch literal 9344 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 W*g8IQ?;Gh;Y&5mCo4ngRI{OBN*p|Nl literal 0 HcmV?d00001 diff --git a/core/public/img/menu.png b/core/public/img/menu.png new file mode 100644 index 0000000000000000000000000000000000000000..249292306a00d09c4c6ff212af0f4eeb6bd86a44 GIT binary patch literal 9344 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(C@^@sIEG}fG8(9yzYP=}1*0J_ z8UmvsFd71*A%Hss{{8!R|34n^J8N(z@cm^iR4qyke9 zY8S!8anUffqx6ssfv;b`<^gdXE(}Zt2{6ySe*IbjmpYjE`}glb~1{Q13S^zp* iJ!;)(2#kin&<}xm?#ni%-Oq{w`NY%J&t;ucLK6T7Te|Q7 literal 0 HcmV?d00001 diff --git a/core/public/js/load.js b/core/public/js/load.js index e82b2a1..5aff1e7 100644 --- a/core/public/js/load.js +++ b/core/public/js/load.js @@ -4,7 +4,7 @@ $(document).ready(function () { initializeManager(data); window.setTimeout(function () { $(".loader").fadeOut(); - }, 500) + }, 80) }) diff --git a/core/public/js/windowManager.js b/core/public/js/windowManager.js index b3c766c..159070b 100644 --- a/core/public/js/windowManager.js +++ b/core/public/js/windowManager.js @@ -140,6 +140,7 @@ var updateOrder = function () { var wm; var taskbar; +var menu; function initializeManager(_windows) { windows = _windows; @@ -192,6 +193,89 @@ function initializeManager(_windows) { windowOrder.pop(app.title); } updateOrder(); + }, + menu: function () { + // toggle menu + if ($("#menu").css("display") == "block") { + $("#menu").css("overflow", "hidden"); + $("#menu").animate({ + height: 0, + }, + 100, 'swing', function () { + $("#menu").css({ + "display": "none", + "height": "auto" + }) + }); + $("#taskbar").animate({ + bottom: 0 + }, { + duration: 100 + }); + + + } else { + var height = $("#menu").height(); + + // $("#taskbar").css("bottom", height); + $("#menu").css("display", "block"); + $("#menu").css("height", 0); + $("#menu").css("overflow", "hidden"); + $("#menu").animate({ + height: height, + overflow: "scroll" + }, { + duration: 100 + }); + $("#taskbar").animate({ + bottom: height + }, { + duration: 100 + }); + } + } + } + }); + + menu = new Vue({ + el: '#menu', + data: { + apps: windows + }, + methods: { + open: function (app) { + app.running = true; + + // hide menu + $("#menu").css("overflow", "hidden"); + $("#menu").animate({ + height: 0, + }, + 100, 'swing', function () { + $("#menu").css({ + "display": "none", + "height": "auto" + }) + }); + + $("#taskbar").animate({ + bottom: 0 + }, { + duration: 100 + }); + + // open window and move to top + if (app.minimized == false) { + + windowOrder.pop(app.title); + windowOrder.unshift(app.title); + updateOrder(); + + } else { + app.minimized = false; + windowOrder.unshift(app.title); + updateOrder(); + } } } }) diff --git a/index.html b/index.html index 33717ff..c777cb4 100644 --- a/index.html +++ b/index.html @@ -29,21 +29,22 @@

Silk

-
+ +
-
+ + From bbbb22150b3aea914abd95007c9fafe90250ffcd Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 5 Dec 2014 13:23:02 -0600 Subject: [PATCH 02/36] Added terminal --- apps/terminal/index.js | 13 +++++++++++++ apps/terminal/public/icon.png | Bin 0 -> 3531 bytes apps/terminal/window.json | 8 ++++++++ package.json | 3 +++ 4 files changed, 24 insertions(+) create mode 100644 apps/terminal/index.js create mode 100644 apps/terminal/public/icon.png create mode 100644 apps/terminal/window.json diff --git a/apps/terminal/index.js b/apps/terminal/index.js new file mode 100644 index 0000000..3e75702 --- /dev/null +++ b/apps/terminal/index.js @@ -0,0 +1,13 @@ +try { + var tty = require("tty.js"); +} catch (e) { + console.log("Couldn't find tty.js"); + return; +} +var app = tty.createServer({ + shell: 'bash', + port: 8000 +}); + + +app.listen(); \ No newline at end of file diff --git a/apps/terminal/public/icon.png b/apps/terminal/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6de814c9afca14811e692f58bd8280807104cafc GIT binary patch literal 3531 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 FV1hvJmgWEe literal 0 HcmV?d00001 diff --git a/apps/terminal/window.json b/apps/terminal/window.json new file mode 100644 index 0000000..271e3bc --- /dev/null +++ b/apps/terminal/window.json @@ -0,0 +1,8 @@ +{ + "title" : "Terminal", + "url" : "//localhost:8000/", + "icon" : "//localhost:3000/terminal/icon.png", + "minimized": true, + "running": false, + "zIndex": 0 +} \ No newline at end of file diff --git a/package.json b/package.json index f0d3eb4..111391f 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,9 @@ "commander": "2.5.0", "async": "~0.9.0" }, + "optionalDependencies" : { + "tty.js" : "zodern/tty.js" + }, "scripts": { "start": "node server.js" }, From 4ac43d1ea9817978984c70255d81031451b75db9 Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 5 Dec 2014 13:23:45 -0600 Subject: [PATCH 03/36] Removed console.log in app-defaults --- apps/app-defaults/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/app-defaults/index.js b/apps/app-defaults/index.js index 1f4ac16..1b6e4ab 100644 --- a/apps/app-defaults/index.js +++ b/apps/app-defaults/index.js @@ -9,7 +9,6 @@ var Silk = { methods.add({ "windows": function (windows) { initialize(windows); - console.log("Silk.defaults " + JSON.stringify(Silk.defaults)); } }); @@ -58,7 +57,6 @@ function saveDefaults() { for (item in defaults) { // TODO only save items that have a default - console.log("contents: " + item); contents[item] = {}; contents[item].default = defaults[item].default; contents[item].available = []; @@ -106,7 +104,7 @@ function initialize(windows) { } loadDefaults(); - console.log(JSON.stringify(defaults, null, 4)); + //console.log(JSON.stringify(defaults, null, 4)); methods.add({ "Silk/appDefaults": function (mime) { if (mime in Silk.defaults) { From 893411b7a172237b003f1be4b8370d18802cdb05 Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 5 Dec 2014 14:16:10 -0600 Subject: [PATCH 04/36] Many messages only shown when in debug mode. --- core/fork_framework/app_loader.js | 8 ++++---- core/fork_framework/fork_container/fork2server_com.js | 2 +- core/fork_framework/index.js | 2 +- core/fork_framework/ws2fork_com.js | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/fork_framework/app_loader.js b/core/fork_framework/app_loader.js index 559440f..19dfa51 100644 --- a/core/fork_framework/app_loader.js +++ b/core/fork_framework/app_loader.js @@ -38,7 +38,7 @@ function AppFactory(folder,urlpath,app){ res.redirect(301,j.url); }); if(j.url != "headless"){ - console.log("not headless") + debug("not headless") that.clean.push(j.clean); } delete j.clean; @@ -69,7 +69,7 @@ AppFactory.prototype.compileFolder = function(app){ } AppFactory.prototype.fsEvent = function(event, filename){ - console.log(event); + debug(event); } AppFactory.prototype.closeSingle = function(window,next){ if(!window.fork) @@ -133,7 +133,7 @@ AppFactory.prototype.checkWindowJSON = function(file,next){ AppFactory.prototype.checkURIs = function(j,next){ var that = this; if(j.url == "headless"){ - console.log("headless"); + debug("headless"); return next(void(0),j); } async.each(["url","icon"],function(ns,next){ @@ -254,7 +254,7 @@ AppFactory.prototype.createFork = function(j,next){ fork.kill(); return next(new Error("fork process sending messages before initialization")); } - console.log("forkready"); + debug("forkready"); that.emit("forked",fork,j); next(void(0),j); }); diff --git a/core/fork_framework/fork_container/fork2server_com.js b/core/fork_framework/fork_container/fork2server_com.js index 300330a..207736e 100644 --- a/core/fork_framework/fork_container/fork2server_com.js +++ b/core/fork_framework/fork_container/fork2server_com.js @@ -1,7 +1,7 @@ /* Similar to meteor.methods */ -console.log("in the child"); +//console.log("in the child"); function MethodCall(message){ this.id = message.id; diff --git a/core/fork_framework/index.js b/core/fork_framework/index.js index f7ec703..b6ff96b 100644 --- a/core/fork_framework/index.js +++ b/core/fork_framework/index.js @@ -12,7 +12,7 @@ module.exports = function(app,wss){ console.log("\nThese Windows were completed: "+ JSON.stringify(results)); }); windows.on("forked", function(fork){ - console.log("emitted"); + debug("emitted"); methods.addFork(fork); fork.on("error",function(err){ console.log(err); diff --git a/core/fork_framework/ws2fork_com.js b/core/fork_framework/ws2fork_com.js index 1a717ff..df45eaa 100644 --- a/core/fork_framework/ws2fork_com.js +++ b/core/fork_framework/ws2fork_com.js @@ -16,14 +16,14 @@ var methods = { }; methods.add = function(m,fork){ - console.log("adding"); + debug("adding"); this.responders[m.name] = fork; this.fork_resp[fork.pid].push(m.name) } methods.send = function(message){ if(!this.requests[message.id]){ - console.log("user removed or no request"); + debug("user removed or no request"); return; } this.requests[message.id].send(JSON.stringify(message)); @@ -39,11 +39,11 @@ methods.removeFork = function(fork,code,signal){ } methods.addFork = function(fork){ - console.log("adding fork"); + debug("adding fork"); this.fork_resp[fork.pid] = []; this.forks[fork.pid] = fork; fork.on("message", function(message){ - console.log(JSON.stringify(message)); + debug(JSON.stringify(message)); switch(message.cmd){ case "send": methods.send(message.message);break; case "add": methods.add(message,fork);break; From 7aed167201fd22fc24643d465394c4939fba9615 Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 5 Dec 2014 14:17:38 -0600 Subject: [PATCH 05/36] Box shown around silk url. --- server.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 9214de8..72e1df2 100644 --- a/server.js +++ b/server.js @@ -40,7 +40,28 @@ app.get("/bc/:component", require(__root + "/core/bower_static.js")); var windows = require(__root + "/core/fork_framework")(app, wss); var server = app.listen(3000, function () { + var add = server.address(); - console.log('Silk at http://%s:%s', add.address, add.port) + var message = 'Silk at http://' + add.address + ":" + add.port; + var length = message.length; + var prespace = " "; + // form box + var box = ""; + for (var i = 0; i < length + 10; ++i) { + box += "="; + } + var space = " "; + var empty = ""; + for (var i = 0; i < length + 10 - 2; ++i) { + empty += " "; + } + console.log(prespace + box); + console.log(prespace + "|" + empty + "|"); + console.log(prespace + "|" + space + message + space + "|"); + console.log(prespace + "|" + empty + "|"); + console.log(prespace + box); + console.log(""); -}); + // console.log('Silk at http://%s:%s', add.address, add.port) + +}); \ No newline at end of file From 02f253a55d50adc2b8daf01726427fe189259c33 Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 5 Dec 2014 14:42:03 -0600 Subject: [PATCH 06/36] moved window manager into folder --- server.js | 11 ++++++++--- .../public/js => window-manager/public/JS}/call.js | 0 .../public/js => window-manager/public/JS}/clock.js | 0 .../public/JS}/libraries/jquery.js | 0 .../public/JS}/libraries/jsChannel.js | 0 .../public/JS}/libraries/vue.js | 0 .../public/js => window-manager/public/JS}/load.js | 0 .../public/JS}/windowManager.js | 0 {core => window-manager}/public/css/main.css | 0 {core => window-manager}/public/css/normalize.css | 0 {core => window-manager}/public/img/Close-48.png | Bin {core => window-manager}/public/img/menu.png | Bin index.html => window-manager/public/index.html | 0 13 files changed, 8 insertions(+), 3 deletions(-) rename {core/public/js => window-manager/public/JS}/call.js (100%) rename {core/public/js => window-manager/public/JS}/clock.js (100%) rename {core/public/js => window-manager/public/JS}/libraries/jquery.js (100%) rename {core/public/js => window-manager/public/JS}/libraries/jsChannel.js (100%) rename {core/public/js => window-manager/public/JS}/libraries/vue.js (100%) rename {core/public/js => window-manager/public/JS}/load.js (100%) rename {core/public/js => window-manager/public/JS}/windowManager.js (100%) rename {core => window-manager}/public/css/main.css (100%) rename {core => window-manager}/public/css/normalize.css (100%) rename {core => window-manager}/public/img/Close-48.png (100%) rename {core => window-manager}/public/img/menu.png (100%) rename index.html => window-manager/public/index.html (100%) diff --git a/server.js b/server.js index 72e1df2..d4a801b 100644 --- a/server.js +++ b/server.js @@ -30,11 +30,16 @@ var express = require('express') var app = express() app.get('/', function (req, res) { - res.sendFile(path.join(__dirname, 'index.html')); -}) + res.sendFile(__root + "/window-manager/public/index.html"); +}); + + // static files for client -app.use(express.static(__dirname + '/core/public')); +app.use(express.static(__dirname + '/window-manager/public')); +app.get("/js/call.js", function(req, res){ + res.sendFile(__root + "/core/public/js/call.js"); +}) app.get("/bc/:component", require(__root + "/core/bower_static.js")); var windows = require(__root + "/core/fork_framework")(app, wss); diff --git a/core/public/js/call.js b/window-manager/public/JS/call.js similarity index 100% rename from core/public/js/call.js rename to window-manager/public/JS/call.js diff --git a/core/public/js/clock.js b/window-manager/public/JS/clock.js similarity index 100% rename from core/public/js/clock.js rename to window-manager/public/JS/clock.js diff --git a/core/public/js/libraries/jquery.js b/window-manager/public/JS/libraries/jquery.js similarity index 100% rename from core/public/js/libraries/jquery.js rename to window-manager/public/JS/libraries/jquery.js diff --git a/core/public/js/libraries/jsChannel.js b/window-manager/public/JS/libraries/jsChannel.js similarity index 100% rename from core/public/js/libraries/jsChannel.js rename to window-manager/public/JS/libraries/jsChannel.js diff --git a/core/public/js/libraries/vue.js b/window-manager/public/JS/libraries/vue.js similarity index 100% rename from core/public/js/libraries/vue.js rename to window-manager/public/JS/libraries/vue.js diff --git a/core/public/js/load.js b/window-manager/public/JS/load.js similarity index 100% rename from core/public/js/load.js rename to window-manager/public/JS/load.js diff --git a/core/public/js/windowManager.js b/window-manager/public/JS/windowManager.js similarity index 100% rename from core/public/js/windowManager.js rename to window-manager/public/JS/windowManager.js diff --git a/core/public/css/main.css b/window-manager/public/css/main.css similarity index 100% rename from core/public/css/main.css rename to window-manager/public/css/main.css diff --git a/core/public/css/normalize.css b/window-manager/public/css/normalize.css similarity index 100% rename from core/public/css/normalize.css rename to window-manager/public/css/normalize.css diff --git a/core/public/img/Close-48.png b/window-manager/public/img/Close-48.png similarity index 100% rename from core/public/img/Close-48.png rename to window-manager/public/img/Close-48.png diff --git a/core/public/img/menu.png b/window-manager/public/img/menu.png similarity index 100% rename from core/public/img/menu.png rename to window-manager/public/img/menu.png diff --git a/index.html b/window-manager/public/index.html similarity index 100% rename from index.html rename to window-manager/public/index.html From a26ce50c0286bfd5c641fab2568357e099b56481 Mon Sep 17 00:00:00 2001 From: zodern Date: Wed, 10 Dec 2014 19:22:37 -0600 Subject: [PATCH 07/36] fixed conflicts --- core/fork_framework/index.js | 4 ---- core/fork_framework/ws2fork_com.js | 5 ----- server.js | 8 -------- 3 files changed, 17 deletions(-) diff --git a/core/fork_framework/index.js b/core/fork_framework/index.js index 028e001..125b343 100644 --- a/core/fork_framework/index.js +++ b/core/fork_framework/index.js @@ -12,10 +12,6 @@ module.exports = function(app,wss){ console.log("\nThese Windows were completed: "+ JSON.stringify(results)); }); windows.on("forked", function(fork){ -<<<<<<< HEAD - debug("emitted"); -======= ->>>>>>> master methods.addFork(fork); fork.on("error",function(err){ console.log(err); diff --git a/core/fork_framework/ws2fork_com.js b/core/fork_framework/ws2fork_com.js index 60a9d44..e253033 100644 --- a/core/fork_framework/ws2fork_com.js +++ b/core/fork_framework/ws2fork_com.js @@ -43,11 +43,6 @@ methods.addFork = function(fork){ this.fork_resp[fork.pid] = []; this.forks[fork.pid] = fork; fork.on("message", function(message){ -<<<<<<< HEAD - debug(JSON.stringify(message)); -======= -// console.log(JSON.stringify(message)); ->>>>>>> master switch(message.cmd){ case "send": methods.send(message.message);break; case "add": methods.add(message,fork);break; diff --git a/server.js b/server.js index 23a852a..06865a8 100644 --- a/server.js +++ b/server.js @@ -36,17 +36,9 @@ app.get('/', function (req, res) { // static files for client -<<<<<<< HEAD app.use(express.static(__dirname + '/window-manager/public')); -app.get("/js/call.js", function(req, res){ - res.sendFile(__root + "/core/public/js/call.js"); -}) -app.get("/bc/:component", require(__root + "/core/bower_static.js")); -======= -app.use(express.static(__dirname + '/core/public')); app.get(/^\/bc\//, require(__root + "/core/bower_static.js")); app.get("/api.js", require(__root + "/core/client_api.js")); ->>>>>>> master var windows = require(__root + "/core/fork_framework")(app, wss); From b4ca24903c1e016494e6bbc91e0aa9d549eda505 Mon Sep 17 00:00:00 2001 From: zodern Date: Mon, 15 Dec 2014 09:41:06 -0600 Subject: [PATCH 08/36] Added app manager to install and remove apps. --- .gitignore | 2 + apps/appManager/index.js | 202 +++++++++++++++++++++++++++ apps/appManager/public/icon.png | Bin 0 -> 9344 bytes apps/appManager/public/index.html | 224 ++++++++++++++++++++++++++++++ apps/appManager/window.json | 16 +++ 5 files changed, 444 insertions(+) create mode 100644 apps/appManager/index.js create mode 100644 apps/appManager/public/icon.png create mode 100644 apps/appManager/public/index.html create mode 100644 apps/appManager/window.json diff --git a/.gitignore b/.gitignore index bf413e1..90eeec3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ npm-debug.log roadmap *.orig *.*~ + +.brackets.json diff --git a/apps/appManager/index.js b/apps/appManager/index.js new file mode 100644 index 0000000..2a0225f --- /dev/null +++ b/apps/appManager/index.js @@ -0,0 +1,202 @@ +var request = require('request'); +var fs = require('fs'); +var path = require('path'); +var yauzl = require("yauzl"); +var mkdirp = require('mkdirp'); +var async = require('async'); + +var apps = []; +var appsFolder = __dirname.split(path.sep); +appsFolder = appsFolder.slice(0, appsFolder.length - 1); +appsFolder = appsFolder.join(path.sep); + +methods.add({ + "apps/remove": function (data, call_obj, send) { + send(void(0), "Deleting..."); + + var file = data.folder; + var folder = appsFolder + path.sep + file; + console.log(folder); + var deleteFolderRecursive = function (path) { + if (fs.existsSync(path)) { + fs.readdirSync(path).forEach(function (file, index) { + var curPath = path + "/" + file; + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(path); + console.log("Finished removing"); + send(void(0), " "); + } + }; + deleteFolderRecursive(folder); + }, + "apps/list": function (data, call_obj, send) { + fs.readdir(appsFolder, function (err, files) { + if (err) { + send(err); + } + apps = []; + async.each(files, function (file, next) { + console.log("each"); + console.log(apps); + console.log(appsFolder + path.sep + file + "/window.json"); + fs.exists(appsFolder + path.sep + file + "/window.json", function (exists) { + if (!exists) { + console.log("file doesn't exist"); + return next(new Error(appsFolder + file + "/window.json does not exist.")); + } + + + fs.readFile(appsFolder + path.sep + file + "/window.json", function (err, contents) { + console.log(contents); + if (err) { + console.log(err); + return next(err) + } + try { + var j = JSON.parse(contents); + } catch (err) { + return next(err); + } + if (!j.url) { + console.log("URL is always standard"); + return next(new Error("URL is always standard")) + } + if (!j.title) return next(new Error("for now, title is standard")) + if (!j.icon) return next(new Error("for now, Logo is standard")) + j.name = file; + j.path = appsFolder + path.sep + file; + + console.log(j.name); + // no erros. add to apps + apps.push(j); + console.log("no errors"); + + // was being sent before all complete so sending every time + send(void(0), apps); + return next(); + }) + }) + }, function (err) { + console.log(err); + console.log("list done"); + console.dir(apps); + send(void(0), apps); + }); + console.log(err); + console.dir(files); + + }); + + }, + "apps/install": download +}); + +function download(data, call_ob, send) { + + fs.exists(appsFolder + path.sep + data.url.replace("/", "-"), function (exists) { + if (exists === true) { + send(new Error("App already exists")); + return; + } + + if (data.url === "") { + send(new Error("Url can not be empty")); + } + var repo = data.url; + + var url = "https://api.github.com/repos/" + repo + "/zipball"; + console.log("url is " + url); + var options = { + url: url, + headers: { + 'User-Agent': 'silk-gui' + } + }; + + send(void(0), "Downloading..."); + request(options).on('response', function (response) { + console.log(response.statusCode); + console.log(response.headers['content-type]']); + }).on('error', function (err) { + send(err) + }).on("end", function () { + send(void(0), "pending"); + install(data, call_ob, send) + }).pipe(fs.createWriteStream(__dirname + path.sep + 'test.zip')); + + }); +} + +function install(data, call_ob, send) { + send(void(0), "Installing ..."); + var extractTo = appsFolder + path.sep + data.url.replace("/", "-"); + try { + yauzl.open(__dirname + path.sep + 'test.zip', function (err, zipfile) { + if (err) { + send(err); + return; + } + zipfile.once('end', function () { + send(void(0), "Finished installing!") + console.log("deleting file"); + fs.unlink(__dirname + path.sep + 'test.zip', function (err) { + console.log("finished deleting"); + if (err) { + send(err); + + } + send(void(0), " "); + }) + }); + zipfile.on("entry", function (entry) { + + if (/\/$/.test(entry.fileName)) { + // directory file names end with '/' + return; + } + + var fileName = entry.fileName; + fileName = fileName.split(path.sep); + fileName = fileName.splice(1, fileName.length) + fileName = fileName.join(path.sep); + + entry.fileName = fileName; + var dest = path.join(extractTo, entry.fileName) + var destDir = path.dirname(dest) + // dest = dest.split(path.sep); + // dest = dest.slice(0, dest.length - 1); + + zipfile.openReadStream(entry, function (err, readStream) { + if (err) { + send(err); + return; + } + + mkdirp(destDir, function (err) { + if (err) { + send(err); + } + + + //entry.fileName = data.url.replace("/", "-"); + // ensure parent directory exists, and then: + + readStream.pipe(fs.createWriteStream(dest).on("error", function (err) { + send(err) + })) + }); + + }); + + }); + }); + + } catch (e) { + send(e); + } +} \ No newline at end of file diff --git a/apps/appManager/public/icon.png b/apps/appManager/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..9b80c61ec5c2e51d4416f470566fee8edd5db651 GIT binary patch literal 9344 zcmeHNZAep57+$eLWJZLH@JIL~D9gF4n>tNx+MCB#6a+fK2l%{wOqfZO0UdYmV-p|%0FL-T}8giNP5Xs*@T?)jVbT#kv zG{?Kf4@Xvd?c<;du^XqF;zkg*RSBXqay2j*B;-1OZ?duEoLhJqJZG3;EM2xuogW6rvvJo zfUrGWiei$sJ*=JFGp)%9fWDGAp_8GNI0IzkOhaPOu~EpP$9PM6eNKRbN<~mi($=LD z!6R==MFDTN@I|yv8pl=3J&{ci7l5VG7l3RwcQ`ABXs{!yb!^DI30Y^1&g#^Y95(mt ztV##``#xyt%1k1>drCuBr6(kPsMH-?e%UzN7(az31wq5^hGeIsB9mon_#xK7??Z94 z4dVLUb=*$_m|E_*+rST?IDEb-n;Aq7+ljKSptfF*$(CFB^BaMtdYlVLH*UO&HxA?}0gd8Rk4c7oYtMqh#c6 zyljbgGe+*VIBK(4HtR8@&&no<3*f2e%xF@QZMrdb9G717L34N*#vO` zUT&EwpF8v@2{~<7>-Qd9e%W~FM0hnUnUc9HhcxayvRA5@ZKlrhXh{L!bP?Y$I z3#iBlY(HC=ni=*q&q)h_8iB(ZM+}F%sB{Z}Z0`P87?t`;j36!$?0<&-nCLuW8J$qL zXZ`SuXOOf2r-Ad~j3b6aQGSuM04Q#r5+jHUu5fvY;j|%jfV2Qu*@lP_ z#07$)q?fb+R~>f)mzNmMG?5oT8 + + + App Manager + + + + +
+

Your Apps

+
    +
  • {{title}} + +
  • +
+
+ +
+ + +
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/apps/appManager/window.json b/apps/appManager/window.json new file mode 100644 index 0000000..66bad71 --- /dev/null +++ b/apps/appManager/window.json @@ -0,0 +1,16 @@ +{ + "title": "App Manager", + "url": "index.html", + "zIndex": 0, + "running": false, + "minimized": true, + "icon": "icon.png", + "bower_dependencies": { + "jquery": "latest" + }, + "npm_dependencies": { + "request": "*", + "yauzl": "*", + "mkdirp": "*" + } +} \ No newline at end of file From 562feeec0b342dae3949f2431df3a826cb4e9ffa Mon Sep 17 00:00:00 2001 From: zodern Date: Mon, 15 Dec 2014 11:45:22 -0600 Subject: [PATCH 09/36] improved window.json and urls app loader adds/overwrites zIndex, running and minimized properties of the window.json. All of the apps except terminal should load remotely now. --- apps/appManager/window.json | 3 --- apps/fileExplorer/window.json | 7 ++----- apps/terminal/window.json | 5 +---- apps/textEditor/window.json | 5 +---- core/fork_framework/app_loader.js | 8 ++++++++ 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/apps/appManager/window.json b/apps/appManager/window.json index 66bad71..e2b2d3f 100644 --- a/apps/appManager/window.json +++ b/apps/appManager/window.json @@ -1,9 +1,6 @@ { "title": "App Manager", "url": "index.html", - "zIndex": 0, - "running": false, - "minimized": true, "icon": "icon.png", "bower_dependencies": { "jquery": "latest" diff --git a/apps/fileExplorer/window.json b/apps/fileExplorer/window.json index 0e09a0b..37e4e8e 100644 --- a/apps/fileExplorer/window.json +++ b/apps/fileExplorer/window.json @@ -1,8 +1,5 @@ { "title": "File Explorer", - "url": "http://0.0.0.0:3000/fileExplorer/index.html", - "running": false, - "minimized": true, - "icon": "/fileExplorer/logo.png", - "zIndex": 0 + "url": "/fileExplorer/index.html", + "icon": "/fileExplorer/logo.png" } diff --git a/apps/terminal/window.json b/apps/terminal/window.json index 271e3bc..e6a2b22 100644 --- a/apps/terminal/window.json +++ b/apps/terminal/window.json @@ -1,8 +1,5 @@ { "title" : "Terminal", "url" : "//localhost:8000/", - "icon" : "//localhost:3000/terminal/icon.png", - "minimized": true, - "running": false, - "zIndex": 0 + "icon" : "//localhost:3000/terminal/icon.png" } \ No newline at end of file diff --git a/apps/textEditor/window.json b/apps/textEditor/window.json index d613904..31996ea 100644 --- a/apps/textEditor/window.json +++ b/apps/textEditor/window.json @@ -1,10 +1,7 @@ { "title": "Text Editor", - "url": "http://0.0.0.0:3000/textEditor/index.html", - "running": false, - "minimized": true, + "url": "/textEditor/index.html", "icon": "logo.png", - "zIndex": 0, "opens": [ "text/plain", "*" diff --git a/core/fork_framework/app_loader.js b/core/fork_framework/app_loader.js index 136bc88..4923959 100644 --- a/core/fork_framework/app_loader.js +++ b/core/fork_framework/app_loader.js @@ -122,6 +122,14 @@ AppFactory.prototype.checkWindowJSON = function(file,next){ if(!j.url) return next(new Error("URL is always standard")) if(!j.title) return next(new Error("for now, title is standard")) if(!j.icon) return next(new Error("for now, Logo is standard")) + + // add fields necessary for windows + if(j.url !== 'headless'){ + j.zIndex = 0; + j.running = false; + j.minimized = true; + } + j.name = file; j.clean = JSON.parse(JSON.stringify(j)); j.path = f+file; From cffefff4e0ddb213ae83f97bc658e66b746937e5 Mon Sep 17 00:00:00 2001 From: zodern Date: Mon, 15 Dec 2014 14:29:40 -0600 Subject: [PATCH 10/36] Apps can have multiple windows open --- apps/appManager/window.json | 1 + apps/fileExplorer/window.json | 3 +- apps/terminal/window.json | 6 +- apps/textEditor/window.json | 1 + bower.json | 3 +- package.json | 3 +- window-manager/public/JS/windowManager.js | 282 ---------------------- window-manager/public/index.html | 21 +- window-manager/public/js/channel.js | 121 ++++++++++ 9 files changed, 147 insertions(+), 294 deletions(-) delete mode 100644 window-manager/public/JS/windowManager.js create mode 100644 window-manager/public/js/channel.js diff --git a/apps/appManager/window.json b/apps/appManager/window.json index e2b2d3f..cdb9195 100644 --- a/apps/appManager/window.json +++ b/apps/appManager/window.json @@ -2,6 +2,7 @@ "title": "App Manager", "url": "index.html", "icon": "icon.png", + "multipleWindows": false, "bower_dependencies": { "jquery": "latest" }, diff --git a/apps/fileExplorer/window.json b/apps/fileExplorer/window.json index 37e4e8e..a87a8f9 100644 --- a/apps/fileExplorer/window.json +++ b/apps/fileExplorer/window.json @@ -1,5 +1,6 @@ { "title": "File Explorer", "url": "/fileExplorer/index.html", - "icon": "/fileExplorer/logo.png" + "icon": "/fileExplorer/logo.png", + "multipleWindows": true } diff --git a/apps/terminal/window.json b/apps/terminal/window.json index e6a2b22..fc09daf 100644 --- a/apps/terminal/window.json +++ b/apps/terminal/window.json @@ -1,5 +1,9 @@ { "title" : "Terminal", "url" : "//localhost:8000/", - "icon" : "//localhost:3000/terminal/icon.png" + "icon" : "//localhost:3000/terminal/icon.png", + "remote" : { + "enabled": false + }, + "multipleWindows": false } \ No newline at end of file diff --git a/apps/textEditor/window.json b/apps/textEditor/window.json index 31996ea..2afc629 100644 --- a/apps/textEditor/window.json +++ b/apps/textEditor/window.json @@ -2,6 +2,7 @@ "title": "Text Editor", "url": "/textEditor/index.html", "icon": "logo.png", + "multipleWindows": true, "opens": [ "text/plain", "*" diff --git a/bower.json b/bower.json index 2b47e9a..ca2bbbd 100644 --- a/bower.json +++ b/bower.json @@ -21,7 +21,8 @@ "jquery": "~2.1.1", "fontawesome": "*", "rsvp": "*", - "eventEmitter": "*" + "eventEmitter": "*", + "jspath": "*" }, "resolutions": { "jquery": ">=1.9.1" diff --git a/package.json b/package.json index bae1c26..5034038 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "commander": "2.5.0", "async": "~0.9.0", "bower-json": "latest", - "rsvp": "latest" + "rsvp": "latest", + "jspath": "latest" }, "optionalDependencies" : { "tty.js" : "zodern/tty.js" diff --git a/window-manager/public/JS/windowManager.js b/window-manager/public/JS/windowManager.js deleted file mode 100644 index 159070b..0000000 --- a/window-manager/public/JS/windowManager.js +++ /dev/null @@ -1,282 +0,0 @@ -var windows = []; - -// channel for each window -var channels = {}; - -function CreateChannel(app) { - app.running = true; - var windowName = app.title; - // allow html to be updated - console.log(windowName); - chan = Channel.build({ - window: $("#desktop .window iframe[data-name='" + windowName + "']")[0].contentWindow, - origin: "*", - scope: "testScope", - onReady: function () { - console.log("channel is ready!"); - console.log("ready"); - - } - }) - - chan.bind("openFile", function (context, params) { - console.log("=============") - console.log(context); - console.log(params); - - // open text editor and include path in url - // find text editor - - methods.call("Silk/appDefaults", params.mime, function (err, data) { - function openWindow(title) { - // find window index - for (var i = 0; i < windows.length; ++i) { - - if (windows[i].title === title) { - - // start the app - if (windows[i].running == false) { - var url = windows[i].url; - url = url.split("?")[0]; - windows[i].url = url + "?file=" + encodeURIComponent(params.path); - windows[i].running = true; - windows[i].minimized = false; - windowOrder.unshift(windows[i].title); - - } else { - - channels[windows[i].title].notify({ - method: "fileToOpen", - params: { - path: params.path, - mime: params.mime - } - }); - - if (windows[i].minimized == true) { - windows[i].minimized = false; - windowOrder.unshift(windows[i].title); - } else { - // move position to top - windowOrder.pop(windows[i].title); - windowOrder.unshift(windows[i].title); - } - - } - - updateOrder(); - - break; - } - } - } - - console.log(data); - - // open using default program - if (data.default !== "") { - openWindow(data.default); - } - // if one app use it if it is not for *. - else if (data.available.length < 2 && data.mime != "*") { - openWindow(data.available[0]); - } - // let user choose program - else { - var html = '
Choose App To Open
'; - html += params.path; - html += '
    '; - for (var i = 0; i < data.available.length; ++i) { - html += "
  • "; - html += data.available[i]; - html += "
  • "; - } - html += '
Always Use This App
' - $("#appNotifications").append(html); - $("#appNotifications").css("display", "block"); - - // set up click hander - $("#appNotifications .content button").click(function (e) { - $("#appNotifications").css("display", "none"); - $("#appNotifications").html(""); - }); - $("#appNotifications .content li").click(function (e) { - console.log($(e.target).html()); - openWindow($(e.target).html()); - // if chewckbox is checked, set up default app - if ($('#appNotifications input').is(':checked') == true) { - methods.call("Silk/setDefault", { - mime: params.mime, - app: $(e.target).html() - }, function () {}) - } - $("#appNotifications").css("display", "none"); - $("#appNotifications").html(""); - }); - } - }); - - }); - - channels[windowName] = chan; -} - -// order of open windows. Used to calculate z-index. -var windowOrder = []; - -// update z-index of windows -var updateOrder = function () { - for (var i = 0; i < windows.length; ++i) { - console.log(windows[i].title) - if (windows[i].running === true & windows[i].minimized !== true) { - console.log(windows[i].title + "will be updated"); - var position = windowOrder.indexOf(windows[i].title); - if (position > -1) { - windows[i].zIndex = 200 - position; - } - } - } -} - -var wm; -var taskbar; -var menu; - -function initializeManager(_windows) { - windows = _windows; - wm = new Vue({ - el: '#desktop', - data: { - windows: windows - }, - methods: { - buildChannel: CreateChannel, - minimize: function (app) { - // put window on top - app.minimized = !app.minimized; - - }, - close: function (app) { - // reset url - app.url = app.url.split("?")[0]; - app.running = false; - app.minimized = true; - windowOrder.pop(app.title); - updateOrder(); - } - } - }); - - taskbar = new Vue({ - el: '#taskbar', - data: { - programs: windows - }, - methods: { - open: function (app) { - app.running = true; - // move to top if behind - if (app.minimized == false) { - if (windowOrder.indexOf(app.title) > 0) { - // move to top - windowOrder.pop(app.title); - windowOrder.unshift(app.title); - updateOrder(); - return - } - } - app.minimized = !app.minimized; - if (app.minimized === false) { - windowOrder.unshift(app.title); - } - if (app.minimized === true) { - windowOrder.pop(app.title); - } - updateOrder(); - }, - menu: function () { - // toggle menu - if ($("#menu").css("display") == "block") { - $("#menu").css("overflow", "hidden"); - $("#menu").animate({ - height: 0, - }, - 100, 'swing', function () { - $("#menu").css({ - "display": "none", - "height": "auto" - }) - }); - $("#taskbar").animate({ - bottom: 0 - }, { - duration: 100 - }); - - - } else { - var height = $("#menu").height(); - - // $("#taskbar").css("bottom", height); - $("#menu").css("display", "block"); - $("#menu").css("height", 0); - $("#menu").css("overflow", "hidden"); - $("#menu").animate({ - height: height, - overflow: "scroll" - }, { - duration: 100 - }); - $("#taskbar").animate({ - bottom: height - }, { - duration: 100 - }); - } - } - } - }); - - menu = new Vue({ - el: '#menu', - data: { - apps: windows - }, - methods: { - open: function (app) { - app.running = true; - - // hide menu - $("#menu").css("overflow", "hidden"); - $("#menu").animate({ - height: 0, - }, - 100, 'swing', function () { - $("#menu").css({ - "display": "none", - "height": "auto" - }) - }); - - $("#taskbar").animate({ - bottom: 0 - }, { - duration: 100 - }); - - // open window and move to top - if (app.minimized == false) { - - windowOrder.pop(app.title); - windowOrder.unshift(app.title); - updateOrder(); - - } else { - app.minimized = false; - windowOrder.unshift(app.title); - updateOrder(); - } - } - } - }) -} \ No newline at end of file diff --git a/window-manager/public/index.html b/window-manager/public/index.html index c777cb4..218fad8 100644 --- a/window-manager/public/index.html +++ b/window-manager/public/index.html @@ -15,10 +15,10 @@

Silk

-
{{title}} _ × +
{{title}} _ ×
- +
- + + + diff --git a/window-manager/public/js/channel.js b/window-manager/public/js/channel.js new file mode 100644 index 0000000..2844670 --- /dev/null +++ b/window-manager/public/js/channel.js @@ -0,0 +1,121 @@ +// channel for each window +var channels = {}; + +function CreateChannel(index) { + var app = windows[index]; + app.running = true; + var windowName = app.title; + // allow html to be updated + console.log(windowName); + chan = Channel.build({ + window: $("#desktop .window iframe[data-name='" + windowName + "']")[0].contentWindow, + origin: "*", + scope: "testScope", + onReady: function () { + console.log("channel is ready!"); + console.log("ready"); + + } + }) + + chan.bind("openFile", function (context, params) { + console.log("=============") + console.log(context); + console.log(params); + + // open text editor and include path in url + // find text editor + + methods.call("Silk/appDefaults", params.mime, function (err, data) { + function openWindow(title) { + // find window index + for (var i = 0; i < windows.length; ++i) { + + if (windows[i].title === title) { + + // start the app + if (windows[i].running == false) { + var url = windows[i].url; + url = url.split("?")[0]; + windows[i].url = url + "?file=" + encodeURIComponent(params.path); + windows[i].running = true; + windows[i].minimized = false; + windowOrder.unshift(windows[i].title); + + } else { + + channels[windows[i].title].notify({ + method: "fileToOpen", + params: { + path: params.path, + mime: params.mime + } + }); + + if (windows[i].minimized == true) { + windows[i].minimized = false; + windowOrder.unshift(windows[i].title); + } else { + // move position to top + windowOrder.pop(windows[i].title); + windowOrder.unshift(windows[i].title); + } + + } + + updateOrder(); + + break; + } + } + } + + console.log(data); + + // open using default program + if (data.default !== "") { + openWindow(data.default); + } + // if one app use it if it is not for *. + else if (data.available.length < 2 && data.mime != "*") { + openWindow(data.available[0]); + } + // let user choose program + else { + var html = '
Choose App To Open
'; + html += params.path; + html += '
    '; + for (var i = 0; i < data.available.length; ++i) { + html += "
  • "; + html += data.available[i]; + html += "
  • "; + } + html += '
Always Use This App
' + $("#appNotifications").append(html); + $("#appNotifications").css("display", "block"); + + // set up click hander + $("#appNotifications .content button").click(function (e) { + $("#appNotifications").css("display", "none"); + $("#appNotifications").html(""); + }); + $("#appNotifications .content li").click(function (e) { + console.log($(e.target).html()); + openWindow($(e.target).html()); + // if chewckbox is checked, set up default app + if ($('#appNotifications input').is(':checked') == true) { + methods.call("Silk/setDefault", { + mime: params.mime, + app: $(e.target).html() + }, function () {}) + } + $("#appNotifications").css("display", "none"); + $("#appNotifications").html(""); + }); + } + }); + + }); + + channels[windowName] = chan; +} \ No newline at end of file From d3993985f25322bd5222910bf6e35c8be1c6c356 Mon Sep 17 00:00:00 2001 From: zodern Date: Mon, 15 Dec 2014 14:46:15 -0600 Subject: [PATCH 11/36] re-added windowManager.js --- window-manager/public/js/windowManager.js | 188 ++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 window-manager/public/js/windowManager.js diff --git a/window-manager/public/js/windowManager.js b/window-manager/public/js/windowManager.js new file mode 100644 index 0000000..b82c0aa --- /dev/null +++ b/window-manager/public/js/windowManager.js @@ -0,0 +1,188 @@ +var windows = []; +var apps = []; + +// order of open windows. Used to calculate z-index. +var windowOrder = []; + +// update z-index of windows +var updateOrder = function () { + for (var i = 0; i < windows.length; ++i) { + console.log(windows[i].title) + if (windows[i].running === true & windows[i].minimized !== true) { + console.log(windows[i].title + "will be updated"); + var position = windowOrder.indexOf(i); + if (position > -1) { + windows[i].zIndex = 200 - position; + } + } + } +} + +var wm; +var taskbar; +var menu; + +function initializeManager(_windows) { + apps = _windows; + wm = new Vue({ + el: '#desktop', + data: { + windows: windows + }, + methods: { + buildChannel: CreateChannel, + minimize: function (index) { + windows[index].minimized = true; + windowOrder.pop(index); + }, + close: function (index) { + // reset url + var app = windows[index]; + app.url = app.url.split("?")[0]; + app.running = false; + app.minimized = true; + windowOrder.pop(index); + updateOrder(); + } + } + }); + + taskbar = new Vue({ + el: '#taskbar', + data: { + programs: windows + }, + methods: { + open: function (index) { + app = windows[index]; + app.running = true; + + // move to top if behind + if (app.minimized == false) { + if (windowOrder.indexOf(index) > 0) { + // move to top + windowOrder.pop(index); + windowOrder.unshift(index); + updateOrder(); + return + } + } + + app.minimized = !app.minimized; + if (app.minimized === false) { + windowOrder.unshift(index); + } + if (app.minimized === true) { + windowOrder.pop(index); + } + updateOrder(); + }, + menu: function () { + // toggle menu + if ($("#menu").css("display") == "block") { + $("#menu").css("overflow", "hidden"); + $("#menu").animate({ + height: 0, + }, + 100, 'swing', function () { + $("#menu").css({ + "display": "none", + "height": "auto" + }) + }); + $("#taskbar").animate({ + bottom: 0 + }, { + duration: 100 + }); + + + } else { + var height = $("#menu").height(); + + // $("#taskbar").css("bottom", height); + $("#menu").css("display", "block"); + $("#menu").css("height", 0); + $("#menu").css("overflow", "hidden"); + $("#menu").animate({ + height: height, + overflow: "scroll" + }, { + duration: 100 + }); + $("#taskbar").animate({ + bottom: height + }, { + duration: 100 + }); + } + } + } + }); + + menu = new Vue({ + el: '#menu', + data: { + apps: apps + }, + methods: { + open: function (index) { + + // hide menu + $("#menu").css("overflow", "hidden"); + $("#menu").animate({ + height: 0, + }, + 100, 'swing', function () { + $("#menu").css({ + "display": "none", + "height": "auto" + }) + }); + + $("#taskbar").animate({ + bottom: 0 + }, { + duration: 100 + }); + + var app = menu.$data.apps[index]; + + // create new window + if (app.multipleWindows === true) { + // clone object + var win = JSON.parse(JSON.stringify(app)); + win.running = true; + win.minimized = false; + windows.push(win); + windowOrder.unshift(index); + updateOrder(); + + } else { + var win = JSPath.apply('.windows{.title == "' + app.title + '"}', wm.$data); + if ( win.length > 0) { + app = win[0]; + } else{ + app = windows.push(app); + app = windows[app - 1]; + } + + // open existing window and move to top + if (app.minimized == false) { + // check if window open + + windowOrder.pop(index); + windowOrder.unshift(index); + updateOrder(); + + } else { + app.minimized = false; + app.running = true; + windowOrder.unshift(index); + updateOrder(); + } + } + } + } + }) +} \ No newline at end of file From 0bdcea9222cc0beb67d34d6aa56c5b37aac37325 Mon Sep 17 00:00:00 2001 From: zodern Date: Tue, 16 Dec 2014 11:12:38 -0600 Subject: [PATCH 12/36] Text editor correctly handles tab --- apps/textEditor/public/js/textEditor.js | 21 ++++++++++++++++++++- bower.json | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/textEditor/public/js/textEditor.js b/apps/textEditor/public/js/textEditor.js index 98a685a..9045462 100644 --- a/apps/textEditor/public/js/textEditor.js +++ b/apps/textEditor/public/js/textEditor.js @@ -61,4 +61,23 @@ $("#save").click(function () { file.changed = false; } -}) \ No newline at end of file +}); + +$(document).delegate('#text', 'keydown', function(e) { + var keyCode = e.keyCode || e.which; + + if (keyCode == 9) { + e.preventDefault(); + var start = $(this).get(0).selectionStart; + var end = $(this).get(0).selectionEnd; + + // set textarea value to: text before caret + tab + text after caret + $(this).val($(this).val().substring(0, start) + + "\t" + + $(this).val().substring(end)); + + // put caret at right position again + $(this).get(0).selectionStart = + $(this).get(0).selectionEnd = start + 1; + } +}); \ No newline at end of file diff --git a/bower.json b/bower.json index ca2bbbd..b9a6bbb 100644 --- a/bower.json +++ b/bower.json @@ -22,7 +22,8 @@ "fontawesome": "*", "rsvp": "*", "eventEmitter": "*", - "jspath": "*" + "jspath": "*", + "color-thief": "*" }, "resolutions": { "jquery": ">=1.9.1" From 3e83aebf45e58e560ea4438ca439ac067e85acf0 Mon Sep 17 00:00:00 2001 From: zodern Date: Tue, 16 Dec 2014 12:44:07 -0600 Subject: [PATCH 13/36] Added keyboard shortcut to save in Text Editor. --- apps/textEditor/index.js | 35 ++++++++++++++----------- apps/textEditor/public/index.html | 3 ++- apps/textEditor/public/js/mousetrap.js | 9 +++++++ apps/textEditor/public/js/textEditor.js | 16 +++++++++-- 4 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 apps/textEditor/public/js/mousetrap.js diff --git a/apps/textEditor/index.js b/apps/textEditor/index.js index 6dc60ec..d96d193 100644 --- a/apps/textEditor/index.js +++ b/apps/textEditor/index.js @@ -1,19 +1,17 @@ - - methods.add({ - "te/open": function(file, callObj, send){ + "te/open": function (file, callObj, send) { var fs = require("fs"); var fileName = file; console.log("fileName"); - fs.exists(fileName, function(exists) { + fs.exists(fileName, function (exists) { if (!exists) return send("this file does not exist"); - fs.stat(fileName, function(err, stats) { - if(err) return send(err); - if(stats.isDirectory()) + fs.stat(fileName, function (err, stats) { + if (err) return send(err); + if (stats.isDirectory()) return send(new Error("Editing directories in a text editor is not currently supported")); - fs.readFile(fileName,function(err,data){ - if(err) return send(err); + fs.readFile(fileName, function (err, data) { + if (err) return send(err); var ret = { state: "ready", content: data.toString("utf-8") @@ -22,22 +20,27 @@ methods.add({ }) }); }); - return {state: "loading"} + return { + state: "loading" + } } }); methods.add({ - "te/save" : function(data){ + "te/save": function (data, callObj, send) { var fs = require("fs"); console.log(data); path = data.path; contents = data.contents; console.log("=========="); - // console.log(contents); + // console.log(contents); fs.writeFile(path, contents, function (err) { - if (err) return console.log(err); - console.log("saved: " + path); -}); + if (err) return console.log(err); + console.log("saved: " + path); + }); console.log("finished"); + + // tricks silk into sending return value; + return " "; } -}) +}) \ No newline at end of file diff --git a/apps/textEditor/public/index.html b/apps/textEditor/public/index.html index 38ca72c..c40c8e1 100644 --- a/apps/textEditor/public/index.html +++ b/apps/textEditor/public/index.html @@ -10,9 +10,10 @@
- + + diff --git a/apps/textEditor/public/js/mousetrap.js b/apps/textEditor/public/js/mousetrap.js new file mode 100644 index 0000000..d5f6af2 --- /dev/null +++ b/apps/textEditor/public/js/mousetrap.js @@ -0,0 +1,9 @@ +/* mousetrap v1.4.6 craig.is/killing/mice */ +(function(J,r,f){function s(a,b,d){a.addEventListener?a.addEventListener(b,d,!1):a.attachEvent("on"+b,d)}function A(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return h[a.which]?h[a.which]:B[a.which]?B[a.which]:String.fromCharCode(a.which).toLowerCase()}function t(a){a=a||{};var b=!1,d;for(d in n)a[d]?b=!0:n[d]=0;b||(u=!1)}function C(a,b,d,c,e,v){var g,k,f=[],h=d.type;if(!l[a])return[];"keyup"==h&&w(a)&&(b=[a]);for(g=0;gg||h.hasOwnProperty(g)&&(p[h[g]]=g)}e=p[d]?"keydown":"keypress"}"keypress"==e&&f.length&&(e="keydown");return{key:c,modifiers:f,action:e}}function F(a,b,d,c,e){q[a+":"+d]=b;a=a.replace(/\s+/g," ");var f=a.split(" ");1":".","?":"/","|":"\\"},G={option:"alt",command:"meta","return":"enter",escape:"esc",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p,l={},q={},n={},D,z=!1,I=!1,u=!1;for(f=1;20>f;++f)h[111+f]="f"+f;for(f=0;9>=f;++f)h[f+96]=f;s(r,"keypress",y);s(r,"keydown",y);s(r,"keyup",y);var m={bind:function(a,b,d){a=a instanceof Array?a:[a];for(var c=0;c Date: Wed, 17 Dec 2014 08:24:36 -0600 Subject: [PATCH 14/36] Added tooltips with title for running apps --- bower.json | 3 ++- window-manager/public/JS/load.js | 8 ++++---- window-manager/public/css/main.css | 31 ++++++++++++++++++++++++++++++ window-manager/public/index.html | 16 ++++++--------- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/bower.json b/bower.json index b9a6bbb..b80340c 100644 --- a/bower.json +++ b/bower.json @@ -23,7 +23,8 @@ "rsvp": "*", "eventEmitter": "*", "jspath": "*", - "color-thief": "*" + "color-thief": "*", + "hint.css": "*" }, "resolutions": { "jquery": ">=1.9.1" diff --git a/window-manager/public/JS/load.js b/window-manager/public/JS/load.js index 5aff1e7..620496c 100644 --- a/window-manager/public/JS/load.js +++ b/window-manager/public/JS/load.js @@ -1,11 +1,11 @@ $(document).ready(function () { $(".loader span").css("animationIterationCount", "1"); - $.ajax("/windows.json").done(function(data){ + $.ajax("/windows.json").done(function (data) { initializeManager(data); - window.setTimeout(function () { - $(".loader").fadeOut(); + window.setTimeout(function () { + $(".loader").fadeOut(); }, 80) }) -}); +}); \ No newline at end of file diff --git a/window-manager/public/css/main.css b/window-manager/public/css/main.css index 4e142a8..c931d34 100644 --- a/window-manager/public/css/main.css +++ b/window-manager/public/css/main.css @@ -280,3 +280,34 @@ margin-right: -4px; #taskbar .app.menu:hover{ background-color: rgba(0,0,0,0.57); } + +/* tooltips */ + +/* remove arrow */ +.hint--top:before { +border-color: transparent; +} + +.hint:after, [data-hint]:after { +background: #FFF; +color: #808080; +box-shadow: 0px 0px 9px #808080; +border: 1px solid #808080; +} + +.hint--top:hover:after, .hint--top:hover:before, .hint--top:focus:after, .hint--top:focus:before{ +-webkit-transform: translateY(-8px) translateX(-50%); +-moz-transform: translateY(-8px) translateX(-50%); +transform: translateY(-8px) translateX(-50%); +margin-left: 0px; +} + +.hint:hover:before, .hint:hover:after, [data-hint]:hover:before, [data-hint]:hover:after{ + -webkit-transition: .3s opacity; + -moz-transition: .3s opacity; + transition: .3s opacity; + -webkit-transition-delay: 300ms; +-moz-transition-delay: 300ms; +transition-delay: 300ms; + +} diff --git a/window-manager/public/index.html b/window-manager/public/index.html index 218fad8..15067a6 100644 --- a/window-manager/public/index.html +++ b/window-manager/public/index.html @@ -3,8 +3,9 @@ Silk GUI + - + @@ -13,6 +14,7 @@

Silk

+
{{title}} _ × @@ -20,21 +22,14 @@

Silk

-
-
+
-
@@ -44,7 +39,8 @@

Silk

Apps

  • - {{title}}
  • + {{title}} +
From d41c6112dfc4666aad0132f0e18d50cce869c1ee Mon Sep 17 00:00:00 2001 From: zodern Date: Wed, 17 Dec 2014 13:08:25 -0600 Subject: [PATCH 15/36] File Explorer can create folders. --- apps/fileExplorer/index.js | 23 ++++++++ apps/fileExplorer/public/css/fileExplorer.css | 55 +++++++++++-------- apps/fileExplorer/public/index.html | 1 + apps/fileExplorer/public/js/fileExplorer.js | 32 +++++++---- 4 files changed, 79 insertions(+), 32 deletions(-) diff --git a/apps/fileExplorer/index.js b/apps/fileExplorer/index.js index d394b21..3850c31 100644 --- a/apps/fileExplorer/index.js +++ b/apps/fileExplorer/index.js @@ -60,5 +60,28 @@ methods.add({ } setupWatcher(path,call_ob,next); return parsePath(path); + }, + "fe/create/folder": function (data, call_ob, send){ + var path = data.path; + var name = data.name; + console.log(path); + console.log(name); + console.log(path + "/" + name); + + if(typeof path == "undefined"){ + path = "/" + } + if(typeof name == "undefined"){ + name = "Untitled"; + } + + fs.mkdir(path + "/" + name,function(err) { + if (err) { + if (err.code == 'EEXIST') send("Fodler already exists"); // ignore the error if the folder already exists + else send(err); // something else went wrong + } + else send(void(0), {"status": "done"}); // successfully created folder + }); + } }) diff --git a/apps/fileExplorer/public/css/fileExplorer.css b/apps/fileExplorer/public/css/fileExplorer.css index 5d4de35..dec9d3a 100644 --- a/apps/fileExplorer/public/css/fileExplorer.css +++ b/apps/fileExplorer/public/css/fileExplorer.css @@ -1,5 +1,6 @@ body { font-family: "Trebuchet MS", Helvetica, sans-serif; + margin-bottom: 50px; } h1 a { color: rgb(128, 128, 128); @@ -12,43 +13,53 @@ h1 a { h1 .current_path i:first-child { display: none; } - h1 a:last-child { -color:rgb(69, 159, 224); + color: rgb(69, 159, 224); } .files .directory { /*background-color: #DDD;*/ } .files .directory i { -color: rgb(234, 204, 78); + color: rgb(234, 204, 78); } -h1 .current_path span{ - display:none; +h1 .current_path span { + display: none; } .files { -list-style: none; + list-style: none; } .files li { -padding: 2px; -margin: 5px; -width: 80px; -display: inline-block; -text-align: center; -vertical-align: top; + padding: 2px; + margin: 5px; + width: 80px; + display: inline-block; + text-align: center; + vertical-align: top; } .files li a { -font-size: 12px; -width: 80px; -word-wrap: break-word; -text-decoration: none; -color: grey; + font-size: 12px; + width: 80px; + word-wrap: break-word; + text-decoration: none; + color: grey; } .files li i { -font-size: 40px; -display: block; + font-size: 40px; + display: block; } .files .file i { -font-size: 30px; -margin-top: 3px; -margin-bottom: 7px; + font-size: 30px; + margin-top: 3px; + margin-bottom: 7px; +} +#newFolder { + background-color: 4EBAEA; + border: none; + color: #FFF; + padding: 10px; + font-size: 14px; + position: fixed; + bottom: 5px; + left: 5px; + cursor: pointer; } \ No newline at end of file diff --git a/apps/fileExplorer/public/index.html b/apps/fileExplorer/public/index.html index c3429e0..8dd0c24 100644 --- a/apps/fileExplorer/public/index.html +++ b/apps/fileExplorer/public/index.html @@ -15,6 +15,7 @@

+ diff --git a/apps/fileExplorer/public/js/fileExplorer.js b/apps/fileExplorer/public/js/fileExplorer.js index f1a1206..e091d63 100644 --- a/apps/fileExplorer/public/js/fileExplorer.js +++ b/apps/fileExplorer/public/js/fileExplorer.js @@ -21,6 +21,16 @@ function file_explorer(elem) { // alert("You're going to have to setup a default view for mimetype: " + $(this).parent().attr("data-mime")); return false; }) + // Create folder + jQuery("#newFolder").click(function (e) { + var name = prompt("Name of Folder"); + methods.listen("fe/create/folder", {path: that.href, name: name}, function (err, result) { + if(err){ + alert(err); + return; + } + }) + }) this.listener = methods.listen("fe/list/path", function (err, list) { if (err) return alert(JSON.stringify(err)); that.processList(that.href, list); @@ -56,7 +66,7 @@ file_explorer.prototype.processList = function (href, list) { var files = []; this.processCD(href); this.files.empty(); - + // add folders and separate files for (var i = 0; i < list.length; i++) { var item = list[i]; @@ -64,24 +74,26 @@ file_explorer.prototype.processList = function (href, list) { var el = jQuery("
  • " + item.name + "
  • "); this.files.append(el); el.addClass("directory"); - + } else { files.push(item); } } - + // add files - for(var i = 0; i < files.length; i++){ + for (var i = 0; i < files.length; i++) { var item = list[i]; - var el = jQuery("
  • " + item.name + "
  • "); - this.files.append(el); - el.addClass("file"); - el.attr("data-mime", item.mime); - + var el = jQuery("
  • " + item.name + "
  • "); + this.files.append(el); + el.addClass("file"); + el.attr("data-mime", item.mime); + } - + } + + jQuery(function ($) { new file_explorer(); }) \ No newline at end of file From 5d06af8c9f7961f6db4be63714350107d827347e Mon Sep 17 00:00:00 2001 From: zodern Date: Thu, 18 Dec 2014 10:55:27 -0600 Subject: [PATCH 16/36] Fixed apps and icons when remote. ws still broken --- window-manager/public/JS/load.js | 11 +++++++++++ window-manager/public/index.html | 1 + window-manager/public/js/remote.js | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 window-manager/public/js/remote.js diff --git a/window-manager/public/JS/load.js b/window-manager/public/JS/load.js index 620496c..2ed9878 100644 --- a/window-manager/public/JS/load.js +++ b/window-manager/public/JS/load.js @@ -1,6 +1,17 @@ $(document).ready(function () { $(".loader span").css("animationIterationCount", "1"); $.ajax("/windows.json").done(function (data) { + + // fix urls if remote + if(remote.isRemote === true){ + console.log("fixing urls"); + for(var i = 0; i < data.length; ++i){ + data[i].url = remote.fixURL(data[i].url); + data[i].icon = remote.fixURL(data[i].icon); + } + console.log(JSON.stringify(data)); + } + initializeManager(data); window.setTimeout(function () { $(".loader").fadeOut(); diff --git a/window-manager/public/index.html b/window-manager/public/index.html index 15067a6..43d8e23 100644 --- a/window-manager/public/index.html +++ b/window-manager/public/index.html @@ -51,6 +51,7 @@

    Apps

    + diff --git a/window-manager/public/js/remote.js b/window-manager/public/js/remote.js new file mode 100644 index 0000000..f7e2c21 --- /dev/null +++ b/window-manager/public/js/remote.js @@ -0,0 +1,26 @@ +var remote = {}; + +(function () { + + // check if url is remote + if(/localhost:3000/.test(location.host) | /0.0.0.0:3000/.test(location.host)){ + // not remote + } else{ + remote.isRemote = true; + } + + // change http://localhost or 0.0.0.0 to remote address + remote.fixURL = function(url){ + if(remote.isRemote === false){ + return url; + } + var http = /^http:/i; + var https = /^https:/i; + + if(/localhost:3000/.test(url) | /0.0.0.0:3000/.test(url)){ + url = location.protocol + "//" + url.replace("http://localhost:3000", location.host); + return url; + } + } + +})() \ No newline at end of file From 31498e4ae04b547f65039fb74bdc18b92c2242a8 Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 19 Dec 2014 14:35:47 -0600 Subject: [PATCH 17/36] web socket uses same port as express app --- apps/fileExplorer/public/js/call.js | 5 ++ core/client_api/window/Window2Server_com.js | 2 +- core/fork_framework/index.js | 2 +- server.js | 58 +++++++++++---------- window-manager/public/JS/call.js | 9 +++- 5 files changed, 45 insertions(+), 31 deletions(-) diff --git a/apps/fileExplorer/public/js/call.js b/apps/fileExplorer/public/js/call.js index 829c6f6..b5ccd84 100644 --- a/apps/fileExplorer/public/js/call.js +++ b/apps/fileExplorer/public/js/call.js @@ -5,6 +5,11 @@ var socket; try { var host = "ws://0.0.0.0:9999"; + + // change host url if remote + if(/localhost:3000/.test(location.host) | /0.0.0.0:3000/.test(location.host)){{ + host = location.protocol + "//" + location.host + ":9999"; + } socket = new WebSocket(host); socket.onopen = function () { diff --git a/core/client_api/window/Window2Server_com.js b/core/client_api/window/Window2Server_com.js index 67c809a..3c5b95d 100644 --- a/core/client_api/window/Window2Server_com.js +++ b/core/client_api/window/Window2Server_com.js @@ -66,7 +66,7 @@ if(typeof module != "undefined" && module.exports){ window.DocumentHost = null; (function(url){ url = /^(http[s]?):\/\/([0-9\.]+|[a-z\-.]+)([?::][0-9]+)?([\/][A-Za-z0-9_\-]+)?(\?.*)?/.exec(url); - var port = (typeof wp != "undefined")?wp:(document.cookie.pwp)?document.cookie.pwp:9999+(parseInt(url[3].substring(1))-3000); + var port = (typeof wp != "undefined")?wp:(document.cookie.pwp)?document.cookie.pwp:3000+(parseInt(url[3].substring(1))-3000); console.log(port); window.DocumentHost = new Server(url[2],port); if(url[4]) diff --git a/core/fork_framework/index.js b/core/fork_framework/index.js index 125b343..bc18318 100644 --- a/core/fork_framework/index.js +++ b/core/fork_framework/index.js @@ -34,7 +34,7 @@ module.exports = function(app,wss){ }); */ app.get("/windows.json",function(req,res,next){ - console.log(windows.clean); + debug(windows.clean); res.type("json").send(windows.clean); }); diff --git a/server.js b/server.js index 06865a8..bd476d8 100644 --- a/server.js +++ b/server.js @@ -1,70 +1,72 @@ +var path = require('path'); +var http = require('http'); +var express = require('express') +var WebSocketServer = require('ws').Server; + global.__root = __dirname; // debug mode -if (global.debug == undefined) { +if (global.debug === undefined) { global.debug = function (message) { console.log(message); } } -var path = require('path'); -var WebSocketServer = require('ws').Server; -var wss = new WebSocketServer({ - port: 9999 -}); - - -debug("web socket is at: " + wss.options.host + ":" + wss.options.port); - -wss.on('connection', function (ws) { - ws.on('message', function (message) { - - debug("websocket message: " + message); - - - methods.call(ws, message); - }); -}); - -var express = require('express') var app = express() app.get('/', function (req, res) { res.sendFile(__root + "/window-manager/public/index.html"); }); - - // static files for client app.use(express.static(__dirname + '/window-manager/public')); app.get(/^\/bc\//, require(__root + "/core/bower_static.js")); app.get("/api.js", require(__root + "/core/client_api.js")); -var windows = require(__root + "/core/fork_framework")(app, wss); - var server = app.listen(3000, function () { - var add = server.address(); + + // display url in box var message = 'Silk at http://' + add.address + ":" + add.port; var length = message.length; var prespace = " "; - // form box var box = ""; + for (var i = 0; i < length + 10; ++i) { box += "="; } + var space = " "; var empty = ""; + for (var i = 0; i < length + 10 - 2; ++i) { empty += " "; } + console.log(prespace + box); console.log(prespace + "|" + empty + "|"); console.log(prespace + "|" + space + message + space + "|"); console.log(prespace + "|" + empty + "|"); console.log(prespace + box); console.log(""); +}) + +var wss = new WebSocketServer({ + server: server, + path: '/websocket' +}); - // console.log('Silk at http://%s:%s', add.address, add.port) +debug("web socket is at: " + wss.options.host + wss.options.path); +wss.on('connection', function (ws) { + console.log("connected"); + ws.on('message', function (message) { + + debug("websocket message: " + message); + + + methods.call(ws, message); + }); }); + +var windows = require(__root + "/core/fork_framework")(app, wss); \ No newline at end of file diff --git a/window-manager/public/JS/call.js b/window-manager/public/JS/call.js index 6312e2c..2010111 100644 --- a/window-manager/public/JS/call.js +++ b/window-manager/public/JS/call.js @@ -4,7 +4,14 @@ var socket; (function () { try { - var host = "ws://0.0.0.0:9999"; + var host = "ws://0.0.0.0:3000/websocket"; + + // change host url if remote + if(/localhost:3000/.test(location.host) | /0.0.0.0:3000/.test(location.host)){ + } else{ + host = "ws://" + location.host + "/websocket"; + } + console.log(host); socket = new WebSocket(host); socket.onopen = function () { From 75472b19ef18121e524bc747579aa965861e2bd0 Mon Sep 17 00:00:00 2001 From: zodern Date: Sat, 20 Dec 2014 15:26:47 -0600 Subject: [PATCH 18/36] app-defaults creates settings file if missing. Also the settings file will be ignored by git. --- .gitignore | 2 ++ apps/app-defaults/index.js | 5 ++++- apps/app-defaults/settings/app-defaults.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 90eeec3..26a0422 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ roadmap *.*~ .brackets.json + +apps/app-defaults/settings/app-defaults.json diff --git a/apps/app-defaults/index.js b/apps/app-defaults/index.js index 1b6e4ab..ba4306a 100644 --- a/apps/app-defaults/index.js +++ b/apps/app-defaults/index.js @@ -19,7 +19,10 @@ function loadDefaults() { fs.exists(fileName, function (exists) { // TODO create file if it doesn't exist - if (!exists) return; + if (!exists){ + fs.writeFileSync(djson, '{}') + + } fs.stat(fileName, function (err, stats) { if (err) return console.log(err); diff --git a/apps/app-defaults/settings/app-defaults.json b/apps/app-defaults/settings/app-defaults.json index 4b50749..9e26dfe 100644 --- a/apps/app-defaults/settings/app-defaults.json +++ b/apps/app-defaults/settings/app-defaults.json @@ -1 +1 @@ -{"text/plain":{"default":"","available":[]},"*":{"default":"","available":[]},"undefined":{"default":"Text Editor","available":[]},"text/html":{"default":"Text Editor","available":[]}} \ No newline at end of file +{} \ No newline at end of file From bb9cc11f10905eb0fe56dd28f20b53aeb1faa93c Mon Sep 17 00:00:00 2001 From: zodern Date: Sat, 27 Dec 2014 15:51:25 -0600 Subject: [PATCH 19/36] fixed window order --- window-manager/public/js/windowManager.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/window-manager/public/js/windowManager.js b/window-manager/public/js/windowManager.js index b82c0aa..19c8ff3 100644 --- a/window-manager/public/js/windowManager.js +++ b/window-manager/public/js/windowManager.js @@ -33,15 +33,19 @@ function initializeManager(_windows) { buildChannel: CreateChannel, minimize: function (index) { windows[index].minimized = true; - windowOrder.pop(index); + var position = windowOrder.indexOf(index); + windowOrder.splice(position, 1); }, close: function (index) { // reset url var app = windows[index]; app.url = app.url.split("?")[0]; + app.running = false; app.minimized = true; - windowOrder.pop(index); + + var position = windowOrder.indexOf(index); + windowOrder.splice(position, 1); updateOrder(); } } @@ -58,10 +62,11 @@ function initializeManager(_windows) { app.running = true; // move to top if behind - if (app.minimized == false) { - if (windowOrder.indexOf(index) > 0) { + if (app.minimized === false) { + if (windowOrder.indexOf(index) > -1) { // move to top - windowOrder.pop(index); + var position = windowOrder.indexOf(index); + windowOrder.splice(position, 1); windowOrder.unshift(index); updateOrder(); return @@ -73,7 +78,8 @@ function initializeManager(_windows) { windowOrder.unshift(index); } if (app.minimized === true) { - windowOrder.pop(index); + var position = windowOrder.indexOf(index); + windowOrder.splice(position, 1); } updateOrder(); }, @@ -155,7 +161,7 @@ function initializeManager(_windows) { win.running = true; win.minimized = false; windows.push(win); - windowOrder.unshift(index); + windowOrder.unshift(windows.length - 1); updateOrder(); } else { From fe27adb9964f7cd57dfcb609006dcea2fff5aac0 Mon Sep 17 00:00:00 2001 From: zodern Date: Wed, 31 Dec 2014 11:47:08 -0600 Subject: [PATCH 20/36] fixed opening windows when opening file --- window-manager/public/js/channel.js | 53 ++++++++++------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/window-manager/public/js/channel.js b/window-manager/public/js/channel.js index 2844670..1f3343e 100644 --- a/window-manager/public/js/channel.js +++ b/window-manager/public/js/channel.js @@ -29,43 +29,26 @@ function CreateChannel(index) { methods.call("Silk/appDefaults", params.mime, function (err, data) { function openWindow(title) { // find window index - for (var i = 0; i < windows.length; ++i) { - - if (windows[i].title === title) { - - // start the app - if (windows[i].running == false) { - var url = windows[i].url; - url = url.split("?")[0]; - windows[i].url = url + "?file=" + encodeURIComponent(params.path); - windows[i].running = true; - windows[i].minimized = false; - windowOrder.unshift(windows[i].title); - - } else { - - channels[windows[i].title].notify({ - method: "fileToOpen", - params: { - path: params.path, - mime: params.mime - } - }); - - if (windows[i].minimized == true) { - windows[i].minimized = false; - windowOrder.unshift(windows[i].title); - } else { - // move position to top - windowOrder.pop(windows[i].title); - windowOrder.unshift(windows[i].title); - } - - } - + for (var i = 0; i < apps.length; ++i) { + + //TODO correctly handle apps that have multipleWindows : false + if (apps[i].title === title) { + // clone object + var win = JSON.parse(JSON.stringify(apps[i])); + + // open the window + console.log("win.title = " + win.title); + win.running = true; + win.minimized = false; + windows.push(win); + windowOrder.unshift(windows.length - 1); updateOrder(); - break; + var url = win.url; + url = url.split("?")[0]; + win.url = url + "?file=" + encodeURIComponent(params.path); + + return; } } } From 2cf65f36806f05ff670d1031166cf84d7716fae2 Mon Sep 17 00:00:00 2001 From: zodern Date: Wed, 31 Dec 2014 12:26:15 -0600 Subject: [PATCH 21/36] improved app look of menu, task bar --- window-manager/public/css/main.css | 50 ++++++++++++++++------- window-manager/public/index.html | 4 +- window-manager/public/js/windowManager.js | 46 ++++++++++----------- 3 files changed, 61 insertions(+), 39 deletions(-) diff --git a/window-manager/public/css/main.css b/window-manager/public/css/main.css index c931d34..880755c 100644 --- a/window-manager/public/css/main.css +++ b/window-manager/public/css/main.css @@ -63,10 +63,11 @@ bottom: 0px; left: 0px; width: 100%; height: 50px; -background-color: rgba(69, 159, 224, 0.81); +background-color: rgba(255, 255, 255, 0.15); opacity: 1; transition: .3s opacity; box-shadow: 0px 3px 5px #000; +border-top: 3px solid #FFF; } #taskbar *{ -webkit-user-select: none; @@ -82,7 +83,7 @@ box-shadow: 0px 3px 5px #000; cursor: pointer; } #taskbar .app:hover { - background-color: rgba(0, 0, 0, 0.57); + background-color: rgba(255, 255, 255, 0.3); } #taskbar .app img { height: 40px; @@ -154,7 +155,7 @@ box-shadow: 0px 3px 5px #000; -webkit-transition: .2s background-color; } .window .title .close:hover { - background-color: rgba(16, 67, 103, 0.32); +background-color: #B01717; } #desktop .window iframe { background-color: white; @@ -234,20 +235,29 @@ box-sizing: border-box; position: absolute; bottom: 0px; width: 100%; -background-color: rgba(0, 0, 0, 0.6); +background-color: rgba(255, 255, 255, 0.8); height: auto; -color: #FFF; +color: #3A3939; display: none; -z-index: 500; +z-index: 201; box-sizing: border-box; -padding: 0px 20px 20px 20px; - -webkit-user-select: none; +padding: 0px; + -webkit-user-select: one; + opacity: 0; + margin-bottom: 50px; } #menu h1 { font-weight: 300; text-align: left; font-size: 30px; - cursor: default; +cursor: default; +background-color: #459FE0; + color: white; + width: 100%; + padding: 10px; + padding-left: 50px; + margin-top: 0px; + box-sizing: border-box; } #menu ul { padding-left: 0px; @@ -259,26 +269,30 @@ vertical-align: middle; width: 175px; cursor: pointer; box-sizing: border-box; -color: rgba(255, 255, 255, 0.67); +color: #3A3939; +margin-bottom:5px; +transition: .3s all; + padding: 3px; } #menu li img { vertical-align: middle; height: 30px; + margin-right: 5px; + transition: .3s all; } #menu li:hover { - background-color: rgba(0, 0, 0, 0.6); - color:white; +box-shadow: 0px 3px 0px #459FE0; } #taskbar .app.menu { border-top: 0px; -background-color: rgba(0, 0, 0, 0.2); +background-color: #459FE0; vertical-align: top; padding-top: 3px; margin-right: -4px; } #taskbar .app.menu:hover{ - background-color: rgba(0,0,0,0.57); + background-color: #1E5C88; } /* tooltips */ @@ -311,3 +325,11 @@ margin-left: 0px; transition-delay: 300ms; } + +h1 img { +height: 32; +position: absolute; +right: 10px; +margin-top: 3px; + cursor: pointer; +} diff --git a/window-manager/public/index.html b/window-manager/public/index.html index 43d8e23..d049392 100644 --- a/window-manager/public/index.html +++ b/window-manager/public/index.html @@ -28,7 +28,7 @@

    Silk

    -
    +
    @@ -36,7 +36,7 @@

    Silk