summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlpha <ngcoder@live.com>2015-07-27 12:03:53 -0400
committerAlpha <ngcoder@live.com>2015-07-27 12:03:53 -0400
commit01d1eb99b2ff4cb96eefd968990cd7f3c5011395 (patch)
tree25e798162395ac301c536a949382c389957b8b86
parent700adef5a321773bc0feabc206fc7b89bd44e05f (diff)
downloadwebgrind-01d1eb99b2ff4cb96eefd968990cd7f3c5011395.zip
webgrind-01d1eb99b2ff4cb96eefd968990cd7f3c5011395.tar.gz
webgrind-01d1eb99b2ff4cb96eefd968990cd7f3c5011395.tar.bz2
Add clear trace files function
-rw-r--r--index.php18
-rw-r--r--templates/index.phtml16
2 files changed, 34 insertions, 0 deletions
diff --git a/index.php b/index.php
index ab3b5d5..9361c55 100644
--- a/index.php
+++ b/index.php
@@ -174,6 +174,24 @@ try {
echo $response;
break;
+ case 'clear_files':
+ $files = Webgrind_FileHandler::getInstance()->getTraceList();
+ if (!$files) {
+ echo json_encode(array('done' => 'no files found'));
+ break;
+ }
+ $format = array();
+ foreach ($files as $file) {
+ unlink(Webgrind_Config::xdebugOutputDir().$file['filename']);
+ $format[] = preg_quote($file['filename'], '/');
+ }
+ $files = preg_grep('/'.implode('|', $format).'/', scandir(Webgrind_Config::storageDir()));
+ foreach ($files as $file) {
+ unlink(Webgrind_Config::storageDir().$file);
+ }
+ echo json_encode(array('done' => true));
+ break;
+
default:
$welcome = '';
if (!file_exists(Webgrind_Config::storageDir()) || !is_writable(Webgrind_Config::storageDir())) {
diff --git a/templates/index.phtml b/templates/index.phtml
index 8dcd8d9..6ff435c 100644
--- a/templates/index.phtml
+++ b/templates/index.phtml
@@ -276,6 +276,21 @@
);
}
+ function clearFiles() {
+ $.getJSON("index.php",
+ {'op':'clear_files'},
+ function(data) {
+ if (data.error) {
+ $("#hello_message").html(data.error);
+ $("#hello_message").show();
+ return;
+ }
+ reloadFilelist();
+ }
+ );
+ }
+
+
$(document).ready(function() {
$.blockUI.defaults.pageMessage = '<div class="block_box"><h1>Loading...</h1><p>Loading information from server. If the callgrind file is large this may take some time.</p></div>';
$.blockUI.defaults.overlayCSS = { backgroundColor: '#fff', opacity: '0' };
@@ -367,6 +382,7 @@
<div style="margin:0 70px">
<input type="checkbox" name="hideInternals" value="1" <?php echo (Webgrind_Config::$defaultHideInternalFunctions==1) ? 'checked' : ''?> id="hideInternals">
<label for="hideInternals">Hide PHP functions</label>
+ <input type="button" value="clear files" onclick="clearFiles()">
</div>
</form>
</div>