diff --git a/app/img/aiscript.svg b/app/img/aiscript.svg new file mode 100644 index 00000000..fd015c45 --- /dev/null +++ b/app/img/aiscript.svg @@ -0,0 +1,50 @@ + + + diff --git a/app/js/platform/plugin.js b/app/js/platform/plugin.js index 8c2280af..8b75afa9 100644 --- a/app/js/platform/plugin.js +++ b/app/js/platform/plugin.js @@ -6,20 +6,8 @@ function getPlugin() { buttonOnPostbox: [], buttonOnToot: [] } - //if(!json) return ret - //const plugins = JSON.parse(json) - const plugins = [ - { - id: randomStr(20), - content: `### { - name: "マイ・ファースト・プラグイン" - version: 1 - event: "buttonOnPostbox" - author: "Cutls P" - } - ` - } - ] + if(!json) return ret + const plugins = JSON.parse(json) for (let plugin of plugins) { const meta = getMeta(plugin.content) if (!meta) continue diff --git a/app/js/ui/settings.js b/app/js/ui/settings.js index ea99af3c..71591eb0 100644 --- a/app/js/ui/settings.js +++ b/app/js/ui/settings.js @@ -502,9 +502,9 @@ function copyColor(from, to) { let i = 0 let color for (tag of props) { - if(tag == from) { + if (tag == from) { let used = $(`#use-color_${i}`).prop('checked') - if(!used) { + if (!used) { Swal.fire({ type: 'error', title: 'Not checked', @@ -516,9 +516,9 @@ function copyColor(from, to) { } i++ } - if(!color) return false + if (!color) return false for (tag of props) { - if(tag == to) { + if (tag == to) { $(`#color-picker${i}_value`).val(color) $(`#use-color_${i}`).prop('checked', true) break @@ -555,7 +555,7 @@ function customComp() { var my = JSON.parse(multi)[0].name var id = $('#custom-edit-sel').val() const defaults = [ - 'black','blue','brown','green','indigo','polar','snow','white' + 'black', 'blue', 'brown', 'green', 'indigo', 'polar', 'snow', 'white' ] if (id == 'add_new' || defaults.includes(id)) { id = makeCID() @@ -690,7 +690,7 @@ function customConnect(raw) { i++ } $('#custom_json').val(raw[1]) - if(args.default) { + if (args.default) { $('#delTheme').addClass('disabled') } } @@ -728,6 +728,107 @@ function customSoundSave(key, file) { localStorage.setItem('custom' + key, file) $(`#c${key}-file`).text(file) } +function pluginLoad() { + $('#plugin-edit-sel').val('add_new') + $(".plugin_delete").addClass('disabled') + var template = '' + var pgns = localStorage.getItem('plugins') + var args = JSON.parse(pgns ? pgns : '[]') + Object.keys(args).forEach(function (key) { + var theme = args[key] + var themeid = theme.id + template = template + `` + }) + template = '' + template + $('#plugin-edit-sel').html(template) + $('select').formSelect() +} +function pluginEdit() { + var id = $('#plugin-edit-sel').val() + $('#plugin').attr('data-id', id) + if (id == 'add_new') { + $('#plugin').val('') + $(".plugin_delete").addClass('disabled') + } else { + $(".plugin_delete").removeClass('disabled') + var pgns = localStorage.getItem('plugins') + var args = JSON.parse(pgns ? pgns : '[]') + Object.keys(args).forEach(function (key) { + var plugin = args[key] + var targetId = plugin.id + if (targetId == id) $('#plugin').val(plugin.content) + }) + } +} +function completePlugin(comp) { + var pgns = localStorage.getItem('plugins') + var args = JSON.parse(pgns ? pgns : '[]') + var id = $('#plugin').attr('data-id') + + var inputPlugin = $('#plugin').val() + var meta = getMeta(inputPlugin) + if (!meta) { + Swal.fire({ + icon: 'error', + title: 'error', + }) + return false + } + if (!meta.name || !meta.version || !meta.event || !meta.author) { + Swal.fire({ + icon: 'error', + title: 'error', + }) + return false + } + if (id == 'add_new') { + id = makeCID() + args.push({ + id: id, + content: inputPlugin + }) + } else { + Object.keys(args).forEach(function (key) { + var plugin = args[key] + var targetId = plugin.id + if (targetId == id) args[key].content = inputPlugin + }) + } + var ss = args + localStorage.setItem('plugins', JSON.stringify(ss)) + if(comp) return false + $('#plugin').attr('data-id', 'add_new') + $('#plugin').val('') + pluginLoad() +} +async function deletePlugin() { + const alert = await Swal.fire({ + title: 'delete', + icon: 'warning', + showCancelButton: true + }) + if (!alert) return false + $('#plugin').val('') + var pgns = localStorage.getItem('plugins') + var args = JSON.parse(pgns ? pgns : '[]') + var id = $('#plugin').attr('data-id') + $('#plugin').attr('data-id', 'add_new') + var ss = [] + Object.keys(args).forEach(function (key) { + var plugin = args[key] + var targetId = plugin.id + if (targetId != id) ss.push(plugin) + }) + localStorage.setItem('plugins', JSON.stringify(ss)) + pluginLoad() +} +function execEditPlugin() { + completePlugin(true) + var id = $('#plugin').attr('data-id') + var inputPlugin = $('#plugin').val() + var meta = getMeta(inputPlugin) + execPlugin(id, meta.event, { acct_id: 0, id: null }) +} window.onload = function () { //最初に読む load() @@ -738,6 +839,7 @@ window.onload = function () { voiceSettingLoad() oksload() ctLoad() + pluginLoad() $('body').addClass(localStorage.getItem('platform')) } //設定画面で未読マーカーは要らない diff --git a/app/view/make/language/en/setting.json b/app/view/make/language/en/setting.json index 33c63163..c6932c60 100644 --- a/app/view/make/language/en/setting.json +++ b/app/view/make/language/en/setting.json @@ -158,6 +158,9 @@ "keysc": "Keyboard shortcut Preferences", "iks": "Easy inserter", "okswarn": "You can insert any letters and emojis with only 3 keys", + "plugin": "Plugins", + "howToWritePlugin": "Japanese docs of AiScript TheDesk plugins", + "pluginList": "Plugin list", "muteemp": "Mute & Emphasis Preferences", "climute": "Client Mute", "cliemp": "Client Emphasis", diff --git a/app/view/make/language/ja-KS/setting.json b/app/view/make/language/ja-KS/setting.json index 333266d6..0478a551 100644 --- a/app/view/make/language/ja-KS/setting.json +++ b/app/view/make/language/ja-KS/setting.json @@ -156,6 +156,9 @@ "keysc": "キーボードショートカットの設定", "iks": "簡単文字入力", "okswarn": "絵文字やタグ、>BTなどを登録しておくとすぐに使えてええ感じや。", + "plugin": "プラグイン", + "howToWritePlugin": "AiScriptでTheDeskプラグイン書いたろ!", + "pluginList": "プラグイン一覧", "muteemp": "ミュート・強調の設定", "climute": "クライアントミュート", "cliemp": "クライアント強調", diff --git a/app/view/make/language/ja/setting.json b/app/view/make/language/ja/setting.json index 02fa9c0d..2f04bf09 100644 --- a/app/view/make/language/ja/setting.json +++ b/app/view/make/language/ja/setting.json @@ -155,6 +155,9 @@ "zeroWidthEmoji": "絵文字にゼロ幅スペースを使う", "uploadCrop": "添付画像の自動リサイズ", "uploadCropWarn": "最大の長辺ピクセル指定。JPEG以外は自動でPNGイメージに変換されます。大きなGIFアニメは静止画になります。0に設定するとリサイズしません。", + "plugin": "プラグイン", + "howToWritePlugin": "AiScriptによるTheDeskプラグインの書き方", + "pluginList": "プラグイン一覧", "keysc": "キーボードショートカットの設定", "iks": "簡単文字入力", "okswarn": "絵文字やタグ、>BTなどを登録しておくとすぐに入力できます。", diff --git a/app/view/make/setting.sample.html b/app/view/make/setting.sample.html index e06d4ae7..1f9b6f88 100644 --- a/app/view/make/setting.sample.html +++ b/app/view/make/setting.sample.html @@ -398,10 +398,19 @@