Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// execute the select query
db = Ti.Database.open(dbName);
// run a specific sql query if defined
if (opts.query) {
if (opts.query.params) {
var rs = db.execute(opts.query.sql, opts.query.params);
} else {
var rs = db.execute(opts.query.sql);
}
} else {
//extend sql where with data
if (opts.data) {
opts.sql = opts.sql || {};
opts.sql.where = opts.sql.where || {};
_.extend(opts.sql.where, opts.data);
}
// build the sql query
var sql = _buildQuery(table, opts.sql || opts);
logger(DEBUG, "SQL QUERY: " + sql);
var rs = db.execute(sql);
}
var len = 0,
values = [];
// iterate through all queried rows
while (rs.isValidRow()) {
var o = {};
var fc = 0;
fc = _.isFunction(rs.fieldCount) ? rs.fieldCount() : rs.fieldCount;
// eTag enabled
var eTagEnabled = model.config.eTagEnabled;
// Used for custom parsing of the response data
var parentNode = model.config.parentNode;
// REST - CRUD
var methodMap = {
'create' : 'POST',
'read' : 'GET',
'update' : 'PUT',
'delete' : 'DELETE'
};
var type = methodMap[method];
var params = _.extend({}, opts);
params.type = opts.requestMethod || type;
//set default headers
params.headers = params.headers || {};
// Send our own custom headers
if (model.config.hasOwnProperty("headers")) {
var configHeaders = model.config.headers;
if (_.isFunction(configHeaders)) {
configHeaders = configHeaders();
}
for (var header in configHeaders) {
params.headers[header] = configHeaders[header];
}
}
var DEBUG = opts.debug || model.config.debug;
// Are we dealing with a colleciton or a model?
var isCollection = ( model instanceof Backbone.Collection) ? true : false;
var singleModelRequest = null;
if (model.config.adapter.lastModifiedColumn) {
if (opts.sql && opts.sql.where) {
singleModelRequest = opts.sql.where[model.idAttribute];
}
if (!singleModelRequest && opts.data && opts.data[model.idAttribute]) {
singleModelRequest = opts.data[model.idAttribute];
}
}
var params = _.extend({}, opts);
// fill params with default values
_.defaults(params, {
// Last modified logic
lastModifiedColumn : model.config.adapter.lastModifiedColumn,
addModifedToUrl : model.config.adapter.addModifedToUrl,
lastModifiedDateFormat : model.config.adapter.lastModifiedDateFormat,
singleModelRequest : singleModelRequest,
// eTag
eTagEnabled : model.config.eTagEnabled,
// Used for custom parsing of the response data
parentNode : model.config.parentNode,
apiName && -1 === apiName.indexOf(".") && (apiName = addNamespace(apiName));
var styleArray;
styleArray = controller && _.isObject(controller) ? require("alloy/widgets/" + controller.widgetId + "/styles/" + controller.name) : require("alloy/styles/" + controller);
var styleFinal = {};
var i, len;
for (i = 0, len = styleArray.length; len > i; i++) {
var style = styleArray[i];
var styleApi = style.key;
style.isApi && -1 === styleApi.indexOf(".") && (styleApi = (CONST.IMPLICIT_NAMESPACES[styleApi] || CONST.NAMESPACE_DEFAULT) + "." + styleApi);
if (style.isId && opts.id && style.key === opts.id || style.isClass && _.contains(classes, style.key)) ; else {
if (!style.isApi) continue;
-1 === style.key.indexOf(".") && (style.key = addNamespace(style.key));
if (style.key !== apiName) continue;
}
if (style.queries && style.queries.formFactor && !Alloy[style.queries.formFactor]) continue;
_.extend(styleFinal, style.style);
}
var extraStyle = _.omit(opts, [ CONST.CLASS_PROPERTY, CONST.APINAME_PROPERTY ]);
_.extend(styleFinal, extraStyle);
styleFinal[CONST.CLASS_PROPERTY] = classes;
styleFinal[CONST.APINAME_PROPERTY] = apiName;
MW320_CHECK && delete styleFinal[CONST.APINAME_PROPERTY];
return defaults ? _.defaults(styleFinal, defaults) : styleFinal;
};
touchEnabled: true,
enabled: true,
horizontalWrap: true,
zIndex: 0,
backgroundColor: null,
font: null,
visible: true,
color: null,
transform: null,
backgroundGradient: {},
borderColor: "transparent",
borderRadius: 0,
borderWidth: 0
};
RESET = _.extend(RESET, {
backgroundLeftCap: 0,
backgroundTopCap: 0
});
exports.M = function(name, modelDesc, migrations) {
var config = (modelDesc || {}).config || {};
var adapter = config.adapter || {};
var extendObj = {};
var extendClass = {};
var mod;
if (adapter.type) {
mod = require("alloy/sync/" + adapter.type);
extendObj.sync = function(method, model, opts) {
mod.sync(method, model, opts);
};
} else extendObj.sync = function(method, model) {
touchEnabled: true,
enabled: true,
horizontalWrap: true,
zIndex: 0,
backgroundColor: null,
font: null,
visible: true,
color: null,
transform: null,
backgroundGradient: {},
borderColor: "transparent",
borderRadius: 0,
borderWidth: 0
};
RESET = _.extend(RESET, {
backgroundLeftCap: 0,
backgroundTopCap: 0
});
exports.M = function(name, modelDesc, migrations) {
var config = (modelDesc || {}).config || {};
var adapter = config.adapter || {};
var extendObj = {};
var extendClass = {};
var mod;
if (adapter.type) {
mod = require("alloy/sync/" + adapter.type);
extendObj.sync = function(method, model, opts) {
mod.sync(method, model, opts);
};
} else extendObj.sync = function(method, model) {
exports.A = function(t, type, parent) {
_.extend(t, Backbone.Events);
(function() {
var al = t.addEventListener, rl = t.removeEventListener, oo = t.on, of = t.off, tg = t.trigger, cbs = {}, ctx = _.extend({}, Backbone.Events);
if (!al || !rl) return;
t.trigger = function() {
ctx.trigger.apply(ctx, Array.prototype.slice.apply(arguments));
};
t.on = function(e, cb, context) {
var wcb = function(evt) {
try {
_.bind(tg, ctx, e, evt)();
} catch (E) {
Ti.API.error("Error triggering '" + e + "' event: " + E);
}
};
if (!cbs[e]) {
cbs[e] = {};
/**
* @module firebase/analytics
* @author Andrea Jonus
*/
var Alloy = require('alloy');
var _ = require('alloy/underscore')._;
/**
* @property config
* @property {String} [config.log=false] Set to true to display log messages for each call
* @type {Object}
*/
exports.config = _.extend({
log: false,
}, (Alloy.CFG.T && Alloy.CFG.T.firebase) ? Alloy.CFG.T.firebase.analytics : {});
var MODULE_NAME = 'firebase/analytics';
var Util = require('T/util');
var FC = Util.requireOrNull('firebase.core');
var FA = Util.requireOrNull('firebase.analytics');
function checkModules() {
if (FC === null) {
Ti.API.error(MODULE_NAME + ': firebase.core module not initialized.');
return false;
} else if (FA === null) {
Ti.API.error(MODULE_NAME + ': firebase.analytics module not initialized.');
return false;
_save: function(attributes) {
var self = this;
var deferred = Q.defer();
var tempInstallationM = Alloy.createModel("installation");
tempInstallationM.save(_.extend({
objectId: this.id
}, attributes), {
success: function() {
self.set(attributes, {
change: false
});
deferred.resolve(self);
},
error: function(error) {
deferred.reject(error);
}
});
return deferred.promise;
}
});