second instance to customurl
This commit is contained in:
@@ -423,10 +423,6 @@ function login(url) {
|
||||
versionChecker(url)
|
||||
$('#add').hide()
|
||||
postMessage(['openUrl', auth], '*')
|
||||
if ($('#linux:checked').val() == 'on') {
|
||||
} else {
|
||||
postMessage(['sendSinmpleIpc', 'quit'], '*')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -625,15 +621,16 @@ function misskeyAuth(url, mkc) {
|
||||
|
||||
//テキストボックスにURL入れた
|
||||
function instance() {
|
||||
var url = $('#url').val()
|
||||
var url = $('#autocomplete-input').val()
|
||||
if (url.indexOf('@') != -1 || url.indexOf('https') != -1) {
|
||||
alert('入力形式が違います。(Cutls@mstdn.jpにログインする場合、入力するのは"mstdn.jp"です。)')
|
||||
return false
|
||||
}
|
||||
login(url)
|
||||
login(url)
|
||||
}
|
||||
//コード入れてAccessTokenゲット
|
||||
function code(code) {
|
||||
var red = localStorage.getItem('redirect')
|
||||
localStorage.removeItem('redirect')
|
||||
if (!code) {
|
||||
var code = $('#code').val()
|
||||
@@ -696,7 +693,7 @@ function code(code) {
|
||||
}
|
||||
return
|
||||
} else {
|
||||
var red = 'urn:ietf:wg:oauth:2.0:oob'
|
||||
if (!red) red = 'urn:ietf:wg:oauth:2.0:oob'
|
||||
if (~url.indexOf('pixelfed')) {
|
||||
red = 'https://thedesk.top/hello.html'
|
||||
}
|
||||
@@ -720,6 +717,7 @@ function code(code) {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error: cannot complete', displayLength: 5000 })
|
||||
setLog(start, this.status, json)
|
||||
}
|
||||
if (json['access_token']) {
|
||||
@@ -1089,15 +1087,14 @@ function coloradd(key, bg, txt) {
|
||||
//入力時にハッシュタグと@をサジェスト
|
||||
var timer = null
|
||||
|
||||
var input = document.getElementById('url')
|
||||
|
||||
var input = document.getElementById('autocomplete-input')
|
||||
var prev_val = input.value
|
||||
var oldSuggest
|
||||
var suggest
|
||||
input.addEventListener(
|
||||
'focus',
|
||||
function () {
|
||||
$('#ins-suggest').html('')
|
||||
const instance = M.Autocomplete.getInstance(input)
|
||||
window.clearInterval(timer)
|
||||
timer = window.setInterval(function () {
|
||||
var new_val = input.value
|
||||
@@ -1108,7 +1105,7 @@ input.addEventListener(
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
@@ -1125,21 +1122,20 @@ input.addEventListener(
|
||||
})
|
||||
.then(function (json) {
|
||||
if (!json.error) {
|
||||
var urls = 'Suggest:'
|
||||
let data = {}
|
||||
Object.keys(json.data).forEach(function (key) {
|
||||
var url = json.data[key]
|
||||
urls =
|
||||
urls +
|
||||
`<a onclick="login('${url.uri}')" class="pointer" title="${url.uri}">${escapeHTML(url.title ? url.title : url.uri)}</a>, `
|
||||
data[url.uri] = escapeHTML(url.title ? url.title : url.uri)
|
||||
})
|
||||
$('#ins-suggest').html(urls)
|
||||
instance.updateData(data)
|
||||
instance.open()
|
||||
} else {
|
||||
console.error(json.error)
|
||||
}
|
||||
})
|
||||
}
|
||||
oldSuggest = suggest
|
||||
prev_value = new_val
|
||||
prev_val = new_val
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
@@ -1157,3 +1153,12 @@ input.addEventListener(
|
||||
function asReadEnd() {
|
||||
postMessage(['asReadComp', ''], '*')
|
||||
}
|
||||
|
||||
// Or with jQuery
|
||||
|
||||
$(document).ready(function(){
|
||||
$('input.autocomplete').autocomplete({
|
||||
data: {},
|
||||
});
|
||||
});
|
||||
|
@@ -186,7 +186,7 @@ onmessage = function (e) {
|
||||
} else if (e.data[0] == 'asReadEnd') {
|
||||
asReadEnd()
|
||||
} else if (e.data[0] == 'accessibility') {
|
||||
console.log('atrue')
|
||||
console.log('accessibility mode')
|
||||
$('body').addClass('accessibility')
|
||||
$('.window-title').before('<div class="accessMark">Screen Reader Optimized</div>')
|
||||
} else if (e.data[0] == 'logData') {
|
||||
@@ -200,6 +200,22 @@ onmessage = function (e) {
|
||||
})
|
||||
} else if (e.data[0] == 'twitterLoginComplete') {
|
||||
location.reload()
|
||||
} else if (e.data[0] == 'customUrl') {
|
||||
const mode = e.data[1][0]
|
||||
const codex = e.data[1][1]
|
||||
if (mode === 'share') {
|
||||
$('textarea').focus()
|
||||
$('#textarea').val(decodeURI(codex))
|
||||
show()
|
||||
$('body').removeClass('mini-post')
|
||||
$('.mini-btn').text('expand_less')
|
||||
} else if (mode === 'manager' || mode === 'login') {
|
||||
code(codex)
|
||||
} else if (mode === 'spotify') {
|
||||
var coder = codex.split(':')
|
||||
localStorage.setItem('spotify', coder[0])
|
||||
localStorage.setItem('spotify-refresh', coder[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
/* PWA */
|
||||
@@ -236,3 +252,34 @@ const connection = function (event) {
|
||||
}
|
||||
window.onoffline = connection
|
||||
window.ononline = connection
|
||||
|
||||
let lastSelection = null
|
||||
let isSame = true
|
||||
$(document).on('keyup mouseup', function (e) {
|
||||
lastSelection = (window.getSelection().toString() !== '') ? window.getSelection().getRangeAt(0) : null
|
||||
if (!isSame) $('#pageSrc').addClass('hide')
|
||||
})
|
||||
|
||||
// カスタム右クリックメニュー
|
||||
$(document).on('contextmenu', function (e) {
|
||||
// テキスト選択中であれば何もしない
|
||||
if (lastSelection !== null) {
|
||||
const currentSelection = window.getSelection().getRangeAt(0)
|
||||
for (let key in currentSelection) {
|
||||
if (currentSelection[key] != lastSelection[key]) {
|
||||
isSame = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (isSame && currentSelection != '') {
|
||||
$('#pageSrc').removeClass('hide')
|
||||
$('#pageSrc').css('left', e.pageX)
|
||||
$('#pageSrc').css('top', e.pageY)
|
||||
$('.srcQ').text(currentSelection)
|
||||
}
|
||||
}
|
||||
})
|
||||
$('textarea, input').on('contextmenu', function (e) {
|
||||
postMessage(['textareaContextMenu', { x: e.pageX, y: e.pageY }], '*')
|
||||
})
|
Reference in New Issue
Block a user