Better handling of changed files

Insetad of notifying user that file they're attempting to save, now they
can revert
This means the file they're trying to save is reverted to the server
file
Changes they have made are copied into a new file
User can optionally cancel to avoid this
This commit is contained in:
Matt Pass
2012-05-26 22:25:12 +01:00
parent acbe46b013
commit abd61689f1

View File

@@ -157,7 +157,31 @@ if ($_GET['action']=="save") {
}
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);if (top.ICEcoder.stickyTabWindow.location) {top.ICEcoder.stickyTabWindow.location.reload()};action="doneSave";</script>';
} else {
echo "<script>alert('Sorry, this file has changed, cannot save\\n".$file."');</script>";
$loadedFile = file_get_contents($saveFile);
echo '<textarea name="loadedFile" id="loadedFile">'.str_replace("</textarea>","<ICEcoder:/:textarea>",$loadedFile).'</textarea>';
echo '<textarea name="userVersionFile" id="userVersionFile"></textarea>';
?>
<script>
var refreshFile = confirm('Sorry, this file has changed, cannot save\n<?php echo $file;?>\n\nReload this file and copy your version to a new document?');
if (refreshFile) {
var cM = top.ICEcoder.getcMInstance();
var thisTab = top.ICEcoder.selectedTab;
document.getElementById('userVersionFile').value = cM.getValue();
// Revert back to original
cM.setValue(document.getElementById('loadedFile').value);
top.ICEcoder.changedContent[thisTab-1] = 0;
top.ICEcoder.openFileMDTs[top.ICEcoder.selectedTab-1] = "<?php echo filemtime($saveFile); ?>";
cM.clearHistory();
// Now for the new file
top.ICEcoder.newTab();
cM = top.ICEcoder.getcMInstance();
cM.setValue(document.getElementById('userVersionFile').value);
cM.clearHistory();
// Finally, switch back to original tab
top.ICEcoder.switchTab(thisTab);
}
</script>
<?php
echo '<script>top.ICEcoder.serverMessage();top.ICEcoder.serverQueue("del",0);action="nothing";</script>';
}
} else {