Posts

Showing posts from May, 2015

KOWTS #3

Image
"To live with no regrets is to live happily."

Generate Random Quotes from a Text File

So to do that, you need a text file full of quotes. HAHAHA
Separated by new line. DEMO
$('#btn_modal').click(function () { var num = 0; $.ajax({ url: "https://dl.dropboxusercontent.com/u/75734877/taglines.txt", type: "GET", dataType: "text", beforeSend: function () { $('#kowts').show().html('<img src="http://www.feelol.com/Content/images/Loading.gif" />'); }, success: function (t) { var lines = t; var lineArr = lines.split('\n'); num = Math.floor(Math.random() * lineArr.length); $('#kowts').show().text(lineArr[num]); }, error: function(){ alert('Error') } }); });
Split the quotes from text file by "\n" (new line), then get its length and generate a random number between 0 to maximum length. Then use the generated number as index to…

Kowts #2

Image
This song keeps me awake during office hours. :)