introduce uuid yeah

This commit is contained in:
cutls 2021-06-19 19:16:08 +09:00
parent 679151e8ea
commit ab460d1401
11 changed files with 1897 additions and 1890 deletions

2
.gitignore vendored
View File

@ -26,7 +26,7 @@ app/git
*.code-workspace
releasenote.md
app/yarn-error.log
app/js/platform/aiscript.js
app/js/platform/native.js
app/view/es-ES
app/view/fr-FR
app/view/no-NO

View File

@ -1,312 +1,303 @@
window.onload = function () {
console.log('loaded')
initPostbox()
connection()
initPlugin(plugins)
if (localStorage.getItem('control-center-np')) $('#ccnp').removeClass('hide')
window.onload = function() {
console.log('loaded')
initPostbox()
connection()
initPlugin(plugins)
if (localStorage.getItem('control-center-np')) $('#ccnp').removeClass('hide')
}
$.strip_tags = function (str, allowed) {
if (!str) {
return ''
}
allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('')
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi,
commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi
return str.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''
})
$.strip_tags = function(str, allowed) {
if (!str) {
return ''
}
allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('')
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi,
commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi
return str.replace(commentsAndPhpTags, '').replace(tags, function($0, $1) {
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''
})
}
function escapeHTML(str) {
if (!str) {
return ''
}
return str
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
if (!str) {
return ''
}
return str
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
}
//PHPのnl2brと同様
function nl2br(str) {
if (!str) {
return ''
}
str = str.replace(/\r\n/g, '<br />')
str = str.replace(/(\n|\r)/g, '<br />')
return str
if (!str) {
return ''
}
str = str.replace(/\r\n/g, '<br />')
str = str.replace(/(\n|\r)/g, '<br />')
return str
}
function br2nl(str) {
if (!str) {
return ''
}
str = str.replace(/<br \/>/g, '\r\n')
return str
if (!str) {
return ''
}
str = str.replace(/<br \/>/g, '\r\n')
return str
}
function formattime(date) {
var str = date.getFullYear() + '-'
if (date.getMonth() + 1 < 10) {
str = str + '0' + (date.getMonth() + 1) + '-'
} else {
str = str + (date.getMonth() + 1) + '-'
}
if (date.getDate() < 10) {
str = str + '0' + date.getDate()
} else {
str = str + date.getDate()
}
str = str + 'T'
if (date.getHours() < 10) {
str = str + '0' + date.getHours() + ':'
} else {
str = str + date.getHours() + ':'
}
if (date.getMinutes() < 10) {
str = str + '0' + date.getMinutes()
} else {
str = str + date.getMinutes()
}
return escapeHTML(str)
var str = date.getFullYear() + '-'
if (date.getMonth() + 1 < 10) {
str = str + '0' + (date.getMonth() + 1) + '-'
} else {
str = str + (date.getMonth() + 1) + '-'
}
if (date.getDate() < 10) {
str = str + '0' + date.getDate()
} else {
str = str + date.getDate()
}
str = str + 'T'
if (date.getHours() < 10) {
str = str + '0' + date.getHours() + ':'
} else {
str = str + date.getHours() + ':'
}
if (date.getMinutes() < 10) {
str = str + '0' + date.getMinutes()
} else {
str = str + date.getMinutes()
}
return escapeHTML(str)
}
function formattimeutc(date) {
var str = date.getUTCFullYear() + '-'
if (date.getUTCMonth() + 1 < 10) {
str = str + '0' + (date.getUTCMonth() + 1) + '-'
} else {
str = str + (date.getUTCMonth() + 1) + '-'
}
if (date.getUTCDate() < 10) {
str = str + '0' + date.getUTCDate()
} else {
str = str + date.getUTCDate()
}
str = str + 'T'
if (date.getUTCHours() < 10) {
str = str + '0' + date.getUTCHours() + ':'
} else {
str = str + date.getUTCHours() + ':'
}
if (date.getUTCMinutes() < 10) {
str = str + '0' + date.getUTCMinutes()
} else {
str = str + date.getUTCMinutes()
}
return escapeHTML(str)
var str = date.getUTCFullYear() + '-'
if (date.getUTCMonth() + 1 < 10) {
str = str + '0' + (date.getUTCMonth() + 1) + '-'
} else {
str = str + (date.getUTCMonth() + 1) + '-'
}
if (date.getUTCDate() < 10) {
str = str + '0' + date.getUTCDate()
} else {
str = str + date.getUTCDate()
}
str = str + 'T'
if (date.getUTCHours() < 10) {
str = str + '0' + date.getUTCHours() + ':'
} else {
str = str + date.getUTCHours() + ':'
}
if (date.getUTCMinutes() < 10) {
str = str + '0' + date.getUTCMinutes()
} else {
str = str + date.getUTCMinutes()
}
return escapeHTML(str)
}
postMessage(['sendSinmpleIpc', 'custom-css-request'], '*')
function makeCID() {
let chars = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split("")
for (let i = 0, len = chars.length; i < len; i++) {
switch (chars[i]) {
case "x":
chars[i] = Math.floor(Math.random() * 16).toString(16)
break
case "y":
chars[i] = (Math.floor(Math.random() * 4) + 8).toString(16)
break
}
}
return chars.join("")
}
function randomStr(l) {
// 生成する文字列に含める文字セット
var c = 'abcdefghijklmnopqrstuvwxyz0123456789'
var cl = c.length
var r = ''
for (var i = 0; i < l; i++) {
r += c[Math.floor(Math.random() * cl)]
}
return r
return uuid()
}
function rgbToHex(color) {
// HEXに変換したものを代入する変数
var hex = ''
// HEXに変換したものを代入する変数
var hex = ''
// 第1引数がHEXのとき変換処理は必要ないのでそのままreturn
// IE8の場合はjQueryのcss()関数でHEXを返すので除外
if (color.match(/^#[a-f\d]{3}$|^#[a-f\d]{6}$/i)) {
return color
}
// 第1引数がHEXのとき変換処理は必要ないのでそのままreturn
// IE8の場合はjQueryのcss()関数でHEXを返すので除外
if (color.match(/^#[a-f\d]{3}$|^#[a-f\d]{6}$/i)) {
return color
}
// 正規表現
var regex = color.match(/^rgb\(([0-9.]+),\s*([0-9.]+),\s*([0-9.]+)\)$/)
// 正規表現
var regex = color.match(/^rgb\(([0-9.]+),\s*([0-9.]+),\s*([0-9.]+)\)$/)
// 正規表現でマッチしたとき
if (regex) {
var rgb = [
// RGBからHEXへ変換
parseInt(regex[1]).toString(16),
parseInt(regex[2]).toString(16),
parseInt(regex[3]).toString(16)
]
// 正規表現でマッチしたとき
if (regex) {
var rgb = [
// RGBからHEXへ変換
parseInt(regex[1]).toString(16),
parseInt(regex[2]).toString(16),
parseInt(regex[3]).toString(16)
]
for (var i = 0; i < rgb.length; ++i) {
// rgb(1,1,1)のようなときHEXに変換すると1桁になる
// 1桁のときは前に0を足す
if (rgb[i].length == 1) {
rgb[i] = '0' + rgb[i]
}
hex += rgb[i]
}
for (var i = 0; i < rgb.length; ++i) {
// rgb(1,1,1)のようなときHEXに変換すると1桁になる
// 1桁のときは前に0を足す
if (rgb[i].length == 1) {
rgb[i] = '0' + rgb[i]
}
hex += rgb[i]
}
return hex
}
return hex
}
console.error(color + ':第1引数はRGB形式で入力')
console.error(color + ':第1引数はRGB形式で入力')
}
/*マルチバイト用切り出し*/
$.isSurrogatePear = function (upper, lower) {
return 0xd800 <= upper && upper <= 0xdbff && 0xdc00 <= lower && lower <= 0xdfff
$.isSurrogatePear = function(upper, lower) {
return 0xd800 <= upper && upper <= 0xdbff && 0xdc00 <= lower && lower <= 0xdfff
}
$.mb_strlen = function (str) {
var splitter = new GraphemeSplitter()
var arr = splitter.splitGraphemes(str)
return arr.length
$.mb_strlen = function(str) {
var splitter = new GraphemeSplitter()
var arr = splitter.splitGraphemes(str)
return arr.length
}
$.mb_substr = function (str, begin, end) {
//配列にする
var splitter = new GraphemeSplitter()
var arr = splitter.splitGraphemes(str)
var newarr = []
for (var i = 0; i < arr.length; i++) {
if (i >= begin && i <= end) {
newarr.push(arr[i])
}
}
return newarr.join('')
}
//ソートするやつ
$.mb_substr = function(str, begin, end) {
//配列にする
var splitter = new GraphemeSplitter()
var arr = splitter.splitGraphemes(str)
var newarr = []
for (var i = 0; i < arr.length; i++) {
if (i >= begin && i <= end) {
newarr.push(arr[i])
}
}
return newarr.join('')
}
//ソートするやつ
function object_array_sort(data, key, order, fn) {
var num_a = -1
var num_b = 1
if (order === 'asc') {
num_a = 1
num_b = -1
}
data = data.sort(function (a, b) {
var x = a[key]
var y = b[key]
if (x > y) return num_a
if (x < y) return num_b
return 0
})
var arrObj = {}
for (var i = 0; i < data.length; i++) {
arrObj[data[i]['family']] = data[i]
}
data = []
for (var key in arrObj) {
data.push(arrObj[key])
}
fn(data)
var num_a = -1
var num_b = 1
if (order === 'asc') {
num_a = 1
num_b = -1
}
data = data.sort(function(a, b) {
var x = a[key]
var y = b[key]
if (x > y) return num_a
if (x < y) return num_b
return 0
})
var arrObj = {}
for (var i = 0; i < data.length; i++) {
arrObj[data[i]['family']] = data[i]
}
data = []
for (var key in arrObj) {
data.push(arrObj[key])
}
fn(data)
}
function setLog(txt1, txt2, txt3) {
//url,statuscode,responsetext
var text = new Date().toUTCString()
text = text + ',' + txt1 + ',' + txt2 + ',' + escapeCsv(txt3)
console.error(text)
postMessage(['log', text], '*')
//url,statuscode,responsetext
var text = new Date().toUTCString()
text = text + ',' + txt1 + ',' + txt2 + ',' + escapeCsv(txt3)
console.error(text)
postMessage(['log', text], '*')
}
function escapeCsv(str) {
if (!str) {
return str
}
var result
result = str.toString().replace(/\"/g, '""')
if (result.indexOf(',') >= 0) {
result = '"' + result + '"'
}
return result
if (!str) {
return str
}
var result
result = str.toString().replace(/\"/g, '""')
if (result.indexOf(',') >= 0) {
result = '"' + result + '"'
}
return result
}
function evalAttr(json, attr, lenCk) {
if (json[attr]) {
if (lenCk) {
if (json[attr][0]) {
return true
} else {
return false
}
} else {
return true
}
} else {
return false
}
if (json[attr]) {
if (lenCk) {
if (json[attr][0]) {
return true
} else {
return false
}
} else {
return true
}
} else {
return false
}
}
function statusModel(now) {
if (!now) {
var now = new Date().toString()
}
return {
id: '',
created_at: now,
in_reply_to_id: null,
in_reply_to_account_id: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
language: 'en',
uri: '',
url: '',
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
favourited: false,
reblogged: false,
muted: false,
bookmarked: false,
pinned: false,
content: '<p><i>No status here</i></p>',
reblog: null,
application: {
name: null,
website: null
},
account: {
id: '',
username: '',
acct: '',
display_name: '',
locked: false,
bot: false,
created_at: now,
note: '',
url: '',
avatar: '',
avatar_static: '',
header: '',
header_static: '',
followers_count: 0,
following_count: 0,
statuses_count: 0,
last_status_at: now,
emojis: [],
fields: []
},
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null
}
if (!now) {
var now = new Date().toString()
}
return {
id: '',
created_at: now,
in_reply_to_id: null,
in_reply_to_account_id: null,
sensitive: false,
spoiler_text: '',
visibility: 'public',
language: 'en',
uri: '',
url: '',
replies_count: 0,
reblogs_count: 0,
favourites_count: 0,
favourited: false,
reblogged: false,
muted: false,
bookmarked: false,
pinned: false,
content: '<p><i>No status here</i></p>',
reblog: null,
application: {
name: null,
website: null
},
account: {
id: '',
username: '',
acct: '',
display_name: '',
locked: false,
bot: false,
created_at: now,
note: '',
url: '',
avatar: '',
avatar_static: '',
header: '',
header_static: '',
followers_count: 0,
following_count: 0,
statuses_count: 0,
last_status_at: now,
emojis: [],
fields: []
},
media_attachments: [],
mentions: [],
tags: [],
card: null,
poll: null
}
}
function webviewFinder() {
const webview = document.querySelector('webview')
webview.addEventListener('did-navigate', (e) => {
const url = webview.getURL()
if (url.match('https://mobile.twitter.com/login')) {
postMessage(['twitterLogin', null], '*')
} else if (url.match('https://mobile.twitter.com/logout')) {
postMessage(['twitterLogin', true], '*')
}
})
const webview = document.querySelector('webview')
webview.addEventListener('did-navigate', (e) => {
const url = webview.getURL()
if (url.match('https://mobile.twitter.com/login')) {
postMessage(['twitterLogin', null], '*')
} else if (url.match('https://mobile.twitter.com/logout')) {
postMessage(['twitterLogin', true], '*')
}
})
}
function initWebviewEvent() {
if (document.querySelector('webview')) { webviewFinder() } else {
const timerWV = setInterval(function () {
document.querySelector('webview')
? (webviewFinder(), clearInterval(timerWV))
: console.log('まだロード中')
}, 500)
}
if (document.querySelector('webview')) { webviewFinder() } else {
const timerWV = setInterval(function() {
document.querySelector('webview') ?
(webviewFinder(), clearInterval(timerWV)) :
console.log('まだロード中')
}, 500)
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
const { AiScript, parse, values, utils } = require('@syuilo/aiscript')
const gcc = require('textarea-caret')
const { v4: uuidv4 } = require('uuid')
global.uuid = uuidv4
global.getCaretCoordinates = gcc
global.sanitizeHtml = require('sanitize-html')
global.asValue = values

View File

@ -9,7 +9,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "run-s util:*",
"util:hash": "node gitHash.js",
"util:browserify": "browserify aiscript.js -o js/platform/aiscript.js",
"util:browserify": "browserify native.js -o js/platform/native.js",
"construct": "node view/make/makeCli.js",
"construct:store": "node view/make/makeCli.js --store",
"dev": "run-p dev:*",
@ -38,7 +38,8 @@
"url": "https://cutls.dev",
"email": "p@cutls.com"
},
"contributor": [{
"contributor": [
{
"name": "とねぢ",
"url": "https://minohdon.jp/@toneji",
"email": "solfa.tono@gmail.com"
@ -71,6 +72,7 @@
"sweetalert2": "^11.0.17",
"system-font-families": "^0.4.1",
"textarea-caret": "^3.1.0",
"uuid": "^8.3.2",
"vue": "^2.6.14"
},
"devDependencies": {
@ -89,4 +91,4 @@
"@types/fs-extra": "9.0.11",
"plist": "3.0.2"
}
}
}

View File

@ -1055,7 +1055,7 @@
<!--JS-->
<script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../../js/platform/first.js"></script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../@@node_base@@/materialize-css/dist/js/materialize.js"></script>
<script type="text/javascript" src="../../@@node_base@@/grapheme-splitter/index.js"></script>

View File

@ -683,7 +683,7 @@
apiGet: no
}`, -1)
</script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../js/common/modal.js"></script>
<script type="text/javascript" src="../../js/common/about.js"></script>

View File

@ -25,8 +25,8 @@
<body class="">
<script>
var ver = '22.2.0 (Koume)'
var gitHash = 'da76c6732db27e91a895277d14fd16f0c1434679'
var ver = '22.3.0 (Koume)'
var gitHash = '679151e8eadafebe68b8c0887e9189caeb94474e'
//betaを入れるとバージョンチェックしない
//var ver="beta";
var acct_id = 0
@ -1055,7 +1055,7 @@
<!--JS-->
<script type="text/javascript" src="../../node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="../../js/platform/first.js"></script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../node_modules/materialize-css/dist/js/materialize.js"></script>
<script type="text/javascript" src="../../node_modules/grapheme-splitter/index.js"></script>

View File

@ -645,7 +645,7 @@
class="material-icons left">list</i>Help/Docs</a>
<a href="https://github.com/cutls/TheDesk" class="btn waves-effect black lighten-2" style="width:100%; max-width:40rem;"><i class="fab fa-github left"></i>GitHub</a>
<a href="index.html?mode=user&code=Cutls@1m.cutls.com" class="btn waves-effect blue lighten-2" style="width:100%; max-width:40rem;"><img src="../../img/desk_full.svg" class="left" width="25" style="padding-top:5px;">Main author: Cutls@1m.cutls.com</a>
<br> TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/da76c6732db27e91a895277d14fd16f0c1434679">da76c6732db27e91a895277d14fd16f0c1434679</a> - <a onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';" class="pointer pwa">Sprawdź aktualizacje</a><br>
<br> TheDesk @ <a href="https://github.com/cutls/TheDesk/commits/679151e8eadafebe68b8c0887e9189caeb94474e">679151e8eadafebe68b8c0887e9189caeb94474e</a> - <a onclick="checkupd(); return localStorage.removeItem('new-ver-skip'); location.href='index.html';" class="pointer pwa">Sprawdź aktualizacje</a><br>
<br> Kyash
<br>
<img src="../../img/kyash.png" width="100"><br>
@ -653,7 +653,7 @@
<img src="https://status.cutls.com/badge-service?site=thedesk.top">
</a><br>
<h5>OSS License</h5>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/da76c6732db27e91a895277d14fd16f0c1434679" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a>
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2Fcutls%2FTheDesk/refs/branch/master/679151e8eadafebe68b8c0887e9189caeb94474e" alt="FOSSA Status"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcutls%2FTheDesk.svg?type=small" /></a>
<br>
<span style="font-family:Open Sans;">Copyright &copy; TheDesk 2018
Under <a href="https://github.com/cutls/TheDesk/blob/master/LICENSE">GNU General Public License v3.0</a> and <a
@ -683,7 +683,7 @@
apiGet: no
}`, -1)
</script>
<script type="text/javascript" src="../../js/platform/aiscript.js"></script>
<script type="text/javascript" src="../../js/platform/native.js"></script>
<script type="text/javascript" src="../../js/platform/plugin.js"></script>
<script type="text/javascript" src="../../js/common/modal.js"></script>
<script type="text/javascript" src="../../js/common/about.js"></script>

View File

@ -5246,6 +5246,11 @@ uuid@^3.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.3.tgz#4568f0216e78760ee1dbf3a4d2cf53e224112866"
integrity sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==
uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
v8-compile-cache@^2.0.3:
version "2.1.1"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745"