Snapchat StoryNote

@class
@param {Object} params
198562
function StoryNote (params) {
  var self = this
  if (!(self instanceof StoryNote)) return new StoryNote(params)

  // who viewed the story
  self.viewer = params['viewer']

  // when the story was viewed by the viewer
  self.viewDate = new Date(+params['timestamp'])

  // whether or not the viewer took a screenshot of the story
  self.screenshot = !!params['screenshotted']

  // obscure data. not sure what is's for but it has the following format:
  // {
  //   mField : "123456.023Z"
  //   mId    : "username~unixtime"
  //   mKey   : "story:{username}:YYYYMMDD"
  // }
  self.storyPointer = params['storypointer']
}
849332
function StoryCollection (client, params) {
  var self = this
  if (!(self instanceof StoryCollection)) return new StoryCollection(client, params)
  if (!(client instanceof Snapchat)) throw new Error('invalid client')

  self.client = client

  var thumbs = params['thumbnails']

  // The username of the user associated with this story collection.
  self.username = params['username']
  // Whether this story contains explicit content.
  self.matureContent = !!params['mature_content']

  // shared stories only

  // Only applies to shared stories.
  self.adPlacementData = params['ad_placement_metadata']
  // The display name of the shared story.
  self.displayName = params['display_name']
  // The identifier of the shared story.
  self.sharedIdentifier = params['shared_id']
  // Whether the shared story is local or not.
  self.isLocal = !!params['is_local']

  // Only applies to shared stories.
  if (thumbs) {
    // The thumbnail for the viewed state of the story.
    self.viewedThumbnail = thumbs['viewed']['url']
    // The thumbnail for the unviewed state of the story.
    self.unviewedThumbnail = thumbs['unviewed']['url']

    self.viewedThumbnailNeedsAuth = !!thumbs['viewed']['needs_auth']
    self.unviewedThumbnailNeedsAuth = !!thumbs['unviewed']['needs_auth']
  }

  // An array of Story objects.
  self.stories = (params['stories'] || []).map(function (story) {
    xtend(story.story, {
      'viewed': story.viewed
    })
    return new Story(self.client, story.story)
  })
}
357308
function Snapchat (opts) {
  var self = this
  if (!(self instanceof Snapchat)) return new Snapchat(opts)
  if (!opts) opts = {}

  debug('new snapchat client')

  self._account = new Account(self, opts)
  self._chat = new Chat(self, opts)
  self._device = new Device(self, opts)
  self._friends = new Friends(self, opts)
  self._snaps = new Snaps(self, opts)
  self._stories = new Stories(self, opts)
}
1159002
function populateSnapshot(app, uid, cb) {
  logger.debug('populateSnapshot entry');

  app.models.snapshot.create(
    { id: uid,
      refcount: '1',
      current: 'false' },
    function(err, mymodel) {
      if (err) {
        logger.error('populateSnapshot error');
        cb(err);
        return;
      }
      logger.debug('populateSnapshot exit: %j', mymodel);
      cb();
    });
}
1348560
function(params){
        var allDataMatches = true;
        for(var k = 0; k < query[params.name].length; k++){
          var data = query[params.name][k];
          var operator = data.operator;
          var value = data.value;
          var field = data.field;
          var matches;
          
          if( operator != null && value != null ){
            
            var fieldVal = params.fieldValue(field);
            var fieldStr = !$$.is.string(fieldVal) && !$$.is.number(fieldVal) ? '' : '' + fieldVal;
            var valStr = '' + value;
            
            var caseInsensitive = false;
            if( operator.charAt(0) == '@' ){
              fieldStr = fieldStr.toLowerCase();
              valStr = valStr.toLowerCase();
              
              operator = operator.substring(1);
              caseInsensitive = true;
            }
            
            // if we're doing a case insensitive comparison, then we're using a STRING comparison
            // even if we're comparing numbers
            if( caseInsensitive ){
              value = valStr.toLowerCase();
              fieldVal = fieldStr.toLowerCase();
            }

            switch(operator){
            case '*=':
              matches = fieldStr.search(valStr) >= 0;
              break;
            case '$=':
              matches = new RegExp(valStr + '$').exec(fieldStr) != null;
              break;
            case '^=':
              matches = new RegExp('^' + valStr).exec(fieldStr) != null;
              break;
            case '=':
              matches = fieldVal === value;
              break;
            case '!=':
              matches = fieldVal !== value;
              break;
            case '>':
              matches = fieldVal > value;
              break;
            case '>=':
              matches = fieldVal >= value;
              break;
            case '<':
              matches = fieldVal < value;
              break;
            case '<=':
              matches = fieldVal <= value;
              break;
            default:
              matches = false;
              break;
              
            }
          } else if( operator != null ){
            switch(operator){
            case '?':
              matches = params.fieldTruthy(field);
              break;
            case '!':
              matches = !params.fieldTruthy(field);
              break;
            case '^':
              matches = params.fieldUndefined(field);
              break;
            }
          } else {   
            matches = !params.fieldUndefined(field);
          }
          
          if( !matches ){
            allDataMatches = false;
            break;
          }
        } // for
        
        return allDataMatches;
      }
