Shindig
  1. Shindig
  2. SHINDIG-1398

Shindig feature has Javascript error in setUserPref

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: Javascript
    • Labels:
      None

      Description

      This can be reproduced very easily. Try the sample container, pointing to the Pixies Lab TODO list.
      (http://localhost:8080/samplecontainer/samplecontainer.html with "Displaying gadget" = http://www.labpixies.com/campaigns/todo/todo.xml)
      Then, with Firebug open, simply add a new TODO item.

      You will see a JS error in the following code from shindig-container.js (from the shindig-container feature).
      It happens on the line "this.userPrefs[...] = ... (see code below).

      The GadgetService doesn't have a userPrefs member. Instead, it should be calling the function on the gadget.

      shindig.IfrGadgetService.prototype.setUserPref = function(editToken, name,
      value) {
      var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
      var gadget = shindig.container.getGadget(id);
      for (var i = 1, j = arguments.length; i < j; i += 2)

      { this.userPrefs[arguments[i]].value = arguments[i + 1]; }

      gadget.saveUserPrefs();
      };

      Changing the line inside the loop to this fixes the problem:
      gadget.userPrefs[arguments[i]].value = arguments[i + 1];

        Activity

        Hide
        Damian Biollo added a comment - - edited

        Additionally, even with this fix, the sample1 container is broken:
        http://localhost:4242/container/sample1.html

        You get a javascript error when adding TODO's in the gadget:
        gadget.userPrefs[arguments[i]] is undefined
        anonymous("383154205", "saved_tasks", "#$LAB_MATAN$#_0#$LAB_UDI$#adf#$LAB_UDI$#_black")shindig-...nocache=1 (line 5114)
        process()shindig-...nocache=1 (line 2820)
        anonymous()

        In the samplecontainer.html, this problem doesn't occur because the metadata, including userPrefs, is initialized on startup.

        Perhaps there should be a check to allow the gadget to work without user preferences?

        Ex:

        if (gadget.userPrefs[arguments[i]])

        { gadget.userPrefs[arguments[i]].value = arguments[i + 1]; }

        else

        { gadgets.warn("User preference does not exist: " + arguments[i] + " for gadget: " + gadget.specUrl); }
        Show
        Damian Biollo added a comment - - edited Additionally, even with this fix, the sample1 container is broken: http://localhost:4242/container/sample1.html You get a javascript error when adding TODO's in the gadget: gadget.userPrefs[arguments [i] ] is undefined anonymous("383154205", "saved_tasks", " #$LAB_MATAN$#_0 #$LAB_UDI$# adf #$LAB_UDI$#_black")shindig-...nocache=1 (line 5114) process()shindig-...nocache=1 (line 2820) anonymous() In the samplecontainer.html, this problem doesn't occur because the metadata, including userPrefs, is initialized on startup. Perhaps there should be a check to allow the gadget to work without user preferences? Ex: if (gadget.userPrefs[arguments [i] ]) { gadget.userPrefs[arguments[i]].value = arguments[i + 1]; } else { gadgets.warn("User preference does not exist: " + arguments[i] + " for gadget: " + gadget.specUrl); }

          People

          • Assignee:
            Unassigned
            Reporter:
            Damian Biollo
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development