Example #1
0
function trim(path, tree, callback) {
  // Trim rows that are not in the tree anymore.  I welcome a more effecient way
  // to do this than scan over the entire list looking for patterns.
  var regExp = new RegExp("^" + rescape(path) + "\/([^\/]+)(?=\/|$)");
  var match;
  var paths = Object.keys(rows);
  for (var i = 0, l = paths.length; i < l; i++) {
    var childPath = paths[i];
    match = childPath.match(regExp);
    if (match && !tree[match[1]]) {
      delete rows[childPath];
      if (openPaths[childPath]) delete openPaths[childPath];
      if (hookConfigs[path]) delete hookConfigs[path];
      if (hooks[path]) delete hooks[path];
    }
  }

  match = activePath && activePath.match(regExp);
  if (match && !tree[match[1]]) {
    activePath = null;
    prefs.set("activePath", activePath);
    setDoc();
  }

  callback();
}
Example #2
0
 dialogFn(config, function (settings) {
   if (!settings) return;
   hookConfigs[row.path] = settings;
   if (settings.entry) prefs.set("defaultExportEntry", settings.entry);
   hooks[row.path] = action(row, settings);
   prefs.save();
 });
Example #3
0
function slide(x) {
  size = x;
  if (size < 0) size = 0;
  if (size > innerWidth - 42) size = innerWidth - 42;
  prefs.set("slider", size);
  $.tree.style.width = size + "px";
  $.titlebar.style.left = size + "px";
  $.main.style.left = size + "px";
}
Example #4
0
function zoom() {
  if (zoomIndex === oldIndex) return;
  var percent = zooms[zoomIndex];
  var scale = percent / 100;
  var oldScale = oldIndex && zooms[oldIndex] / 100;
  oldIndex = zoomIndex;
  handlers.forEach(function (handler) {
    handler(scale, oldScale);
  });
  prefs.set("zoomIndex", zoomIndex);
  notify(percent + "% zoom");
}
Example #5
0
 ], function onResult(result) {
   if (!result) return;
   if (result.name !== userName) prefs.set("userName", result.name);
   if (result.email !== userEmail) prefs.set("userEmail", result.email);
   var commit = {
     tree: entry.commit.tree,
     author: {
       name: result.name,
       email: result.email
     },
     parent: entry.headHash,
     message: result.message
   };
   row.call(fs.saveAs, "commit", commit, function (hash) {
     row.ahead++;
     var config = fs.configs[row.path];
     config.ahead = row.ahead;
     prefs.save();
     row.call(fs.setHead, hash);
   });
 });
Example #6
0
function setActive(path) {
  var row = rows[path];
  var old = active;
  active = row;
  activePath = active ? active.path : null;
  prefs.set("activePath", activePath);
  if (old) old.active = false;
  if (active) {
    active.active = true;
    showRow(active.path);
  }
}
Example #7
0
 dialog.confirm("Are you sure you want to remove all repos?", function (confirm) {
   if (!confirm) return;
   var key;
   for (key in fs.configs) delete fs.configs[key];
   for (key in fs.repos) delete fs.repos[key];
   for (key in hookConfigs) delete hookConfigs[key];
   for (key in hooks) delete hooks[key];
   prefs.set("rootHash");
   prefs.save();
   if (window.chrome && window.chrome.runtime && window.chrome.runtime.reload) {
     window.chrome.runtime.reload();
   }
   else {
     window.location.reload();
   }
 });