236397
function popupElectronLogin(params) {
	if ( require('electron').remote )
		BrowserWindow = require('electron').remote.BrowserWindow;
	else
		BrowserWindow = require('electron').BrowserWindow;

	var url = core.REDIRECT_URL + 'oauth2/authorize?' + util.param(params);

	var win = new BrowserWindow({
		width: WIDTH,
		height: HEIGHT,
		resizable: false,
		show: false,
		webPreferences:{
      nodeIntegration: false
    }
	});

	win.loadURL(url);
	win.webContents.on('did-finish-load', function() {
		var location = URL.parse(win.webContents.getURL());

		if (location.hostname == 'api.twitch.tv' && location.pathname == '/kraken/') {
      core.setSession(util.parseFragment(location.hash));

      auth.getStatus(function(err, status) {
        if (status.authenticated) {
          core.events.emit('auth.login', status);
        }
      });

      win.close();
    }
    else {
      win.show();
    }
	});
}
975192
function (params) {
		var pointerEventsSpec = params.pointerEventsSpec || "all", renderer = {};

		_jp.jsPlumbUIComponent.apply(this, params.originalArgs);
		this.canvas = null;
		this.path = null;
		this.svg = null;
		this.bgCanvas = null;

		var clazz = params.cssClass + " " + (params.originalArgs[0].cssClass || ""),
			svgParams = {
				"style": "",
				"width": 0,
				"height": 0,
				"pointer-events": pointerEventsSpec,
				"position": "absolute"
			};

		this.svg = _node("svg", svgParams);

		if (params.useDivWrapper) {
			this.canvas = jsPlumb.createElement("div", { position : "absolute" });
			_ju.sizeElement(this.canvas, 0, 0, 1, 1);
			this.canvas.className = clazz;
		}
		else {
			_attr(this.svg, { "class": clazz });
			this.canvas = this.svg;
		}

		params._jsPlumb.appendElement(this.canvas, params.originalArgs[0].parent);
		if (params.useDivWrapper) this.canvas.appendChild(this.svg);

		var displayElements = [ this.canvas ];
		this.getDisplayElements = function () {
			return displayElements;
		};

		this.appendDisplayElement = function (el) {
			displayElements.push(el);
		};

		this.paint = function (style, anchor, extents) {
			if (style != null) {

				var xy = [ this.x, this.y ], wh = [ this.w, this.h ], p;
				if (extents != null) {
					if (extents.xmin < 0) xy[0] += extents.xmin;
					if (extents.ymin < 0) xy[1] += extents.ymin;
					wh[0] = extents.xmax + ((extents.xmin < 0) ? -extents.xmin : 0);
					wh[1] = extents.ymax + ((extents.ymin < 0) ? -extents.ymin : 0);
				}

				if (params.useDivWrapper) {
					_ju.sizeElement(this.canvas, xy[0], xy[1], wh[0], wh[1]);
					xy[0] = 0;
					xy[1] = 0;
					p = _pos([ 0, 0 ]);
				}
				else
					p = _pos([ xy[0], xy[1] ]);

				renderer.paint.apply(this, arguments);

				_attr(this.svg, {
					"style": p,
					"width": wh[0] || 0,
					"height": wh[1] || 0
				});
			}
		};

		return {
			renderer: renderer
		};
	}
