+"use strict";
+
// _ _ _
// | | _(_) |_
// | |/ / | __|
// | <| | |_
// |_|\_\_|\__|
//
-// THIS IS THE KIT KERNEL AND KIT WINDOW SYSTEM
+// THIS IS THE KIT KERNEL, KIT APPS FRAMEWORK AND KIT WINDOW SYSTEM
// http://web.kitit.ml/
// https://github.com/mtsgi/kit
-"use strict";
$( document ).ready( kit );
function kit() {
S = System;
- if( !localStorage.getItem( "kit-pid" ) ) processID = 0;
- else processID = localStorage.getItem( "kit-pid" );
+ if( localStorage.getItem( "kit-pid" ) ) pid = localStorage.getItem( "kit-pid" );
if( !localStorage.getItem( "kit-username" ) ) localStorage.setItem( "kit-username", "ユーザー" );
$( "#kit-header-username" ).text( localStorage.getItem( "kit-username" ) );
if( localStorage.getItem( "kit-lock" ) == null ) localStorage.setItem( "kit-lock", "false" );
if( System.bootopt.get("safe") ) $( "#kit-wallpaper" ).css( "background","#404040" );
- else if( localStorage.getItem( "kit-wallpaper" ) ) $( "#kit-wallpaper" ).css( "background", localStorage.getItem( "kit-wallpaper" ) ).css( "background-size", "cover" );
+ else if( localStorage.getItem( "kit-wallpaper" ) ) $( "#kit-wallpaper" ).css( "background", localStorage.getItem( "kit-wallpaper" ) ).css( "background-size", "cover" ).css( "background-position", "center" );
if( !localStorage.getItem( "kit-default-browser" ) ) localStorage.setItem( "kit-default-browser", "browser" );
if( !localStorage.getItem( "kit-appdir" ) ) localStorage.setItem( "kit-appdir", "./app/" );
S.appdir = localStorage.getItem( "kit-appdir" );
+ if( localStorage.getItem( "kit-installed" ) ) System.installed = JSON.parse( localStorage.getItem( "kit-installed" ) );
+
if( localStorage["kit-userarea"] ) System.userarea = JSON.parse(localStorage["kit-userarea"]);
if( localStorage["kit-recycle"] ) System.recycle = JSON.parse(localStorage["kit-recycle"]);
if( System.bootopt.get("safe") ) clockmove = setInterval( System.clock, 1000 );
else clockmove = setInterval( System.clock, 10 );
- Notification.push( "kitへようこそ", localStorage["kit-username"] + "さん、こんにちは。", "system" );
- //スタートアップ
+ if ( localStorage.getItem("kit-shutted-down") == "false" ) {
+ Notification.push("お知らせ", "kitは前回終了時、正しくシャットダウンされませんでした。", "system");
+ }
+ localStorage.setItem("kit-shutted-down", false);
+
+ Notification.push("kitへようこそ", localStorage["kit-username"] + "さん、こんにちは。", "system", null, null, 'documents/icon.png', [
+ {
+ label: 'kitについて',
+ func: () => launch( 'settings', {'view': 'about'} )
+ }
+ ]);
+
if( localStorage.getItem( "kit-startup" ) == undefined ) {
localStorage.setItem( "kit-startup", new Array( "welcome" ) );
}
System.startup = localStorage.getItem( "kit-startup" ).split( "," );
if( System.bootopt.get("safe") ){
Notification.push( "セーフブート", "現在、kitをセーフモードで起動しています。", "system" );
- System.alert( "セーフブート", "現在、kitをセーフモードで起動しています。<br><a class='kit-hyperlink' onclick='location.href=\"index.html\";'>通常モードで再起動</a>", "system" );
+ System.alert( "セーフブート", "現在、kitをセーフモードで起動しています。<br><a class='kit-hyperlink' onclick='System.reboot()'>通常モードで再起動</a>", "system" );
}
else for( let i of System.startup ) if( i != "" ) launch( i );
$( "#kit-tasks" ).html( $( "#tasks" ).html() ).fadeIn( 300 ).css( "z-index", "9997" );
}
} );
- //デスクトップアイコン
+ $.getJSON("system/testload.json").fail( () => {
+ $('#body').append(`<div id='wcors' class="window windowactive" style="top: 70px; left: 50px; width: calc(100% - 100px)">
+ <div class="wt">問題が発生しました</div>
+ <div class="winc">JSONデータ読み込みに失敗しました。<br>
+ クロスオリジン制約によりkitアプリケーションの動作が制限されている場合があります。<br>
+ 詳細は<a class="kit-hyperlink" onclick="location.href = 'https://mtsgi.github.io/kitdocs/#/cors'">こちらの記事</a>をご確認ください。</div>
+ </div>`);
+ $('<kit-button-alt class="kit-block kit-text-c m">閉じる</kit-button-alt>').appendTo('#wcors .winc').on('click', ()=>{
+ $('#wcors').remove();
+ })
+ });
+
$.getJSON("config/desktop.json", (data) => {
for( let i in data ){
$(".desktop-icons").append("<div class='desktop-icon' data-launch='" + i + "'><img src='" + data[i].icon + "'>" + data[i].name + "</div>");
launch( $(this).attr("data-launch") );
});
}).fail( function() {
- Notification.push( "読み込みに失敗", "デスクトップ(config/desktop.json)の読み込みに失敗しました。", system );
+ Notification.push( "読み込みに失敗", "デスクトップ(config/desktop.json)の読み込みに失敗しました。", "system" );
} );
- //ランチャー
+
$.getJSON("config/apps.json", System.initLauncher).fail( function() {
- Notification.push( "ランチャー初期化失敗", "アプリケーション一覧(config/apps.json)の読み込みに失敗しました。", system );
+ Notification.push( "ランチャー初期化失敗", "アプリケーション一覧(config/apps.json)の読み込みに失敗しました。", "system" );
} );
$( "#kit-tasks" ).delegate( ".task", "click", function() {
System.close( this.id.slice( 1 ) );
$( this ).hide();
} );
- //通知バー
+
$( "#footer-noti" ).click( function() {
$( "#last-notification" ).hide( "drop", {direction: "right"}, 300 );
if( $( "#notifications" ).is( ":visible" ) ) {
}
else Notification.goodnight = false;
});
- //電源管理
+
$( ".power-button" ).click( function() {
$( "#notifications" ).hide( "drop", {direction: "right"}, 300 );
$( "#last-notification" ).hide( "drop", {direction: "right"}, 300 );
- $( "section, header, footer, #kit-wallpaper, .dropdown" ).css( "filter", "blur(5px)" );
- $( "#kit-power" ).fadeIn( 300 );
+ $( "#kit-wallpaper" ).css( "filter", "blur(5px)" );
+ $( "footer, header, #launcher, #task-ctx, #kit-sightre, .dropdown, #desktop-" + currentDesktop ).hide();
+ $( "#kit-power" ).show();
} );
$( "#kit-power-back" ).click( function() {
$( "section, header, footer, #kit-wallpaper, .dropdown" ).css( "filter", "none" );
- $( "#kit-power" ).fadeOut( 300 );
+ $( "footer, header, #desktop-" + currentDesktop ).show();
+ $( "#kit-power" ).hide();
} );
$( "#kit-power-shutdown" ).click( function() {
System.shutdown();
System.reboot();
} );
$( "#kit-power-suspend" ).click( function() {
+ location.reload();
$( "section, header, footer, #kit-wallpaper" ).css( "filter", "none" );
$( "#kit-power" ).fadeOut( 300 );
System.alert("サスペンド機能", "サスペンド機能はこのバージョンのkitではサポートされていません。");
$( "#kit-power-lock" ).click( function() {
System.lock();
} );
- $( "#lock-password" ).keypress( function( e ) {
+ $( "#lock-password" ).on( 'keypress', function( e ) {
if( e.which == 13 ) $( "#lock-unl" ).click();
} );
- $( "#lock-unl" ).click( function() {
+ $( "#lock-unl" ).on( 'click', function() {
if( !localStorage.getItem( "kit-password" ) || $( "#lock-password" ).val() == localStorage.getItem( "kit-password" ) ) {
$( "header, footer" ).show();
$( "section, header, footer, #kit-wallpaper" ).css( "filter", "none" );
}, function() {
$( "#lock-unl span" ).removeClass( "fa-lock-open" ).addClass( "fa-lock" );
} );
- //ランチャー起動
+
$( "#launch" ).click( function() {
$( "#notifications" ).hide( "drop", {direction: "right"}, 300 );
if( $( "#launcher" ).is( ":visible" ) ) {
}
else {
$( "#kit-wallpaper" ).css( "filter", "blur(5px)" )
- $( "section" ).hide();
+ $( "section, #task-ctx" ).hide();
$( "#launcher" ).show();
}
} );
- //検索バー
- $( "#milp" ).val( "" ).on( "focus", function() {
- $( "#kit-milp" ).show();
- } ).on( "blur", function() {
- $( "#kit-milp" ).fadeOut( 200 );
- } ).on( 'keydown keyup keypress change', function() {
- $( "#kit-milp-text" ).text( $( this ).val() );
- } ).keypress( function( e ) {
- if( e.which == 13 ) $( "#kit-milp-launch" ).click();
- } );
- $( "#kit-milp-launch" ).click( function() {
- if( $("#milp").val() == "kit" ){
- System.alert("", "<div style='text-align:left;'> _ _ _ <br>| | _(_) |_ <br>| |/ / | __|<br>| 〈| | |_ <br>|_|\_ \ _\__|</div><hr>", S.version);
- return;
+ //Sightre
+ $('#kit-header-sightre').on('click', () => {
+ if($('#kit-sightre').is( ":visible" )) {
+ $('#kit-sightre').fadeOut(300);
}
- let _app = $( "#milp" ).val().split(",")[0];
- let _args = null;
- try {
- if( $( "#milp" ).val().split(",")[1] ){
- _args = JSON.parse( $( "#milp" ).val().split(",").slice(1).join() );
+ else {
+ $('#kit-sightre-results').html('');
+ $('#kit-sightre').show();
+ $('#kit-sightre-form').val('').focus();
+ }
+ });
+ let sightrePrevWord = '';
+ $('#kit-sightre-form').on('keypress', (e) => {
+ let _word = $('#kit-sightre-form').val();
+ if( e.which == 13 && _word ) {
+ if( _word == "kit" ){
+ S.alert("", "<div style='text-align:left;'> _ _ _ <br>| | _(_) |_ <br>| |/ / | __|<br>| 〈| | |_ <br>|_|\_ \ _\__|</div><hr>", S.version);
+ return;
}
+ $('.kit-sightre-result.-first').click();
+ sightrePrevWord = '';
+ $('#kit-sightre-form').val('');
+ $('#kit-sightre-results').html('');
+ $('#kit-sightre').fadeOut(300);
}
- catch(error) {
- Notification.push("引数の解釈に失敗", error, "system");
+ }).on('keydown keyup change', (e) => {
+ let _word = $('#kit-sightre-form').val();
+ if( e.which == 27 ) $('#kit-sightre').fadeOut(300);
+ else {
+ if( _word == sightrePrevWord ) return;
+ $('#kit-sightre-results').html('');
+ if( !_word ) return;
+ sightrePrevWord = _word;
+ if( _word.indexOf('kish ') == 0 || _word.indexOf('🥧 ') == 0 ){
+ let _cmd = _word.substring( _word.indexOf(" ") + 1 );
+ if( _cmd ){
+ $(`<div class='kit-sightre-result -first'>
+ <img class='--icon' src='app/kish/icon.png'/>
+ <div class='--info'>
+ <div class='--name'>${_cmd}</div>
+ <div class='--desc'>kishでコマンドを実行</div>
+ </div>
+ <div class='--open fa fa-arrow-right'></div>
+ </div>`).appendTo('#kit-sightre-results').on('click', () => {
+ launch('kish', { 'rc': [ _cmd ] });
+ });
+ }
+ }
+ else if( _word.indexOf('http://') == 0 || _word.indexOf('https://') == 0 || _word.indexOf('localhost') == 0 ){
+ $(`<div class='kit-sightre-result -first'>
+ <img class='--icon' src='app/browser/icon.png'/>
+ <div class='--info'>
+ <div class='--name'>${_word}</div>
+ <div class='--desc'>ブラウザでURLを開く</div>
+ </div>
+ <div class='--open fa fa-arrow-right'></div>
+ </div>`).appendTo('#kit-sightre-results').on('click', () => {
+ launch( localStorage.getItem( "kit-default-browser" ), { "url" : _word } );
+ });
+ }
+ else {
+ $(`<div class='kit-sightre-result -first'>
+ <img class='--icon' src='system/icons/q.png'/>
+ <div class='--info'>
+ <div class='--name'>${_word}</div>
+ <div class='--desc'>アプリを起動する</div>
+ </div>
+ <div class='--open fa fa-arrow-right'></div>
+ </div>`).appendTo('#kit-sightre-results').on('click', () => {
+ let _args = null;
+ try {
+ if( _word.split(",")[1] ) _args = JSON.parse( _word.split(",").slice(1).join().trim() );
+ }
+ catch(error) {
+ Notification.push("引数の解釈に失敗", error, "system");
+ }
+ launch( _word.split(",")[0], _args );
+ });
+ }
+ for( let i in System.apps ){
+ if( i.indexOf(_word) == 0 || S.apps[i].name.indexOf(_word) == 0 ){
+ $(`<div class='kit-sightre-result -app'>
+ <img class='--icon' src='${S.apps[i].icon}'/>
+ <div class='--info'>
+ <div class='--name'>${S.apps[i].name}</div>
+ <div class='--desc'>kitアプリケーション - ${i}</div>
+ </div>
+ <div class='--open fa fa-arrow-right'></div>
+ </div>`).appendTo('#kit-sightre-results').on('click', () => {
+ launch(i);
+ $('#kit-sightre-results').html('');
+ $('#kit-sightre').fadeOut(300);
+ });
+ }
+ }
+ for( let i in System.userarea ){
+ if( i.indexOf(_word) == 0 || i.indexOf(_word) == 0 ){
+ $(`<div class='kit-sightre-result -file'>
+ <i class="fa fa-file --icon"></i>
+ <div class='--info'>
+ <div class='--name'>${i}</div>
+ <div class='--desc'>ファイル - 種類:${S.userarea[i].type} - ユーザー:${System.username}</div>
+ </div>
+ <div class='--open fa fa-arrow-right'></div>
+ </div>`).appendTo('#kit-sightre-results').on('click', () => {
+ System.open(i);
+ $('#kit-sightre-results').html('');
+ $('#kit-sightre').fadeOut(300);
+ });
+ }
+ }
+ $(`<div class='kit-sightre-result -link'>
+ <i class="fa fa-search --icon"></i>
+ <div class='--info'>
+ <div class='--name'>${_word}</div>
+ <div class='--desc'>をWebで検索</div>
+ </div>
+ <div class='--open fa fa-arrow-right'></div>
+ </div>`).appendTo('#kit-sightre-results').on('click', () => {
+ launch( 'browser', { 'url' : 'https://www.bing.com/search?q=' + _word } );
+ $('#kit-sightre-results').html('');
+ $('#kit-sightre').fadeOut(300);
+ });
+ $(`<div class='kit-sightre-result -link'>
+ <i class="fab fa-wikipedia-w --icon"></i>
+ <div class='--info'>
+ <div class='--name'>${_word}</div>
+ <div class='--desc'>wikipediaの記事を表示</div>
+ </div>
+ <div class='--open fa fa-arrow-right'></div>
+ </div>`).appendTo('#kit-sightre-results').on('click', () => {
+ launch( 'browser', { 'url' : 'https://ja.wikipedia.org/wiki/' + _word } );
+ $('#kit-sightre-results').html('');
+ $('#kit-sightre').fadeOut(300);
+ });
}
- launch( _app, _args );
- } );
- $( "#kit-milp-search" ).click( function() {
- launch( "browser", { "url" : "https://www.bing.com/search?q=" + $( "#milp" ).val() } );
- } );
- $( "#kit-milp-wikipedia" ).click( function() {
- launch( "browser", { "url" : "https://ja.wikipedia.org/wiki/" + $( "#milp" ).val() } );
- } );
+ });
- //サウンドドロップダウン
$("#dropdown-sound-slider").slider({
min: 0, max: 100, step: 1, value: 100,
change: (e, ui) => {
launch("user");
});
- //コンテキストメニュー
$(":root section:not(#desktop-l)").on("contextmenu", function() {
let _ptelem = $( document.elementFromPoint(S.mouseX, S.mouseY) );
S.selectedElement = _ptelem;
$( "#kit-context-elem" ).text( _ptelem.prop("tagName").toLowerCase() + "要素" );
$("#kit-contextgroup-custom").hide();
- let _ctxid = _ptelem.attr("data-kit-contextid");
+ let _ctxid = _ptelem.attr("data-kit-contextid") || _ptelem.attr("kit-context");
if( _ctxid ){
$("#kit-contextgroup-custom").show().html('<div id="kit-context-custom"></div>');
let _ctxname = KWS.context[_ctxid].name || _ctxid;
System.mouseX = event.clientX;
System.mouseY = event.clientY;
}).delegate( ".textbox", "keypress", function( e ) {
- if( e.which == 13 && this.id && $("#" + this.id + " + .kit-button") ){
- Notification.push("debug", this.id, "system");
- $("#" + this.id + " + .kit-button").click();
+ if( e.which == 13 && this.id ){
+ if( $("#" + this.id + " + .kit-button").length ){
+ Notification.push("debug", this.id, "system");
+ $("#" + this.id + " + .kit-button").click();
+ }
+ else if( $("#" + this.id + " + kit-button").length ){
+ Notification.push("debug", this.id, "system");
+ $("#" + this.id + " + kit-button").click();
+ }
}
} );
}
}
-function launch( str, args ) {
- pid = processID;
- System.args[pid] = args;
+function launch( str, args, dir ) {
+ let _pid = pid;
+ System.args[_pid] = args;
+ System.launchpath[_pid] = dir || System.appdir + str;
+
if( System.appCache[str] ) {
if( KWS.fullscreen.pid ) KWS.unmax(KWS.fullscreen.pid);
- //app[str].open();
appData( System.appCache[str] );
}
else {
try{
- $.getJSON( S.appdir + str + "/define.json", appData ).fail( function() {
- System.alert( "起動エラー", "アプリケーションの起動に失敗しました<br>アプリケーション" + str + "は存在しないかアクセス権がありません(pid:" + processID + ")。ヘルプは<a class='kit-hyperlink' href='https://kitdev.home.blog/'>こちら</a>" );
+ $.getJSON( S.launchpath[_pid] + '/define.json', appData ).fail( () => {
+ Notification.push('kitアプリをロードできません。', `${str}を展開できませんでした。`, 'system');
} );
}
catch(error){
}
function appData( data ) {
- var pid = processID;
- process[String( pid )] = {
+ let _pid = pid;
+ process[String( _pid )] = {
id: data.id,
time: System.time.obj.toLocaleString(),
isactive: false,
- preventclose: false
+ preventclose: false,
+ title: data.name
};
System.appCache[data.id] = data;
- $( "#tasks" ).append( "<span id='t" + pid + "'><img src='./app/" + data.id + "/" + data.icon + "'><span id='tname" + pid + "'>" + data.name + "<span></span>" );
- //タスクバーのクリック挙動
- $( "#t" + pid ).addClass( "task" ).click( function() {
- if( $(this).hasClass("t-active") || $(this).hasClass("task-min") ) KWS.min( pid );
- else{
- $("#w"+pid).css("z-index", KWS.windowIndex + 1);
- KWS.refreshWindowIndex();
+ app = new App(_pid);
+ let _taskAppend = `<span id='t${_pid}'>`;
+ if( data.icon && data.icon != "none" ) _taskAppend += `<img src='${S.launchpath[_pid]}/${data.icon}'>`;
+ _taskAppend += `<span id='tname${_pid}'>${data.name}<span></span>`;
+ $( "#tasks" ).append( _taskAppend );
+ $( "#t" + _pid ).addClass( "task" ).on({
+ click: function() {
+ if( $(this).hasClass("t-active") || $(this).hasClass("task-min") ) KWS.min( _pid );
+ else{
+ $("#w"+_pid).css("z-index", KWS.windowIndex + 1);
+ KWS.refreshWindowIndex();
+ }
+ },
+ mouseenter: function() {
+ $( "#task-ctx-name" ).text( data.name );
+ if( data.icon && data.icon != "none" ) $( "#task-ctx-img" ).attr( "src", System.launchpath[_pid] + "/" + data.icon );
+ else $( "#task-ctx-img" ).hide();
+ $( "#task-ctx-ver" ).text( data.version + "/pid:" + _pid );
+ $( "#task-ctx-info" ).off().on( "click", function() { System.appInfo( _pid )} );
+ $( "#task-ctx-sshot" ).off().on( "click", function() { S.screenshot(_pid, true) } );
+ $( "#task-ctx-min" ).off().on( "click", function() { KWS.min( String(_pid) ) } );
+ if( $(this).hasClass("t-active") ) $( "#task-ctx-front" ).hide();
+ else $( "#task-ctx-front" ).show();
+ $( "#task-ctx-front" ).off().on( "click", function() {
+ $("#w"+_pid).css("z-index", KWS.windowIndex + 1);
+ KWS.refreshWindowIndex();
+ } );
+ $( "#task-ctx-close" ).off().on("click", () => System.close(_pid));
+ $( "#task-ctx-kill" ).off().on("click", () => System.kill( data.id));
+ const _ctxleft = $(this).offset().left, _ctxtop = window.innerHeight - $(this).offset().top;
+ if( _ctxleft != $( "#task-ctx" ).offset().left ) $( "#task-ctx" ).hide();
+ $( "#task-ctx" ).css( "left", _ctxleft ).css( "bottom", _ctxtop ).show();
}
} );
- $( "#t" + pid ).addClass( "task" ).on( "mouseenter", function() {
- $( "#task-ctx-name" ).text( data.name );
- $( "#task-ctx-img" ).attr( "src", "./app/" + data.id + "/" + data.icon );
- $( "#task-ctx-ver" ).text( data.version + "/pid:" + pid );
- $( "#task-ctx-info" ).off().on( "click", function() { System.appInfo( data.id )} );
- $( "#task-ctx-sshot" ).off().on( "click", function() { S.screenshot(pid, true) } );
- $( "#task-ctx-min" ).off().on( "click", function() { KWS.min( String(pid) ) } );
- if( $(this).hasClass("t-active") ) $( "#task-ctx-front" ).hide();
- else $( "#task-ctx-front" ).show();
- $( "#task-ctx-front" ).off().on( "click", function() {
- $("#w"+pid).css("z-index", KWS.windowIndex + 1);
- KWS.refreshWindowIndex();
- } );
- $( "#task-ctx-close" ).off().on( "click", () => { System.close( String(pid) ) } );
- $( "#task-ctx-kill" ).off().on( "click", () => { System.kill( String(data.id) ) } );
- const _ctxleft = $( "#t" + pid ).offset().left;
- const _ctxtop = window.innerHeight - $( "#t" + pid ).offset().top;
- if( _ctxleft != $( "#task-ctx" ).offset().left ) {
- $( "#task-ctx" ).hide();
- }
- $( "#task-ctx" ).css( "left", _ctxleft ).css( "bottom", _ctxtop ).show();
- } );
$( "section, #kit-tasks" ).on( "mouseenter", function() {
$( "#task-ctx" ).fadeOut( 200 );
} );
- $( "#t" + pid ).hover( function() {
- prevWindowIndex = $( "#w" + pid ).css( "z-index" );
- $( "#w" + pid ).addClass( "win-highlight" );
- }, function() {
- $( "#w" + pid ).removeClass( "win-highlight" );
- } );
- let WINDOWAPPEND = "<div id='w" + pid + "'><div id='wt" + pid + "' class='wt'><i class='wmzx'><span id='wm" + pid + "'></span>";
- if( data.support && data.support.fullscreen == true ) WINDOWAPPEND += "<span id='wz" + pid + "'></span>";
- WINDOWAPPEND += "<span id='wx" + pid + "'></span></i><img src='./app/" + data.id + "/" + data.icon + "'><span id='wtname" + pid + "'>" + data.name + "</span></div><div class='winc winc-" + data.id + "' id='winc" + pid + "'></div></div>";
- $( "#desktop-" + currentDesktop ).append( WINDOWAPPEND );
- if( data.support && data.support.darkmode == true ) $("#winc"+pid).addClass("winc-darkmode");
- if( KWS.darkmode ) $("#winc"+pid).addClass("kit-darkmode");
+ $( "#t" + _pid ).on({
+ mouseenter: () => {
+ prevWindowIndex = $( "#w" + _pid ).css( "z-index" );
+ $( "#w" + _pid ).addClass( "win-highlight" );
+ },
+ mouseleave: () => $( "#w" + _pid ).removeClass( "win-highlight" )
+ });
+
+ let _windowAppend = "<div id='w" + _pid + "'><div id='wt" + _pid + "' class='wt'><i class='wmzx'><span id='wm" + _pid + "'></span>";
+ if( data.support && data.support['fullscreen'] == true ) _windowAppend += "<span id='wz" + _pid + "'></span>";
+ _windowAppend += "<span id='wx" + _pid + "'></span></i>";
+ if( data.icon && data.icon != "none" ) _windowAppend += "<img src='" + S.launchpath[_pid] + "/" + data.icon + "'>";
+ _windowAppend += "<span id='wtname" + _pid + "'>" + data.name + "</span></div><div class='winc winc-" + data.id + "' id='winc" + _pid + "'></div></div>";
+ $( "#desktop-" + currentDesktop ).append( _windowAppend );
+
+ if( data.support && data.support['darkmode'] == true ) $("#winc"+_pid).addClass("winc-darkmode");
+ if( KWS.darkmode ) $("#winc"+_pid).addClass("kit-darkmode");
if( data.size ){
- $("#winc"+pid).css("width", data.size.width).css("height", data.size.height);
+ $("#winc"+_pid).css("width", data.size.width).css("height", data.size.height);
}
if( data.resize ){
let _minwidth = 200, _minheight = 40;
if( data.resize.minWidth ) _minwidth = data.resize.minWidth;
if( data.resize.minHeight ) _minheight = data.resize.minHeight;
- $("#winc"+pid).windowResizable({
+ $("#winc"+_pid).windowResizable({
minWidth: _minwidth,
minHeight: _minheight
});
}
- var windowPos = 50 + ( pid % 10 ) * 20;
- //$( "#w" + pid ).addClass( "window" ).draggable( {cancel: ".winc", stack: ".window"} ).css( "left", windowPos + "px" ).css( "top", windowPos + "px" ).css( "z-index", $( ".window" ).length + 1 );
+ let windowPos = 50 + ( _pid % 10 ) * 20;
KWS.windowIndex ++;
- $( "#w"+pid ).addClass( "window" ).pep({
+ $( "#w"+_pid ).addClass( "window" ).pep({
elementsWithInteraction: ".winc, .ui-resizable-handle",
useCSSTranslation: false,
disableSelect: false,
KWS.refreshWindowIndex();
} ).css( "left", windowPos + "px" ).css( "top", windowPos + "px" ).css( "z-index", KWS.windowIndex );
KWS.refreshWindowIndex();
- $( "#wm" + pid ).addClass( "wm fa fa-window-minimize" ).click( () => KWS.min( String(pid) ) );
- $( "#wz" + pid ).addClass( "wz fas fa-square" ).click( () => KWS.max( String(pid) ) );
- $( "#wx" + pid ).addClass( "wx fa fa-times" ).click( () => System.close( String(pid) ) );
- $( "#winc" + pid ).resizable( {
+ $( `#wm${_pid}` ).addClass( "wm fa fa-window-minimize" ).on("click", () => KWS.min( _pid ) );
+ $( `#wz${_pid}` ).addClass( "wz fas fa-square" ).on("click", () => KWS.max( _pid ) );
+ $( `#wx${_pid}` ).addClass( "wx fa fa-times" ).on("click", () => System.close( _pid ) );
+ $( "#winc" + _pid ).resizable( {
minWidth: "200"
- } ).load( "./app/" + data.id + "/" + data.view );
-
- //スクリプト読み込み
- if( data.script != "none" ) $.getScript( "./app/" + data.id + "/" + data.script );
- if( data.css != "none" && $("#kit-style-"+data.id).length == 0 ){
- $( "head" ).append( '<link href="./app/' + data.id + '/' + data.css + '" rel="stylesheet" id="kit-style-' + data.id + '"></link>' );
- Notification.push("debug", "新規スタイルシートの読み込み", data.id);
- }
-
- processID++;
- localStorage.setItem( "kit-pid", processID );
-}
-
-//非推奨メソッド
-function appInfo( str ){
- System.appInfo(str)
-}
-
-//非推奨メソッド
-function close( str ) {
- System.close( str )
-}
-
-//非推奨メソッド
-function kill( str ) {
- System.kill(str)
+ } ).load( System.launchpath[_pid] + "/" + data.view, (r, s, x) => {
+ if( s == "error" ){
+ Notification.push("起動に失敗:" + x.status, x.statusText);
+ return false;
+ }
+ if( !data.script || data.script != "none" ) $.getScript( System.launchpath[_pid] + "/" + data.script, () => {
+ if( !data.support || data.support['kaf'] != false ) App.kaf(_pid);
+ pid++;
+ }).fail( () => {
+ App.kaf(_pid);
+ pid++;
+ });
+ else if( !data.support || data.support['kaf'] != false ){
+ App.kaf(_pid);
+ pid++;
+ }
+ else pid++;
+ if( data.css != "none" && $("#kit-style-"+data.id).length == 0 ){
+ $( "head" ).append( '<link href="' + System.launchpath[_pid] + '/' + data.css + '" rel="stylesheet" id="kit-style-' + data.id + '"></link>' );
+ }
+ localStorage.setItem( "kit-pid", pid );
+ } );
}
const System = new function() {
- this.version = "0.2.0";
+ this.version = "0.2.1";
this.username = localStorage.getItem("kit-username");
this.appdir = localStorage.getItem("kit-appdir");
+ this.loc = { ...location };
this.bootopt = new URLSearchParams(location.search);
this.selectedElement = null;
this.selectedText = null;
- this.dom = function(_pid, _elements) {
- _elements = _elements || "";
- return $("#winc" + _pid + " " + _elements);
+ this.dom = function(_pid, ..._elems) {
+ let q = "";
+ if( !_elems.length ) q = ",#winc" + _pid;
+ else for( let i of _elems ){
+ q += ",#winc" + _pid + " " + i;
+ }
+ return $( q.substring(1) );
+ }
+
+ this.qs = ( _pid, ..._elems ) => {
+ let q = "";
+ if( !_elems.length ) q = ",#winc" + _pid;
+ else for( let i of _elems ) q += ",#winc" + _pid + " " + i;
+ return document.querySelectorAll( q.substring(1) )
}
this.userarea = new Object();
this.recycle = new Object();
this.appCache = {};
- //引数
+ //アプリ引数
this.args = {};
+ //アプリ起動パス
+ this.launchpath = {};
this.support = $.support;
this.debugmode = false;
$( "body" ).css( "background-color", "black" );
$( "header, footer" ).fadeOut( 300 );
$( "#kit-wallpaper" ).fadeOut( 1500 );
- if( _opt == "reboot" ) location.reload();
+ if( _opt == "reboot" ) location.href = "autorun.html";
+ localStorage.setItem("kit-shutted-down", true);
}
this.reboot = function() {
})
}
- this.appInfo = function( str ){
+ this.appInfo = function( _pid ){
let _title = "", _content = "";
- let ac = System.appCache[str];
+ let ac = System.appCache[process[_pid].id];
+ let _lp = System.launchpath[_pid];
if( ac ){
- _title = ac.name + " (" + ac.version + ")";
- _content = "<img style='height: 96px' src='./app/" + ac.id + "/" + ac.icon + "'><br>";
+ _title = ac.name + " " + ac.version;
+ if( ac.icon && ac.icon != "none" ) _content = "<img style='height: 96px' src='" + _lp + "/" + ac.icon + "'><br>";
for( let i in ac ){
- _content += "<div><span style='font-weight: 100'>" + i + " </span>" + ac[i] + "</div>";
+ if( typeof ac[i] != "object" ) _content += "<div><span style='font-weight: 100'>" + i + " </span>" + ac[i] + "</div>";
}
+ _content += "<br><span style='font-weight: 100'>起動パス " + _lp + "</span><br><br>"
}
else _title = "取得に失敗しました";
System.alert( _title, _content );
}
-
- //非推奨です(削除予定)。
- this.min = function( _str ) {
- KWS.min( _str );
- }
+
+ this.apps = new Object();
+ this.installed = new Array();
this.close = function( _str ) {
let _pid = String( _str );
}
this.kill = function( _str ){
- for( let pid in process ) {
- if( process[pid] && process[pid].id == _str ) System.close( pid );
+ for( let _pid in process ) {
+ if( process[_pid] && process[_pid].id == _str ) System.close( _pid );
}
}
context.lineTo(center.x + Math.sin(angle) * radius * line.to, center.y - Math.cos(angle) * radius * line.to);
context.stroke();
}
- angle = Math.PI * ( Hour+Min/60 ) / 6, len = radius * hands.hour.length;
+ angle = Math.PI * ( Number(Hour)+Number(Min)/60 ) / 6, len = radius * hands.hour.length;
context.beginPath(), context.lineWidth = hands.hour.width;
context.lineCap = hands.hour.cap, context.strokeStyle = hands.hour.color;
context.moveTo(center.x - Math.sin(angle) * len * hands.hour.ratio, center.y + Math.cos(angle) * len * hands.hour.ratio);
context.lineTo(center.x + Math.sin(angle) * len, center.y - Math.cos(angle) * len), context.stroke();
- angle = Math.PI * (Min + Sec / 60) / 30, len = radius * hands.minute.length;
+ angle = Math.PI * ( Number(Min)+Number(Sec) / 60) / 30, len = radius * hands.minute.length;
context.beginPath(), context.lineWidth = hands.minute.width;
context.lineCap = hands.minute.cap, context.strokeStyle = hands.minute.color;
context.moveTo(center.x - Math.sin(angle) * len * hands.minute.ratio, center.y + Math.cos(angle) * len * hands.minute.ratio);
context.lineTo(center.x + Math.sin(angle) * len, center.y - Math.cos(angle) * len), context.stroke();
- angle = Math.PI * Sec / 30, len = radius * hands.second.length;
+ angle = Math.PI * Number(Sec) / 30, len = radius * hands.second.length;
context.beginPath(), context.lineWidth = hands.second.width;
context.lineCap = hands.second.cap, context.strokeStyle = hands.second.color;
context.moveTo(center.x - Math.sin(angle) * len * hands.second.ratio, center.y + Math.cos(angle) * len * hands.second.ratio);
for( let i in process ) {
if( process[i].id == _id ) _cnt += 1;
}
- console.log( _cnt );
+ Notification.push( "debug", _cnt );
if( _cnt > 1 ) {
System.close( _pid );
if( !_alert ){
}
this.initLauncher = function(data){
+ $("#launcher-apps").html("");
+ System.apps = data;
for( let i in data ){
$("#launcher-apps").append("<div class='launcher-app' data-launch='" + i + "'><img src='" + data[i].icon + "'>" + data[i].name + "</div>");
}
+ if( !System.bootopt.get("safe") ){
+ for( let i of System.installed ){
+ $("#launcher-apps").append("<div class='launcher-app' data-define-path='" + i.path + "' data-define-id='" + i.id + "'><img src='" + i.icon + "'>" + i.name + "</div>");
+ }
+ }
$(".launcher-app").on("click", function(){
$("#launch").click();
- launch( $(this).attr("data-launch") );
+ if( $(this).attr("data-launch") ) launch( $(this).attr("data-launch") );
+ else if( $(this).attr("data-define-path") ){
+ launch( $(this).attr("data-define-id"), null, $(this).attr("data-define-path") );
+ };
});
}
}
const KWS = new function(){
- this.version = "3.2.2";
+ this.version = "3.2.3";
this.active = null;
this.darkmode = false;
this.max = function( _pid ){
if( KWS.fullscreen.pid ){
- Notification.push("最大化に失敗", "最大化しているウィンドウがあります。");
+ Notification.push("最大化に失敗", "最大化しているウィンドウがあります。", "system");
return;
}
$( "#wt"+_pid ).addClass("wtmaximize");
KWS.windowIndex = num;
}
+ this.front = function( _pid ) {
+ $(`#w${_pid}`).css("z-index", KWS.windowIndex + 1);
+ KWS.refreshWindowIndex();
+ }
+
this.resize = function( _pid, _width, _height ){
if( _width ) $("#winc"+_pid).css("width", _width)
if( _height ) $("#winc"+_pid).css("height", _height);
}
+ this.setTheme = function(_name){
+ localStorage.setItem('kit-theme', _name);
+ if(_name != 'none') $('#kit-theme-file').attr('href', `./system/theme/${localStorage.getItem('kit-theme')}`);
+ else $('#kit-theme-file').attr('href', '');
+ System.moveDesktop(currentDesktop);
+ }
+
this.fusen = new function(){
this.fid = 0;
this.list = new Object();
this.add = function(_text){
KWS.fusen.list[KWS.fusen.fid] = String(_text);
- $("#desktop-"+currentDesktop).append("<div class='kit-fusen' id='kit-f"+KWS.fusen.fid+"'><i class='fa fa-quote-left'></i><textarea class='kit-fusen-textarea kit-selectable' data-fid='"+KWS.fusen.fid+"' data-kit-contextid='fusen'>"+_text+"</textarea></div>");
+ $("#desktop-"+currentDesktop).append("<div class='kit-fusen' id='kit-f"+KWS.fusen.fid+"'><i class='fa fa-quote-left'></i><textarea class='kit-fusen-textarea kit-selectable' data-fid='"+KWS.fusen.fid+"' kit-context='fusen'>"+_text+"</textarea></div>");
$("#kit-f"+KWS.fusen.fid).css({
"left": Number(KWS.fusen.fid)*40 + 20,
"top": Number(KWS.fusen.fid)*10 + 100,
}
})
$(".kit-fusen-textarea").off().on("change",function(){
- Notification.push($(this).attr("data-fid"), $(this).val(), "debug");
KWS.fusen.list[$(this).attr("data-fid")] = $(this).val();
localStorage.setItem("kit-fusen", JSON.stringify( KWS.fusen.list ));
});
this.goodnight = false;
this.sound = null;
- this.push = function( _title, _content, _app ) {
+ this.push = function( _title, _content, _app, _pid, _action, _img, _buttons ) {
+ let _nid = this.nid;
if( !System.debugmode && ( _title == "debug" || _app == "debug" ) ){
return false;
}
- this.list[this.nid] = {
- "title" : _title,
- "content" : _content,
- "app" : _app,
- "time" : System.time.obj.toLocaleString()
+ Notification.list[_nid] = {
+ title: _title,
+ content: _content,
+ app: _app,
+ time: System.time.obj.toLocaleString(),
+ pid: _pid,
+ action: () => {
+ if( typeof _action == 'function' ) _action();
+ else if( _pid ) KWS.front(_pid);
+ $('#notifications').hide('drop', {direction: 'right'}, 300);
+ },
+ img: _img
};
+ if( _pid && System.appCache[_app] ){
+ _app = `<img src='${System.launchpath[_pid]}/${System.appCache[_app].icon}'>${_app}`;
+ }
if( !this.goodnight ){
if( this.sound ) System.audio.play( "n" + this.nid, this.sound );
- $( "#last-notification-title" ).text("").text( _title );
- $( "#last-notification-content" ).text("").text( _content );
- $( "#last-notification-app" ).text("").text( _app );
- $( "#last-notification" ).hide().show( "drop", {direction: "right"}, 300 );
- }
- $( "#notifications" ).append( "<div class='notis' id='nt" + this.nid + "'><span class='notis_close' id='nc" + this.nid + "'></span><span><span class='fas fa-comment-alt'></span>" + _title + "</span>" + _content + "<div class='notis_time'>" + System.time.obj.toLocaleString() + "</div></div>" );
- $("#nc" + this.nid).on("click", function(){
- let _nid = this.id.slice(2);
- $("#nt" + _nid).fadeOut(300);
- return false;
- } );
- $("#nt" + this.nid).on("click", function(){
- let _nid = this.id.slice(2);
- if( Notification.list[ _nid ].app != "system" ){
- launch(Notification.list[ _nid ].app);
+ $('#last-notification-title').text('').text( _title );
+ $('#last-notification-content').text('').text( _content );
+ $('#last-notification-app').text('').html( _app );
+ $('#last-notification').hide().show('drop', {direction: "right"}, 300).off().on('click', Notification.list[this.nid].action);
+ if( _img ) $('#last-notification-img').attr('src', _img).show();
+ else $('#last-notification-img').attr('src', '').hide();
+ }
+ let imgtag = '';
+ if( _img ) imgtag = `<img src='${_img }' alt='' class='notis_img'>`;
+ $(`<div class='notis' id='nt${_nid}'>
+ ${imgtag}
+ <span class='notis_close' id='nc${_nid}'></span>
+ <div class='notis_app'>${_app}</div>
+ <span>${_title}</span>
+ ${_content}
+ <div class='notis_buttons'></div>
+ <div class='notis_time'>${System.time.obj.toTimeString()}</div>
+ </div>`).appendTo('#notifications').on('click', Notification.list[this.nid].action);
+ $(`#nc${_nid}`).on('click', (e) => {
+ e.stopPropagation();
+ $(`#nt${_nid}`).fadeOut(300);
+ });
+ $('#last-notification-buttons').html('');
+ if( _buttons ){
+ for( let b of _buttons ){
+ $(`<a>${b.label}</a>`).appendTo('#last-notification-buttons').on('click', (e) => {
+ e.stopPropagation();
+ b.func();
+ });
+ $(`<a>${b.label}</a>`).appendTo(`#nt${_nid} .notis_buttons`).on('click', (e) => {
+ e.stopPropagation();
+ b.func();
+ });
}
- } );
+ }
this.nid ++;
return (this.nid - 1);
}
}
-var process = {}, processID = 0, pid, currentDesktop = 1, currentCTX = "", prevWindowIndex, S;
\ No newline at end of file
+class App {
+ constructor(_pid) {
+ App.e[_pid] = new Object();
+ App.d[_pid] = new Object();
+
+ this.process = process[_pid];
+ this.info = System.appCache[process[_pid].id];
+
+ this.args = System.args[_pid];
+ this.close = () => System.close(_pid);
+ this.d = App.d[_pid];
+ this.dom = (..._args) => System.dom(_pid, ..._args);
+ this.e = App.e[_pid];
+ this.ntf = (_title, _content, _action, _img, _buttons) => Notification.push(_title, _content, this.info.id, _pid, _action, _img, _buttons);
+ this.qs = (...args) => System.qs(_pid, ...args);
+ this.front = () => KWS.front(_pid);
+
+ this.changeWindowTitle = _t => App.changeWindowTitle( _pid, _t );
+ this.data = (_name, _value) => App.data(_pid, _name, _value);
+ this.event = (_name, _event) => App.event(_pid, _name, _event);
+ this.getPath = _path => App.getPath(_pid, _path);
+ this.kaf = () => App.kaf(_pid);
+ this.load = _path => App.load(_pid, _path);
+ this.preventClose = _bool => App.preventClose(_pid, _bool);
+ }
+
+ static changeWindowTitle( _pid, _t ) {
+ $( "#tname"+_pid ).text( _t );
+ $( "#wtname"+_pid ).text( _t );
+ process[_pid].title = _t;
+ return App;
+ }
+
+ static context( _cid, _obj ) {
+ KWS.context[ _cid ] = _obj;
+ return App;
+ }
+
+ static data( _pid, _name, _value ) {
+ if( _value !== undefined ) {
+ S.dom(_pid, `[kit\\:bind=${_name}]`).val( _value );
+ S.dom(_pid, `[kit\\:observe=${_name}]`).text( _value );
+ if( _value ) S.dom(_pid, `[kit\\:if=${_name}]`).show();
+ else S.dom(_pid, `[kit\\:if=${_name}]`).hide();
+ return App.d[_pid][_name] = _value;
+ }
+ else if( _name ) return App.d[_pid][_name];
+ else return App.d[_pid];
+ }
+
+ static event( _pid, _name, _event ) {
+ if( !App.e[_pid] ) App.e[_pid] = new Object();
+ App.e[_pid][_name] = _event;
+ return App;
+ }
+
+ static getPath( _pid, _path ) {
+ return System.launchpath[_pid] + _path;
+ }
+
+ static kaf( _pid ) {
+ let attrs = [
+ "[kit-ref]",
+ "[kit-e]",
+ "[kit-src]",
+ "[kit-alert]",
+ "[kit-launch]",
+ "[kit-close]",
+ "[kit-text]",
+ "[kit-html]",
+ "[kit\\:bind]",
+ "[kit\\:observe]",
+ "[kit\\:value]",
+ "[kit-value]",
+ "[kit-color]",
+ "[kit\\:if]",
+ "[kit-if]"
+ ]
+ const PID = _pid;
+ const DATA = App.data(_pid);
+ const ARGS = System.args[_pid];
+ for( let i of S.qs(_pid, ...attrs) ){
+ if( i.hasAttribute("kit-ref") ){
+ $(i).on("click", () => App.load(_pid, i.getAttribute("kit-ref")) );
+ }
+ if( i.hasAttribute("kit-e") ){
+ let _eqs = i.getAttribute("kit-e").split(",");
+ for( let k of _eqs ){
+ let _eq = k.split(" ");
+ $(i).on( _eq[1]||"click", App.e[_pid][_eq[0]] );
+ }
+ }
+ if( i.hasAttribute("kit-src") ){
+ $(i).attr("src", `${System.launchpath[_pid]}/${i.getAttribute("kit-src")}` );
+ }
+ if( i.hasAttribute("kit-alert") ){
+ $(i).on("click", ()=> System.alert( System.appCache[ process[_pid].id ].name, i.getAttribute("kit-alert") ) );
+ }
+ if( i.hasAttribute("kit-launch") ){
+ $(i).on("click", ()=> launch( i.getAttribute("kit-launch") ) );
+ }
+ if( i.hasAttribute("kit-close") ){
+ $(i).on("click", ()=> System.close( i.getAttribute("kit-close") || _pid ) );
+ }
+ if( i.hasAttribute("kit-text") ){
+ $(i).text( eval(i.getAttribute("kit-text")) );
+ }
+ if( i.hasAttribute("kit-html") ){
+ $(i).html( eval(i.getAttribute("kit-html")) );
+ }
+ if( i.hasAttribute("kit:bind") ){
+ if( App.d[_pid] == undefined ) App.d[_pid] = new Object();
+ $(i).on('keydown keyup keypress change', () => {
+ let _name = i.getAttribute("kit:bind");
+ App.d[_pid][_name] = i.value;
+ S.dom(_pid, `[kit\\:observe=${_name}]`).text( i.value );
+ if( i.value ) S.dom(_pid, `[kit\\:if=${_name}]`).show();
+ else S.dom(_pid, `[kit\\:if=${_name}]`).hide();
+ } );
+ }
+ if( i.hasAttribute("kit:observe") ){
+ $(i).text( App.d[_pid][i.getAttribute("kit:observe")] );
+ }
+ if( i.hasAttribute("kit:value") ){
+ $(i).val( App.d[_pid][i.getAttribute("kit:value")] );
+ }
+ if( i.hasAttribute("kit-value") ){
+ $(i).val( eval(i.getAttribute("kit-value")) );
+ }
+ if( i.hasAttribute("kit-color") ){
+ $(i).css('color', i.getAttribute("kit-color"));
+ }
+ if( i.hasAttribute("kit:if") ){
+ if( App.d[_pid][i.getAttribute("kit:if")] ){
+ $(i).show();
+ }
+ else $(i).hide();
+ }
+ if( i.hasAttribute("kit-if") ){
+ if( eval( i.getAttribute("kit-if")) ){
+ $(i).show();
+ }
+ else $(i).hide();
+ }
+ }
+ }
+
+ static load( _pid, _path ) {
+ S.dom(_pid).load( System.launchpath[_pid] +"/"+ _path, () => {
+ App.kaf(_pid);
+ } );
+ return App;
+ }
+
+ static preventClose( _pid, _bool = true ) {
+ process[_pid].preventclose = _bool || true;
+ return App;
+ }
+}
+
+App.d = new Object();
+App.e = new Object();
+App.version = "2.1.1";
+
+var process = {}, pid = 0, app, currentDesktop = 1, currentCTX = "", prevWindowIndex, S;