Skip to main content
edited tags
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473
Tweeted twitter.com/#!/StackCodeReview/status/490741810923581440
Rollback to Revision 3
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

EDIT: So I have optimized it down to the point of using different type of array and calling...

var quotes =    [
                ["The true sign of intelligence is not knowledge but imagination.","Albert Einstein","48"],
                ["A people without the knowledge of their past history, origin and culture is like a tree without roots.","Marcus Garvey","48"],
                ["Real knowledge is to know the extent of one's ignorance.","Confucius","48"],
                ["Ignorance is the curse of God; knowledge is the wing wherewith we fly to heaven.","William Shakespeare","48"],
                ["Human behavior flows from three main sources: desire, emotion, and knowledge.","Plato","48"],
                ["If money is your hope for independence you will never have it. The only real security that a man will have in this world is a reserve of knowledge, experience, and ability.","Henry Ford","80"],
                ["Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.","Kofi Annan","80"],
                ["Knowledge has to be improved, challenged, and increased constantly, or it vanishes.","David Bailey","80"],
                ["I'm hungry for knowledge. The whole thing is to learn every day, to get brighter and brighter. That's what this world is about. You look at someone like Gandhi, and he glowed. Martin Luther King glowed. Muhammad Ali glows. I think that's from being bright all the time, and trying to be brighter.","Jay-Z","112"],
                ["Wisdom is the right use of knowledge. To know is not to be wise. Many men know a great deal, and are all the greater fools for it. There is no fool so great a fool as a knowing fool. But to know how to use knowledge is to have wisdom.","Charles Spurgeon","112"],
                ["To know, is to know that you know nothing. That is the meaning of true knowledge.","Socrates","48"],
                ["The best advice I ever got was that knowledge is power and to keep reading.","David Bailey","48"],
                ["He who knows nothing is closer to the truth than he whose mind is filled with falsehoods and errors.","Thomas Jefferson","80"],
                ["To know what you know and what you do not know, that is true knowledge.","Confucius","48"],
                ["I was bold in the pursuit of knowledge, never fearing to follow truth and reason to whatever results they led, and bearding every authority which stood in their way.","Thomas Jefferson","80"]
                ];
$( document ).ready(function() {
    $("ul.recent-posts").find("li.post p.details").hide();
    $("ul.recent-posts").find("li.post a.hide").hide();
    quote();
});
function quote() {
    var rand = Math.floor(Math.random() * quotes.length);
    $("p.quote").text(quotes[rand][0]);
    $("p.creator").text(quotes[rand][1]);

    $("p.quote")    .hide()
                    .delay(1000)
                    .fadeIn(300);
    $("p.creator")  .hide()
                    .delay(1000)
                    .fadeIn(300);
    var marginTop = ($(".quotes .quotes-container").height() - quotes[rand][2]) / 2 + "px";
    $(".quotes .quotes-container .content").attr("style","padding-top:" + marginTop);
};

I also fixed a fadeIn() and fadeOut() glitch that I was having issues with!

EDIT: So I have optimized it down to the point of using different type of array and calling...

