Shout: Tweak the page data initializtion and fix edit form
authorBen Klang <ben@alkaloid.net>
Sun, 3 Jan 2010 05:12:16 +0000 (00:12 -0500)
committerBen Klang <ben@alkaloid.net>
Sun, 3 Jan 2010 05:12:16 +0000 (00:12 -0500)
shout/templates/extensions/list.inc

index 5ac07ed..de149e4 100644 (file)
@@ -93,25 +93,6 @@ var device_image = "<?php echo $registry->getImageDir() . '/shout.png'; ?>";
 var number_image = "<?php echo $registry->getImageDir() . '/telephone-pole.png'; ?>";
 
 var destinations = new Array();
-<?php
-foreach ($extensions as $extension => $info)
-{
-    echo "destinations[${extension}] = {";
-    if (count($info['devices'])) {
-        echo 'devices: ["' . implode('","', $info['devices']) . '"],';
-    }
-    if (count($info['numbers'])) {
-        echo 'numbers: ["' . implode('","', $info['numbers']) . '"],';
-    }
-    echo "};\n";
-
-    echo "contract('${extension}');\n";
-}
-?>
-
-var destX101 = {
-    numbers: []
-}
 
 function resetDestInfo(exten)
 {
@@ -148,9 +129,9 @@ function resetDestInfo(exten)
 
     a = document.createElement('a');
     a.id = 'destX'+exten+'addDest';
-    a.class = 'addDest';
+    a['className'] = 'addDest';
     a.href='#';
-    a.onclick='addDest('+exten+')';
+    a.setAttribute('onclick', 'addDest('+exten+')');
     t = document.createTextNode('Add more destinations...');
     a.appendChild(t);
     $('destX'+exten+'info').appendChild(a);
@@ -198,5 +179,25 @@ function addDest(exten)
     Event.observe($('destX'+exten+'form'), 'submit', function(event) {processForm(event);});
 }
 
+<?php
+foreach ($extensions as $extension => $info)
+{
+    echo "destinations[${extension}] = {";
+    if (count($info['devices'])) {
+        echo 'devices: ["' . implode('","', $info['devices']) . '"],';
+    }
+    if (count($info['numbers'])) {
+        echo 'numbers: ["' . implode('","', $info['numbers']) . '"],';
+    }
+    echo "};\n";
+}
+?>
+
+// Initialize the data.
+for (var i in destinations) {
+    resetDestInfo(i);
+    contract(i);
+}
+
 // -->
 </script>