/*
action [data] [options]
8539
function() {
         //copy to make real Array
         var args = Array.prototype.slice.call( arguments );
         var action = args.shift();
         args = deduceArgs(args);
         var txn = args[1].txn, data = args[0], callback = args[1].callback,
            comment = args[1].comment, override = args[1].override,
            fileinput = args[1].fileinput;
         var commitNow = false;
         // set changedOnly default to true unless action == replace
         var changedOnly = typeof args[1].changedOnly !== 'undefined'
                              ? args[1].changedOnly : action !== 'replace';
         if (!txn) {
             txn = this.data('currentTxn');
             if (!txn) {
                 txn = new Txn(args[1].url || $.db.url);
                 commitNow = true;
             } else if (args[1].url) {
               konsole.assert(txn.url ===  args[1].url);
             }
         }
      try {
         //konsole.log('execute', action, data, callback);
         var requestIds = [];
         if (data) {
            if (action == 'query') {
                if (!data.conditions) {
                    data = { conditions : data };
                }
                //assert data.query;
                var thisid = this.attr('itemid');
                if (thisid) {
                    if (!data.bindvars) {
                        data.bindvars = {}
                    }
                    data.bindvars['this'] =  thisid;
                }
            } else if (!data[_IDkey] && this.attr('itemid')) {
                data[_IDkey] = this.attr('itemid');
            }
            requestIds = [txn.execute(action, data, callback, this.length ? this[0] : null)];
            if (fileinput)
             txn._addFileInput(fileinput, data, requestIds[0]);
         } else {
            konsole.assert(!fileinput);
            requestIds = this.map(function() {
                var obj = bindElement(this, false, undefined, changedOnly);
                if (override) {
                  if (typeof override == 'function')
                    obj = override(obj);
                  else
                    $.extend(obj[0], override);
                }

                var requestid = txn.execute(action, obj, callback, this);
                $(this).find('[data-dbmethod]').each(function() {
                  txn._addFileInput(this, obj, requestid);
                });
                //konsole.log('about to', action, 'obj', obj);
                return requestid;
            }).get();
         }
         if (comment) { //XXX this is all kind of hacky
            comment = comment.replace('$new0', '$new'+requestIds[0]);
            if (txn.txnComment)
                txn.txnComment += ' and ' + comment;
            else
                txn.txnComment = comment;
         }
       } catch (err) {
         // invoke callback if it hasn't already been bound
         // (if we have requestIds then it has)
         var rollbackCB = null;
         if (callback && !requestIds.length) {
           var elem = this;
           rollbackCB = function(response) {
              // note: if callback returns false event bubbling is stopped
              return callback.call(elem, null, response.error);
           };
         }
         this.dbRollback(rollbackCB, err, txn);
         return this;
       }
         if (commitNow)
            txn.commit(null, this);
         return this;
     }
402059
function unsupportedAction(res, statusCode, data) {

  return res.status(data
    ? statusCode
    : status.UNSUPPORTED_ACTION).json(data || statusCode || {
    message: 'Unsupported Action'
  });
}
1018739
function _doRequest($action,$params,$options){
		$params += array(
			"lang" => $this->lang,
		);
		$params += $this->default_params;

		$options += array(
			"cache" => 0,
			"return_cached_content_on_error" => false,
			"acceptable_error_codes" => array(),
			"file" => array(), // see postFile(),
			"raw_post_data" => null,
			"additional_headers" => array() // array("X-Forwarded-For: 127.0.0.1","X-Logged-User-Id: 123")
		);

		$this->errors = array();
		$this->data = null;

		$timer = new StopWatch();
		$timer->start();

		$lang = $params["lang"];
		unset($params["lang"]);

		$url = $this->base_url;
		if($lang){
			if($this->automatically_add_leading_slash && !preg_match('/\/$/',$url)){
				$url .= "/";
			}
			$url .= "$lang/";
		}
		if($this->automatically_add_leading_slash && !preg_match('/\/$/',$url)){
			$url .= "/";
		}
		$url .= "$action";
		if($this->automatically_add_trailing_slash && !preg_match('/\/$/',$url) && !preg_match('/\?/',$url)){
			$url .= "/";
		}

		$action_url = $url;

		if($options["method"]!="POST" || $options["file"] || !is_null($options["raw_post_data"])){
			$url = $this->_addParamsToUrl($url,$params);
		}
		$this->url = $url;
		$this->method = $options["method"];
		$this->duration = null;

		$cached_ar = null;
		if($options["cache"]>0 && ($ar = $this->_readCache($url,$options["cache"],$cached_ar))){
			return $this->__setCacheAndReturnData($ar);
		}

		// Pro stahovani dat se pouziva UrlFetcher - soucast ATK14
		$headers = $this->additional_headers;
		//if($options["file"]){
		//	$headers["X-FileName"] = $options["name"];
		//}
		$u = new UrlFetcher($url,array(
			"user_agent" => $this->user_agent,
			"additional_headers" => $headers
		));

		if(!is_null($options["raw_post_data"])){
			$u->post($options["raw_post_data"],array(
				"content_type" => $options["mime_type"],
				"additional_headers" => $options["additional_headers"],
			));

		}elseif($options["file"]){
			$content = Files::GetFileContent($options["file"]["path"]);
			$u->post($content,array(
				"content_type" => $options["file"]["mime_type"],
				"additional_headers" => array(
					sprintf('Content-Type: %s',$options["file"]["mime_type"]),
					sprintf('Content-Disposition: attachment; filename="%s"',rawurlencode($options["file"]["name"]))
				)
			));

		}elseif($options["method"]=="POST"){
			// Content-Type: application/x-www-form-urlencoded
			// Content-Length: 244

			$u->post($params);
		}else{
			$u->fetchContent(array(
				"request_method" => $options["method"],
			));
		}
		$this->status_code = $u->getStatusCode();

		$timer->stop();

		$this->duration = $timer->getResult();

		$this->status_code = $u->getStatusCode();

		// TODO: vyresit zalogovani parametru POSTem

		$content = $u->getContent();
		if(!strlen($content) && ($this->status_code!=204)){
			if($options["return_cached_content_on_error"] && $cached_ar){
				return $this->__useOutdatedCache($cached_ar);
			}
			throw new Exception("No content on $url (HTTP $this->status_code)");
		}

		if(strlen($content)>0){

			$d = json_decode($content,true);
			if(is_null($d)){
				trigger_error("ApiDataFetcher:
URL: $url
response code: ".$u->getStatusCode()."
invalid json:\n".$u->getContent()
				);
				if($options["return_cached_content_on_error"] && $cached_ar){
					return $this->__useOutdatedCache($cached_ar);
				}
				throw new Exception("json_decode() failed on $url (HTTP status code: $this->status_code; content: ".$u->getContent().")");
			}

		}else{

			// The $content is empty (HTTP status code is 204).
			// Empty answer means empty JSON.
			$d = array();

		}

		ApiDataFetcher::$QueriesExecuted[] = array(
			"action" => $action,
			"action_url" => $action_url,
			"method" => $options["method"],
			"url" => $url,
			"status_code" => $this->status_code,
			"status_message" => $u->getStatusMessage(),
			"params" => $params,
			"duration" => $timer->getResult(),
			"data" => $d,
		);

		if(preg_match('/^2/',$this->status_code)){
			$this->data = $d;
			$valid_response = true;
		}else{
			$this->errors = $d;
			$valid_response = false;
		}

		if(!$valid_response && !in_array($this->status_code,$options["acceptable_error_codes"])){
			$this->_loggerLog(
				"ApiDataFetcher: $options[method] $url (HTTP $this->status_code, $timer)\n".
				($options["method"] == "POST" ? "params: ".print_r($params,true)."\n" : "").
				"error: ".join(" | ",$this->errors)."\n".
				"requested URL: ".$this->request->getUrl()
			);
			$this->_loggerFlush();
			if($options["return_cached_content_on_error"] && $cached_ar){
				return $this->__useOutdatedCache($cached_ar);
			}
			throw new Exception("HTTP status code $this->status_code (".join(" | ",$this->errors)."), url: $url");
		}else{
			$this->_loggerDebug(
				"ApiDataFetcher: $options[method] $url (HTTP $this->status_code, $timer)".
				($options["method"] == "POST" ? "\nparams: ".print_r($params,true)."\n" : "")
			);
			if($options["cache"]>0){
				$this->_writeCache($url,$this->status_code,$this->data,$this->errors);
			}
		}

		return $this->data;
	}
1222017
function _extractActions( opts )
	{
		// main properties
		const 	data 		= opts.data,
				configState = opts.stateData,
				stateView 	= opts.stateView,
				stateName  	= opts.stateName;

		// new defined properties
		let stateTransitions = [],
			viewData 		 = opts.viewData,
			appDataView,
			action,
			statePrefix;

		forein( configState.actions, ( prop, actionName ) => {

			statePrefix = (stateName+ '->' +actionName);
			appDataView = data[ prop.target ].view;

			// Return action data for FSM
			action = {
				action 		: actionName,
				target 		: prop.target,
				_id 		: statePrefix
			};

			// return ViewData for View manager and append all views
			viewData[ statePrefix ] = {
				currentView 		: stateView,
				nextView 			: appDataView,
				linkedVTransModules : _extractTransitions( prop, stateView, appDataView ),
				name  				: actionName
			};

			// // assign fsm action to state
			stateTransitions[ stateTransitions.length ] = action;
		});

		return { stateTransitions : stateTransitions, viewData : viewData };
	}
505404
function Option(handler, options, desc) {
  Option.super_.apply(this, [handler, options, desc]);

  if (options.params && options.params.hasOwnProperty('optional')) {
    throw new Error('optional parameter is not allowed for options');
  }
}
994048
def control_request_options(action, options = nil)
      case action.to_sym
      when :start
        start_control_request_options options
      when :unsilence
        { LS_session: @session.session_id, LS_op: :start, LS_table: id }
      when :stop
        { LS_session: @session.session_id, LS_op: :delete, LS_table: id }
      end
    end
1301300
public function options($url, $data = [], array $options = [])
    {
        $options = $this->_mergeOptions($options);
        $url = $this->buildUrl($url, [], $options);

        return $this->_doRequest(Request::METHOD_OPTIONS, $url, $data, $options);
    }
765808
function next(actionData) {
        index++;
        if(index === store.middlewares.length) {
            done(actionData);
        } else {
            store.middlewares[index](store, actionName, actionData, next);
        }
    }
716243
function Query(model, action, conditions) {
    var self = this;
    self.model = model;
    self.action = action || 'all';
    self.q = {
        conditions: {},
        params: {},
        pkey: false,
        fields: false
    };
    if (typeof conditions === 'object') {
        self.q.conditions = helpers.merge(self.q.conditions, conditions);
    }

    ['all', 'run', 'exec'].forEach(function(method) {
        self[method] = function(params, callback) {
            if (arguments.length === 1) {
                callback = params;
                params = {};
            }
            params = buildQuery(params, this);
            var action = self.action ? self.action : 'all';
            self.model[action](params, callback);
        };
    });

    ['find', 'findOne'].forEach(function(method) {
        self[method] = function(params, callback) {
            if (arguments.length === 1) {
                callback = params;
                params = {};
            }
            params = buildQuery(params, this);
            self.model[method](params, callback);
        };
    });

    ['skip', 'limit', 'order', 'sort', 'group'].forEach(function(method) {
        self[method] = function(key, value) {
            this.q.pkey = false;
            if (method === 'sort') {
                method = 'order';
            }
            if (typeof value === 'undefined') {
                if (/^-/.test(key)) {
                    this.q.params[method] = key.replace(/^-/, '') + ' DESC';
                } else {
                    this.q.params[method] = key;
                }
            } else {
                this.q.params[method] = key + ' ' + value;
            }
            return this;
        };
    });

    self.asc = function(value) {
        this.q.pkey = false;
        this.q.params['order'] = value + ' ASC';
        return this;
    };

    self.desc = function(value) {
        this.q.pkey = false;
        this.q.params['order'] = value + ' DESC';
        return this;
    };

    self.where = function(key, value) {
        if (typeof value === 'undefined') {
            this.q.pkey = key;
        } else {
            this.q.pkey = false;
            this.q.conditions[key] = value;
        }
        return this;
    };

    self.or = function(values) {
        if (Array.isArray(values)) {
            this.q.conditions['or'] = values;
        }
        return this;
    };

    self.range = function(key, from, to) {
        if (typeof to === 'undefined') {
            if (this.q.pkey) {
                to = from;
                from = key;
                if (typeof this.q.conditions[this.q.pkey] === 'undefined') {
                    this.q.conditions[this.q.pkey] = {};
                }
                this.q.conditions[this.q.pkey].gt = from;
                this.q.conditions[this.q.pkey].lt = to;
            }
        } else {
            this.q.pkey = false;
            if (typeof this.q.conditions[key] === 'undefined') {
                this.q.conditions[key] = {};
            }
            this.q.conditions[key].gt = from;
            this.q.conditions[key].lt = to;
        }
        return this;
    };

    ['gt', 'gte', 'lt', 'lte', 'in', 'inq', 'ne', 'neq', 'nin', 'regex', 'like', 'nlike', 'between'].forEach(function(method) {
        self[method] = function(key, value) {
            if (typeof value === 'undefined') {
                if (this.q.pkey) {
                    if (typeof this.q.conditions[this.q.pkey] === 'undefined') {
                        this.q.conditions[this.q.pkey] = {};
                    }
                    this.q.conditions[this.q.pkey][method] = key;
                }
            } else {
                this.q.pkey = false;
                if (typeof this.q.conditions[key] === 'undefined') {
                    this.q.conditions[key] = {};
                }
                this.q.conditions[key][method] = value;
            }
            return this;
        };
    });

    self.slice = function(values) {
        if (Array.isArray(values)) {
            if (typeof values[1] === 'undefined') {
                this.q.params['limit'] = values[0];
            } else {
                this.q.params['skip'] = values[0];
                this.q.params['limit'] = values[1];
            }
        }
        return this;
    };

    /**
     * Destroy records
     * @param {Object} params
     * @param {Function} callback
     */
    self.remove = function(params, callback) {
        if (arguments.length === 1) {
            callback = params;
            params = {};
        }
        params = buildQuery(params, this);
        self.model.remove(params, callback);
    };

    function buildQuery(opts, query) {
        if (typeof opts.where === 'undefined') {
            opts.where = {};
        }
        opts.where = helpers.merge(opts.where, query.q.conditions);
        query.q.conditions = {};

        for (var pkey in query.q.params) {
            if (typeof opts[pkey] === 'undefined') {
                opts[pkey] = {};
            }
            opts[pkey] = query.q.params[pkey];
        }

        query.q.params = {};
        query.q.pkey = false;
        return opts;
    }
}
925245
function Resource(url, params, actions, options$$1) {

    var self = this || {}, resource = {};

    actions = assign({},
        Resource.actions,
        actions
    );

    each(actions, function (action, name) {

        action = merge({url: url, params: assign({}, params)}, options$$1, action);

        resource[name] = function () {
            return (self.$http || Http)(opts(action, arguments));
        };
    });

    return resource;
}
916490
function (options) {
            if (!options) {
                throw Error("Ajax options missing");
            }
            var that = this, util = Rocket.Util;
            options.success = util.ajaxResponse(options.callback);
            util.ajax(options);
        }
