3 $.getJSON( System.launchpath[_pid] + "/kish_config.json", (data) => {
4 let props = ["background","font-family","font-size","font-weight","color","text-align","text-shadow","background-size","background-attachment","backdrop-filter"];
5 KWS.resize(_pid, data.width || "", data.height || "");
6 if( data.styles ) for( let i in data.styles ){
7 if( props.includes(i) ){
8 S.dom( _pid, "#kish-wrapper" ).css( i, data.styles[i] );
9 if( i == "backdrop-filter" ) S.dom( _pid ).css( i, data.styles[i] );
14 let kishHistory = [], kishCur = -1;
16 const Kish = new function(){
19 this.cat = function(arg){
20 let path = arg.split(" ", 1), _r = "";
21 if( S.userarea[path] ) _r = "<pre><code>" + JSON.stringify( System.userarea[path].data + "</code></pre>", null, 4 );
22 else _r = "File not found: " + path;
26 this.clear = function(arg){
27 let args = arg.split(" ");
28 let num = Number(args[0]);
29 if( !num ) S.dom(_pid, "#kish-out").html("");
33 this.echo = function(arg){
35 if( typeof arg == "object" ) _r = JSON.stringify(arg, null, 4);
39 this.eval = (arg) => { return eval(arg) }
41 this.exec = function(arg){
42 let cmd = arg.split(" ", 1);
44 kishHistory.unshift( arg );
46 if( arg.indexOf(" ") != -1 ) args = arg.substring( arg.indexOf(" ") + 1 );
47 S.dom(_pid, "#kish-out").append( "<div class='kish-item'><i class='fa fa-dollar-sign'></i><span class='kish-highlight'>" + cmd + "</span>" + args + "</div>" );
49 S.dom(_pid, "#kish-out").append( "<div class='kish-item'><i class='fa fa-angle-double-right'></i> kishコマンドは存在しません: " + cmd + "</div>" );
52 let exec = "Kish." + cmd + "('" + args + "')";
55 if( typeof rtn == "object" ) rtn = JSON.stringify(rtn, null, 4);
56 if( rtn ) S.dom(_pid, "#kish-out").append( "<div class='kish-item'><span class='kish-from'>" +cmd+ "</span><i class='fa fa-angle-double-right'></i> " + rtn + "</div>" );
59 S.dom(_pid, "#kish-out").append( "<div class='kish-item'><span class='kish-from'>" +cmd+ "</span><i class='fa fa-exclamation-triangle'></i> " + error + "</div>" );
64 this.exit = function(){
68 this.install = function(arg){
69 let args = arg.split(" ");
70 let iobj = new Object();
71 $.getJSON( args[0] + "define.json" , function( data ){
74 iobj.name = data.name;
75 iobj.icon = args[0] + data.icon;
76 System.installed.push(iobj);
77 localStorage.setItem("kit-installed", JSON.stringify(System.installed));
78 Kish.print("An app was installed from " + args[0], "install");
79 $.getJSON("config/apps.json", System.initLauncher);
82 Kish.print("Faild to install an app from " + args[0], "install");
84 return "Start installing...";
87 this.kish = function(){
91 this.launch = function(arg){
92 args = arg.split(" ");
93 System.launchpath[processID] = System.appdir + args[0];
94 $.getJSON( "./app/" + args[0] + "/define.json", appData ).fail( function() {
95 System.launchpath[processID] = args[0];
96 $.getJSON( args[0] + "/define.json", appData ).fail( function() {
97 Kish.print("Faild to launch an App: " + args[0], "launch");
102 this.load = function(arg){
105 this.ls = function(){
106 let _r = "<i>path ~</i><br>";
107 for( let i in System.userarea ){
108 _r += "- " + i + "<br>";
113 this.open = function(arg){
114 if( !arg ) return "ファイル名を指定してください";
115 else System.open(arg);
118 this.print = function(arg, from){
121 _from = "<span class='kish-from'>" +from+ "</span><i class='fa fa-angle-double-right'></i> "
123 S.dom(_pid, "#kish-out").append( "<div class='kish-item'>" + _from + arg + "</div>" );
126 this.uninstall = function(arg){
128 for( let i in System.installed ){
129 if( System.installed[i].path == arg ){
130 System.installed.splice(i, 1);
134 localStorage.setItem("kit-installed", JSON.stringify(System.installed));
135 $.getJSON("config/apps.json", System.initLauncher);
136 return count + "app(s) was uninstalled from kit.";
139 this.ver = function(){
140 return System.version;
144 $.getJSON( System.launchpath[_pid] + "/kishrc.json", (data) => {
145 for( let i of data.rc ) Kish.exec(i);
148 S.dom(_pid, "#kish-input").on( "keypress keyup keydown", (e) => {
149 let input = S.dom(_pid, "#kish-input").val().split(" ");
151 if( typeof Kish[ input[0] ] == "function" ){
152 S.dom(_pid, "#kish-curcmd").show().text( input[0] );
154 else S.dom(_pid, "#kish-curcmd").hide();
156 if( e.keyCode == 13 && S.dom(_pid, "#kish-input").val() ){
157 Kish.exec( S.dom(_pid, "#kish-input").val() );
158 S.dom(_pid, "#kish-input").val("");
162 S.dom(_pid, "#kish-input").on( "keydown", (e) => {
163 if( e.keyCode == 38 ){
164 if( kishCur < kishHistory.length - 1 ){
166 S.dom(_pid, "#kish-input").val( kishHistory[kishCur] );
169 else if( e.keyCode == 40 ){
172 S.dom(_pid, "#kish-input").val( kishHistory[kishCur] );
174 else if( kishCur == 0 ){
176 S.dom(_pid, "#kish-input").val( "" );
181 KWS.changeWindowTitle(_pid, "(kish)"+ System.username);
182 App.changeWindowTitle(_pid, "(kish)"+ System.username);