以下是重构后的代码,保留了原有的代码风格和结构:
```javascript
var message = "免费图铃";
var neonBaseColor = "#0071C0";
var neonTextColor = "#FFFFFF";
var flashSpeed = 200; // in milliseconds
var n = 0;
if (document.all) {
document.write('');
for (m = 0; m < message.length; m++) {
document.write('' + message.charAt(m) + '');
}
document.write('');
// cache reference to neonLight array
var tempRef = document.all.neonLight;
} else {
document.write(message);
}
function neon() {
// Change all letters to base color
if (n == 0) {
for (m = 0; m < message.length; m++) {
tempRef[m].style.color = neonBaseColor;
}
}
// Cycle through and change individual letters to neon color
tempRef[n].style.color = neonTextColor;
if (n < tempRef.length - 1) {
n++;
} else {
n = 0;
clearInterval(flashing);
setTimeout("beginNeon()", 1500);
}
}
```
以下是重构后的代码块:
```javascript
function beginneon() {
if (document.all) {
flashing = setInterval("neon()", flashspeed);
}
}
beginneon();
```