define([ '/bower_components/jquery/dist/jquery.min.js', ],function () { var $ = window.jQuery; var Board = {}; var proxy; var Uid = function (prefix) { return function () { return prefix + Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)) .toString(32).replace(/\./g, ''); }; }; var removeUid = function (A, e) { var i = A.indexOf(e); if (i === -1) { return -1; } A.splice(i, 1); return i; }; var luid = Board.luid = Uid('l-'); // list-uid var cuid = Board.cuid = Uid('c-'); // card uid var Input = Board.Input = function (opt) { return $('', opt); }; /* populate the proxy with all the relevant fields return boolean whether you are the first user */ Board.initialize = function (_proxy) { proxy = _proxy; var first = false; ['listOrder'].forEach(function (k) { if (typeof(proxy[k]) === 'undefined') { first = true; proxy[k] = []; } }); ['lists', 'cards'].forEach(function (k) { if (typeof(proxy[k]) === 'undefined') { proxy[k] = {}; } }); return first; }; /* * a list is appended to the extant order */ var List = Board.List = function (id) { if (!id) { id = List.create(); } var $input = Input({ type: 'text', placeholder: 'list title', }) .addClass('list-title') .on('keyup change', function () { var val = $input.val(); proxy.lists[id].title = val; }); var $cards = $('