0

Hi I have created a Random Quote Generator Windows Store App, All of the Quotes populate fine the only issue that I'm having is how to get the Quotes to change daily instead of having them change every time you go from the first page to the second page in the app or vice versa. Any help or a point in the right direction would be greatly appreciated.

BELOW IS A COPY OF THE CODE FROM THE PAGE THE QUOTE WILL DISPLAY IN JAVASCRIPT:

// For an introduction to the Page Control template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232511
(function () {
"use strict";

    WinJS.UI.Pages.define("/pages/page2/page2.html", {
    // This function is called whenever a user navigates to this page. It
    // populates the page elements with the app's data.

    ready: function (element, options) {
        // TODO: Initialize the page here.

        client.getTable("quotes").read().then(function (q) {

                {
                    var randomquote = Math.round(Math.random() * (q.length));
                    function printquote() {
                        output.innerHTML += "<div>" + (q[randomquote].body + "</div>");     
                    }
                    printquote();
            }  
        }, function (err) { debugger; });

    },
    unload: function () {
        // TODO: Respond to navigations away from this page.
    },
    updateLayout: function (element) {
        /// <param name="element" domElement="true" />

        // TODO: Respond to changes in layout.
    }
});

})();

3
  • Seems it would be simpler to just change the quote on the server each day.
    – RobG
    Apr 14, 2014 at 3:02
  • What do you mean?…I have them stored in a mobile server in Azure but Im confused on how to actually do that. I tried to research creating and API and do it that way but I'm confused on how to do so. Apr 14, 2014 at 3:24
  • You could also just save as a local or roaming setting the date and quote. If today's date is different from what was saved, generate a new quote and store it. Apr 14, 2014 at 10:48

1 Answer 1

0

Like said in the comments, it makes more sense to change the quotes on the server instead of the client.

Create a server page that, based on the current date, returns a quote. You can implement that in many ways but a straight-forward implementation will be to add each of your quotes a date when it's first created, and then serve it only in it's date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.