Author: jvloothuis
Date: Sun Sep 30 21:37:08 2007
New Revision: 47046

Modified:
   
kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js
Log:
Fixed up the plugin a bit more

Modified: 
kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js
==============================================================================
--- 
kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js
    (original)
+++ 
kukit/docs/creating-plugins-plone-conf-2007/src/KSSDemoPlugin/kssdemoplugin/javascript/plugin.js
    Sun Sep 30 21:37:08 2007
@@ -22,18 +22,21 @@
 kukit.actionsGlobalRegistry.register('demoplugin-canvasRect', function (oper) {
 ;;; oper.componentName = '[demoplugin-canvasRect] action';
     
-    oper.evaluateParameters(['fromX', 'fromY', 'toX', 'toY'], 
+    oper.evaluateParameters(['x', 'y', 'width', 'height'], 
                             {'fillStyle': 'rgb(0, 255, 0)'});
-    oper.evalInt('fromX');
-    oper.evalInt('fromY');
-    oper.evalInt('toX');
-    oper.evalInt('toY');
+    oper.evalInt('x');
+    oper.evalInt('y');
+    oper.evalInt('width');
+    oper.evalInt('height');
+
+    var x = oper.parms.x;
+    var y = oper.parms.y;
 
     var ctx = oper.node.getContext("2d");
 
     ctx.fillStyle = oper.parms.fillStyle;
-    ctx.fillRect(oper.parms.fromX, oper.parms.fromY, 
-                 oper.parms.toX, oper.parms.toY);
+    ctx.fillRect(x, y, 
+                 oper.parms.width, oper.parms.height);
 });
 kukit.commandsGlobalRegistry.registerFromAction(
     'demoplugin-canvasRect', kukit.cr.makeSelectorCommand);
@@ -42,30 +45,32 @@
 //-----------------------------------------------------------
 //                      Value provider
 //-----------------------------------------------------------
-var ExampleProvider = function() {};
-ExampleProvider.prototype = {
-    // The check function is executed during the parsing of KSS. Use
-    // this to make sure the arguments are correct.
-    // Use ;;; in the beginning of each line in check.
+var RandomProvider = function() {};
+RandomProvider.prototype = {
 ;;; check: function(args) {
 ;;;     // An example of what you could check is the argument length
-;;;     if (args.length != 1) {
+;;;     if (args.length < 1) {
 ;;;         // Raise an error in case something is wrong
-;;;         throw new Error('exampleProvider provider needs 1 argument 
[message]');
+;;;         throw new Error('demoplugin-random needs at least 1 argument 
[max]');
 ;;;     }
 ;;; },
     eval: function(args, node) {
         // Return the value which for this provider
-        return window.prompt(args[0]);
+        if(args.length == 2){
+            var min = args[0];
+            var max = args[1];
+        } else {
+            var min = 0;
+            var max = args[0];
+        }
+        var range = max - min;
+        var rand = (Math.random() * range) + min;
+        return rand;
+                  
     }
 };
 kukit.pprovidersGlobalRegistry.register(
-    'demoplugin-prompt', ExampleProvider);
-// The line above registers the value provider under the name
-// `demoplugin-exampleProvider`
-
-
-
+    'demoplugin-random', RandomProvider);
 
 //-----------------------------------------------------------
 //              Simple event binder for stateful events
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to