391505
function(newCallFrames, details, asyncStackTrace)
    {
        // FIXME: declare this property in protocol and in JavaScript.
        if (details && details["stack_update_needs_step_in"])
            this.stepInto();
        else if (newCallFrames && newCallFrames.length)
            this._pausedScript(newCallFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData, this._debuggerPausedDetails.breakpointIds, asyncStackTrace);
    }
890089
function(params, callback) {
        /**
         * Callback for QB.chat.dialog.create().
         * @param {Object} error - The error object
         * @param {Object} createdDialog - the dialog object
         * @callback createDialogCallback
         * */

        if (params && params.occupants_ids && Utils.isArray(params.occupants_ids)) {
            params.occupants_ids = params.occupants_ids.join(', ');
        }

        this.service.ajax({
            url: Utils.getUrl(DIALOGS_API_URL),
            type: 'POST',
            data: params
        }, callback);
    }
575866
function (params) {
            var element = this.element;
            var text = this.__text;
            var waiAria = this._waiAria;
            var waiAriaReadInterval = this._waiAriaReadInterval;
            var waiAriaReadOnceFirst = this._waiAriaReadOnceFirst;

            var overlay = this.$Overlay._createOverlay.call(this, params);

            if (waiAria) {
                this._showElementBack = ariaUtilsDomNavigationManager.hidingManager.hide(element);
                this._navigationInterceptor = ariaUtilsDomNavigationManager.SkippedElementNavigationHandler(element);
                this._navigationInterceptor.ensureElements();
            }

            if (text) {
                overlay.innerHTML = waiAria ?
                    "<span class='xLDI-text' aria-live='polite'>" + text + "</span>" :
                    "<span class='xLDI-text'>" + text + "</span>";

                if (waiAria) {
                    if (waiAriaReadOnceFirst) {
                        this._readText();
                    }
                    this._waiAriaReadIntervalId = setInterval(ariaUtilsFunction.bind(this._readText, this), waiAriaReadInterval);
                }
            }

            return overlay;
        }
407084
function(params, callback) {
      var t = this,
          connectError = false,
          monitors = t.get('monitors');

      if (t.get('started')) {
        var err = {code:'RUNNING', msg:'Cannot start - the recipe is already running.'};
        logger.warn(err);
        return callback(err);
      }

      // Called when a monitor has connected
      var onConnect = function(error) {
        if (connectError) {return;}
        if (error) {
          var err = {code:'CONNECT_ERROR', err: error};
          connectError = true;
          logger.error('start', err);
          return callback(err);
        }
        for (var name1 in t.monitors) {
          if (!t.monitors[name1].isConnected()) {
            return;
          }
        }
        t.set({started:true});
        t.connectListeners(true);
        callback();
      };

      // Connect all monitors
      for (var name2 in monitors) {
        t.monitors[name2] = new Monitor(monitors[name2]);
        t.monitors[name2].connect(onConnect);
      }

    }
