每日随机报价生成器

时间:2014-04-14 00:40:40

标签: javascript html css azure winjs

您好我已经创建了一个随机报价生成器Windows应用商店应用程序,所有报价填写正常我唯一的问题是如何让报价每天更改而不是每次从第一次更改时更改页面到应用程序的第二页,反之亦然。任何帮助或正确方向的一点将不胜感激。

以下是本书中的代码副本将在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.
    }
});

})();

1 个答案:

答案 0 :(得分:0)

如评论中所述,更改服务器而不是客户端上的引号更有意义。

创建一个服务器页面,根据当前日期返回报价。您可以通过多种方式实现这一点,但直接的实现方法是在每个引号首次创建时添加日期,然后仅在它的日期提供。