diff --git a/tagcloud/tagcloud.js b/tagcloud/tagcloud.js
index d0701e3..91b3356 100644
--- a/tagcloud/tagcloud.js
+++ b/tagcloud/tagcloud.js
@@ -23,15 +23,28 @@
for(index = 0; index < slideNotes.length; ++index) {
text = text.replace(slideNotes[index].textContent, '');
}
+ //@see http://stackoverflow.com/questions/24512636/split-words-shuffle-jumble-letters
+ var a = text.split(/\n/),
+ n = a.length;
+
+ if (cloud.hasAttribute('shuffle')) {
+ //shuffle order
+ for (var i = n - 1; i > 0; i--) {
+ var j = Math.floor(Math.random() * (i + 1));
+ var tmp = a[i];
+ a[i] = a[j];
+ a[j] = tmp;
+ }
+ } //end if shuffle
+
+ return a.filter(function(item) {
+ return item.trim() !== '';
+ })
+ .map(function(item) {
+ return ( item.indexOf('span') === -1 ) ? '' + item.trim() + ' ' : item.trim();
+ })
+ .join("");
- return text.split(/\n/)
- .filter(function(item) {
- return item.trim() !== '';
- })
- .map(function(item) {
- return ( item.indexOf('span') === -1 ) ? '' + item.trim() + ' ' : item.trim();
- })
- .join('');
}
/**