use pad titles in home page table
This commit is contained in:
parent
a3da10766a
commit
47edccf42d
1 changed files with 47 additions and 33 deletions
|
@ -46,9 +46,9 @@
|
||||||
table.scroll thead { display: block; }
|
table.scroll thead { display: block; }
|
||||||
|
|
||||||
table.scroll tbody {
|
table.scroll tbody {
|
||||||
max-height: 100px;
|
/* max-height: 100px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden; */
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody { border-top: 2px solid black; }
|
tbody { border-top: 2px solid black; }
|
||||||
|
@ -68,6 +68,7 @@
|
||||||
|
|
||||||
.remove {
|
.remove {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
color: #ab0000;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="/bower_components/requirejs/require.js"></script>
|
<script src="/bower_components/requirejs/require.js"></script>
|
||||||
|
@ -163,46 +164,59 @@
|
||||||
'/code/': 'Code'
|
'/code/': 'Code'
|
||||||
};
|
};
|
||||||
|
|
||||||
recentPads.length && recentPads.some(function (pad, index) {
|
var makeRecentPadsTable = function () {
|
||||||
if (!pad) return true;
|
recentPads.length && recentPads.some(function (pad, index) {
|
||||||
|
if (!pad) return true;
|
||||||
|
|
||||||
// don't link to old pads
|
// don't link to old pads
|
||||||
if (now.getTime() - pad[1] > memorySpan) return true;
|
if (now.getTime() - pad[1] > memorySpan) return true;
|
||||||
|
|
||||||
hasRecent = true;
|
hasRecent = true;
|
||||||
|
|
||||||
// split up the uri
|
// split up the uri
|
||||||
var uri = LilUri(pad[0]);
|
var uri = LilUri(pad[0]);
|
||||||
|
|
||||||
// derive the name
|
// derive the name
|
||||||
var name = padTypes[uri.path()];
|
var name = padTypes[uri.path()];
|
||||||
|
|
||||||
var date = new Date(pad[1]).toLocaleDateString();
|
var title = pad[2] || '';
|
||||||
if (date === now.toLocaleDateString()) {
|
|
||||||
date = new Date(pad[1]).toLocaleTimeString().replace(/ /g, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
var id = 'pad-'+index;
|
var date = new Date(pad[1]).toLocaleDateString();
|
||||||
$tbody.append('<tr id="'+id+'">' +
|
if (date === now.toLocaleDateString()) {
|
||||||
'<td>' + name + '</td>' +
|
date = new Date(pad[1]).toLocaleTimeString().replace(/ /g, '');
|
||||||
'<td><a href="' + pad[0] + '"' + '">' + pad[0] + '</a></td>' +
|
}
|
||||||
'<td>' + date + '</td>' +
|
|
||||||
'<td class="remove">remove</td>'+
|
|
||||||
'</tr>');
|
|
||||||
|
|
||||||
var $row = $('#'+id);
|
var id = 'pad-'+index;
|
||||||
$row.find('.remove').click(function () {
|
$tbody.append('<tr id="'+id+'">' +
|
||||||
forgetPad(pad[0]);
|
'<td>' + name + '</td>' +
|
||||||
$row.fadeOut(750, function () {
|
'<td>' + title + '</td>' +
|
||||||
$row.remove();
|
'<td><a href="' + pad[0] + '">' + pad[0] + '</a></td>' +
|
||||||
if (!$table.find('tr').length) {
|
'<td>' + date + '</td>' +
|
||||||
$table.remove();
|
'<td class="remove">✖</td>'+
|
||||||
$tryit.text("Try it out!");
|
'</tr>');
|
||||||
}
|
|
||||||
setTableHeight();
|
var $row = $('#'+id);
|
||||||
|
$row.find('.remove').click(function () {
|
||||||
|
forgetPad(pad[0]);
|
||||||
|
$row.fadeOut(750, function () {
|
||||||
|
$row.remove();
|
||||||
|
if (!$table.find('tr').length) {
|
||||||
|
$table.remove();
|
||||||
|
$tryit.text("Try it out!");
|
||||||
|
}
|
||||||
|
setTableHeight();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (recentPads.length) {
|
||||||
|
recentPads.sort(function (a, b) {
|
||||||
|
// b - a
|
||||||
|
return new Date(b[1]).getTime() - new Date(a[1]).getTime();
|
||||||
|
});
|
||||||
|
makeRecentPadsTable();
|
||||||
|
}
|
||||||
|
|
||||||
var setTableHeight = function () {
|
var setTableHeight = function () {
|
||||||
if (recentPads.length < 5) {
|
if (recentPads.length < 5) {
|
||||||
|
|
Loading…
Reference in a new issue