var quotes =    [
                ["The true sign of intelligence is not knowledge but imagination.","Albert Einstein","48"],
                ["A people without the knowledge of their past history, origin and culture is like a tree without roots.","Marcus Garvey","48"],
                ["Real knowledge is to know the extent of one's ignorance.","Confucius","48"],
                ["Ignorance is the curse of God; knowledge is the wing wherewith we fly to heaven.","William Shakespeare","48"],
                ["Human behavior flows from three main sources: desire, emotion, and knowledge.","Plato","48"],
                ["If money is your hope for independence you will never have it. The only real security that a man will have in this world is a reserve of knowledge, experience, and ability.","Henry Ford","80"],
                ["Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.","Kofi Annan","80"],
                ["Knowledge has to be improved, challenged, and increased constantly, or it vanishes.","David Bailey","80"],
                ["I'm hungry for knowledge. The whole thing is to learn every day, to get brighter and brighter. That's what this world is about. You look at someone like Gandhi, and he glowed. Martin Luther King glowed. Muhammad Ali glows. I think that's from being bright all the time, and trying to be brighter.","Jay-Z","112"],
                ["Wisdom is the right use of knowledge. To know is not to be wise. Many men know a great deal, and are all the greater fools for it. There is no fool so great a fool as a knowing fool. But to know how to use knowledge is to have wisdom.","Charles Spurgeon","112"],
                ["To know, is to know that you know nothing. That is the meaning of true knowledge.","Socrates","48"],
                ["The best advice I ever got was that knowledge is power and to keep reading.","David Bailey","48"],
                ["He who knows nothing is closer to the truth than he whose mind is filled with falsehoods and errors.","Thomas Jefferson","80"],
                ["To know what you know and what you do not know, that is true knowledge.","Confucius","48"],
                ["I was bold in the pursuit of knowledge, never fearing to follow truth and reason to whatever results they led, and bearding every authority which stood in their way.","Thomas Jefferson","80"]
                ];
$( document ).ready(function() {
    $("ul.recent-posts").find("li.post p.details").hide();
    $("ul.recent-posts").find("li.post a.hide").hide();
    quote();
});
function quote() {
    var rand = Math.floor(Math.random() * quotes.length);
    $("p.quote").text(quotes[rand][0]);
    $("p.creator").text(quotes[rand][1]);

    $("p.quote")    .hide()
                    .delay(1000)
                    .fadeIn(300);
    $("p.creator")  .hide()
                    .delay(1000)
                    .fadeIn(300);
    var marginTop = ($(".quotes .quotes-container").height() - quotes[rand][2]) / 2 + "px";
    $(".quotes .quotes-container .content").attr("style","padding-top:" + marginTop);
};

I also fixed a fadeIn() and fadeOut() glitch that I was having issues with!

added 3204 characters in body
Source Link

EDIT: So I have optimized it down to the point of using different type of array and calling...

var quotes =    [
                ["The true sign of intelligence is not knowledge but imagination.","Albert Einstein","48"],
                ["A people without the knowledge of their past history, origin and culture is like a tree without roots.","Marcus Garvey","48"],
                ["Real knowledge is to know the extent of one's ignorance.","Confucius","48"],
                ["Ignorance is the curse of God; knowledge is the wing wherewith we fly to heaven.","William Shakespeare","48"],
                ["Human behavior flows from three main sources: desire, emotion, and knowledge.","Plato","48"],
                ["If money is your hope for independence you will never have it. The only real security that a man will have in this world is a reserve of knowledge, experience, and ability.","Henry Ford","80"],
                ["Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.","Kofi Annan","80"],
                ["Knowledge has to be improved, challenged, and increased constantly, or it vanishes.","David Bailey","80"],
                ["I'm hungry for knowledge. The whole thing is to learn every day, to get brighter and brighter. That's what this world is about. You look at someone like Gandhi, and he glowed. Martin Luther King glowed. Muhammad Ali glows. I think that's from being bright all the time, and trying to be brighter.","Jay-Z","112"],
                ["Wisdom is the right use of knowledge. To know is not to be wise. Many men know a great deal, and are all the greater fools for it. There is no fool so great a fool as a knowing fool. But to know how to use knowledge is to have wisdom.","Charles Spurgeon","112"],
                ["To know, is to know that you know nothing. That is the meaning of true knowledge.","Socrates","48"],
                ["The best advice I ever got was that knowledge is power and to keep reading.","David Bailey","48"],
                ["He who knows nothing is closer to the truth than he whose mind is filled with falsehoods and errors.","Thomas Jefferson","80"],
                ["To know what you know and what you do not know, that is true knowledge.","Confucius","48"],
                ["I was bold in the pursuit of knowledge, never fearing to follow truth and reason to whatever results they led, and bearding every authority which stood in their way.","Thomas Jefferson","80"]
                ];
