对于标题感到抱歉,对于那些标题不是很好,所以这里有一点解释;
我想完全浏览数组' ids',一旦我完成最后一个,我想再将i设置为1,这个if语句是否有效?
if(i === ids.length){
i = 1
print(i)
}
完整代码:
var ids = ["232494086", "110891941", "232746775", "50382985", "108147528", "110207437", "232532449", "232532377", "151784429", "63043890", "1029025", "116777149", "1365767", "98346834", "100929604", "82332012", "215751161", "232491040", "20052135", "209995252", "19264845", "81725506", "35292167"]
function Post(Id,Comment){
$.get("http://www.roblox.com/Item-item?id=" + Id).always(function(Data){
var Token = Data.match(/setToken(\W(.+)\W);/)[2].replace(/'/g,"")
Token = Token.replace("+","%2B").replace("/","%2F")
$.post("http://www.roblox.com/API/Comments.ashx?rqtype=makeComment&assetID=" + Id + "&token=" + Token,Comment)
document.write('<a target="_blank" href="http://www.roblox.com/Item-item?id='+Id+'">'+Id+'</a><br/>')
})
}
function getCatalog() {
var ids = [];
var json = $.getJSON( "http://www.roblox.com/catalog/json", function( data ) {
//alert(data[1]['AssetId'])
var len = Object.keys(data).length;
for (i = 0; i < len; i++) {
ids.push(data[i]['AssetId']);
}
console.log('var ids = ["'+ids.join("\", \"")+'"]');
});
}
var msg = 'Send me trades!'
Post(ids[0],msg);
var i = 1;
var Interval = setInterval(function(){
Post(ids[i],msg)
i++
if(i === ids.length){
i = 1
print(i)
}
},300000)
答案 0 :(得分:0)
如果我理解你的话......
我想说如果你想再次使用它,你必须将其设置为0
,并且-1
的长度为if(i === ids.length-1){
i = 0;
print(i)
}
:
{{1}}
我不确定的是你的document.write那里,你的目标是什么?
... write()方法主要用于测试:如果之后使用它 HTML文档已完全加载,它将删除所有现有的HTML ...