实现评分不限频-widget.com

Implement unlimited frequency in rating-widget.com

rating-widget documentation 写道他们的星级系统的用户评级频率不受限制。但我不确定如何将它添加到主要功能代码中。

在哪里可以添加行 frequency=unlimited。应该很容易。不过我是个JS菜鸟

(function(d, t, e, m){
    window.RW_Async_Init = function(){
        RW.init({
            huid: "336233",
            uid: "2e7de74f3aeb426c10a2087ead09259c",
            source: "website",
            options: {
                "size": "medium",
                "style": "oxygen",
                "isDummy": false
            } 
        });
        RW.render();
    };
    // Append Rating-Widget JavaScript library.
    var rw, s = d.getElementsByTagName(e)[0], id = "rw-js",
        l = d.location, 
        ck = "Y" + t.getFullYear() + "M" + t.getMonth() + "D" + t.getDate(),
        p = l.protocol,
        f = ((l.search.indexOf("DBG=") > -1) ? "" : ".min"),
        a = ("https:" == p ? "secure." + m + "js/" : "js." + m);
    if (d.getElementById(id)) return;              
    rw = d.createElement(e);
    rw.id = id; rw.async = true;
    rw.type = "text/javascript";
    rw.src = p + "//" + a + "external" + f + ".js?ck=" + ck;
    s.parentNode.insertBefore(rw, s);
}(document, new Date(), "script", "rating-widget.com/"));

options object section中描述了你可以指定哪些选项,其中包括frequency,所以你可以指定这个key/value:

frequency: RW.FREQUENCY.UNLIMITED

您可以在 init 调用中,在 options 对象中指定,如下所示:

RW.init({
    huid: "336233",
    uid: "2e7de74f3aeb426c10a2087ead09259c",
    source: "website",
    options: {
        frequency: RW.FREQUENCY.UNLIMITED, // <-- added
        "size": "medium",
        "style": "oxygen",
        "isDummy": false
    } 
});

注意:文档并不是很完整,因为上面的语法没有包含在 RW methods section, where the init call is said to need the uid as the first argument. This evidently is only one of the ways to call init, as the page you used 中,以获取您的代码传递嵌套对象作为第一个(也是唯一的)参数。

此外,使用预定义的枚举来设置选项似乎更符合主要文档。因此,您可以将 size 设置为 RW.SIZE.SMALL 而不是 "small".