$( document ).ready(function() {
    $("ul.recent-posts").find("li.post p.details").hide();
    $("ul.recent-posts").find("li.post a.hide").hide();
    quote();
});
function quote() {
    var rand = Math.floor(Math.random() * quotes.length);
    $("p.quote").text(quotes[rand][0]);
    $("p.creator").text(quotes[rand][1]);

    $("p.quote")    .hide()
                    .delay(1000)
                    .fadeIn(300);
    $("p.creator")  .hide()
                    .delay(1000)
                    .fadeIn(300);
    var marginTop = ($(".quotes .quotes-container").height() - quotes[rand][2]) / 2 + "px";
    $(".quotes .quotes-container .content").attr("style","padding-top:" + marginTop);
};

I also fixed a fadeIn() and fadeOut() glitch that I was having issues with!

EDIT: So I have optimized it down to the point of using different type of array and calling...

var quotes =    [
                ["The true sign of intelligence is not knowledge but imagination.","Albert Einstein","48"],
                ["A people without the knowledge of their past history, origin and culture is like a tree without roots.","Marcus Garvey","48"],
                ["Real knowledge is to know the extent of one's ignorance.","Confucius","48"],
                ["Ignorance is the curse of God; knowledge is the wing wherewith we fly to heaven.","William Shakespeare","48"],
                ["Human behavior flows from three main sources: desire, emotion, and knowledge.","Plato","48"],
                ["If money is your hope for independence you will never have it. The only real security that a man will have in this world is a reserve of knowledge, experience, and ability.","Henry Ford","80"],
                ["Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.","Kofi Annan","80"],
                ["Knowledge has to be improved, challenged, and increased constantly, or it vanishes.","David Bailey","80"],
                ["I'm hungry for knowledge. The whole thing is to learn every day, to get brighter and brighter. That's what this world is about. You look at someone like Gandhi, and he glowed. Martin Luther King glowed. Muhammad Ali glows. I think that's from being bright all the time, and trying to be brighter.","Jay-Z","112"],
                ["Wisdom is the right use of knowledge. To know is not to be wise. Many men know a great deal, and are all the greater fools for it. There is no fool so great a fool as a knowing fool. But to know how to use knowledge is to have wisdom.","Charles Spurgeon","112"],
                ["To know, is to know that you know nothing. That is the meaning of true knowledge.","Socrates","48"],
                ["The best advice I ever got was that knowledge is power and to keep reading.","David Bailey","48"],
                ["He who knows nothing is closer to the truth than he whose mind is filled with falsehoods and errors.","Thomas Jefferson","80"],
                ["To know what you know and what you do not know, that is true knowledge.","Confucius","48"],
                ["I was bold in the pursuit of knowledge, never fearing to follow truth and reason to whatever results they led, and bearding every authority which stood in their way.","Thomas Jefferson","80"]
                ];
$( document ).ready(function() {
    $("ul.recent-posts").find("li.post p.details").hide();
    $("ul.recent-posts").find("li.post a.hide").hide();
    quote();
});
function quote() {
    var rand = Math.floor(Math.random() * quotes.length);
    $("p.quote").text(quotes[rand][0]);
    $("p.creator").text(quotes[rand][1]);

    $("p.quote")    .hide()
                    .delay(1000)
                    .fadeIn(300);
    $("p.creator")  .hide()
                    .delay(1000)
                    .fadeIn(300);
    var marginTop = ($(".quotes .quotes-container").height() - quotes[rand][2]) / 2 + "px";
    $(".quotes .quotes-container .content").attr("style","padding-top:" + marginTop);
};

I also fixed a fadeIn() and fadeOut() glitch that I was having issues with!

deleted 241 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
Loading
added 88 characters in body
Source Link
Loading
Source Link
Loading