// | <| | |_
// |_|\_\_|\__|
//
-// 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
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( 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" ) );
}
$( "#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>");
}).fail( function() {
Notification.push( "読み込みに失敗", "デスクトップ(config/desktop.json)の読み込みに失敗しました。", "system" );
} );
- //ランチャー
+
$.getJSON("config/apps.json", System.initLauncher).fail( function() {
Notification.push( "ランチャー初期化失敗", "アプリケーション一覧(config/apps.json)の読み込みに失敗しました。", "system" );
} );
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 );
$( "#kit-wallpaper" ).css( "filter", "blur(5px)" );
- $( "footer, header, #launcher, #task-ctx, .dropdown, #desktop-" + currentDesktop ).hide();
+ $( "footer, header, #launcher, #task-ctx, #kit-sightre, .dropdown, #desktop-" + currentDesktop ).hide();
$( "#kit-power" ).show();
} );
$( "#kit-power-back" ).click( function() {
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" ) ) {
}
} );
- //検索バー
- $( "#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);
+ }
+ else {
+ $('#kit-sightre-results').html('');
+ $('#kit-sightre').show();
+ $('#kit-sightre-form').val('').focus();
}
- let _app = $( "#milp" ).val().split(",")[0];
- let _args = null;
- try {
- if( $( "#milp" ).val().split(",")[1] ){
- _args = JSON.parse( $( "#milp" ).val().split(",").slice(1).join() );
+ });
+ 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;
}
function launch( str, args, dir ) {
- pid = processID;
- System.args[pid] = args;
- System.launchpath[pid] = dir || System.appdir + str;
+ 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.launchpath[pid] + "/define.json", appData ).fail( function() {
- Notification.push("kitアプリをロードできません", str + "を展開できませんでした。アプリが存在しないか、クロスオリジン要求がブロックされている可能性があります。詳細:https://kitdev.home.blog/", "system");
- //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,
title: data.name
};
System.appCache[data.id] = data;
- 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>";
+ 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" ).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();
+ $( "#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 );
- 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( 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>";
- 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>";
+ $( "#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.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( System.launchpath[pid] + "/" + data.view, (r, s, x) =>{
+ } ).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, () => App.kaf(pid) ).fail( () => App.kaf(pid) );
- else App.kaf(pid);
+ 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>' );
- //Notification.push("debug", "新規スタイルシートの読み込み", data.id);
- }
- processID++;
- localStorage.setItem( "kit-pid", processID );
+ $( "head" ).append( '<link href="' + System.launchpath[_pid] + '/' + data.css + '" rel="stylesheet" id="kit-style-' + data.id + '"></link>' );
+ }
+ localStorage.setItem( "kit-pid", pid );
} );
}
-//非推奨メソッド
-function close( str ) {
- System.close( str )
-}
-
-//非推奨メソッド
-function kill( str ) {
- System.kill(str)
-}
-
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);
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();
$( "header, footer" ).fadeOut( 300 );
$( "#kit-wallpaper" ).fadeOut( 1500 );
if( _opt == "reboot" ) location.href = "autorun.html";
+ localStorage.setItem("kit-shutted-down", true);
}
this.reboot = function() {
System.alert( _title, _content );
}
+ this.apps = new Object();
this.installed = new Array();
-
- //非推奨です(削除予定)。
- this.min = function( _str ) {
- KWS.min( _str );
- }
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 );
}
}
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>");
}
}
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();
}
})
$(".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);
}
}
-const App = new function() {
- this.changeWindowTitle = ( _pid, _t ) => {
+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;
}
- this.context = ( _cid, _obj ) => {
+ static context( _cid, _obj ) {
KWS.context[ _cid ] = _obj;
return App;
}
- this.d = new Object();
-
- this.data = ( _pid, _name ) => {
- let _r;
- if( _name ) _r = App.d[_pid][_name];
- else _r = App.d[_pid];
- return _r;
+ 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];
}
- this.e = new Object();
-
- this.event = ( _pid, _name, _event ) => {
+ static event( _pid, _name, _event ) {
if( !App.e[_pid] ) App.e[_pid] = new Object();
App.e[_pid][_name] = _event;
return App;
}
- this.getPath = ( _pid, _path ) => System.launchpath[_pid] + _path;
+ static getPath( _pid, _path ) {
+ return System.launchpath[_pid] + _path;
+ }
- this.kaf = ( _pid ) => {
- for( let i of S.dom(_pid, ".kaf", "kaf", "[kaf]") ){
+ 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-src") ){
- $(i).attr("src", System.launchpath[_pid] +"/"+ i.getAttribute("kit-ref") )
+ $(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-html") ){
$(i).html( eval(i.getAttribute("kit-html")) );
}
- if( i.hasAttribute("kit-bind") ){
+ if( i.hasAttribute("kit:bind") ){
if( App.d[_pid] == undefined ) App.d[_pid] = new Object();
- $(i).on("change", () => App.d[_pid][i.getAttribute("kit-bind")] = $(i).val() );
+ $(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();
}
}
}
- this.load = ( _pid, _path ) => {
+ static load( _pid, _path ) {
S.dom(_pid).load( System.launchpath[_pid] +"/"+ _path, () => {
App.kaf(_pid);
} );
return App;
}
- this.preventClose = ( _pid, _bool ) => {
+ static preventClose( _pid, _bool = true ) {
process[_pid].preventclose = _bool || true;
return App;
}
}
-var process = {}, processID = 0, pid, currentDesktop = 1, currentCTX = "", prevWindowIndex, S;
\ No newline at end of file
+App.d = new Object();
+App.e = new Object();
+App.version = "2.1.1";
+
+var process = {}, pid = 0, app, currentDesktop = 1, currentCTX = "", prevWindowIndex, S;