Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "tmux.js", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/tadeuzagallo/tmux.js", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -11,3 +11,3 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"tmux.js":[function(require,module,exports){ | ||
Tmux.init = function (terminal, fs) { | ||
Tmux.init = function (terminal) { | ||
Terminal = terminal; | ||
@@ -26,3 +26,3 @@ | ||
var statusList = document.createElement('ul'); | ||
this.rootTab = Tmux.createTabLabel(true).tab; | ||
this.rootTab = Tmux.createTabLabel(true, 0).tab; | ||
statusbar.appendChild(statusList); | ||
@@ -63,2 +63,14 @@ Terminal._statusbar = statusList; | ||
break; | ||
case 81: // Q | ||
Tmux.removeWindow(windows[index]); | ||
windows.splice(index, 1); | ||
if (windows.length) { | ||
index--; | ||
if (index < 0) { | ||
index = 0; | ||
} | ||
Tmux.use(windows[index]); | ||
} | ||
} | ||
@@ -71,3 +83,3 @@ | ||
waiting = true; | ||
} else { | ||
} else if (_onkeydown) { | ||
_onkeydown(event); | ||
@@ -87,3 +99,3 @@ } | ||
Tmux.createTabLabel = function (indexOnly) { | ||
Tmux.createTabLabel = function (indexOnly, id) { | ||
var tab = document.createElement('li'); | ||
@@ -96,3 +108,3 @@ | ||
index.className = 'index'; | ||
index.innerText = windows.length; | ||
index.innerText = id; | ||
@@ -119,12 +131,20 @@ data.appendChild(index); | ||
var id = 1; | ||
for (var i = 0, l = windows.length; i < l; i++) { | ||
if (windows[i].id !== id) { | ||
break; | ||
} else { | ||
id++; | ||
} | ||
} | ||
var window = { | ||
id: windows.count, | ||
window: w | ||
id: id, | ||
window: w, | ||
tab: this.createTabLabel(false, id) | ||
}; | ||
index = windows.length; | ||
index = i; | ||
windows.push(window); | ||
window.tab = this.createTabLabel(); | ||
this.use(window); | ||
@@ -170,4 +190,8 @@ this.update(); | ||
Tmux.removeWindow = function (window) { | ||
Terminal._statusbar.removeChild(window.tab.tab); | ||
}; | ||
module.exports = Tmux; | ||
},{}]},{},["N8OV1Y"]) |
@@ -1,2 +0,2 @@ | ||
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"tmux.js":[function(require,module,exports){module.exports=require("N8OV1Y")},{}],N8OV1Y:[function(require,module,exports){"use strict";var Tmux={};var FS=require("zsh.js/lib/fs");var Terminal;var windows=[];var index=0;Tmux.init=function(terminal,fs){Terminal=terminal;Terminal.container.innerHTML="";Terminal.statusbar.innerHTML="";windows=[];Terminal._container=Terminal.container;Terminal.container=null;var statusbar=Terminal.statusbar;Terminal.statusbar=null;var statusList=document.createElement("ul");this.rootTab=Tmux.createTabLabel(true).tab;statusbar.appendChild(statusList);Terminal._statusbar=statusList;this.newWindow();var _onkeydown=window.onkeydown||function(){};var waiting=false;window.onkeydown=function(event){if(waiting){waiting=false;switch(event.keyCode){case 67:Tmux.newWindow();break;case 37:case 72:index--;if(index<0){index=windows.length-1}Tmux.use(windows[index]);break;case 39:case 76:index++;if(index>=windows.length){index=0}Tmux.use(windows[index]);break}return}if(event.keyCode===66&&event.ctrlKey){waiting=true}else{_onkeydown(event)}};Object.defineProperty(window,"onkeydown",{set:function(value){_onkeydown=value},get:function(){return _onkeydown}})};Tmux.createTabLabel=function(indexOnly){var tab=document.createElement("li");var data=document.createElement("span");data.className="data";var index=document.createElement("span");index.className="index";index.innerText=windows.length;data.appendChild(index);tab.appendChild(data);var ps=null;if(!indexOnly){ps=document.createElement("span");ps.className="ps";data.appendChild(ps)}return{tab:tab,ps:ps}};Tmux.newWindow=function(){var w=document.createElement("div");w.className="tmux";var window={id:windows.count,window:w};index=windows.length;windows.push(window);window.tab=this.createTabLabel();this.use(window);this.update()};var using=null;Tmux.use=function(window){if(using){using.tab.tab.className=false;using.currentPath=FS.currentPath}Terminal._container.innerHTML="";Terminal._container.appendChild(window.window);Terminal.container=window.window;Terminal.statusbar=window.tab.ps;window.tab.tab.className="active";if(window.currentPath){FS.currentPath=window.currentPath}Terminal.update();using=window};Tmux.update=function(){windows=windows.sort(function(a,b){return a.id-b.id});Terminal._statusbar.innerHTML="";Terminal._statusbar.appendChild(this.rootTab);windows.forEach(function(window){Terminal._statusbar.appendChild(window.tab.tab)})};module.exports=Tmux},{}]},{},["N8OV1Y"]); | ||
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({"tmux.js":[function(require,module,exports){module.exports=require("N8OV1Y")},{}],N8OV1Y:[function(require,module,exports){"use strict";var Tmux={};var FS=require("zsh.js/lib/fs");var Terminal;var windows=[];var index=0;Tmux.init=function(terminal){Terminal=terminal;Terminal.container.innerHTML="";Terminal.statusbar.innerHTML="";windows=[];Terminal._container=Terminal.container;Terminal.container=null;var statusbar=Terminal.statusbar;Terminal.statusbar=null;var statusList=document.createElement("ul");this.rootTab=Tmux.createTabLabel(true,0).tab;statusbar.appendChild(statusList);Terminal._statusbar=statusList;this.newWindow();var _onkeydown=window.onkeydown||function(){};var waiting=false;window.onkeydown=function(event){if(waiting){waiting=false;switch(event.keyCode){case 67:Tmux.newWindow();break;case 37:case 72:index--;if(index<0){index=windows.length-1}Tmux.use(windows[index]);break;case 39:case 76:index++;if(index>=windows.length){index=0}Tmux.use(windows[index]);break;case 81:Tmux.removeWindow(windows[index]);windows.splice(index,1);if(windows.length){index--;if(index<0){index=0}Tmux.use(windows[index])}}return}if(event.keyCode===66&&event.ctrlKey){waiting=true}else if(_onkeydown){_onkeydown(event)}};Object.defineProperty(window,"onkeydown",{set:function(value){_onkeydown=value},get:function(){return _onkeydown}})};Tmux.createTabLabel=function(indexOnly,id){var tab=document.createElement("li");var data=document.createElement("span");data.className="data";var index=document.createElement("span");index.className="index";index.innerText=id;data.appendChild(index);tab.appendChild(data);var ps=null;if(!indexOnly){ps=document.createElement("span");ps.className="ps";data.appendChild(ps)}return{tab:tab,ps:ps}};Tmux.newWindow=function(){var w=document.createElement("div");w.className="tmux";var id=1;for(var i=0,l=windows.length;i<l;i++){if(windows[i].id!==id){break}else{id++}}var window={id:id,window:w,tab:this.createTabLabel(false,id)};index=i;windows.push(window);this.use(window);this.update()};var using=null;Tmux.use=function(window){if(using){using.tab.tab.className=false;using.currentPath=FS.currentPath}Terminal._container.innerHTML="";Terminal._container.appendChild(window.window);Terminal.container=window.window;Terminal.statusbar=window.tab.ps;window.tab.tab.className="active";if(window.currentPath){FS.currentPath=window.currentPath}Terminal.update();using=window};Tmux.update=function(){windows=windows.sort(function(a,b){return a.id-b.id});Terminal._statusbar.innerHTML="";Terminal._statusbar.appendChild(this.rootTab);windows.forEach(function(window){Terminal._statusbar.appendChild(window.tab.tab)})};Tmux.removeWindow=function(window){Terminal._statusbar.removeChild(window.tab.tab)};module.exports=Tmux},{}]},{},["N8OV1Y"]); | ||
//# sourceMappingURL=dist/tmux.min.map |
{ | ||
"name": "tmux.js", | ||
"description": "A web version of my terminal", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"keywords": [ | ||
@@ -25,5 +25,5 @@ "terminal", | ||
"browserify": "^3.46.0", | ||
"uglifyjs": "^2.3.6", | ||
"uglify-js": "^2.4.16", | ||
"zsh.js": "*" | ||
} | ||
} |
44
tmux.js
@@ -8,3 +8,3 @@ 'use strict'; | ||
Tmux.init = function (terminal, fs) { | ||
Tmux.init = function (terminal) { | ||
Terminal = terminal; | ||
@@ -23,3 +23,3 @@ | ||
var statusList = document.createElement('ul'); | ||
this.rootTab = Tmux.createTabLabel(true).tab; | ||
this.rootTab = Tmux.createTabLabel(true, 0).tab; | ||
statusbar.appendChild(statusList); | ||
@@ -60,2 +60,14 @@ Terminal._statusbar = statusList; | ||
break; | ||
case 81: // Q | ||
Tmux.removeWindow(windows[index]); | ||
windows.splice(index, 1); | ||
if (windows.length) { | ||
index--; | ||
if (index < 0) { | ||
index = 0; | ||
} | ||
Tmux.use(windows[index]); | ||
} | ||
} | ||
@@ -68,3 +80,3 @@ | ||
waiting = true; | ||
} else { | ||
} else if (_onkeydown) { | ||
_onkeydown(event); | ||
@@ -84,3 +96,3 @@ } | ||
Tmux.createTabLabel = function (indexOnly) { | ||
Tmux.createTabLabel = function (indexOnly, id) { | ||
var tab = document.createElement('li'); | ||
@@ -93,3 +105,3 @@ | ||
index.className = 'index'; | ||
index.innerText = windows.length; | ||
index.innerText = id; | ||
@@ -116,12 +128,20 @@ data.appendChild(index); | ||
var id = 1; | ||
for (var i = 0, l = windows.length; i < l; i++) { | ||
if (windows[i].id !== id) { | ||
break; | ||
} else { | ||
id++; | ||
} | ||
} | ||
var window = { | ||
id: windows.count, | ||
window: w | ||
id: id, | ||
window: w, | ||
tab: this.createTabLabel(false, id) | ||
}; | ||
index = windows.length; | ||
index = i; | ||
windows.push(window); | ||
window.tab = this.createTabLabel(); | ||
this.use(window); | ||
@@ -167,2 +187,6 @@ this.update(); | ||
Tmux.removeWindow = function (window) { | ||
Terminal._statusbar.removeChild(window.tab.tab); | ||
}; | ||
module.exports = Tmux; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18307
340