Condor.prototype._getSessionData = function() { var session = {} , interval = -1 , lastActivity = cookie.get('condor-time') session.count = cookie.get('condor-session') if (!session.count) { session.count = 1 } else { if (lastActivity) { interval = Date.now() - lastActivity } if (interval === -1 || interval > 30 * 60 * 1000) { session.count++ } } cookie.set('condor-session', session.count) session.visitor = cookie.get('condor-visitor') if (!session.visitor) { session.visitor = shortId.generate() cookie.set('condor-visitor', session.visitor) } return session }
}).then(function (user) { var oneMonth = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000) cookie.set('ahchoo_token', user.token, {expires: oneMonth}) cookie.set('ahchoo_user_id', user._id, {expires: oneMonth}) location.href = '/' })
install: function() { this.hide(); cookie.set('smartbanner-installed', 'true', { path: '/', expires: +new Date() + this.options.daysReminder * 1000 * 60 * 60 * 24 }); },
close: function() { this.hide(); cookie.set('smartbanner-closed', 'true', { path: '/', expires: +new Date() + this.options.daysHidden * 1000 * 60 * 60 * 24 }); },
}, function() { tree.set('lng', lng); if (tree.get(['auth', 'loggedin'])) { actions.saveLanguage(lng); } cookie.set('language', lng, {expires: 365}); });
close: function() { this.hide(); this.options.closeCallback && this.options.closeCallback(); cookie.set('smartbanner-closed-' + this.options.instanceId, 'true', { path: '/', expires: new Date(+new Date() + this.options.daysHidden * 1000 * 60 * 60 * 24) }); },
Condor.prototype._toCsv = function (eventType, extra, duration) { duration = typeof(duration) === 'number' ? duration : now() - this._startTime extra = extra || {} var session = this._getSessionData() cookie.set('condor-time', Date.now()) var array = [ pkg.name , pkg.version , eventType , window.innerWidth , window.innerHeight // pageXOffset & pageYOffset instead of scrollX/scrollY for browser // compability // https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX#Notes , window.pageXOffset , window.pageYOffset , window.location.toString() , duration , (new Date()).toUTCString() , this._timezone , document.referrer , extra.path , extra.clickX , extra.clickY , extra.href , extra.target , extra.visibility , extra.name , extra.trackableType , extra.trackableValue , session.visitor , session.count ] return toCsv(array) }
var cookie = require('cookie-cutter') var location = require('global/window').location cookie.set('ahchoo_token', '') location.href = '/login'
import SmartBanner from 'react-smartbanner'; import cookie from 'cookie-cutter'; var DemoComponent = React.createClass({ getInitialState() { return { deviceType: '' }; }, changeType(device) { this.setState({ deviceType: device }); }, deleteCookie() { cookie.set('smartbanner-closed', null, { path: '/', expires: new Date(0) }); cookie.set('smartbanner-installed', null, { path: '/', expires: new Date(0) }); }, render() { let navButtonStyle = { margin: '20px 0 0 0' }; return ( <div> <SmartBanner title={'Facebook'} force={this.state.deviceType} /> <div className="row" style={navButtonStyle}> <div className="col-md-10 col-md-offset-1"> <div className="btn-group btn-group-justified" role="group">
auth.login(function (err, profile, token) { if (err) return store({ type: 'error', error: err }) store({ type: 'user:login', profile: profile, token: token }) cookie.set(config.site.slug, token) window.location = window.location.origin })
onLogOut: function (e) { e.preventDefault() cookie.set(config.site.slug, '', { expires: new Date(0) }) store({ type: 'user:logout' }) }
var game = require('./game'); var input = require('./input'); var debug = require('debug')('8bit-mayhem:index'); var io = require('socket.io-client'); var cookie = require('cookie-cutter'); var clientId = cookie.get('clientId'); if(!clientId) { var Guid = require('guid'); clientId = Guid.raw(); cookie.set('clientId', clientId); } var socket = io.connect('', { query: 'clientId=' + clientId }); debug('client connecting', clientId); window.addEventListener('load', function() { me.input.registerPointerEvent('pointerdown', me.game.viewport, input.touchStart.bind(input), true); me.input.registerPointerEvent('pointermove', me.game.viewport, input.touchMove.bind(input), true); me.input.registerPointerEvent('pointerup', me.game.viewport, input.touchEnd.bind(input), true); setTimeout(function() { window.scrollTo(0, 1); }, 0); }); input.on('move-start', socket.emit.bind(socket, 'move-start')); input.on('move', socket.emit.bind(socket, 'move')); input.on('move-end', socket.emit.bind(socket, 'move-end')); input.on('shoot-start', socket.emit.bind(socket, 'shoot-start'));
function modifyState (action, state) { var editor state = xtend({}, initialState, state) switch (action.type) { case constants.SET_URL: var newURL = url.parse(window.location.href) newURL.query = qs.parse(newURL.query) return xtend({}, state, { url: newURL }) case constants.SIGN_OUT: cookie.set('editdata', '', { expires: new Date(0) }) window.location = window.location.origin return initialState case constants.SET_USER: cookie.set('editdata', action.user.token) return xtend({}, state, { user: action.user }) case constants.SET_USER_PROFILE: var user = xtend({}, state.user) user.profile = action.profile return xtend({}, state, { user: user }) case constants.SET_NOTIFICATION: var notification = xtend({}, state.notification) notification.level = action.level notification.message = action.message return xtend({}, state, { notification: notification }) case constants.NEW_ROW: editor = xtend({}, state.editor) var row = { key: editor.data.length + 1, value: {} } Object.keys(editor.properties).forEach(function (key) { row.value[key] = null }) editor.data.push(row) return xtend({}, state, { editor: editor }) case constants.NEW_COLUMN: var property = action.property editor = xtend({}, state.editor) if (!property.key) property.key = cuid() if (!property.default) property.default = null if (!property.type) property.type = ['string'] if (typeof property.type === 'string') property.type = [property.type] var prop = schema.addProperty(property) editor.properties[prop.key] = prop editor.data.forEach(function (item) { item.value[property.key] = null }) return xtend({}, state, { editor: editor }) case constants.DESTROY: editor = xtend({}, state.editor) editor.data = [] editor.properties = {} return xtend({}, state, { editor: editor }) case constants.DESTROY_ROW: editor = xtend({}, state.editor) var newData = editor.data.filter(function (row) { return row.key !== action.key }) editor.data = newData return xtend({}, state, { editor: editor }) case constants.DESTROY_COLUMN: editor = xtend({}, state.editor) editor.data.forEach(function (item) { delete item.value[action.key] }) delete editor.properties[action.key] return xtend({}, state, { editor: editor }) case constants.RENAME_COLUMN: editor = xtend({}, state.editor) editor.properties[action.key].name = action.newName return xtend({}, state, { editor: editor }) case constants.PROPERTY_TYPE: editor = xtend({}, state.editor) editor.properties[action.propertyKey].type = [action.propertyType] return xtend({}, state, { editor: editor }) case constants.SET_ACTIVE_ROW: editor = xtend({}, state.editor) editor.activeRow = action.activeRow return xtend({}, state, { editor: editor }) case constants.SET_ACTIVE_PROPERTY: editor = xtend({}, state.editor) editor.activeProperty = action.propertyKey return xtend({}, state, { editor: editor }) case constants.UPDATE_ROW: editor = xtend({}, state.editor) editor.data.forEach(function (row, i) { if (row.key === action.row.key) { editor.data[i] = action.row } }) return xtend({}, state, { editor: editor }) case constants.SET_GITHUB_ORGS: action.orgs.unshift({ login: state.user.profile.login }) return xtend({}, state, { githubOrgs: action.orgs }) case constants.SET_GITHUB_REPOS: return xtend({}, state, { githubRepos: action.repos }) case constants.CLEAR_REPOS: return xtend({}, state, { githubRepos: [], activeRepo: null }) case constants.CLEAR_ORGS: return xtend({}, state, { githubOrgs: [], activeOrg: null }) case constants.SELECTED_REPO: return xtend({}, state, { activeRepo: action.repo }) case constants.SELECTED_ORG: return xtend({}, state, { activeOrg: action.org }) case constants.SELECTED_BRANCH: return xtend({}, state, { activeBranch: action.branch }) case constants.SELECTED_FILE: editor = xtend({}, editor) editor.data = action.data editor.properties = action.properties editor.saveData = action.saveData || initialState.saveData return xtend({}, state, { editor: editor }) case constants.SET_GITHUB_BRANCHES: return xtend({}, state, { githubBranches: action.branches }) case constants.SET_GITHUB_FILES: return xtend({}, state, { githubFiles: action.files }) case constants.MODAL: var ui = xtend({}, state.ui) if (action.value) { Object.keys(ui.modals).forEach(function (key) { if (key === action.modal) { ui.modals[key] = true return } ui.modals[key] = false }) } else { ui.modals[action.modal] = false } return xtend({}, state, { ui: ui }) case constants.MENU: ui = xtend({}, state.ui) if (action.value) { Object.keys(ui.menus).forEach(function (key) { if (key === action.menu) { ui.menus[key] = true return } ui.menus[key] = false }) } else { ui.menus[action.menu] = false } state = xtend({}, state, { ui: ui }) return state case constants.SAVE_TO_GITHUB_SUCCESS: var file = xtend({}, state.file) file.saveData = action.saveData return xtend({}, state, { file: file }) case constants.RESET: return xtend({}, state, { editor: initialState.editor }) case constants.SET_FILENAME: file = xtend({}, state.file) file.name = action.filename return xtend({}, state, { file: file }) case constants.SET_FILE_TYPE: file = xtend({}, state.file) file.type = action.fileType return xtend({}, state, { file: file }) case constants.SET_FILE: editor = xtend({}, state.editor) editor.data = action.data editor.properties = action.properties editor.activeProperty = null editor.activeRow = null state.editor.properties = {} return xtend({}, state, { editor: editor }) case constants.CLOSE_MODALS: ui = xtend({}, state.ui) Object.keys(ui.modals).forEach(function (key) { ui.modals[key] = false }) return xtend({}, state, { ui: ui }) default: return xtend({}, state) } }
var assign = require('object-assign'); var Marvel = require('../utils/MarvelCharacters'); var cookies = require('cookie-cutter'); var AT = Constants.ActionTypes, CHANGE_EVENT = Constants.Events.CHANGE; /* * App have 2 states: * 0 - Question state (default) * 1 - Answer state * */ var _appState = Constants.AppState.QUESTION_STATE, _primaryLang = 'eng', // TODO: this is mocked _userName = cookies.get("userName") || Marvel.getCharacter(); cookies.set("userName", _userName); console.log("Singed as " + _userName); var AppStore = assign({}, EventEmitter.prototype, { emitChange: function () { this.emit(CHANGE_EVENT); }, addChangeListener: function (callback) { this.on(CHANGE_EVENT, callback); }, removeChangeListener: function (callback) { this.removeListener(CHANGE_EVENT, callback); },