Showing posts from May, 2015


"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: "", type: "GET", dataType: "text", beforeSend: function () { $('#kowts').show().html('<img src="" />'); }, 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

This song keeps me awake during office hours. :)