Commits

Anonymous committed 64b005c

fixing HTSQL 1.0 compatibility

Comments (0)

Files changed (9)

htraf/examples10/chart.html

     <div class="chart" style="width: 450px;" 
          data-htsql="/program{degree^,count(student)}
          ?school=$school&count(student)>0" 
+         data-ref="school"
          data-widget="chart"
          data-type="pie"></div>
     

htraf/examples10/error/attr_handler.html

                 if(!$el.is('.error'))
                     $el = $('<div class="error"></div>')
                         .insertAfter(info.element);
-                var reason = $('<strong/>').text(info.reason);
-                var detail = $('<em/>').text(info.detail);
+                var reason = $('<pre/>').text(info.reason);
+                var detail = $('<pre/>').text(info.detail);
                 $el.append('<h3>Custom handler for prev. element</h3>')
                     .append(reason).append('<br>').append(detail);
             } 
     <select id="school" data-htsql="/school{code, name}"></select>
     <div>Selected School: 
         <span data-htsql="/school{na me}?code=$school"
-              data-onerror="onerror(arguments[1]);"></span>
+              data-onerror="onerror(arguments[1]);"
+              data-ref="school"></span>
     </div>
     <h3>Departments</h3>
     <p>Filter By Name <input id="department_name"/></p>
     <table id="department"
         data-htsql="/department{code, name, school.name}
-                     ?school=$school&name~$department_name">
+                   ?school=$school&name~$department_name"
+        data-ref="school department_name">
     </table>
     <p>
         Selected Department: 
-        <em data-htsql="/department{name}?code=$department"></em> <br/>
+        <em data-htsql="/department{name}?code=$department"
+            data-ref="department"></em> <br/>
         Count of Courses in Selected Department: 
-        <strong data-htsql="department_name.htsql">
+        <strong data-htsql="department_name.htsql"
+                data-ref="department">
         </strong>
     </p>
 </body>

htraf/examples10/error/custom_handler.html

             if(!$el.is('.error'))
                 $el = $('<div class="error"></div>')
                     .insertAfter(info.element);
-            var reason = $('<strong/>').text(info.reason);
-            var detail = $('<em/>').text(info.detail);
-            $el.append('<h3>Previous element has triggered error</h3>')
+            var reason = $('<pre/>').text(info.reason);
+            var detail = $('<pre/>').text(info.detail);
+            $el.append('<h3>Previous element has triggered an error</h3>')
                 .append(reason).append('<br>').append(detail);
         } 
     </script>
     <h3>Select School</h3>
     <select id="school" data-htsql="/school{code, name}"></select>
     <div>Selected School: 
-        <span data-htsql="/school{na me}?code=$school"></span>
+        <span data-htsql="/school{na me}?code=$school"
+              data-ref="school"></span>
     </div>
     <h3>Departments</h3>
     <p>Filter By Name <input id="department_name"/></p>
     <table id="department"
         data-htsql="/department{code, name, school.name}
-                     ?school=$school&name~$department_name">
+                    ?school=$school&name~$department_name"
+        data-ref="school department_name">
     </table>
     <p>
         Selected Department: 
-        <em data-htsql="/department{name}?code=$department"></em> <br/>
+        <em data-htsql="/department{name}?code=$department"
+            data-ref="department"></em> <br/>
         Count of Courses in Selected Department: 
-        <strong data-htsql="department_name.htsql">
+        <strong data-htsql="department_name.htsql"
+                data-ref="department">
         </strong>
     </p>
 </body>

htraf/examples10/error/index.html

     <h3>Select School</h3>
     <select id="school" data-htsql="/school{code, name}"></select>
     <div>Selected School: 
-        <span data-htsql="/school{na me}?code=$school"></span>
+        <span data-htsql="/school{na me}?code=$school"
+              data-ref="school"></span>
     </div>
     <h3>Departments</h3>
     <p>Filter By Name <input id="department_name"/></p>
     <table id="department"
         data-htsql="/department{code, name, school.name}
-                     ?school=$school&name~$department_name">
+                    ?school=$school&name~$department_name"
+        data-ref="school department_name">
     </table>
     <p>
         Selected Department: 
-        <em data-htsql="/department{name}?code=$department"></em> <br/>
+        <em data-htsql="/department{name}?code=$department"
+            data-ref="department"></em> <br/>
         Count of Courses in Selected Department: 
-        <strong data-htsql="department_name.htsql">
+        <strong data-htsql="department_name.htsql"
+                data-ref="department">
         </strong>
     </p>
 </body>

htraf/examples10/iframe_list.html

     <iframe data-htsql="/program{title, count(student)}
                          ?count(student)>0&school=$school
                         /chart(type='pie', legend='ne', 
-                               title='Students By Program')">
+                        title='Students By Program')"
+            data-ref="school">
     </iframe>
-    <script data-htsql="/department{1^,count(course)}?school=$school">
+    <script data-htsql="/department{1^,count(course)}?school=$school"
+            data-ref="school">
     </script>
 </body>
 </html>

htraf/examples10/param.html

+<!DOCTYPE html>
+<html>
+<head>
+    <title>Query string parameters handling</title>
+    <script type="text/javascript" src="/-/htraf/htraf.js"></script>
+    <link type="text/css" rel="stylesheet" href="../css/htraf-02.css"/> 
+</head>
+<body>
+    <h1>Use query string to get more departments (?school=bus for example)</h1>
+
+    <h3>Select School</h3>
+    <select id="school" data-htsql="/school{code, name}"></select>
+
+    <h3>Departments</h3>
+    <table id="department"
+        data-htsql="/department{code, name, school.name}
+                   ?school=$school|school.name~$_school"
+        data-ref="school _school">
+    </table>
+</body>
+</html>

htraf/examples10/slots.html

     <h3>Select School</h3>
     <select id="school" data-htsql="/school{code, name}"></select>
     <h3>Departments</h3>
-    <script id="department" data-htsql="/department?school=$school"></script>
+    <script id="department" data-htsql="/department?school=$school"
+            data-ref="school"></script>
     <table id="department_table" data-bind="department">
     </table>
     <p>
         <script id="d" data-bind="department_table" data-slot="code"></script>
         <br/>
         <span>Count of Courses in Selected Department: </span>
-        <strong data-htsql="/department{count(course)}?code=$d">
+        <strong data-htsql="/department{count(course)}?code=$d" data-ref="d">
         </strong>
     </p>
 
     <div class="description">
         On-page widgets linking and data-slot functionality.
     </div>
+    <h3><a href="examples10/param.html">Query string parameters</a></h3>
+    <div class="description">
+        <em>?var=value</em> is accessible inside the <em>data-htsql</em> as 
+        $_var. If _var value is not provided but _var is listed in 
+        <em>data-ref</em> - null is assummed.
+    </div>
 </body>
 </html>

htraf/js/htraf.widgets.js

         }
         else if (obj instanceof Object) {
             var ret = []; 
-            for(var key in obj)
+            for(var key in obj) {
+                if(HTRAF.htsqlVersion == '1' && (obj[key] === null 
+                || obj[key] === undefined))
+                    continue;
                 ret.push(_escape(key) + ':' + _escape(obj[key]));
+            }
             return '{' + ret.join(',') + '}';
         }
         else {
                         return;
                     if(id.substr(0, 1) == '_') {
                         var value = HTRAF.param[id.substr(1, id.length)];
-                        if(value)
-                            self._param[id] = value;
+                        self._param[id] = value || null;
                     }
                     else
                         refs.push('#' + id);