Skip to content

Instantly share code, notes, and snippets.

View niraj-shah's full-sized avatar
🏠
Working from home

Niraj Shah niraj-shah

🏠
Working from home
View GitHub Profile
@niraj-shah
niraj-shah / word_cloud_1.html
Created January 2, 2013 14:54
Start of Word Cloud
<div id="text"></div>
<div id="cloud"></div>
@niraj-shah
niraj-shah / word_cloud.css
Created January 2, 2013 21:29
Word Cloud CSS
body {
font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", sans-serif;
}
#text {
display: none;
}
.tag {
display: inline-block;
@niraj-shah
niraj-shah / word_cloud_full.js
Last active December 10, 2015 12:58
Complete Word Cloud JS File
$(document).ready(function() {
var text = $('#text').text();
var word_array = text.split(' ');
// blank array to store result
var word_count = {};
// lets count the words
for ( var x in word_array ) {
@niraj-shah
niraj-shah / word_cloud_2.html
Created January 3, 2013 10:56
Divs with Text
<div id="text">
Itself two one. All. Us wherein replenish seas fly i open creeping dominion
deep over created so so. Isn't made lights is day won't he air first also
darkness fruit called bring. Forth one moving moved void to divided saw.
Shall air us own they're. Place fill meat heaven stars lights tree. Have
all, gathered saying third. Hath hath upon you of moved doesn't that own is
called own heaven he one whales, every dominion you'll. For creature appear,
male seas. Deep. Were Over. Created she'd a creature Signs whales is god.
Place given you'll brought his hath very may be Land creeping. Saw good our
face moving fly wherein air, a don't without fish void behold creeping every
@niraj-shah
niraj-shah / word_cloud_1.js
Last active December 10, 2015 13:39
Get the text from the div
var text = $('#text').text();
@niraj-shah
niraj-shah / word_cloud_2.js
Created January 3, 2013 11:00
Split the text into an array by space
var text = $('#text').text();
var word_array = text.split(' ');
@niraj-shah
niraj-shah / word_cloud_3.js
Created January 3, 2013 11:13
Create an array to store our result
var text = $('#text').text();
var word_array = text.split(' ');
// blank array to store result
var word_count = {};
@niraj-shah
niraj-shah / word_cloud_4.js
Last active December 10, 2015 13:48
Counting the words
var text = $('#text').text();
var word_array = text.split(' ');
// blank array to store result
var word_count = {};
// lets count the words
for ( var x in word_array ) {
// make the word lowercase
var word = word_array[x].toLowerCase();
@niraj-shah
niraj-shah / word_cloud_5.js
Created January 3, 2013 11:40
Displaying the Word Cloud
for ( var y in word_count ) {
$('#cloud').append('<div class="tag" style="font-size: '+ word_count[y] +'px;">' + y + '</div>');
}
@niraj-shah
niraj-shah / word_cloud_html.html
Created January 3, 2013 11:50
How the JavaScript outputs the Word Cloud HTML
<div class="tag" style="font-size: {value}px;">{word}</div>