You can make it a bit shorter overall using jquery's $.inArray()
method with a modulus:
var p = [ 645,629,648 ];
var start = 645;
var next = p[($.inArray(start, p) + 1) % p.length];
var prev = p[($.inArray(start, p) - 1 + p.length) % p.length];
Or, function based:
function nextProject(num) {
return p[($.inArray(num, p) + 1) % p.length];
}
function prevProject(num) {
return p[($.inArray(num, p) - 1 + p.length) % p.length];
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…