diff options
author | oetting <jacob@oettinger.dk> | 2008-06-08 14:58:01 +0000 |
---|---|---|
committer | oetting <jacob@oettinger.dk> | 2008-06-08 14:58:01 +0000 |
commit | eb98e16e0871501c54f7da0ba38aa298a7210fc8 (patch) | |
tree | 553ba284a96903bcda2e3f46c4ae9958a1f6d74a | |
parent | 387876778916bd10ddb837aa540003c557a1e29d (diff) | |
download | webgrind-eb98e16e0871501c54f7da0ba38aa298a7210fc8.zip webgrind-eb98e16e0871501c54f7da0ba38aa298a7210fc8.tar.gz webgrind-eb98e16e0871501c54f7da0ba38aa298a7210fc8.tar.bz2 |
Changed version checker to use ajax request
-rw-r--r-- | config.php | 4 | ||||
-rw-r--r-- | index.php | 14 | ||||
-rw-r--r-- | templates/index.phtml | 34 |
3 files changed, 40 insertions, 12 deletions
@@ -7,6 +7,10 @@ */ class Webgrind_Config{ static $webgrindVersion = '0.7'; + + /** + * Automatically check if a newer version of webgrind is available for download + */ static $checkVersion = true; /** @@ -129,17 +129,11 @@ switch(get('op')){ require 'templates/fileviewer.phtml'; break; + case 'version_info': + $response = @file_get_contents('http://jokke.dk/webgrindupdate.json?version='.Webgrind_Config::$webgrindVersion); + echo $response; + break; default: - $versionInfo = null; - if (Webgrind_Config::$checkVersion) { - $result = file_get_contents('http://jokke.dk/webgrindupdate.json?version='.Webgrind_Config::$webgrindVersion); - if (false !== $result && ($versionData = json_decode($result)) && isset($versionData->latest_version)) { - if ($versionData->latest_version > Webgrind_Config::$webgrindVersion) - $versionInfo = "Version ".$versionData->latest_version." is available for <a href='".$versionData->download_url."'>download</a>.<br>"; - else - $versionInfo = "You have the latest version.<br>"; - } - } require 'templates/index.phtml'; } diff --git a/templates/index.phtml b/templates/index.phtml index ed795df..1e34ae7 100644 --- a/templates/index.phtml +++ b/templates/index.phtml @@ -14,6 +14,7 @@ var fileUrlFormat = '<?php echo Webgrind_Config::$fileUrlFormat?>'; var currentDataFile = null; var callInfoLoaded = new Array(); + var disableAjaxBlock = false; function getOptions(){ options = new Object(); options.dataFile = $("#dataFile").val(); @@ -174,13 +175,35 @@ $.blockUI('<div class="block_box"><h1>Sorting...</h1></div>'); } + function loadBlock(){ + if(!disableAjaxBlock) + $.blockUI(); + disableAjaxBlock = false; + } + + function checkVersion(){ + disableAjaxBlock = true; + $.getJSON("index.php", + {'op':'version_info'}, + function(data){ + if(data.latest_version><?=Webgrind_Config::$webgrindVersion?>){ + $("#version_info").append('Version '+data.latest_version+' is available for <a href="'+data.download_url+'">download</a>.'); + } else { + $("#version_info").append('You have the latest version.'); + } + + } + ); + + } $(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' }; $.blockUI.defaults.fadeIn = 0; $.blockUI.defaults.fadeOut = 0; - $().ajaxStart($.blockUI).ajaxStop($.unblockUI); + $().ajaxStart(loadBlock).ajaxStop($.unblockUI); $("#function_table").tablesorter({ widgets: ['zebra'], sortInitialOrder: 'desc', @@ -195,6 +218,11 @@ if(document.location.hash) { update(document.location.hash.substr(1)); } + + <?if(Webgrind_Config::$checkVersion):?> + setTimeout(checkVersion,100); + <?endif?> + }); </script> @@ -262,7 +290,9 @@ </div> <h2 id="hello_message">Select a cachegrind file above</h2> <div id="footer"> - <?=$versionInfo?> + <?if(Webgrind_Config::$checkVersion):?> + <div id="version_info"> </div> + <?endif?> Copyright © 2008 Jacob Oettinger & Joakim Nygård. <a href="http://code.google.com/p/webgrind/">webgrind homepage</a> </div> </body> |