function createTodo (state, data) {
  var newState = state.slice()
  data.id = tid().substr(0, 7)
  data.done = false
  newState.push(data)
  kubby.set(TODOS_LABEL, newState)
  return newState
}
Beispiel #2
0
			toImport.passages.forEach(p => {
				p.id = uuid();
				p.story = toImport.id;

				if (p.pid === toImport.startPassagePid) {
					toImport.startPassage = p.id;
				}

				delete p.pid;
			});
Beispiel #3
0
		Object.keys(store.state.pref).forEach(name => {
			const id = uuid();

			ids.push(id);
			window.localStorage.setItem(
				'twine-prefs-' + id,
				JSON.stringify({
					id,
					name,
					value: store.state.pref[name]
				})
			);
		});
Beispiel #4
0
			original.passages.forEach(passage => {
				story.passages.push(Object.assign(
					{},
					passage,
					{
						id: uuid(),
						story: story.id
					}
				));

				if (passage.tags) {
					passage.tags = passage.tags.slice(0);
				}
			});
function LocalStorageScuttlebutt (opts) {
  opts = opts || {}
  this.store = opts.store || localStorage
  this.opts = opts
  this.prefix = opts.prefix || '_lss'

  // changing how ID works.
  // since you may want multiple LSSB instances on a single
  // app, then this should be managed at that level, not
  // internally. so just set a sensible default here...
  var id = opts.id || uuid()

  this.rx = new RegExp('^' + this.prefix)

  Scuttlebutt.call(this, id)

  if('undefined' !== typeof window) {
    var self = this
    window.addEventListener('storage', function (ev) {
      if(!ev) ev = window.event //Internet Explorer WTF
      if(!self.rx.test(ev.key)) return
      var key = ev.key.substring(self.prefix.length)
      try {
        var value = JSON.parse(ev.newValue)

        if(self.store[self.prefix + ev.key] === value)
          return

        self.emit('change', key, value[0])
        self.emit('change:'+key, value[0])
      } catch (err) {
        console.error(err)
      }
    })
  }
}
Beispiel #6
0
		throw new Error(`No passage exists in this story with id ${id}`);
	}

	return passage;
}

const storyStore = module.exports = {
	state: {
		stories: []
	},

	mutations: {
		CREATE_STORY(state, props) {
			let story = Object.assign(
				{
					id: uuid(),
					lastUpdate: new Date(),
					ifid: uuid().toUpperCase(),
					tagColors: {},
					passages: []
				},
				storyStore.storyDefaults,
				props
			);

			if (story.passages) {
				story.passages.forEach(passage => passage.story = story.id);
			}

			state.stories.push(story);
		},