}
upd_note_links(i);
}
+ updt_save_btn();
}
function sync_msg(m) {
}
updt_table(0);
updt_output();
+ updt_save_btn();
}
// "Get updates" button: fetches the current shared state from the server
el.style.display = "";
el.focus();
upd_note_links(i);
+ updt_save_btn();
}
// "[edit note]" link: switches line <i> to edition of the whole note blob
el.style.display = "";
el.focus();
upd_note_links(i);
+ updt_save_btn();
}
// "[cancel]" link: closes the note input of line <i> without sending
note_base[i] = "";
mark_conflict(i, 0);
upd_note_links(i);
+ updt_save_btn();
+}
+
+// Grays the "Save changes" button when nothing differs from the reference
+// (no verdict change, no pending note addition or edition), so it is
+// visible at a glance whether anything remains to be saved. Called after
+// every action which may change that: verdict clicks, note box openings,
+// closings and typing, updates and saves. Bails out at the first pending
+// change so the common case stays cheap.
+function updt_save_btn() {
+ var btn = document.getElementById("save_btn");
+ var pending = false;
+ var i, s, el;
+
+ if (!btn)
+ return;
+ for (i = 1; i < nb_patches && !pending; i++) {
+ s = cur_state(i);
+ if (s && s != ref_state[i])
+ pending = true;
+ else if (note_mode[i]) {
+ el = document.getElementById("in_" + i);
+ if (note_mode[i] == 1 ? el.value.trim() != "" : el.value != note_base[i])
+ pending = true;
+ }
+ }
+ btn.disabled = !pending;
}
// "Save changes" button: pushes the local edits, i.e. the states differing
}
}
sync_msg(nbc ? "saved, but " + nbc + " note conflict(s): use Get updates and revise the red one(s)" : "saved");
+ updt_save_btn();
})
.catch(function() { sync_msg("save failed (busy?), edits kept"); });
}
}
updt_table(line);
updt_output();
+ updt_save_btn();
}
function show_only(b,n,u,w,y) {
if [ -n "$VERSION" ]; then
echo -n "<div style='float: right; text-align: right;'>"
echo -n "<button onclick='fetch_ref();' title='Retrieve the latest shared review state'>Get updates</button> "
- echo -n "<button onclick='save_ref();' title='Push your local edits to the shared state'>Save changes</button>"
+ echo -n "<button id='save_btn' disabled onclick='save_ref();' title='Push your local edits to the shared state'>Save changes</button>"
echo "<br/><small id='sync_msg'></small></div>"
fi
echo -n "<a href='#' onclick='add_note($seq_num); return false;' id='ln_add_$seq_num' title='Add a shared note to this commit'><small>[add note]</small></a>"
echo -n " <a href='#' onclick='edit_note($seq_num); return false;' id='ln_edit_$seq_num' style='display:none' title='Edit or delete the whole note'><small>[edit note]</small></a>"
echo -n " <a href='#' onclick='cancel_note($seq_num); return false;' id='ln_cancel_$seq_num' style='display:none' title='Abort this note edition'><small>[cancel]</small></a>"
- echo -n " <input type='text' id='in_$seq_num' maxlength='500' size='80' style='display:none' />"
+ echo -n " <input type='text' id='in_$seq_num' maxlength='500' size='80' style='display:none' oninput='updt_save_btn();' />"
fi
echo -n "</TD>"
echo "</TR>"