Global.extractContent (param, origContent)
extract content properties from the object containing the submitted form values (req.data)

  • Parameter Obj:
    Parameter object (usually req.data)
  • Parameter Obj:
    HopObject containing any already existing content
  • Returns
    Obj JS object containing the following properties: .value: HopObject() containing extracted content .exists: Boolean true in case content was found .isMajorUpdate: Boolean true in case one content property differs for more than 50 characters
Sourcecode in Global/objectFunctions.js:
1:   function extractContent(param, origContent) {
2:      var result = {isMajorUpdate: false, exists: false, value: new HopObject()};
3:      for (var i in param) {
4:         if (i.startsWith("content_")) {
5:            var partName = i.substring(8);
6:            var newContentPart = param[i].trim();
7:            // check if there's a difference between old and
8:            // new text of more than 50 characters:
9:            if (!result.isMajorUpdate && origContent) {
10:              var len1 = origContent[partName] ? origContent[partName].length : 0;
11:              var len2 = newContentPart.length;
12:              result.isMajorUpdate = Math.abs(len1 - len2) >= 50;
13:           }
14:           result.value[partName] = newContentPart;
15:           if (newContentPart)
16:              result.exists = true;
17:        }
18:     }
19:     return result;
20:  }