1018277
function (opt) {

			var actions = [];
			var handler = function () {
				actions.push(arguments);
			};
			include(opt, handler);
			return actions;
		}
681584
private function renderActions()
    {
        $this->beginButtonGroup();
        foreach ($this->visibleActions as $action) {
            $label = ArrayHelper::getValue($action, $this->actionLabelProperty, '');
            $url = ArrayHelper::getValue($action, $this->actionUrlProperty, null);
            $options = ArrayHelper::getValue($action, $this->actionOptionsProperty, []);

            // Use $this->buttonClasses as base classes, then override with any classes specified in options
            $actionClasses = ArrayHelper::getValue($options, 'class', []);
            $options['class'] = $this->linkClasses;
            Html::addCssClass($options, $actionClasses);

            echo Html::a($label, $url, $options);
        }
        $this->endButtonGroup();
    }
730515
function(elem, action) {
			var inst = this._getInst(elem);
			if (!$.isEmptyObject(inst) && !this.isDisabled(elem)) {
				var commands = inst.options.commands;
				if (commands[action] && commands[action].enabled.apply(elem, [inst])) {
					commands[action].action.apply(elem, [inst]);
				}
			}
		}
385976
function (options) {
            settings = Pilotfish('extend', {}, settings, options || {});

            // ### Click actions

            // #### `url_change_no_pointer`
            // Click resulted in url change, but target wasn't a pointer
            if (settings.url_change_no_pointer) {
                Pilotfish('on', window, 'unload', function () {
                    if (wasLastClickPointer() === false && wasLastClickRecent() === true) {
                        broadcast('url_change_no_pointer');
                    }
                });
            }


            // #### `hash_change_no_pointer`
            // Click resulted in hash tag change, but wasn't a pointer
            if (settings.hash_change_no_pointer) {
                Pilotfish('on', 'window:hashchange', function () {
                    if (wasLastClickPointer() === false && wasLastClickRecent() === true) {
                        broadcast('hash_change_no_pointer');
                    }
                });
            }

            // TODO Click resulted in an ajax request, but no status indicator


            // ### Application problems

            // TODO User clicked on something that was a pointer, twice

            // #### `click_js_error`
            // click resulted in a javascript error
            Pilotfish('on', 'js_error', function (evt, data) {
                if (wasLastClickRecent() === true) {
                    broadcast('click_js_error', data);
                }
            });


            // #### `multiple_reload`
            // user has reloaded more than x times
            if (settings.multiple_reload) {
                (function () {
                    var reloadCount = 0, currentPath = Pilotfish('currentPath');
                    for (var i = recentPaths.length - 1; i >= 0; i--) {
                        if (recentPaths[i].path == currentPath && recentPaths[i].navType == 1) {
                            reloadCount++;
                        } else {
                            break;
                        }
                    }
                    if (reloadCount == 3) {
                        broadcast('multiple_reload', {path: currentPath});
                    }
                })();
            }

            // ###  Application confusion

            // TODO user sees the same message twice

            // TODO user hit stop and interrupted a transfer

            // TODO user hit back x times in a row (stuck: the js isn't re-executed on back/reload)

            // TODO slowed_cadence - this page is taking signifigantly longer than previous pages

            // TODO lost_focus

            // TODO user_searched

            // TODO Tap into the accelerometer and watch for a thrown computer :)

            // TODO Watch for smashed keys :)
        }
