From f3b89056acd18593a09066f343e8f893348542d0 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 17 Sep 2014 12:06:56 +0100 Subject: [PATCH] Load screen, path removal, tweaks & error handling Show loading screen on clicking Commit button Committed filepaths need to have pipes replaced with slashes Splice from diffPaths or deletedPaths array so we remove committed files Hide Loading mask if we don't have more to commit Only display alert message and toggle GitHub diff mode if we have no diff or deleted paths left to deal with Error message is an object, so inform user that we'll console.log that. --- lib/github.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/github.php b/lib/github.php index 7444f5d..17ed028 100644 --- a/lib/github.php +++ b/lib/github.php @@ -137,7 +137,7 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset Message:
-
Commit
+
Commit


@@ -177,7 +177,7 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset var repo = github.getRepo(top.repo.split("/")[0], top.repo.split("/")[1]); repo.write( 'master', - committingFiles[seqFile].substr(1), + committingFiles[seqFile].substr(1).replace(/\|/g,"/"), document.getElementById('loadedFile'+seqFile).value, document.getElementById('commitTitle').value+'\n\n'+document.getElementById('commitMessage').value, function(err) { @@ -185,6 +185,16 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset var locSplit = committingFiles[seqFile].lastIndexOf("|"); var location = committingFiles[seqFile].substr(0,locSplit+1); var file = committingFiles[seqFile].substr(locSplit+1); + + // Splice from diff or deleted paths + if (top.diffPaths.indexOf(committingFiles[seqFile].substr(1).replace(/\|/g,"/")) > -1) { + top.diffPaths.splice(top.diffPaths.indexOf(committingFiles[seqFile].substr(1).replace(/\|/g,"/")),1); + } + if (top.deletedPaths.indexOf(committingFiles[seqFile].substr(1).replace(/\|/g,"/")) > -1) { + top.deletedPaths.splice(top.deletedPaths.indexOf(committingFiles[seqFile].substr(1).replace(/\|/g,"/")),1); + } + + // Then deselect and remove from file manager top.ICEcoder.thisFileFolderLink = committingFiles[seqFile]; top.ICEcoder.selectFileFolder(false,'ctrlSim'); top.ICEcoder.updateFileManagerList("delete",location,file); @@ -193,12 +203,16 @@ if (!$demoMode && isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] && isset if (top.ICEcoder.selectedFiles.length > 0) { commitFiles(); } else { - alert('All done, switching modes'); + top.ICEcoder.showHide('hide',top.get('loadingMask')); top.ICEcoder.showHide('hide',top.get('blackMask')); - top.ICEcoder.githubDiffToggle(); + if (top.diffPaths.length == 0 && top.deletedPaths.length == 0) { + top.ICEcoder.message('All done, switching modes'); + top.ICEcoder.githubDiffToggle(); + } } } else { - top.ICEcoder.message('There was an error with committing:\n\n'+err); + top.ICEcoder.message('There was an error with committing.\n\nSee dev tools console for details.'); + console.log(err); } } );