devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From re...@apache.org
Subject svn commit: r1694243 - in /devicemap/trunk/clients/2.0/javascript: devicemap.js index.html
Date Wed, 05 Aug 2015 15:04:57 GMT
Author: rezan
Date: Wed Aug  5 15:04:56 2015
New Revision: 1694243

URL: http://svn.apache.org/r1694243
Log:
load patterns

Modified:
    devicemap/trunk/clients/2.0/javascript/devicemap.js
    devicemap/trunk/clients/2.0/javascript/index.html

Modified: devicemap/trunk/clients/2.0/javascript/devicemap.js
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/javascript/devicemap.js?rev=1694243&r1=1694242&r2=1694243&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/javascript/devicemap.js (original)
+++ devicemap/trunk/clients/2.0/javascript/devicemap.js Wed Aug  5 15:04:56 2015
@@ -1,6 +1,6 @@
 var devicemap = devicemap || {};
 
-devicemap.version = "2.0.0";
+devicemap.version = '2.0.0';
 devicemap.debugLevel = devicemap.debugLevel || 2;
 
 devicemap.debug = devicemap.debug || function(level, s) {
@@ -10,4 +10,8 @@ devicemap.debug = devicemap.debug || fun
   }
 };
 
-devicemap.debug(1, "Apache DeviceMap Javascript Client", devicemap.version);
+devicemap.loadPattern = function(patternFile) {
+  devicemap.debug(2, 'loadPattern:', patternFile.domain);
+};
+
+devicemap.debug(1, 'Apache DeviceMap Javascript Client', devicemap.version);

Modified: devicemap/trunk/clients/2.0/javascript/index.html
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/javascript/index.html?rev=1694243&r1=1694242&r2=1694243&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/javascript/index.html (original)
+++ devicemap/trunk/clients/2.0/javascript/index.html Wed Aug  5 15:04:56 2015
@@ -4,6 +4,10 @@
 </head>
 <body>
   <h1>Apache DeviceMap 2.0 Javascript Client</h1>
+  Pattern file: <input id="pattern" type="text" size="50" value="http://www.rezsoft.org/devicemap/data/reference/a/patterns.json"><br>
+  <br>
+  <input type="button" value="Load" onclick="load()"><br>
+  <br>
   <div class="out">
     <textarea id="out" rows="6" cols="80" disabled></textarea>
   </div>
@@ -33,6 +37,47 @@
         out.scrollTop = out.scrollHeight;
       }
     };
+
+    function load() {
+      var pattern = document.getElementById('pattern').value;
+
+      devicemap.debug(3, 'Load clicked:', pattern);
+
+      var patternFile = {};
+      var count = 0;
+      var countRequired = 1;
+
+      getFile(pattern, function(request) {
+        if (request.status >= 200 && request.status < 300){
+          patternFile = JSON.parse(request.responseText);
+          count++;
+          if(count === countRequired) {
+            loadClient(patternFile);
+          }
+        } else {
+          devicemap.debug(0, 'Bad response code', request.status, pattern);
+        }
+      });
+    }
+
+    function loadClient(patternFile) {
+      devicemap.loadPattern(patternFile);
+    }
+
+    function getFile(url, onready) {
+      var request = new XMLHttpRequest();
+      request.open('GET', url, true);
+
+      request.onload = function() {
+        onready(request);
+      };
+
+      request.onerror = function() {
+        devicemap.debug(0, 'Error loading', url);
+      };
+
+      request.send();
+    }
   </script>
   <script src="devicemap.js"></script>
   <script src="devicemaptest.js"></script>



Mime
View raw message