761166
function o_function( $id, $action, $options = '' )
    {
        if ( $action != 'new' )
        {
            $o =& $this->objects[$id];
        }

        switch ( $action )
        {
            case 'new':
            {
                $this->objects[$id] = array ( 't' => 'function',
                                              'info' => array() );

                if ( isset( $options['type'] ) ) // Set function type
                {
                    $this->objects[$id]['info']['type'] = $options['type'];
                }
                else
                {
                    $this->objects[$id]['info']['type'] = '2';
                }

                if ( isset( $options['Domain'] ) ) // Set function Domain
                {
                    $this->objects[$id]['info']['Domain'] = $options['Domain'];
                }
                else
                {
                    $this->objects[$id]['info']['Domain'] = '[0.0 1.0]';
                }

                if ( $this->objects[$id]['info']['type'] == '2' ) // set start and en values
                {
                    if ( isset( $options['C0'] ) ) // Set values0
                    {
                        $this->objects[$id]['info']['C0'] = $options['C0'];
                    }

                    if ( isset( $options['C1'] ) ) // Set values1
                    {
                        $this->objects[$id]['info']['C1'] = $options['C1'];
                    }

                    if ( isset( $options['N'] ) ) // set exponent
                    {
                        $this->objects[$id]['info']['N'] = $options['N'];
                    }
                    else
                    {
                        $this->objects[$id]['info']['N'] = '1.0';
                    }
                }

            } break;

            case 'out':
            {
                $res = "\n" . $id . " 0 obj\n<< ";
                $res.= "/FunctionType " . $o['info']['type'] . "\n";
                $res.= "/Domain " . $o['info']['Domain'] . "\n";
                if ( isset ( $o['info']['C0'] ) )
                    $res.= "/C0 " . $o['info']['C0'] . "\n";
                if ( isset ( $o['info']['C1'] ) )
                    $res.= "/C1 " . $o['info']['C1'] . "\n";
                $res.= "/N " . $o['info']['N'] . "\n";
                $res.= ">>\nendobject";
                return $res;
            } break;
        }
    }
144024
function delete($action,$params = array(),$options = array()){
		$options["method"] = "DELETE";
		return $this->_doRequest($action,$params,$options);
	}