Better tab switching with a cookie

Wed, 14 Jan 2015 13:20:16 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 14 Jan 2015 13:20:16 +0100
changeset 305
fc2fae36f4ba
parent 304
c1be51c076c9
child 306
97602274eb58

Better tab switching with a cookie

www-thermferm/js/index.js file | annotate | diff | comparison | revisions
www-thermferm/liveview.php file | annotate | diff | comparison | revisions
--- a/www-thermferm/js/index.js	Wed Jan 14 12:50:12 2015 +0100
+++ b/www-thermferm/js/index.js	Wed Jan 14 13:20:16 2015 +0100
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * Copyright (C) 2014
+ * Copyright (C) 2014-2015
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -29,7 +29,12 @@
       });
     }, 60000);
     // Create jqxTabs.
-    $("#jqxTabs").jqxTabs({ width: 978, height: 428, position: 'top', theme: 'ui-redmond'});
+    var index = $.jqx.cookie.cookie("jqxTabs_jqxWidget");
+    if (undefined == index) index = 0;
+    $("#jqxTabs").jqxTabs({ selectedItem: index, width: 978, height: 428, position: 'top', theme: 'ui-redmond'});
+    $("#jqxTabs").on('selected', function (event) {
+      $.jqx.cookie.cookie("jqxTabs_jqxWidget", event.args.item);
+    });
     $("#maintenance").jqxButton({ width: 150, height: 25, theme: 'ui-redmond' });
 });
 
--- a/www-thermferm/liveview.php	Wed Jan 14 12:50:12 2015 +0100
+++ b/www-thermferm/liveview.php	Wed Jan 14 13:20:16 2015 +0100
@@ -1,6 +1,6 @@
 <?php
 /*****************************************************************************
- * Copyright (C) 2014
+ * Copyright (C) 2014-2015
  *   
  * Michiel Broek <mbroek at mbse dot eu>
  *
@@ -428,19 +428,6 @@
     if (strlen($answer)) {
 	$arr = explode("\r\n", $answer);
 
-	$outstr .= '   <script type="text/javascript">'.PHP_EOL;
-	$outstr .= '    $(document).ready(function () {'.PHP_EOL;
-	$outstr .= '     var index = $.jqx.cookie.cookie("jqxTabs_jqxWidget");'.PHP_EOL;
-	$outstr .= '     if (undefined == index) index = 0;'.PHP_EOL;
-	$outstr .= '       $(\'#jqxTabs\').jqxTabs({selectedItem: index, width: \'90%\', height: 200, position: \'top\'});'.PHP_EOL;
-	// on to the select event.
-	$outstr .= '       $("#jqxTabs").on(\'selected\', function (event) {'.PHP_EOL;
-	// save the index in cookie.
-	$outstr .= '       $.jqx.cookie.cookie("jqxTabs_jqxWidget", event.args.item);'.PHP_EOL;
-	$outstr .= '     });'.PHP_EOL;
-	$outstr .= '    });'.PHP_EOL;
-	$outstr .= '   </script>'.PHP_EOL;
-
 	$outstr .= '   <div id="jqxTabs">'.PHP_EOL;
 	$outstr .= '    <ul>'.PHP_EOL;
 	if (startsWith($arr[0], "212")) {

mercurial