Skip to content

Instantly share code, notes, and snippets.

@tobya
Created July 20, 2016 07:18
Show Gist options
  • Save tobya/f4abacfe487313866fe9605360c5a159 to your computer and use it in GitHub Desktop.
Save tobya/f4abacfe487313866fe9605360c5a159 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>jQCloud Example</title>
<link rel="stylesheet" type="text/css" href="../dist/jqcloud.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="../dist/jqcloud.js"></script>
<script type="text/javascript">
/*!
* Create an array of word objects, each representing a word in the cloud
*/
function onClick(){
// alert(this.textContent);
$("#example").jQCloud('update', word_array2);
}
var word_array = [
{text: "Lorem", weight: 15, handlers:{click:onClick}},
{text: "Ipsum", weight: 9, link: "http://jquery.com/"},
{text: "Dolor", weight: 6, html: {title: "I can haz any html attribute"}},
{text: "Si444t", weight: 7},
{text: "Sit", weight: 17},
{text: "S234123it", weight: 7},
{text: "Sit", weight: 7},
{text: "Sewit", weight: 7, handlers:{click:onClick}},
{text: "Situp", weight: 7, handlers:{click : function(){
alert('itemclicked');
}}},
{text: "Sifft", weight: 7, handlers:{click:onClick}},
{text: "Si2t", weight: 12, handlers:{click:onClick}},
{text: "Ssait", weight: 8},
{text: "Sit", weight: 7},
{text: "A22met", weight: 5, handlers:{click:onClick}}
// ...as many words as you want
];
var word_array2 = [
{text: "NEWTAGem", weight: 15, handlers:{click:onClick}},
{text: "NEWTAGum", weight: 9, link: "http://jquery.com/"},
{text: "NEWTAGor", weight: 6, html: {title: "I can haz any html attribute"}},
{text: "NEWTAG44t", weight: 7},
{text: "NEWTAG", weight: 17},
{text: "NEWTAG4123it", weight: 7},
{text: "NEWTAG", weight: 7},
{text: "NEWTAGit", weight: 7, handlers:{click:onClick}},
{text: "NEWTAGup", weight: 7, handlers:{click : function(){
alert('itemclicked');
}}},
{text: "OLDTAGft", weight: 7, handlers:{click:onClick}},
{text: "OLDTAGt", weight: 12, handlers:{click:onClick}},
{text: "OLDTAGit", weight: 8},
{text: "OLDTAG", weight: 7},
{text: "OLDTAGmet", weight: 5, handlers:{click:onClick}}
// ...as many words as you want
];
$(function() {
// When DOM is ready, select the container element and call the jQCloud method, passing the array of words as the first argument.
$("#example").jQCloud(word_array);
});
</script>
</head>
<body>
<!-- You should explicitly specify the dimensions of the container element -->
<div id="example" style="width: 750px; height: 550px;"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment