forked from skx/bookmarks.public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
255 lines (224 loc) · 7.69 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-gb" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Bookmarks</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
<!--
$(function() {
/**
* Show the number of visible bookmarks in the titlebar.
*/
function updateTitle()
{
var count = $("#bookmarks").children().filter(":visible").size();
var plural = (( count == 0 ) || ( count > 1 ) ) ? 's' : '';
document.title = count + " visible bookmark" + plural;
}
/**
* Sort the items in the UL which contains our bookmarks.
*/
function sortBookmarks()
{
var mylist = $('#bookmarks');
var listitems = mylist.children('li').get();
listitems.sort(function(a, b) {
return $(a).text().toUpperCase().localeCompare($(b).text().toUpperCase());
});
$.each(listitems, function(idx, itm) { mylist.append(itm); });
}
/**
* This horrible function is here to collect each distinct tag,
* stripping whitespace, and placing into sorted order.
*/
function populateTags()
{
var tags = {};
$("#bookmarks").children().each( function() {
var tag = $(this).attr("title");
if ( typeof tag !== 'undefined' )
{
if ( tag.match( "," ) )
{
var a = tag.split( "," );
for ( i in a )
{
var nm = a[i];
nm = nm.replace(/(^\s+|\s+$)/g,'');
tags[ nm.toLowerCase() ] = 1;
}
}
else
{
tag = tag.replace(/(^\s+|\s+$)/g,'');
tags[tag.toLowerCase()]= 1;
}
}
});
var keys = [];
for( var t in tags )
{
keys.push( t );
}
keys.sort();
for ( t in keys )
{
$("#autotags").append( "<a class=\"tagfilter\" href=\"#" + escape(keys[t]) + "\">" + keys[t] + "</a>, ");
}
/** Remove trailng ", ". */
$("#autotags").html( $("#autotags").html().replace( /, $/, '.' ) );
}
/**
* Append the list of tags beneath each bookmark, for easy viewing.
*/
function appendTags()
{
$("#bookmarks").children().each( function() {
var tag = $(this).attr("title");
if ( typeof tag !== 'undefined' )
{
var txt = '<ul>';
var array = tag.toLowerCase().split( "," );
for ( i in array )
{
var nm = array[i];
nm = nm.replace(/(^\s+|\s+$)/g,'');
txt += "<a class=\"tagfilter\" href=\"#\">" + nm + "</a>, ";
}
/** Remove trailing ", ". */
txt = txt.replace( /, $/, "." );
$(this).append( txt + "</ul>" );
}
});
}
/**
* Code the launches at page-load-time:
*/
/** Sort the bookmarks */
sortBookmarks();
/** Populate the tags pane. */
populateTags();
/** Append the tags beneath each bookmark. */
appendTags();
// Focus on the search/filter box.
$("#fill").focus();
/**
* Bind event handlers...
*/
/**
* Search by title/url - case insensitive.
*/
$("#fill").keyup(function() {
filter = $("#fill").val().toLowerCase();
$("#bookmarks").children().each( function(){
var title=$(this).text().toLowerCase();
var links=$(this).find("a");
if ( typeof links !== 'undefined' )
{
links = links.attr("href").toLowerCase();
}
( title.match( filter ) || links.match(filter) || filter == "" )
? $(this).show() : $(this).hide();
} );
updateTitle();
})
/**
* Show only entries with zero tags.
*/
$('#untagged').click(function(event){
event.preventDefault();
$("#bookmarks").children().each( function() {
var tags=$(this).attr('title');
( typeof tags !== 'undefined' ) ? $(this).hide() : $(this).show();
});
updateTitle();
});
/**
* Show only entries with a given tag.
*/
$('.tagfilter').click(function(event) {
event.preventDefault();
/* the tag we're looking for */
var tag = $(this).text();
$("#bookmarks").children().each( function() {
var tags=$(this).attr('title');
( ( typeof tags !== 'undefined' ) && ( tags.toLowerCase().match(tag) ) )
? $(this).show() : $(this).hide() ;
});
updateTitle();
});
});
-->
</script>
<style type="text/css">
#tags {
width: 200px;
}
h2 {
border-bottom: 1px solid black;
}
.tagfilter {
text-decoration: none;
font-family: monospace;
}
#bookmarks {
list-style: none;
}
table {
width: 100%;
padding: 1em;
}
td {
padding: 0.5em;
border: 1px solid silver;
}
li {
padding: 0.2em;
border-bottom: 1px dashed silver;
}
</style>
</head>
<body>
<h1>Bookmarks</h1>
<fieldset>
<legend>Filter Bookmarks</legend>
<form id="filter" name="filter" action="#">
<p>Search within bookmarks: <input type="text" name="fill" id="fill" value="" size="50" /></p>
</form>
</fieldset>
<table>
<tr><td valign="top">
<!-- THE BOOKMARKS -->
<ul class="bookmarks" id="bookmarks">
<li title="debian, planet"><a href="http://planet.debian.org/">Planet Debian</a></li>
<li title="debian, development"><a href="http://www.debian.org/devel/">Debian Developers' Corner</a></li>
<li title="sysadmin, planet"><a href="http://planetsysadmin.com/">Planet Sysadmin</a></li>
<li title="sysadmin, reddit"><a href="http://www.reddit.com/r/sysadmin">Reddit: /r/sysadmin</a></li>
<li title="blog, microsoft"><a href="http://blogs.msdn.com/b/oldnewthing/">The old new thing</a></li>
<li title="blog, personal"><a href="http://blog.steve.org.uk/">Steve Kemp's blog</a></li>
<li title="development, personal"><a href="https://github.com/skx/">Steve Kemp's github account</a></li>
<li title="news"><a href="https://news.ycombinator.com/">Hacker News</a></li>
<li title="news, edinburgh"><a href="http://www.scotsman.com/edinburgh-evening-news">Edinburgh Evening News</a></li>
<li title="NEws"><a href="http://www.bbc.co.uk/news/">BBC News</a></li>
<li title="personal"><a href="http://static.steve.org.uk/start/">My start page</a></li>
<li title="personal, sysadmin, debian"><a href="http://debian-administration.org/">Debian Administration</a></li>
<li title="sysadmin, stackexchange"><a href="http://serverfault.com/">Server Fault</a></li>
<li title="photography, stackexchange"><a href="http://photo.stackexchange.com/">Photography Exchange</a></li>
<li title="reddit, photography"><a href="http://www.reddit.com/r/photography/">Reddit /r/photography</a></li>
<li><a href="http://www.thepondleith.co.uk/">The Pond, Leith</a></li>
</ul>
<!-- THE END OF BOOKMARKS -->
</td>
<td id="tags" valign="top">
<h2>Tags</h2>
<p id="autotags"></p>
<p> </p>
<h2>Untagged</h2>
<p>View <a href="#untagged" id="untagged">untagged</a>.</p>
</td></tr>
</table>
</body>
</html>