Skip to content

Commit

Permalink
Added link to private chat in "Last seen"-List
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthyG committed Apr 15, 2017
1 parent a924ff4 commit b578b6b
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 44 deletions.
4 changes: 4 additions & 0 deletions css/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -1864,4 +1864,8 @@ body>*>*>*>*::-webkit-scrollbar-thumb {
.dropdown-menu-messageinput .textcomplete-footer>a.active {
background: #e5fcf7;
color: #1de9b6;
}

dl dd+dd {
margin-top: -1.5rem;
}
4 changes: 4 additions & 0 deletions css/zstyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,8 @@ body>*>*>*>*::-webkit-scrollbar-thumb {
.dropdown-menu-messageinput .textcomplete-footer>a.active {
background: #e5fcf7;
color: #1de9b6;
}

dl dd+dd {
margin-top: -1.5rem;
}
70 changes: 42 additions & 28 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
</div>-->
</div>

<div id="inputsC2" class="panel-footer #fixed shadow-drop-top">
<div id="inputsC2" class="panel-footer #fixed shadow-drop-top inputsC2">
<div class="hide" id="media_preview">
<figure class="figure">
<img src="" class="img-responsive img-fit-contain" alt="" />
Expand Down Expand Up @@ -169,7 +169,7 @@
<ul id="private_messages" class="unstyled message-list"></ul>
</div>

<div id="private_inputsC2" class="panel-footer #fixed shadow-drop-top">
<div id="private_inputsC2" class="panel-footer #fixed shadow-drop-top inputsC2">
<div class="hide" id="private_media_preview">
<figure class="figure">
<img src="" class="img-responsive img-fit-contain" alt="" />
Expand All @@ -191,9 +191,9 @@
<div tab="LastSeen" class="panel">
<div class="panel-body" style="overflow-x: hidden;">
<p>Total number of logged-in users: <b id="last_seen_list_c">0</b></p>
<ul id="last_seen_list">
<dl id="last_seen_list">

</ul>
</dl>
</div>
</div>

Expand Down Expand Up @@ -343,16 +343,14 @@ <h6 class='col-12' style='margin-bottom: .4rem;'><a href='?u/{{username}}'>{{use
function add2PMSGInput(text) {
$('#private_message').val($('#private_message').val() + text)
}
</script>
<script type="text/javascript" src="js/all.js"></script>
<script>
(function() {
$("body").addClass("loaded")

$(".workin-tabber").each(function(elX, elY) {
function workinTabberS(s) {
var s = s || '.workin-tabber'
$(s).each(function(elX, elY) {
var $dis = $(elY)
var $dis4 = $('.workin-tabber[tabs-target="' + $dis.attr('tabs-target') + '"]')
var $dis2 = $($dis.attr('tabs-target'))
var mtab = $dis.attr('tabs-target')

var $dis2 = $(mtab)

var curtab = $dis2.attr('curtab')
var $curtab = $dis2.find('[tab="' + curtab + '"]')
Expand All @@ -361,27 +359,43 @@ <h6 class='col-12' style='margin-bottom: .4rem;'><a href='?u/{{username}}'>{{use

// console.log($dis, $dis2, curtab, $curtab)

$dis.find('[target-tab]').on('click', function() {
var $dis3 = $(this)
var $tt = $dis.find('[target-tab]')
$tt.off('click')
$tt.on('click', function() {
changeWorkinTabber(mtab, $(this).attr("target-tab"))
})
})
}

function changeWorkinTabber(mtab, ntab) {
var $dis = $('.workin-tabber[tabs-target="' + mtab + '"]')
var $dis2 = $(mtab)

var curtab = $dis2.attr('curtab')
var $curtab = $dis2.find('[tab="' + curtab + '"]')
var $dis3 = $dis.find('[target-tab="' + ntab + '"]')
var curtab = $dis2.attr('curtab')
var $curtab = $dis2.find('[tab="' + curtab + '"]')

var ncurtab = $dis3.attr('target-tab')
var $ncurtab = $dis2.find('[tab="' + ncurtab + '"]')
var ncurtab = ntab
var $ncurtab = $dis2.find('[tab="' + ncurtab + '"]')

// console.log($dis3, ncurtab, $ncurtab)
$dis.find('[target-tab="' + curtab + '"]').parent().removeClass("active")
$dis3.parent().addClass("active")

$dis4.find('[target-tab="' + curtab + '"]').parent().removeClass("active")
$dis3.parent().addClass("active")
$curtab.hide()
$ncurtab.show()

$curtab.hide()
$ncurtab.show()
$dis2.attr('curtab', ncurtab)
config$bH()

$dis2.attr('curtab', ncurtab)
config$bH()
})
})
// console.log(mtab, ntab, $dis, $dis2, $dis3, $curtab, $ncurtab)
}
</script>
<script type="text/javascript" src="js/all.js"></script>
<script>
(function() {
$("body").addClass("loaded")

workinTabberS()

$('.message').textcomplete([{
match: /\B:([\-+\w]*)$/,
Expand Down Expand Up @@ -423,7 +437,7 @@ <h6 class='col-12' style='margin-bottom: .4rem;'><a href='?u/{{username}}'>{{use
index: 1,
maxCount: 5
}], {
appendTo: '#inputsC2',
appendTo: '.inputsC2',
dropdownClassName: 'menu dropdown-menu-messageinput',
footer: '<a href="https://emoji.codes" target="_blank">Browse All<span class="arrow">»</span></a>',
maxCount: 5
Expand Down
89 changes: 81 additions & 8 deletions js/all.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 81 additions & 8 deletions js/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,13 @@ class ThunderWave extends ZeroFrame {
// "inner_path": data2_inner_path,
// "required": false
// }, (data2) => {
if (data2)
var data2 = JSON.parse(data2)
else
var data2 = {}

var data2 = data2 || {}

// if (data2)
// var data2 = JSON.parse(data2)
// else
// var data2 = {}

if (!data2.hasOwnProperty("private_messages"))
data2.private_messages = []
Expand Down Expand Up @@ -756,6 +759,8 @@ class ThunderWave extends ZeroFrame {
var override = override || false
var goingback = goingback || false

changeWorkinTabber('#main-tabs', 'PrivateChat');

page.cmd("dbQuery", [
"SELECT * FROM private_messages LEFT JOIN json USING (json_id) WHERE cert_user_id = '" + sender + "'"
], (messages1) => {
Expand Down Expand Up @@ -1211,17 +1216,85 @@ class ThunderWave extends ZeroFrame {
console.log("Loading last-seen-List")
var count = 0
this.cmd("dbQuery", [
"SELECT * FROM keyvalue LEFT JOIN json USING (json_id) WHERE key = 'last_seen' AND value NOT NULL ORDER BY value DESC"
"SELECT * FROM keyvalue LEFT JOIN json USING (json_id) WHERE key = 'last_seen' AND keyvalue.value NOT NULL OR key = 'public_key' AND keyvalue.value NOT NULL ORDER BY keyvalue.json_id"
], (lsl) => {
var lsl_HTML = ''

var lsl2 = []
for (var x in lsl) {
var y = lsl[x]
if (y) {
lsl_HTML += '<li><b>' + y.cert_user_id + '</b> was last seen <i>' + moment(y.value, "x").format("MMMM Do, YYYY - HH:mm:ss") + '</i></li>'
count++
if (!lsl2[y.json_id])
lsl2[y.json_id] = {
"y1": false,
"y2": false
}

if (y.key === "last_seen")
lsl2[y.json_id].y1 = y
else if (y.key === "public_key")
lsl2[y.json_id].y2 = y
}
}

console.log(lsl2)

lsl2.sort(function(a, b) {
if (typeof a.y1 === "object" && a.y1.key === "last_seen")
var A = a.y1.value
else
var A = -1

if (typeof b.y1 === "object" && b.y1.key === "last_seen")
var B = b.y1.value
else
var B = -1

console.log(a, b, A, B, A < B)

if (A < B) return 1
if (A > B) return -1
return 0
})

for (var x in lsl2) {
var y = lsl2[x]

var y1 = y.y1,
y2 = y.y2

var y3 = y1 || y2

lsl_HTML += '<dt class="divider" data-content="' + y3.cert_user_id + '"></dt>'

if (y1)
lsl_HTML += '<dd>last seen <i>' + moment(y1.value, "x").format("MMMM Do, YYYY - HH:mm:ss") + '</i></dd>'
if (y2)
lsl_HTML += '<dd>public key: <a href="javascript:page.loadPrivateMessages(\'selected user\', true, \'' + y3.cert_user_id + '\');$(\'#private_recipient\').val(\'' + y3.cert_user_id + '\');"><i>' + y2.value + '</i></a></dd>'
}
// for (var x in lsl1) {
// var y1 = lsl1[x]
// console.log(lsl1, y1)
// // this.cmd("dbQuery", [
// // "SELECT * FROM keyvalue LEFT JOIN json USING (json_id) WHERE key = 'public_key' AND value NOT NULL AND keyvalue.json_id = '" + y1.json_id + "' ORDER BY value DESC"
// // ], (y2) => {
// // console.log(y1, y2)

// // lsl_HTML += '<dt class="divider" data-content="' + y1.cert_user_id + '"></dt>'

// // if (y1 && y1.value)
// // lsl_HTML += '<dd>last seen <i>' + moment(y1.value, "x").format("MMMM Do, YYYY - HH:mm:ss") + '</i></dd>'

// // if (y2 && y2.value)
// // lsl_HTML += '<dd>public key: <a href="javascript:page.loadPrivateMessages(\'selected user\', true, \'' + y2.cert_user_id + '\');$(\'#private_recipient\').val(\'' + y2.cert_user_id + '\');"><i>' + y2.value + '</i></a></dd>'
// // else
// // lsl_HTML += '<dd><i>no public key found</i></dd>'

// // count++
// // })
// }
$('#last_seen_list').html(lsl_HTML)

$('#last_seen_list_c').html(count)
})
}
Expand Down Expand Up @@ -1814,7 +1887,7 @@ class ThunderWave extends ZeroFrame {

console.log("VERIFIED data_private.json", olddata, data)

addPrivateContact(page.site_info.cert_user_id, function(data2, cList) {
page.addPrivateContact(page.site_info.cert_user_id, function(data2, cList) {
var json_raw = unescape(encodeURIComponent(JSON.stringify(data2, undefined, '\t')))
var json_rawA = btoa(json_raw)

Expand Down

0 comments on commit b578b6b

Please sign in to comment.