aboutsummaryrefslogtreecommitdiff
path: root/user/plugins/sample-toolbar/js/toolbar.js
blob: bfa249a780c12c3884327a3d7a444be0ebb0d588 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// If javascript is enabled, display the button
document.getElementById('yourls-always').style.display = 'block';

// When button clicked, store a cookie that says the user doesn't want a toolbar
document.getElementById('yourls-always').onclick = yourls_cookie_no_toolbar_please;
function yourls_cookie_no_toolbar_please() {
	var exdate=new Date();
	exdate.setDate( exdate.getDate()+365 ); // store 365 days
	document.cookie = "yourls_no_toolbar=1;expires="+exdate.toUTCString() ;
}

// Get the number of delicious bookmarks
function yourls_get_books(json) {
	if( json.length ) {
		var books = json[0].total_posts.toString();
		if( books ) {
			document.getElementById('yourls-delicious-link').innerHTML  = ' <b>'+books+'</b> bookmarks';
		}
	}
}