From 2cec904fccf6268e93e889ff503a1c2b028918b0 Mon Sep 17 00:00:00 2001 From: Gorrie Date: Fri, 5 Feb 2016 13:29:37 +1300 Subject: [PATCH] Added new config options and fixes Replaced the text search for markup search because the text search is case sensitive. Also is you mark it case insensitive it finds ErrorPage during successful builds. --- code/DevTasks.php | 18 ++++++++++++------ javascript/LeftAndMain.Fancy-devbuild.js | 7 ++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/code/DevTasks.php b/code/DevTasks.php index 19cb599..f8bdcb4 100644 --- a/code/DevTasks.php +++ b/code/DevTasks.php @@ -17,12 +17,14 @@ public function init() return; } - $tasks = array( + $default_tasks = array( 'devbuild' => array( 'title' => 'Dev/Build', 'link' => 'dev/build', 'reset_time' => '5000', + 'error_markup'=> '.xdebug-error,.xe-parse-error', 'error_handler' => 'newtab', + 'success_markup'=> 'li[style="color: blue"],li[style="color: green"]', 'success_handler' => 'ignore' ) ); @@ -30,7 +32,9 @@ public function init() $config_tasks = Config::inst()->get(__CLASS__, 'tasks'); if (is_array($config_tasks)) { - $tasks = array_merge($tasks, $config_tasks); + $tasks = array_merge($default_tasks, $config_tasks); + }else{ + $tasks = $default_tasks; } foreach ($tasks as $item => $values) { @@ -38,10 +42,12 @@ public function init() $attributes = array( 'class' => 'devbuild-trigger', 'data-title' => (isset($values['title']) ? $values['title'] : $item), - 'data-link' => (isset($values['link']) ? $values['link'] : 'dev/build'), - 'data-reset-time' => (isset($values['reset_time']) ? $values['reset_time'] : '5000'), - 'data-error-handler' => (isset($values['error_handler']) ? $values['error_handler'] : 'newtab'), - 'data-success-handler' => (isset($values['success_handler']) ? $values['success_handler'] : 'ignore') + 'data-link' => (isset($values['link']) ? $values['link'] : $default_tasks['devbuild']['link']), + 'data-reset-time' => (isset($values['reset_time']) ? $values['reset_time'] : $default_tasks['devbuild']['reset_time']), + 'data-error-markup' => (isset($values['error_markup']) ? $values['error_markup'] : $default_tasks['devbuild']['error_markup']), + 'data-error-handler' => (isset($values['error_handler']) ? $values['error_handler'] : $default_tasks['devbuild']['error_handler']), + 'data-success-markup' => (isset($values['success_markup']) ? $values['success_markup'] : $default_tasks['devbuild']['success_markup']), + 'data-success-handler' => (isset($values['success_handler']) ? $values['success_handler'] : $default_tasks['devbuild']['success_handler']) ); // priority controls the ordering of the link in the stack. The diff --git a/javascript/LeftAndMain.Fancy-devbuild.js b/javascript/LeftAndMain.Fancy-devbuild.js index c1cec3a..3585171 100644 --- a/javascript/LeftAndMain.Fancy-devbuild.js +++ b/javascript/LeftAndMain.Fancy-devbuild.js @@ -61,11 +61,8 @@ url: $this.data('link') }) .done(function( data, textStatus, xhr ) { - // remove classes - $this.removeClass("loading"); - // search for any errors from returned data - if (data.search("ERROR") > 0) { + if ($(data).find($this.data('error-markup')).length > 0) { completion_handler(data, $this.data('error-handler')); // change text to show an error has occured $this.attr('href', $this.data('link')) @@ -76,7 +73,7 @@ } else { completion_handler(data, $this.data('success-handler')); // change text back to default - changes = $(data).find("li[style='color: blue'], li[style='color: green']").length; + changes = $(data).find($this.data('success-markup')).length; $this.set_trigger(changes+" Changes occurred","success"); setTimeout(function(){ $this.reset_trigger();