This is what should be in the black part of level 7: Full level 7 code
var player = map.getPlayer();
if (player.getColor() == '#0f0') {
player.setColor('#f00');
} else if (player.getColor() == '#f00') {
player.setColor('#ff0');
} else {
player.setColor('#0f0');
}


For level 17, do what the comments imply: hintread the in-game doc to see what would allow you to see where each teleporter goes.