mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-03-13 05:51:03 +00:00
add dummy URI shortener with link in .userMenu-config-dropdown
This commit is contained in:
parent
21ee46a466
commit
2c26754228
@ -49,6 +49,7 @@
|
||||
<a href="#" class="mini-profile-name">Fulano da Silva</a>
|
||||
<span class="mini-profile-view">View</span>
|
||||
</div>
|
||||
<a class="dropdown-menu-item uri-shortener" href="#">URI shortener</a>
|
||||
<a class="dropdown-menu-item" href="options.html">Options</a>
|
||||
<a class="dropdown-menu-item" href="network.html">Network config</a>
|
||||
<a class="dropdown-menu-item" href="profile-edit.html">Setup account</a>
|
||||
|
@ -802,6 +802,30 @@ function openConversationModal(peerAlias, resource) {
|
||||
});
|
||||
}
|
||||
|
||||
function openRequestShortURIForm() {
|
||||
if (!defaultScreenName) {
|
||||
alertPopup({
|
||||
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
|
||||
txtMessage: 'You can\'t short links because you are not logged in.'
|
||||
});
|
||||
}
|
||||
var uri = prompt('enter a link, watch yourself carefully'); // FIXME
|
||||
newShortURI(uri,
|
||||
function (req, uriLong, uriShort) {
|
||||
if (uriShort)
|
||||
alertPopup({
|
||||
txtTitle: 'URI shortener',
|
||||
txtMessage: uriLong + ' — `' + uriShort + '`'
|
||||
});
|
||||
else
|
||||
alertPopup({
|
||||
txtTitle: 'URI shortener',
|
||||
txtMessage: 'something went wrong. RPC error message:\n' + (uriShort && uriShort.message) ? uriShort.message : uriShort
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function fillElemWithTxt(elem, txt, htmlFormatMsgOpt) {
|
||||
var formatted = htmlFormatMsg(txt, htmlFormatMsgOpt);
|
||||
|
||||
@ -2251,6 +2275,8 @@ function initInterfaceCommon() {
|
||||
$('.tox-ctc').on('click', promptCopyAttrData);
|
||||
$('.bitmessage-ctc').on('click', promptCopyAttrData);
|
||||
|
||||
$('.uri-shortener').on('click', openRequestShortURIForm); // FIXME implement Uri Shortener Center with links library etc
|
||||
|
||||
if ($.fn.textcomplete) {
|
||||
$('.post-area-new textarea')
|
||||
.on('focus', {req: getMentionsForAutoComplete}, setTextcompleteOnEventTarget)
|
||||
|
@ -322,6 +322,37 @@ function newRtMsg(postData, msg) {
|
||||
}
|
||||
}
|
||||
|
||||
function newShortURI(uri, cbFunc, cbReq) {
|
||||
if (!uri || !defaultScreenName) return;
|
||||
|
||||
for (var i in twister.URIs)
|
||||
if (twister.URIs[i] === uri) {
|
||||
if (typeof cbFunc === 'function')
|
||||
cbFunc(cbReq, uri, i);
|
||||
return;
|
||||
}
|
||||
|
||||
twisterRpc('newshorturl', [defaultScreenName, lastPostId + 1, uri],
|
||||
function (req, ret) {
|
||||
if (ret) {
|
||||
ret = ret[0]; // FIXME there should be 1 element anyway for daemon version 93500
|
||||
twister.URIs[ret] = req.uri;
|
||||
$.localStorage.set('twistaURIs', twister.URIs);
|
||||
incLastPostId();
|
||||
} else
|
||||
console.warn('RPC "newshorturl" error: empty response');
|
||||
|
||||
if (typeof req.cbFunc === 'function')
|
||||
req.cbFunc(req.cbReq, req.uri, ret);
|
||||
}, {uri: uri, cbFunc: cbFunc, cbReq: cbReq},
|
||||
function (req, ret) {
|
||||
console.warn('RPC "newshorturl" error: ' + (ret && ret.message) ? ret.message : ret);
|
||||
if (typeof req.cbFunc === 'function')
|
||||
req.cbFunc(req.cbReq, req.uri, ret);
|
||||
}, {uri: uri, cbFunc: cbFunc, cbReq: cbReq}
|
||||
);
|
||||
}
|
||||
|
||||
function updateProfileData(profileModalContent, username) {
|
||||
|
||||
//profileModalContent.find("a").attr("href",$.MAL.userUrl(username));
|
||||
|
Loading…
x
Reference in New Issue
Block a user