Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[widgets/count][s]: simple count widget that shows dataset counts for…
… a given query (more of an example than a widget).
- Loading branch information
1 parent
8a4fc98
commit 41789e6
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>CKAN Count Widget</title> | ||
<script src="../../vendor/jquery/1.6.2/jquery.js"></script> | ||
<script type="text/javascript"> | ||
jQuery(document).ready(function($) { | ||
var group = 'economics'; | ||
var url = 'http://thedatahub.org/api/search/dataset?groups=' + group; | ||
$.getJSON(url, function(data) { | ||
$('.ckanjs-widget-count').html(data.count); | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h1>Count Widget</h1> | ||
<h2>Code</h2> | ||
<pre> | ||
// Javascript to load the information (this requires jQuery) | ||
// You can put this in the head of the page or in the page body. | ||
<script type="text/javascript"> | ||
jQuery(document).ready(function($) { | ||
var group = 'economics'; | ||
var url = 'http://thedatahub.org/api/search/dataset?groups=' + group; | ||
$.getJSON(url, function(data) { | ||
// class selector for the page element where info should be inserted | ||
$('.ckanjs-widget-count').html(data.count); | ||
}); | ||
}); | ||
</script> | ||
|
||
// And somewhere in the body of the html page ... | ||
// this is where dataset count will be inserted | ||
<span class="ckanjs-widget-count"></span> | ||
</pre> | ||
<h2>Demo (view source to see HTML and javascript)</h2> | ||
Datasets in the group: <strong class="ckanjs-widget-count"></strong> (this number computed live from the API). | ||
</body> | ||
</html> | ||
|