115425
function requestGoogleNewsRSS(params, callback) {
    // parse the params
    var returnObject = parseGoogleNewsRSSParams(params);
    returnObject.newsArray = null;
    // if no error from the parsing object
    if (!returnObject.error) {
        // make a request to the RSS using the URL
        var request = require("request");
        request({uri: returnObject.url}, 
        function(error, response, body) {
            // if no error in the call
            if (!error) {
                // parse the RSS data
                var parsedData = parseGoogleNewsRSSData(body);
                // if parsing runs okay, add data to the return object and return it
                if (parsedData.error == false) {
                    returnObject.error = false;      
                    returnObject.errorMessage = null;
                    returnObject.newsArray = parsedData.data;
                    callback(returnObject);
                }                    
                // otherwise parsing failed, indicate such
                else {
                    returnObject.error = true;
                    returnObject.errorMessage = 'Error with parsing data return from Google News.';
                    callback(returnObject);
                }
            }
            // otherwise indicate bad request
            else {
                returnObject.error = true;
                returnObject.errorMessage = 'Error with request for data from Google News.';
                callback(returnObject);
            }
        });        
    }
    // otherwise send back error true object from original params parsing
    else {
        callback(returnObject);
    }
}
108416
function (params) {
            if (! this.active) {
                return;
            }

            var paramsArr = Array.prototype.slice.call(arguments),
                n = this._bindings.length,
                bindings;

            if (this.memorize) {
                this._prevParams = paramsArr;
            }

            if (! n) {
                //should come after memorize
                return;
            }

            bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch
            this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch.

            //execute all callbacks until end of the list or until a callback returns `false` or stops propagation
            //reverse loop since listeners with higher priority will be added at the end of the list
            do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
        }
567630
function(params) {
      This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum] = [];
      if (This.isFirstLine(This.lineNum)) {
        if (params.name) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.name;}
      } else {
        if (params.subname) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.staffNum].title[This.voiceNum] = params.subname;}
      }
      if (params.style)
        This.appendElement('style', null, null, {head: params.style});
      if (params.stem)
        This.appendElement('stem', null, null, {direction: params.stem});
      else if (This.voiceNum > 0) {
        if (This.lines[This.lineNum].staff[This.staffNum].voices[0]!== undefined) {
          var found = false;
          for (var i = 0; i < This.lines[This.lineNum].staff[This.staffNum].voices[0].length; i++) {
            if (This.lines[This.lineNum].staff[This.staffNum].voices[0].el_type === 'stem')
              found = true;
          }
          if (!found) {
            var stem = { el_type: 'stem', direction: 'up' };
            This.lines[This.lineNum].staff[This.staffNum].voices[0].splice(0,0,stem);
          }
        }
        This.appendElement('stem', null, null, {direction: 'down'});
      }
      if (params.scale)
        This.appendElement('scale', null, null, { size: params.scale} );
    }
1087934
function StoryUpdater (storyID, timestamp, screenshotCount) {
  var self = this
  if (!(self instanceof StoryUpdater)) return new StoryUpdater(storyID, timestamp, screenshotCount)

  self.storyID = storyID
  self.timestamp = timestamp
  self.screenshotCount = screenshotCount
}
20611
function QueryDBRead(params) {
        RED.nodes.createNode(this, params);
        this.name = params.name;
        this.waitfor = params.waitfor;
        let node = this;
        this.on('input', function(msg) {
            if (msg.error) {
                // FIXME: Add error handling here
            } else {
                params.actionType = 'read';
                node.log('QueryDBNode');
                node.log(JSON.stringify(params));
                // node.log(JSON.stringify(msg));
                processDBNode(node, params, msg);
            }
        });
    }
178722
function LocalStorage (params) {
  events.EventEmitter.call(this);

  if (!params || typeof params === 'string') {
    params = {
      ns: params || ''
    };
  }

  this.ns = params.ns || '';

  if (typeof this.ns !== 'string') {
    throw new Error('Namespace must be a string.');
  }

  this.preSave = params.preSave || defProcessor;
  this.postLoad = params.postLoad || defProcessor;

  if (this.preSave && typeof this.preSave !== 'function') {
    throw new Error('preSave option must be a function');
  }

  if (this.postLoad && typeof this.postLoad !== 'function') {
    throw new Error('postLoad option must be a function');
  }

  this.EVENTS = EVENTS;
}