From: Damyan Ivanov Date: Sat, 19 Feb 2022 08:30:39 +0000 (+0000) Subject: debug messages in development environment X-Git-Url: https://git.ktnx.net/?p=lsl.git;a=commitdiff_plain;h=082a91fa76feab7dc6d4e4a033169b2dbaea1c49 debug messages in development environment --- diff --git a/lib/App/LazyShoppingList/Web.pm b/lib/App/LazyShoppingList/Web.pm index b2ecbf1..e51c314 100644 --- a/lib/App/LazyShoppingList/Web.pm +++ b/lib/App/LazyShoppingList/Web.pm @@ -15,6 +15,7 @@ set charset => 'UTF-8'; # main web-application get '/' => sub { + set environment => $ENV{PLACK_ENV}; template 'index' => { 'title' => 'App::REST::LazyShoppingList' }; }; diff --git a/public/javascripts/lsl.js b/public/javascripts/lsl.js index c594a44..d1656d4 100644 --- a/public/javascripts/lsl.js +++ b/public/javascripts/lsl.js @@ -1,12 +1,17 @@ "use strict"; (function(){ +var uri_base, environment, devel_env; // filled on page load from an HTML attribute var ui_icon_class_re = new RegExp('\\bui-icon-\\S+\\b'); var uri_id_re = new RegExp('/(\\d+)$'); -var uri_base; // filled on page load from an HTML attribute var lists_version = -1; var lists = []; var selected_list; +function debug(...args) { + if (devel_env) + console.debug.apply(console, args); +} + function uri_id(uri) { var m = uri.match(uri_id_re); return m ? m[1] : null; @@ -171,6 +176,9 @@ function handle_list_item_state_changed(ev) { } $(function(){ uri_base = $('#page').attr('lsl-uri-base'); + environment = $('#page').attr('lsl-environment'); + devel_env = environment == 'development'; + $(document).ajaxStart(function(){ $(document).addClass('blocked'); window.setTimeout( diff --git a/views/index.tt b/views/index.tt index 0b7a8ce..d1f4637 100644 --- a/views/index.tt +++ b/views/index.tt @@ -1,4 +1,4 @@ -
+