9 Replies Latest reply on Jun 11, 2015 12:16 PM by JohnnyBQue

    Educate me...There is some section of code that I'm not sure as to what it reperesents...

    JohnnyBQue Level 1

      Being new to java-script and learning on the fly at time I try to get things straight in my mine...In doing so I end up using code that have segments that I don't under stand. Below is a section of code that comes from a dynamic stamp. The words that I've highlighted in RED are what I'm needing to be explain to me as to; what they pertain to in the stamp itself; The whole code is at the bottom of the page if you need to reference it.

       

      Thanks guys....

       

       

             if(event.source.forReal && (event.source.stampName == "#fF_WBqLLUm0cA33ryprG3A"))

             {

                if ("ok" == app.execDialog(dialog)) <<<<< I understand what this is

             {

                var cMsg = dialog.starValue; <<<<< I understand what this is

                event.value = "\n" + cMsg; <<<<<<< I believe I know what this does....anything typed within "\n" will also show up in the text field plus dialog starValue

                event.source.source.info.mj = cMsg; <<<<<I'm not sure what this does and I don't know what "mj" represent. What suppose to come after ".info._ _ _"

       

                cMsg = "\n" + dialog.mjValue;<<<<< I understand what this is

                this.getField("MJ/m²").value = cMsg; <<<<<<does the :getField mean the text box from the stamp? and is "MJ/m2" the name of the text box in the stamp?

       

                cMsg = "\n" + dialog.accValue;<<<<< I understand what this is

                this.getField("accreditation").value = cMsg; <<<<< As with "MJ/m2" I'm not sure what "accreditation" represents here.

       

        }

       

        }

       

      WHOLE CODE

       

      var dialog = {

      starValue: "",

      mjValue: "",

      accValue: "",

      bChk1:false,

      bChk2:false,

       

      initialize: function(dialog)

      {

           var dlgInit =

      {

           "Chk1": this.bChk1,

           "Chk2": this.bChk2,

      };

            dialog.load(dlgInit);

         },

       

               commit:function (dialog) { // called when OK pressed

       

                    var results = dialog.store();

                    this.starValue = results["txt1"];

                    this.mjValue = results["txt2"];

                    this.accValue = results["txt3"];

       

                    var oRslt = dialog.store();

                    this.bChk1 = oRslt["Chk1"];

                    this.bChk2 = oRslt["Chk2"];

       

       

        },

       

                     description:

                {

                               name: "Energy Rating Information", // Dialog box title

                              elements:

                [

                {

                            type: "view",

                            elements:

                [

                                      {           

                                           name: "Enter Star Rating: ",

                                                   type: "static_text",

                                      },

                                      {

                                           item_id: "txt1",

                                           type: "edit_text",

                                           multiline: true,

                                           width: 300,

                                           height: 20

                                      },

                                      {

                                           name: "Enter MJ/m²: ",

                                           type: "static_text",

                                      },

                                      {

                                           item_id: "txt2",

                                           type: "edit_text",

                                           multiline: true,

                                           width: 300,

                                           height: 20

                                      },

                                      {

                                           name: "Enter Accreditation Number: ",

                                           type: "static_text",

                                      },

                                      {

                                           item_id: "txt3",

                                           type: "edit_text",

                                           multiline: true,

                                           width: 300,

                                           height: 20

                                      },

                                      {

                                           type: "view",

                                           char_height: 10,

                                           elements:

                                      [

                                      {

                                           type: "static_text",

                                           item_id: "stat",

                                           name: "What type of rating is this?:",

                                           char_width: 15,

                                           alignment: "align_fill",

                                           font: "dialog",

                                      },

                                      {

                                           type: "view",

                                           char_width: 8,

                                           char_height: 8,

                                           align_children: "align_top",

                                           elements:

                                      [

                                      {

                                           type: "view",

                                           char_width: 8,

                                           char_height: 8,

                                           elements:

                                      [

                                      {

                                           type: "check_box",

                                           item_id: "Chk1",

                                           name: "Single dwelling",

                                      },

                                      {

                                           type: "check_box",

                                           item_id: "Chk2",

                                           name: "Multi-unit development",

                                      },

       

                                      ]

                                      },

                                      ]

                                      },

                                      ]

                                      },

                                      {

                                            type: "ok_cancel",

                                            ok_name: "Ok",

                                            cancel_name: "Cancel"

                                      },

                                      ]

                                      },

                                      ]

                                      }

                                      };

       

       

             if(event.source.forReal && (event.source.stampName == "#fF_WBqLLUm0cA33ryprG3A"))

             {

                if ("ok" == app.execDialog(dialog))

             {

                var cMsg = dialog.starValue;

                event.value = "\n" + cMsg;

                event.source.source.info.mj = cMsg;

       

                cMsg = "\n" + dialog.mjValue;

                this.getField("MJ/m²").value = cMsg;

       

                cMsg = "\n" + dialog.accValue;

                this.getField("accreditation").value = cMsg;

       

        }

       

        }