<commit_before>var elmDebugger = {
    restart: function() {},
    pause: function() {},
    kontinue: function() {},
    getMaxSteps: function() { return 0; },
    stepTo: function(i) {},
    getPaused: function() { return false; },
    getHotSwapState: function() { return null; },
    watchTracker: { frames:[{}] }
};

var mainHandle = {};
var debuggerHandle = {};
var createdSocket = false;
var filePath;

var elmPauseState = false;
var elmPermitHotswaps = true;

var ELM_MAIN_ID = "elmMain";
var ELM_DEBUGGER_ID = "elmToolPanel";
var ELM_DARK_GREY = "#4A4A4A";
var ELM_LIGHT_GREY = "#E4E4E4";

function createMainElement() {
    var mainDiv = document.createElement("div");
    mainDiv.id = ELM_MAIN_ID;
    mainDiv.style.width = "100%";
    mainDiv.style.height = "100%";
    return mainDiv;
}

function createDebuggingElement() {
    var debuggingPanelExpanded = true;
    var debuggerWidth = 275;

    var debugTools = document.createElement("div");
    debugTools.id = ELM_DEBUGGER_ID;

    var debuggerDiv = document.createElement("div");
    debuggerDiv.id = "elmDebugger";
    debuggerDiv.style.overflow = "hidden";

    // Create and style the panel
    debugTools.style.background = ELM_DARK_GREY;
    debugTools.style.width = debuggerWidth + "px";
    debugTools.style.height = "100%";
    debugTools.style.position = "absolute";
    debugTools.style.top = "0px";
    debugTools.style.left = window.innerWidth - debuggerWidth + "px";
    debugTools.style.transitionDuration = "0.3s";
    debugTools.style.opacity = 0.97;
    debugTools.style.zIndex = 1;

    // Create and style the button
    var tabWidth = 40;
    var debugTab = document.createElement("div");
    debugTab.id = "debugToggle";
    debugTab.style.position = "absolute";
    debugTab.style.width = tabWidth + "px";
    debugTab.style.height = "40px";
    debugTab.style.top = window.innerHeight / 2 + "px";
    debugTab.style.left = "-" + tabWidth + "px";
    debugTab.style.borderTopLeftRadius = "3px";
    debugTab.style.borderBottomLeftRadius = "3px";
    debugTab.style.background = ELM_DARK_GREY;

    var wrenchIcon = document.createElement("img");
    wrenchIcon.src = "/debug-wrench-elm-server.png";
    wrenchIcon.height = 30;
    wrenchIcon.title = "Debug panel";
    wrenchIcon.style.margin = "5px";
    debugTab.appendChild(wrenchIcon);

    // Wire the button
    debugTab.onclick = function() {
        var toolPanel = document.getElementById("elmToolPanel");
        if (debuggingPanelExpanded){
            toolPanel.style.left = window.innerWidth + "px";
            toolPanel.style.width = "0px";
            debuggingPanelExpanded = false;
        } else {
            toolPanel.style.left = window.innerWidth - debuggerWidth + "px";
            toolPanel.style.width = debuggerWidth + "px";
            debuggingPanelExpanded = true;
        }
    }

    debugTools.appendChild(debugTab);
    debugTools.appendChild(debuggerDiv);
    return debugTools;
}

Elm.debugFullscreen = function(module, moduleFile, hotSwapState /* =undefined */) {
    filePath = moduleFile;
    initDebugger();
    mainHandle = Elm.fullscreen(Elm.debuggerAttach(module, hotSwapState));
    return mainHandle;
}

function initDebugger() {
    function scrubber(position) {
        if (elmDebugger.getPaused()) {
            elmDebugger.stepTo(position);
            sendWatches(position);
        }
    }

    function elmPauser(doPause) {
        if (doPause) {
          elmDebugger.pause();
        } else {
            elmDebugger.kontinue();
        }
        elmPauseState = doPause;
    }

    function elmRestart() {
        elmDebugger.restart();
        sendWatches(0);
    }

    function elmHotswap(permitHotswaps) {
        elmPermitHotswaps = permitHotswaps;
    }

    var debugTools = createDebuggingElement();
    document.body.appendChild(debugTools);
    var debuggerDiv = document.getElementById("elmDebugger");

    debuggerHandle = Elm.embed(Elm.DebuggerInterface, debuggerDiv,
        { eventCounter: 0,
          watches: []
        });
    debuggerHandle.ports.scrubTo.subscribe(scrubber);
    debuggerHandle.ports.pause.subscribe(elmPauser);
    debuggerHandle.ports.restart.subscribe(elmRestart);
    debuggerHandle.ports.permitHotswap.subscribe(elmHotswap);
}

parent.window.addEventListener("message", function(e) {
    if (e.data === "elmDebuggerInit") {
        elmDebugger = parent.Elm.Debugger;
        if (!createdSocket) {
            initSocket();
        }
    } else if (e.data === "elmNotify") {
        var currentPosition = elmDebugger.getMaxSteps();
        debuggerHandle.ports.eventCounter.send(currentPosition);
        sendWatches(currentPosition);
    }
}, false);

function sendWatches(position) {
    function censor(key, value) {
        if (key === "_") {
            return undefined;
        }
        return value;
    }
    var separator = "  ";
    var output = [];

    var watchAtPoint = elmDebugger.watchTracker.frames[position];

    for(key in watchAtPoint) {
        var value = watchAtPoint[key];
        var stringified = toString(value, separator);
        output.push([key, stringified]);
    }

    debuggerHandle.ports.watches.send(output);
}

function initSocket() {
    createdSocket = true;
    // "/todo.html" => "todo.elm"
    filePath = filePath || window.location.pathname.substr(1).split(".")[0] + ".elm";
    var socketLocation = "ws://" + window.location.host + "/socket?file=" + filePath;
    var serverConnection = new WebSocket(socketLocation);
    serverConnection.onmessage = function(event) {
        if (elmPermitHotswaps) {
            hotSwap(event.data);
        }
    };
}

function hotSwap(raw) {
    var debuggerDiv = document.getElementById(ELM_DEBUGGER_ID);
    var result = JSON.parse(raw);
    var js = result.success;
    var errorMessage = result.error;
    var error = document.getElementById('ErrorMessage');
    if (error) {
        error.parentNode.removeChild(error);
    }
    if (js) {
        var error = document.getElementById('ErrorMessage');
        if (error) {
            error.parentNode.removeChild(error);
        }
        window.eval(js);
        var moduleStr = js.match(/(Elm\..+)\ =\ \1/)[1];
        var module = window.eval(moduleStr);
        if (Elm.Debugger) {
            var debuggerState = Elm.Debugger.getHotSwapState();
            mainHandle.dispose();
            Elm.Debugger.dispose();

            var newMainNode = createMainElement();
            debuggerDiv.parentElement.insertBefore(newMainNode,debuggerDiv);

            var wrappedModule = Elm.debuggerAttach(module, debuggerState);
            mainHandle = Elm.embed(wrappedModule, newMainNode);
        }
        else {
            mainHandle = mainHandle.swap(module);
        }
    } else if (errorMessage) {
        var errorNode = document.createElement("pre");
        errorNode.id = "ErrorMessage";
        errorNode.innerHTML = errorMessage;
        errorNode.style.zindex = 1;
        errorNode.style.position = "absolute";
        errorNode.style.top = "0px";
        errorNode.style.background = ELM_LIGHT_GREY;

        var mainNode = document.getElementById(ELM_MAIN_ID);
        mainNode.parentElement.appendChild(errorNode);
    }
}

// Utilities

var toString = function(v, separator) {
    var type = typeof v;
    if (type === "function") {
        var name = v.func ? v.func.name : v.name;
        return '<function' + (name === '' ? '' : ': ') + name + '>';
    } else if (type === "boolean") {
        return v ? "True" : "False";
    } else if (type === "number") {
        return v.toFixed(2).replace(/\.0+$/g, '');
    } else if ((v instanceof String) && v.isChar) {
        return "'" + addSlashes(v) + "'";
    } else if (type === "string") {
        return '"' + addSlashes(v) + '"';
    } else if (type === "object" && '_' in v && probablyPublic(v)) {
        var output = [];
        for (var k in v._) {
            for (var i = v._[k].length; i--; ) {
                output.push(k + " = " + toString(v._[k][i], separator));
            }
        }
        for (var k in v) {
            if (k === '_') continue;
            output.push(k + " = " + toString(v[k], separator));
        }
        if (output.length === 0) return "{}";
        var body = "\n" + output.join(",\n");
        return "{" + body.replace(/\n/g,"\n" + separator) + "\n}";
    } else if (type === "object" && 'ctor' in v) {
        if (v.ctor.substring(0,6) === "_Tuple") {
            var output = [];
            for (var k in v) {
                if (k === 'ctor') continue;
                output.push(toString(v[k], separator));
            }
            return "(" + output.join(", ") + ")";
        } else if (v.ctor === "_Array") {
            var list = Array.toList(v);
            return "Array.fromList " + toString(list, separator);
        } else if (v.ctor === "::") {
            var output = '[\n' + toString(v._0, separator);
            v = v._1;
            while (v.ctor === "::") {
                output += ",\n" + toString(v._0, separator);
                v = v._1;
            }
            output += ' ]';
            return output.replace(/\n/g,"\n" + separator);
        } else if (v.ctor === "[]") {
            return "[]";
        } else if (v.ctor === "RBNode" || v.ctor === "RBEmpty") {
            var cons = F3(function(k,v,acc){return NList.Cons(Tuple2(k,v),acc)});
            var list = A3(Dict.foldr, cons, NList.Nil, v);
            var name = "Dict";
            if (list.ctor === "::" && list._0._1.ctor === "_Tuple0") {
                name = "Set";
                list = A2(List.map, function(x){return x._0}, list);
            }
            return name + ".fromList " + toString(list, separator);
        } else {
            var output = "";
            for (var i in v) {
                if (i === 'ctor') continue;
                var str = toString(v[i], separator);
                var parenless = str[0] === '{' ||
                                str[0] === '<' ||
                                str[0] === "[" ||
                                str.indexOf(' ') < 0;
                output += ' ' + (parenless ? str : "(" + str + ')');
            }
            return v.ctor + output;
        }
    }
    if (type === 'object' && 'recv' in v) return '<signal>';
    return "<internal structure>";
};

function addSlashes(str) {
    return str.replace(/\\/g, '\\\\')
              .replace(/\n/g, '\\n')
              .replace(/\t/g, '\\t')
              .replace(/\r/g, '\\r')
              .replace(/\v/g, '\\v')
              .replace(/\0/g, '\\0')
              .replace(/\'/g, "\\'")
              .replace(/\"/g, '\\"');
}

function probablyPublic(v) {
    var keys = Object.keys(v);
    var len = keys.length;
    if (len === 3
        && 'props' in v
        && 'element' in v) return false;
    if (len === 5
        && 'horizontal' in v
        && 'vertical' in v
        && 'x' in v
        && 'y' in v) return false;
    if (len === 7
        && 'theta' in v
        && 'scale' in v
        && 'x' in v
        && 'y' in v
        && 'alpha' in v
        && 'form' in v) return false;
    return true;
}
<commit_msg>panel moves with the right edge<commit_after>var elmDebugger = {
    restart: function() {},
    pause: function() {},
    kontinue: function() {},
    getMaxSteps: function() { return 0; },
    stepTo: function(i) {},
    getPaused: function() { return false; },
    getHotSwapState: function() { return null; },
    watchTracker: { frames:[{}] }
};

var mainHandle = {};
var debuggerHandle = {};
var createdSocket = false;
var filePath;

var elmPauseState = false;
var elmPermitHotswaps = true;

var ELM_MAIN_ID = "elmMain";
var ELM_DEBUGGER_ID = "elmToolPanel";
var ELM_DARK_GREY = "#4A4A4A";
var ELM_LIGHT_GREY = "#E4E4E4";

function createMainElement() {
    var mainDiv = document.createElement("div");
    mainDiv.id = ELM_MAIN_ID;
    mainDiv.style.width = "100%";
    mainDiv.style.height = "100%";
    return mainDiv;
}

function createDebuggingElement() {
    var debuggingPanelExpanded = true;
    var debuggerWidth = 275;

    var debugTools = document.createElement("div");
    debugTools.id = ELM_DEBUGGER_ID;

    var debuggerDiv = document.createElement("div");
    debuggerDiv.id = "elmDebugger";
    debuggerDiv.style.overflow = "hidden";

    // Create and style the panel
    debugTools.style.background = ELM_DARK_GREY;
    debugTools.style.width = debuggerWidth + "px";
    debugTools.style.height = "100%";
    debugTools.style.position = "absolute";
    debugTools.style.top = "0px";
    // debugTools.style.left = window.innerWidth - debuggerWidth + "px";
    debugTools.style.right = "0px";
    debugTools.style.transitionDuration = "0.3s";
    debugTools.style.opacity = 0.97;
    debugTools.style.zIndex = 1;

    // Create and style the button
    var tabWidth = 40;
    var debugTab = document.createElement("div");
    debugTab.id = "debugToggle";
    debugTab.style.position = "absolute";
    debugTab.style.width = tabWidth + "px";
    debugTab.style.height = "40px";
    debugTab.style.top = window.innerHeight / 2 + "px";
    debugTab.style.left = "-" + tabWidth + "px";
    debugTab.style.borderTopLeftRadius = "3px";
    debugTab.style.borderBottomLeftRadius = "3px";
    debugTab.style.background = ELM_DARK_GREY;

    var wrenchIcon = document.createElement("img");
    wrenchIcon.src = "/debug-wrench-elm-server.png";
    wrenchIcon.height = 30;
    wrenchIcon.title = "Debug panel";
    wrenchIcon.style.margin = "5px";
    debugTab.appendChild(wrenchIcon);

    // Wire the button
    debugTab.onclick = function() {
        var toolPanel = document.getElementById("elmToolPanel");
        if (debuggingPanelExpanded){
            toolPanel.style.width = "0px";
            debuggingPanelExpanded = false;
        } else {
            toolPanel.style.right = "0px";
            toolPanel.style.width = debuggerWidth + "px";
            debuggingPanelExpanded = true;
        }
    }

    debugTools.appendChild(debugTab);
    debugTools.appendChild(debuggerDiv);
    return debugTools;
}

Elm.debugFullscreen = function(module, moduleFile, hotSwapState /* =undefined */) {
    filePath = moduleFile;
    initDebugger();
    mainHandle = Elm.fullscreen(Elm.debuggerAttach(module, hotSwapState));
    return mainHandle;
}

function initDebugger() {
    function scrubber(position) {
        if (elmDebugger.getPaused()) {
            elmDebugger.stepTo(position);
            sendWatches(position);
        }
    }

    function elmPauser(doPause) {
        if (doPause) {
          elmDebugger.pause();
        } else {
            elmDebugger.kontinue();
        }
        elmPauseState = doPause;
    }

    function elmRestart() {
        elmDebugger.restart();
        sendWatches(0);
    }

    function elmHotswap(permitHotswaps) {
        elmPermitHotswaps = permitHotswaps;
    }

    var debugTools = createDebuggingElement();
    document.body.appendChild(debugTools);
    var debuggerDiv = document.getElementById("elmDebugger");

    debuggerHandle = Elm.embed(Elm.DebuggerInterface, debuggerDiv,
        { eventCounter: 0,
          watches: []
        });
    debuggerHandle.ports.scrubTo.subscribe(scrubber);
    debuggerHandle.ports.pause.subscribe(elmPauser);
    debuggerHandle.ports.restart.subscribe(elmRestart);
    debuggerHandle.ports.permitHotswap.subscribe(elmHotswap);
}

parent.window.addEventListener("message", function(e) {
    if (e.data === "elmDebuggerInit") {
        elmDebugger = parent.Elm.Debugger;
        if (!createdSocket) {
            initSocket();
        }
    } else if (e.data === "elmNotify") {
        var currentPosition = elmDebugger.getMaxSteps();
        debuggerHandle.ports.eventCounter.send(currentPosition);
        sendWatches(currentPosition);
    }
}, false);

function sendWatches(position) {
    function censor(key, value) {
        if (key === "_") {
            return undefined;
        }
        return value;
    }
    var separator = "  ";
    var output = [];

    var watchAtPoint = elmDebugger.watchTracker.frames[position];

    for(key in watchAtPoint) {
        var value = watchAtPoint[key];
        var stringified = toString(value, separator);
        output.push([key, stringified]);
    }

    debuggerHandle.ports.watches.send(output);
}

function initSocket() {
    createdSocket = true;
    // "/todo.html" => "todo.elm"
    filePath = filePath || window.location.pathname.substr(1).split(".")[0] + ".elm";
    var socketLocation = "ws://" + window.location.host + "/socket?file=" + filePath;
    var serverConnection = new WebSocket(socketLocation);
    serverConnection.onmessage = function(event) {
        if (elmPermitHotswaps) {
            hotSwap(event.data);
        }
    };
}

function hotSwap(raw) {
    var debuggerDiv = document.getElementById(ELM_DEBUGGER_ID);
    var result = JSON.parse(raw);
    var js = result.success;
    var errorMessage = result.error;
    var error = document.getElementById('ErrorMessage');
    if (error) {
        error.parentNode.removeChild(error);
    }
    if (js) {
        var error = document.getElementById('ErrorMessage');
        if (error) {
            error.parentNode.removeChild(error);
        }
        window.eval(js);
        var moduleStr = js.match(/(Elm\..+)\ =\ \1/)[1];
        var module = window.eval(moduleStr);
        if (Elm.Debugger) {
            var debuggerState = Elm.Debugger.getHotSwapState();
            mainHandle.dispose();
            Elm.Debugger.dispose();

            var newMainNode = createMainElement();
            debuggerDiv.parentElement.insertBefore(newMainNode,debuggerDiv);

            var wrappedModule = Elm.debuggerAttach(module, debuggerState);
            mainHandle = Elm.embed(wrappedModule, newMainNode);
        }
        else {
            mainHandle = mainHandle.swap(module);
        }
    } else if (errorMessage) {
        var errorNode = document.createElement("pre");
        errorNode.id = "ErrorMessage";
        errorNode.innerHTML = errorMessage;
        errorNode.style.zindex = 1;
        errorNode.style.position = "absolute";
        errorNode.style.top = "0px";
        errorNode.style.background = ELM_LIGHT_GREY;

        var mainNode = document.getElementById(ELM_MAIN_ID);
        mainNode.parentElement.appendChild(errorNode);
    }
}

// Utilities

var toString = function(v, separator) {
    var type = typeof v;
    if (type === "function") {
        var name = v.func ? v.func.name : v.name;
        return '<function' + (name === '' ? '' : ': ') + name + '>';
    } else if (type === "boolean") {
        return v ? "True" : "False";
    } else if (type === "number") {
        return v.toFixed(2).replace(/\.0+$/g, '');
    } else if ((v instanceof String) && v.isChar) {
        return "'" + addSlashes(v) + "'";
    } else if (type === "string") {
        return '"' + addSlashes(v) + '"';
    } else if (type === "object" && '_' in v && probablyPublic(v)) {
        var output = [];
        for (var k in v._) {
            for (var i = v._[k].length; i--; ) {
                output.push(k + " = " + toString(v._[k][i], separator));
            }
        }
        for (var k in v) {
            if (k === '_') continue;
            output.push(k + " = " + toString(v[k], separator));
        }
        if (output.length === 0) return "{}";
        var body = "\n" + output.join(",\n");
        return "{" + body.replace(/\n/g,"\n" + separator) + "\n}";
    } else if (type === "object" && 'ctor' in v) {
        if (v.ctor.substring(0,6) === "_Tuple") {
            var output = [];
            for (var k in v) {
                if (k === 'ctor') continue;
                output.push(toString(v[k], separator));
            }
            return "(" + output.join(", ") + ")";
        } else if (v.ctor === "_Array") {
            var list = Array.toList(v);
            return "Array.fromList " + toString(list, separator);
        } else if (v.ctor === "::") {
            var output = '[\n' + toString(v._0, separator);
            v = v._1;
            while (v.ctor === "::") {
                output += ",\n" + toString(v._0, separator);
                v = v._1;
            }
            output += ' ]';
            return output.replace(/\n/g,"\n" + separator);
        } else if (v.ctor === "[]") {
            return "[]";
        } else if (v.ctor === "RBNode" || v.ctor === "RBEmpty") {
            var cons = F3(function(k,v,acc){return NList.Cons(Tuple2(k,v),acc)});
            var list = A3(Dict.foldr, cons, NList.Nil, v);
            var name = "Dict";
            if (list.ctor === "::" && list._0._1.ctor === "_Tuple0") {
                name = "Set";
                list = A2(List.map, function(x){return x._0}, list);
            }
            return name + ".fromList " + toString(list, separator);
        } else {
            var output = "";
            for (var i in v) {
                if (i === 'ctor') continue;
                var str = toString(v[i], separator);
                var parenless = str[0] === '{' ||
                                str[0] === '<' ||
                                str[0] === "[" ||
                                str.indexOf(' ') < 0;
                output += ' ' + (parenless ? str : "(" + str + ')');
            }
            return v.ctor + output;
        }
    }
    if (type === 'object' && 'recv' in v) return '<signal>';
    return "<internal structure>";
};

function addSlashes(str) {
    return str.replace(/\\/g, '\\\\')
              .replace(/\n/g, '\\n')
              .replace(/\t/g, '\\t')
              .replace(/\r/g, '\\r')
              .replace(/\v/g, '\\v')
              .replace(/\0/g, '\\0')
              .replace(/\'/g, "\\'")
              .replace(/\"/g, '\\"');
}

function probablyPublic(v) {
    var keys = Object.keys(v);
    var len = keys.length;
    if (len === 3
        && 'props' in v
        && 'element' in v) return false;
    if (len === 5
        && 'horizontal' in v
        && 'vertical' in v
        && 'x' in v
        && 'y' in v) return false;
    if (len === 7
        && 'theta' in v
        && 'scale' in v
        && 'x' in v
        && 'y' in v
        && 'alpha' in v
        && 'form' in v) return false;
    return true;
}
<|endoftext|>


<commit_before>'use strict';
var gulp = require('gulp'),
    nodemon = require('gulp-nodemon'),
    style = require('gulp-stylus'),
    nib = require('nib'),
    watch = require('gulp-watch');

var started = false;
var paths = {
  stylus: './content/themes/vimal-suite/assets/stylus/',
  css: './content/themes/vimal-suite/assets/css/',
  js: './content/themes/vimal-suite/js/',
  hbs: './content/themes/vimal-suite/'
};

gulp.task('serve', function(cb) {
  nodemon({
  script: 'index.js',
  ext: 'js hbs',
  watch: [paths.hbs],
  env: {
    'NODE_ENV': 'development'
  },
  ignore: ['./core/**']
  //nodeArgs: ['--debug']
  })
    .on('start', function() {
      if (!started) {
        started = true;
        cb();
      }
    })
    .on('restart', function() {
      console.log('Restart, yo');
    });
});

gulp.task('style', function() {
  return gulp.src(paths.stylus + '**/*.styl')
    .pipe(style({
      use: nib(),
      'include css': true
    }))
    .pipe(gulp.dest(paths.css));
});

gulp.task('watch', function() {
  gulp.watch(paths.stylus + '**/*.styl', ['style']);
});

gulp.task('default', ['serve', 'style', 'watch']);
<commit_msg>Added plumber to style compile in gulp. Keeps compile errors from crashing the pipe and breaking the watch.<commit_after>'use strict';
var gulp = require('gulp'),
    nodemon = require('gulp-nodemon'),
    style = require('gulp-stylus'),
    plumber = require('gulp-plumber'),
    nib = require('nib'),
    watch = require('gulp-watch');

var started = false;
var paths = {
  stylus: './content/themes/vimal-suite/assets/stylus/',
  css: './content/themes/vimal-suite/assets/css/',
  js: './content/themes/vimal-suite/js/',
  hbs: './content/themes/vimal-suite/'
};

gulp.task('serve', function(cb) {
  nodemon({
  script: 'index.js',
  ext: 'js hbs',
  watch: [paths.hbs],
  env: {
    'NODE_ENV': 'development'
  },
  ignore: ['./core/**']
  //nodeArgs: ['--debug']
  })
    .on('start', function() {
      if (!started) {
        started = true;
        cb();
      }
    })
    .on('restart', function() {
      console.log('Restart, yo');
    });
});

gulp.task('style', function() {
  return gulp.src(paths.stylus + '**/*.styl')
    .pipe(plumber())
    .pipe(style({
      use: nib(),
      'include css': true
    }))
    .pipe(gulp.dest(paths.css));
});

gulp.task('watch', function() {
  gulp.watch(paths.stylus + '**/*.styl', ['style']);
});

gulp.task('default', ['serve', 'style', 'watch']);
<|endoftext|>


<commit_before>var gulp     = require("gulp");
var del      = require("del");
var sass     = require("gulp-sass");
var rename   = require("gulp-rename");
var template = require("gulp-template");
var runseq   = require('run-sequence');
var fs       = require("fs");
var _        = require("lodash");
var proc     = require("child_process");

var isDebug = false;

console.log("gulp> Init.");

//Main Paths
var path = {
    src: "source",
    dst: "deploy"
};

//File Paths
path.js   = { src: path.src+"/js",   dst: path.dst+"/js" };
path.scss = { src: path.src+"/scss", dst: path.dst+"/css" };
path.html = { src: path.src+"/html", dst: path.dst };
path.img  = { src: path.src, dst: path.dst };

//Source Streams
var jsFiles   = gulp.src(path.js.src  +"/**/*.js");
var scssFiles = gulp.src(path.scss.src+"/**/*.scss");
var htmlFiles = gulp.src([path.html.src+"/**/*.html","!"+path.html.src+"/**/*.t.html"]);
var imgFiles  = gulp.src([path.src+"/**/*.png",path.src+"/**/*.jpg",path.src+"/**/*.gif",path.src+"/**/*.svg"]);

//Destination Streams
var jsDst   = gulp.dest(path.js.dst);
var scssDst = gulp.dest(path.scss.dst);
var htmlDst = gulp.dest(path.html.dst);
var imgDst  = gulp.dest(path.img.dst);

//Delete the contents of deploy folder
gulp.task("clean",function clean(){
    return del([path.dst+"/**/*","!"+path.dst+"/CNAME*"]);
})

//Move Javascript files to the deploy folder.
gulp.task("move-js", function moveJS() {
    return jsFiles.pipe(jsDst);
});

//Move HTML files to the deploy folder.
gulp.task("move-html", function moveHTML() {
    return htmlFiles.pipe(htmlDst);
});

//Move img files to the deploy folder.
gulp.task("move-img", function moveImg() {
    return imgFiles.pipe(imgDst);
});

//Build Sass files to CSS deploy folder.
gulp.task("build-scss",function buildScss() {

    scssFiles
    .pipe(sass.sync().on("error", sass.logError))
    .pipe(scssDst);

    scssFiles
    .pipe(sass.sync({outputStyle: "compressed"}).on("error", sass.logError))
    .pipe(rename({suffix: ".min"}))
    .pipe(scssDst);

});

//Build Template files to HTML deploy folder.
gulp.task("build-html",function buildScss() {

    var ctx     = {};
    ctx.data    = require("./"+path.html.src+"/config.json");
    ctx.render  = function render(p_file) {
        var s = fs.readFileSync(path.html.src+"/"+p_file).toString();
        var c = _.template(s);
        return c(ctx);
    };
    htmlFiles
    .pipe(template(ctx))
    .pipe(htmlDst);

});

//Builds the website.
gulp.task("build",function build() {
    //Run 'clean' then asynchronously the rest
    runseq("clean",["move-js","move-img","build-html","build-scss"]);
 });

 //Publish the site in github pages
gulp.task("publish",function build() {
    var p;

    function onProcData(data) { console.log(data); }
    function onProcError(err) { console.log(err);  }

    proc.execSync("git add -A",[],{silent:true});

    proc.execSync("git commit -a -m vscode-publish-task",[],{silent:true});

    proc.execSync("git push",[],{silent:true});

    proc.execSync("git subtree push --prefix "+path.dst+" origin master",[],{silent:true});

 });

<commit_msg>vscode-publish-task<commit_after>var gulp     = require("gulp");
var del      = require("del");
var sass     = require("gulp-sass");
var rename   = require("gulp-rename");
var template = require("gulp-template");
var runseq   = require('run-sequence');
var fs       = require("fs");
var _        = require("lodash");
var proc     = require("child_process");

var isDebug = false;

console.log("gulp> Init.");

//Main Paths
var path = {
    src: "source",
    dst: "deploy"
};

//File Paths
path.js   = { src: path.src+"/js",   dst: path.dst+"/js" };
path.scss = { src: path.src+"/scss", dst: path.dst+"/css" };
path.html = { src: path.src+"/html", dst: path.dst };
path.img  = { src: path.src, dst: path.dst };

//Source Streams
var jsFiles   = gulp.src(path.js.src  +"/**/*.js");
var scssFiles = gulp.src(path.scss.src+"/**/*.scss");
var htmlFiles = gulp.src([path.html.src+"/**/*.html","!"+path.html.src+"/**/*.t.html"]);
var imgFiles  = gulp.src([path.src+"/**/*.png",path.src+"/**/*.jpg",path.src+"/**/*.gif",path.src+"/**/*.svg"]);

//Destination Streams
var jsDst   = gulp.dest(path.js.dst);
var scssDst = gulp.dest(path.scss.dst);
var htmlDst = gulp.dest(path.html.dst);
var imgDst  = gulp.dest(path.img.dst);

//Delete the contents of deploy folder
gulp.task("clean",function clean(){
    return del([path.dst+"/**/*","!"+path.dst+"/CNAME*"]);
})

//Move Javascript files to the deploy folder.
gulp.task("move-js", function moveJS() {
    return jsFiles.pipe(jsDst);
});

//Move HTML files to the deploy folder.
gulp.task("move-html", function moveHTML() {
    return htmlFiles.pipe(htmlDst);
});

//Move img files to the deploy folder.
gulp.task("move-img", function moveImg() {
    return imgFiles.pipe(imgDst);
});

//Build Sass files to CSS deploy folder.
gulp.task("build-scss",function buildScss() {

    scssFiles
    .pipe(sass.sync().on("error", sass.logError))
    .pipe(scssDst);

    scssFiles
    .pipe(sass.sync({outputStyle: "compressed"}).on("error", sass.logError))
    .pipe(rename({suffix: ".min"}))
    .pipe(scssDst);

});

//Build Template files to HTML deploy folder.
gulp.task("build-html",function buildScss() {

    var ctx     = {};
    ctx.data    = require("./"+path.html.src+"/config.json");
    ctx.render  = function render(p_file) {
        var s = fs.readFileSync(path.html.src+"/"+p_file).toString();
        var c = _.template(s);
        return c(ctx);
    };
    htmlFiles
    .pipe(template(ctx))
    .pipe(htmlDst);

});

//Builds the website.
gulp.task("build",function build() {
    //Run 'clean' then asynchronously the rest
    runseq("clean",["move-js","move-img","build-html","build-scss"]);
 });

 //Publish the site in github pages
gulp.task("publish",function build() {
    var p;

    function onProcData(data) { console.log(data); }
    function onProcError(err) { console.log(err);  }

    proc.execSync("git add -A",[],{silent:true});
    proc.execSync("git commit -a -m vscode-publish-task",[],{silent:true});
    proc.execSync("git push",[],{silent:true});
    proc.execSync("git subtree push --prefix "+path.dst+" origin master",[],{silent:true});

 });

<|endoftext|>


<commit_before>const gulp = require('gulp');
const babel = require('gulp-babel');
const rename = require("gulp-rename");
const eslint = require('gulp-eslint');
const karma = require('karma').Server;
const uglify = require('gulp-uglifyjs');
const minify = require("gulp-babel-minify");
const browserSync = require('browser-sync');

// Browser sync task
gulp.task('sync', function () {
  browserSync.init({
    server: "./example/"
  });

  // Watch for file changes
  gulp.watch(['./src/*.js'], ['reload', 'build']);
  gulp.watch(['./example/*.html', './example/js/*.js', './example/css/*.css'], browserSync.reload);
});

// Reload task
gulp.task('reload', function () {
  gulp.src(['./src/turtle.js'])
    .pipe(babel({
      presets: ['env'],
      plugins: ['add-module-exports', 'transform-es2015-modules-umd']
    }))
    .pipe(uglify())
    .pipe(rename('turtle.min.js'))
    .pipe(gulp.dest('./example/js'))
});

// Test task
gulp.task('test', function (done) {
  new karma({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, function (exitCode) {
    done();
    process.exit(exitCode);
  }).start();
});

// Lint task
gulp.task('lint', function () {
  return gulp.src(['./src/turtle.js'])
    .pipe(eslint({
      "parser": "babel-eslint",
      rules: {
    		"camelcase": 2,
    		"curly": 1,
    		"eqeqeq": 0,
    		"no-empty": 2,
        "no-const-assign": 2,
        "no-var": 2,
        "prefer-const": 1
      },
      env: {
        "es6": true
      },
      "parserOptions": {
        "ecmaVersion": 7
      }
    }))
    .pipe(eslint.format())
});

// Build task
gulp.task('build', function () {
  gulp.src(['./src/turtle.js'])
    .pipe(rename('turtle.es7.js'))
    .pipe(gulp.dest('./dist'))
    .pipe(minify({
      mangle: {
        keepClassName: true
      }
    }))
    .pipe(rename('turtle.es7.min.js'))
    .pipe(gulp.dest('./dist'))

  gulp.src(['./src/turtle.js'])
    .pipe(babel({
      presets: ['env'],
      plugins: ['add-module-exports', 'transform-es2015-modules-umd']
    }))
    .pipe(gulp.dest('./dist'))
    .pipe(uglify())
    .pipe(rename('turtle.min.js'))
    .pipe(gulp.dest('./dist'))
});

// Set the defaukt task as 'sync'
gulp.task('default', ['sync']);
<commit_msg>Update sync task<commit_after>const gulp = require('gulp');
const babel = require('gulp-babel');
const rename = require("gulp-rename");
const eslint = require('gulp-eslint');
const karma = require('karma').Server;
const uglify = require('gulp-uglifyjs');
const minify = require("gulp-babel-minify");
const browserSync = require('browser-sync');

// Browser sync task
gulp.task('sync', function () {
  browserSync.init({
    server: "./example/"
  });

  // Watch for file changes and reload
  gulp.watch(['./src/*.js'], ['reload']);
  gulp.watch(['./example/*.html', './example/js/*.js', './example/css/*.css'], browserSync.reload);
});

// Reload task
gulp.task('reload', function () {
  gulp.src(['./src/turtle.js'])
    .pipe(babel({
      presets: ['env'],
      plugins: ['add-module-exports', 'transform-es2015-modules-umd']
    }))
    .pipe(uglify())
    .pipe(rename('turtle.min.js'))
    .pipe(gulp.dest('./example/js'))
});

// Test task
gulp.task('test', function (done) {
  new karma({
    configFile: __dirname + '/karma.conf.js',
    singleRun: true
  }, function (exitCode) {
    done();
    process.exit(exitCode);
  }).start();
});

// Lint task
gulp.task('lint', function () {
  return gulp.src(['./src/turtle.js'])
    .pipe(eslint({
      "parser": "babel-eslint",
      rules: {
    		"camelcase": 2,
    		"curly": 1,
    		"eqeqeq": 0,
    		"no-empty": 2,
        "no-const-assign": 2,
        "no-var": 2,
        "prefer-const": 1
      },
      env: {
        "es6": true
      },
      "parserOptions": {
        "ecmaVersion": 7
      }
    }))
    .pipe(eslint.format())
});

// Build task
gulp.task('build', function () {
  gulp.src(['./src/turtle.js'])
    .pipe(rename('turtle.es7.js'))
    .pipe(gulp.dest('./dist'))
    .pipe(minify({
      mangle: {
        keepClassName: true
      }
    }))
    .pipe(rename('turtle.es7.min.js'))
    .pipe(gulp.dest('./dist'))

  gulp.src(['./src/turtle.js'])
    .pipe(babel({
      presets: ['env'],
      plugins: ['add-module-exports', 'transform-es2015-modules-umd']
    }))
    .pipe(gulp.dest('./dist'))
    .pipe(uglify())
    .pipe(rename('turtle.min.js'))
    .pipe(gulp.dest('./dist'))
});

// Set the defaukt task as 'sync'
gulp.task('default', ['sync']);
<|endoftext|>


<commit_before>const E_ITER = 'Argument 1 of seek must be a NodeIterator.';
const E_SHOW = 'Argument 1 of seek must use filter NodeFilter.SHOW_TEXT.';
const E_WHERE = 'Argument 2 of seek must be a number or a Text Node.';

export default function seek(iter, where) {
  if (!(iter instanceof NodeIterator)) {
    throw new Error(E_ITER);
  }

  if (iter.whatToShow !== NodeFilter.SHOW_TEXT) {
    throw new Error(E_SHOW);
  }

  let count = 0;
  let node = iter.referenceNode;
  let predicates = null;

  if (isNumber(where)) {
    predicates = {
      forward: () => count < where,
      backward: () => count > where
    };
  } else if (isText(where)) {
    predicates = {
      forward: () => before(node, where),
      backward: () => after(node, where)
    };
  } else {
    throw new Error(E_WHERE);
  }

  while (predicates.forward() && (node = iter.nextNode()) !== null) {
    count += node.textContent.length;
  }

  while (predicates.backward() && (node = iter.previousNode()) !== null) {
    count -= node.textContent.length;
  }

  return count;
}

function isNumber(n) {
  return !isNaN(parseInt(n)) && isFinite(n);
}

function isText(node) {
  return node.nodeType === Node.TEXT_NODE;
}

function before(referenceNode, node) {
  return referenceNode.compareDocumentPosition(node) &
    (Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_CONTAINED_BY);
}

function after(referenceNode, node) {
  return referenceNode.compareDocumentPosition(node) &
    (Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_CONTAINS);
}
<commit_msg>Fix bug in traversal to node<commit_after>const E_ITER = 'Argument 1 of seek must be a NodeIterator.';
const E_SHOW = 'Argument 1 of seek must use filter NodeFilter.SHOW_TEXT.';
const E_WHERE = 'Argument 2 of seek must be a number or a Text Node.';

export default function seek(iter, where) {
  if (!(iter instanceof NodeIterator)) {
    throw new Error(E_ITER);
  }

  if (iter.whatToShow !== NodeFilter.SHOW_TEXT) {
    throw new Error(E_SHOW);
  }

  let count = 0;
  let node = iter.referenceNode;
  let predicates = null;

  if (isNumber(where)) {
    predicates = {
      forward: () => count < where,
      backward: () => count > where
    };
  } else if (isText(where)) {
    predicates = {
      forward: () => before(node, where),
      backward: () => !iter.pointerBeforeReferenceNode || after(node, where)
    };
  } else {
    throw new Error(E_WHERE);
  }

  while (predicates.forward() && (node = iter.nextNode()) !== null) {
    count += node.textContent.length;
  }

  while (predicates.backward() && (node = iter.previousNode()) !== null) {
    count -= node.textContent.length;
  }

  return count;
}

function isNumber(n) {
  return !isNaN(parseInt(n)) && isFinite(n);
}

function isText(node) {
  return node.nodeType === Node.TEXT_NODE;
}

function before(referenceNode, node) {
  return referenceNode.compareDocumentPosition(node) &
    (Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_CONTAINED_BY);
}

function after(referenceNode, node) {
  return referenceNode.compareDocumentPosition(node) &
    (Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_CONTAINS);
}
<|endoftext|>


<commit_before>/*
 * biojs-vis-context-data-unique-list
 * https://github.com/BioCIDER/biojs-vis-context-data-unique-list
 *
 * Copyright (c) 2015 Carlos Horro
 * Licensed under the MIT license.
 */

// browserify build config
var buildDir = "build";
var outputFile = "biocider";

var imagesDir = "img";

// packages
var gulp   = require('gulp');

// browser builds
var browserify = require('browserify');
var watchify = require('watchify')
var uglify = require('gulp-uglify');

// testing
//var mocha = require('gulp-mocha');

// code style

// gulp helper
var source = require('vinyl-source-stream'); // converts node streams into vinyl streams
var gzip = require('gulp-gzip');
var rename = require('gulp-rename');
var chmod = require('gulp-chmod');
var streamify = require('gulp-streamify'); // converts streams into buffers (legacy support for old plugins)
var watch = require('gulp-watch');

// path tools
var fs = require('fs');
var path = require('path');
var join = path.join;
var mkdirp = require('mkdirp');
var del = require('del');

// auto config
var outputFileMin = join(buildDir,outputFile + ".min.js");
var packageConfig = require('./package.json');

// a failing test breaks the whole build chain
gulp.task('build', ['build-browser', 'build-browser-gzip','copy-images']);
gulp.task('default', [  'build']);

// will remove everything in build
gulp.task('clean', function(cb) {
  del([buildDir+'/img']);
  del([buildDir+'/css']);
  del([buildDir+'/**/*'], cb);
});

// just makes sure that the build dir exists
gulp.task('init', ['clean'], function() {
  mkdirp(buildDir, function (err) {
    if (err) console.error(err)
  });
});

//gulp.task('test', function () {
//  return gulp.src('./test/**/*.js', {read: false})
//    .pipe(mocha({reporter: 'spec',
//                 useColors: false}));
//});

// copy images from source locations to build location
gulp.task('copy-images', function(cb) {
  gulp.src([
    imagesDir+'/**'
])
.pipe(gulp.dest(buildDir+'/'+imagesDir));
});

// browserify debug
gulp.task('build-browser',['init'], function() {
  var b = browserify({debug: true,hasExports: true});
  exposeBundles(b);
  return b.bundle()
    .pipe(source(outputFile + ".js"))
    .pipe(chmod(644))
    .pipe(gulp.dest(buildDir));
});

// browserify min
gulp.task('build-browser-min',['init'], function() {
  var b = browserify({hasExports: true, standalone: "biojs-vis-context-data-unique-list"});
  exposeBundles(b);
  return b.bundle()
    .pipe(source(outputFile + ".min.js"))
    .pipe(chmod(644))
    .pipe(streamify(uglify()))
    .pipe(gulp.dest(buildDir));
});

gulp.task('build-browser-gzip', ['build-browser-min'], function() {
  return gulp.src(outputFileMin)
    .pipe(gzip({append: false, gzipOptions: { level: 9 }}))
    .pipe(rename(outputFile + ".min.gz.js"))
    .pipe(gulp.dest(buildDir));
});

// exposes the main package
// + checks the config whether it should expose other packages
function exposeBundles(b){
   b.add("./" + packageConfig.main, {expose: packageConfig.name });
  //b.add("./" + packageConfig.main, {expose: "BioCider"});
  if(packageConfig.sniper !== undefined && packageConfig.sniper.exposed !== undefined){
    for(var i=0; i<packageConfig.sniper.exposed.length; i++){
      b.require(packageConfig.sniper.exposed[i]);
    }
  }
}

// watch task for browserify
// watchify has an internal cache -> subsequent builds are faster
gulp.task('watch', function() {
  var util = require('gulp-util')

  var b = browserify({debug: true,hasExports: true, cache: {}, packageCache: {} });
  b.add("./" + packageConfig.main, {expose: packageConfig.name});
  //b.add("./" + packageConfig.main, {expose: "BioCider" });
  // expose other bundles
  exposeBundles(b);

  function rebundle(ids){
    b.bundle()
    .on("error", function(error) {
      util.log(util.colors.red("Error: "), error);
     })
    .pipe(source(outputFile + ".js"))
    .pipe(chmod(644))
    .pipe(gulp.dest(buildDir));
  }

  var watcher = watchify(b);
  watcher.on("update", rebundle)
   .on("log", function(message) {
      util.log("Refreshed:", message);
  });
  return rebundle();
});
<commit_msg>Fixed error trying to copy images without the proper folder.<commit_after>/*
 * biojs-vis-context-data-unique-list
 * https://github.com/BioCIDER/biojs-vis-context-data-unique-list
 *
 * Copyright (c) 2015 Carlos Horro
 * Licensed under the MIT license.
 */

// browserify build config
var buildDir = "build";
var outputFile = "biocider";

var imagesDir = "img";

// packages
var gulp   = require('gulp');

// browser builds
var browserify = require('browserify');
var watchify = require('watchify')
var uglify = require('gulp-uglify');

// testing
//var mocha = require('gulp-mocha');

// code style

// gulp helper
var source = require('vinyl-source-stream'); // converts node streams into vinyl streams
var gzip = require('gulp-gzip');
var rename = require('gulp-rename');
var chmod = require('gulp-chmod');
var streamify = require('gulp-streamify'); // converts streams into buffers (legacy support for old plugins)
var watch = require('gulp-watch');

// path tools
var fs = require('fs');
var path = require('path');
var join = path.join;
var mkdirp = require('mkdirp');
var del = require('del');

// auto config
var outputFileMin = join(buildDir,outputFile + ".min.js");
var packageConfig = require('./package.json');

// a failing test breaks the whole build chain
gulp.task('build', ['build-browser', 'build-browser-gzip','copy-images']);
gulp.task('default', [  'build']);

// will remove everything in build
gulp.task('clean', function(cb) {
  del([buildDir+'/img']);
  del([buildDir+'/css']);
  del([buildDir+'/**/*'], cb);
});

// just makes sure that the build dir exists
gulp.task('init', ['clean'], function() {
  mkdirp(buildDir, function (err) {
    if (err) console.error(err)
  });
});

//gulp.task('test', function () {
//  return gulp.src('./test/**/*.js', {read: false})
//    .pipe(mocha({reporter: 'spec',
//                 useColors: false}));
//});

// copy images from source locations to build location
gulp.task('copy-images',['init'], function(cb) {
  gulp.src([
    imagesDir+'/**'
])
.pipe(gulp.dest(buildDir+'/'+imagesDir));
});

// browserify debug
gulp.task('build-browser',['init'], function() {
  var b = browserify({debug: true,hasExports: true});
  exposeBundles(b);
  return b.bundle()
    .pipe(source(outputFile + ".js"))
    .pipe(chmod(644))
    .pipe(gulp.dest(buildDir));
});

// browserify min
gulp.task('build-browser-min',['init'], function() {
  var b = browserify({hasExports: true, standalone: "biojs-vis-context-data-unique-list"});
  exposeBundles(b);
  return b.bundle()
    .pipe(source(outputFile + ".min.js"))
    .pipe(chmod(644))
    .pipe(streamify(uglify()))
    .pipe(gulp.dest(buildDir));
});

gulp.task('build-browser-gzip', ['build-browser-min'], function() {
  return gulp.src(outputFileMin)
    .pipe(gzip({append: false, gzipOptions: { level: 9 }}))
    .pipe(rename(outputFile + ".min.gz.js"))
    .pipe(gulp.dest(buildDir));
});

// exposes the main package
// + checks the config whether it should expose other packages
function exposeBundles(b){
   b.add("./" + packageConfig.main, {expose: packageConfig.name });
  //b.add("./" + packageConfig.main, {expose: "BioCider"});
  if(packageConfig.sniper !== undefined && packageConfig.sniper.exposed !== undefined){
    for(var i=0; i<packageConfig.sniper.exposed.length; i++){
      b.require(packageConfig.sniper.exposed[i]);
    }
  }
}

// watch task for browserify
// watchify has an internal cache -> subsequent builds are faster
gulp.task('watch', function() {
  var util = require('gulp-util')

  var b = browserify({debug: true,hasExports: true, cache: {}, packageCache: {} });
  b.add("./" + packageConfig.main, {expose: packageConfig.name});
  //b.add("./" + packageConfig.main, {expose: "BioCider" });
  // expose other bundles
  exposeBundles(b);

  function rebundle(ids){
    b.bundle()
    .on("error", function(error) {
      util.log(util.colors.red("Error: "), error);
     })
    .pipe(source(outputFile + ".js"))
    .pipe(chmod(644))
    .pipe(gulp.dest(buildDir));
  }

  var watcher = watchify(b);
  watcher.on("update", rebundle)
   .on("log", function(message) {
      util.log("Refreshed:", message);
  });
  return rebundle();
});
<|endoftext|>


<commit_before>/* ***************************************************************************************
ES6 version of milsymbol
*************************************************************************************** */
export { ms } from "./src/milsymbol.js";
export { app6b, std2525b, std2525c } from "./src/lettersidc.js";
export { app6d, std2525d } from "./src/numbersidc.js";
export { default as path2d } from "./src/ms/path2d.js";

/* ***************************************************************************************
ES6 version of milsymbol
******************************************************************************************
To import all and have the same functionality as ordinary milsymbol, do the following:
(Or just import the things that you need)

import {
  ms,
  app6b,
  std2525b,
  std2525c,
  app6d,
  std2525d,
  path2d
} from "./index.esm.js";

ms.addIcons(app6b);
ms.addIcons(std2525b);
ms.addIcons(std2525c);
ms.addIcons(app6d);
ms.addIcons(std2525d);
ms.Path2D = path2d;

*/
<commit_msg>Add comments<commit_after>/* ***************************************************************************************
ES6 version of milsymbol
*************************************************************************************** */
export { ms } from "./src/milsymbol.js";
export { app6b, std2525b, std2525c } from "./src/lettersidc.js";
export { app6d, std2525d } from "./src/numbersidc.js";
export { default as path2d } from "./src/ms/path2d.js";

/* ***************************************************************************************
ES6 version of milsymbol
******************************************************************************************
To import all and have the same functionality as ordinary milsymbol, do the following:
(Or just import the things that you need)

import {
  ms,       // Base for milsymbol
  app6b,    // APP6-B
  std2525b, // 2525B
  std2525c, // 2525C
  app6d,    // APP6-D
  std2525d, // 2525D
  path2d    // Pollyfill for Path2D in IE or node-canvas
} from "./index.esm.js";

ms.addIcons(app6b);
ms.addIcons(std2525b);
ms.addIcons(std2525c);
ms.addIcons(app6d);
ms.addIcons(std2525d);
ms.Path2D = path2d;

*/
<|endoftext|>


<commit_before>/*!
 * rose-normalize-sass [v0.0.1]
 * ___________________________________________________
 * Gulp: The streaming build system.
 * https://github.com/gulpjs/gulp | http://gulpjs.com/
 * @author  : Prabhat Kumar, http://prabhatkumar.org/
 * @date    : 11-July-2015
 * ___________________________________________________
 */

'use strict';

// main module.
var gulp                   = require('gulp');
// required modules.
var sass              = require('gulp-sass');
var concat          = require('gulp-concat');
var scsslint     = require('gulp-scss-lint');
var uglify          = require('gulp-uglify');
var beautify      = require('gulp-beautify');
var sourcemaps  = require('gulp-sourcemaps');
// utility modules.
var path                   = require('path');
var gutil             = require('gulp-util');
var gulpif              = require('gulp-if');
var size              = require('gulp-size');
var del                     = require('del');
var notify          = require("gulp-notify");
var rename          = require("gulp-rename");
var replace        = require('gulp-replace');
var bytediff      = require('gulp-bytediff');
var chmod            = require('gulp-chmod');
<commit_msg>update of gulpfile.js - commit.<commit_after>/*!
 * rose-normalize-sass [v0.0.1]
 * ___________________________________________________
 * Gulp: The streaming build system.
 * https://github.com/gulpjs/gulp | http://gulpjs.com/
 * @author  : Prabhat Kumar, http://prabhatkumar.org/
 * @date    : 11-July-2015
 * ___________________________________________________
 */

'use strict';

// main module.
var gulp                   = require('gulp');
// required modules.
var sass              = require('gulp-sass');
var concat          = require('gulp-concat');
var scsslint     = require('gulp-scss-lint');
var uglify          = require('gulp-uglify');
var beautify      = require('gulp-beautify');
var sourcemaps  = require('gulp-sourcemaps');
// utility modules.
var path                   = require('path');
var gutil             = require('gulp-util');
var gulpif              = require('gulp-if');
var size              = require('gulp-size');
var del                     = require('del');
var notify          = require("gulp-notify");
var rename          = require("gulp-rename");
var replace        = require('gulp-replace');
var bytediff      = require('gulp-bytediff');
var chmod            = require('gulp-chmod');

// ***** SETTINGS ***** //
var AUTOPREFIXER_BROWSERS = [
  'ie >= 10',
  'ie_mob >= 10',
  'ff >= 30',
  'chrome >= 34',
  'safari >= 7',
  'opera >= 22',
  'ios >= 7',
  'android >= 4.4',
  'bb >= 10'
];
<|endoftext|>


<commit_before>import { AppRegistry } from 'react-native';
import App from './app/App';

AppRegistry.registerComponent('FragDenStaat', () => App);
<commit_msg>disable in-app warnings<commit_after>import { AppRegistry } from 'react-native';
import App from './app/App';

console.disableYellowBox = true;

AppRegistry.registerComponent('FragDenStaat', () => App);
<|endoftext|>


<commit_before>'use strict';

var gulp = require( 'gulp' );
var plugins = require( 'gulp-load-plugins' )();

gulp.task( 'watch', function() {
    // Watch .less files
    gulp.watch( 'design/**/*.less', [ 'styles' ] );

    // Watch .js files
    gulp.watch( 'scripts/**/*.js', [ 'scripts' ] );

    gulp.watch( 'web/*', [ 'markup' ] );

    // Watch image files
    gulp.watch( 'design/images/**/*', [ 'images' ] );
});

gulp.task( 'styles', function() {
    var condition = function( file ) {
        return !file.lesshint.success;
    };

    return gulp.src( './design/style.less' )
        .pipe( plugins.lesshint() )
        .pipe( plugins.lesshint.reporter() )
        .pipe( plugins.notify( function ( file ) {
            if ( file.lesshint.success ) {
                // Don't show something if success
                return false;
            }

            return file.relative + ' errored with ' + file.lesshint.resultCount + ' errors';
        }) )
        .pipe( plugins.ignore.exclude( condition ) )
        .pipe( plugins.less() )
        .pipe( plugins.autoprefixer( 'last 2 version' ) )
        .pipe( plugins.rename( { suffix: '.min' } ) )
        .pipe( plugins.cssnano() )
        .pipe( gulp.dest( './dist/' ) )
});

gulp.task( 'scripts', function() {
    return gulp.src( './scripts/**/*.js' )
        .pipe( gulp.dest( './dist/' ) );
});

gulp.task( 'images', function() {
    return gulp.src( 'design/images/**/*' )
        .pipe( plugins.cache( plugins.imagemin( {
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        } ) ) )
        .pipe( gulp.dest( 'dist/images' ));
});

gulp.task( 'markup', function() {
    return gulp.src( './web/*' )
        .pipe( gulp.dest( './dist/' ) );
});

gulp.task( 'default', [ 'styles', 'scripts', 'images', 'markup' ] );
<commit_msg>Use gulp start to first run everything and then watch<commit_after>'use strict';

var gulp = require( 'gulp' );
var plugins = require( 'gulp-load-plugins' )();

gulp.task( 'watch', function() {
    // Watch .less files
    gulp.watch( 'design/**/*.less', [ 'styles' ] );

    // Watch .js files
    gulp.watch( 'scripts/**/*.js', [ 'scripts' ] );

    gulp.watch( 'web/*', [ 'markup' ] );

    // Watch image files
    gulp.watch( 'design/images/**/*', [ 'images' ] );
});

gulp.task( 'styles', function() {
    var condition = function( file ) {
        return !file.lesshint.success;
    };

    return gulp.src( './design/style.less' )
        .pipe( plugins.lesshint() )
        .pipe( plugins.lesshint.reporter() )
        .pipe( plugins.notify( function ( file ) {
            if ( file.lesshint.success ) {
                // Don't show something if success
                return false;
            }

            return file.relative + ' errored with ' + file.lesshint.resultCount + ' errors';
        }) )
        .pipe( plugins.ignore.exclude( condition ) )
        .pipe( plugins.less() )
        .pipe( plugins.autoprefixer( 'last 2 version' ) )
        .pipe( plugins.rename( { suffix: '.min' } ) )
        .pipe( plugins.cssnano() )
        .pipe( gulp.dest( './dist/' ) )
});

gulp.task( 'scripts', function() {
    return gulp.src( './scripts/**/*.js' )
        .pipe( gulp.dest( './dist/' ) );
});

gulp.task( 'images', function() {
    return gulp.src( 'design/images/**/*' )
        .pipe( plugins.cache( plugins.imagemin( {
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        } ) ) )
        .pipe( gulp.dest( 'dist/images' ));
});

gulp.task( 'markup', function() {
    return gulp.src( './web/*' )
        .pipe( gulp.dest( './dist/' ) );
});

gulp.task( 'start', [ 'default', 'watch' ] );

<|endoftext|>


<commit_before>// define namespace to prevent loading js files multiple times
var pepdb = pepdb || {};

$.ajaxSetup ({
    // Disable caching of AJAX responses
    cache: false
});

var isFirstLoad = function(namesp, jsFile) {
  var isFirst = namesp.firstLoad === undefined;
  namesp.firstLoad = false;

  return isFirst;
};

function stopTableSorting(e) {
    if (!e) var e = window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
}

/* get url parameter "name" or return "" if does not exist */
function urlParam(name){
  var result = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
  return result && unescape(result[1]) || "";
}

$(document).ready(function(){
  function baseDir(){
    var url = document.location.pathname.split('/')[1];
    if (url == "pepdb"){
      return '/'+url;
    }else{
      return '';
    }
  };

  var url = baseDir();
  var formAll = ["#all_lib", "#all_sel", "#all_ds", "#c_all_lib", "#r_all_lib", "#all_motl"];
  var propSelect = ['#l', '#s', '#ds', '#c', '#ts', '#tt', '#tc', '#ss', '#st', '#sc'];
  var propInput = ['#seq', '#blos', '#pl', '#sr', '#ralt', '#ragt', '#relt', '#regt', '#dlt', '#dgt'];
  var species = ['#ss', '#ts'];
  var tissue = ['#st', '#tt'];
  var cell = ['#sc', '#tc'];

  $('.optbut').button();
  $('#navigation').menu();

  $('#clear-button').click(function(){
    $('body').load(window.location.pathname);
  });

  $.each(formAll, function(index, value){
    $(value).click(function(){
      var marked = this.checked;
      $(this).closest('fieldset').find(':checkbox').each(function(){
        $(this).prop('checked', marked);
      });
    });
  });

  $('#comp-library input:checkbox').click(function(){
    var checkedLibs = [];
    $(this).closest('fieldset').find(':checkbox').each(function(){
      var elemVal = $(this).attr('value');
      if(this.checked && elemVal != "all_lib"){
        checkedLibs.push(elemVal);
      }
    });
    $('#comp-selection').load(url+'/checklist',{checkedElem: checkedLibs, allElem: 'c_all_sel', allElemVal: 'all_sel', selector: 'sel', sec: 'c_', elemName: 'sels[]' }, function(){
        $.getScript(url+"/script/checkbox.js");
      } );
  });

  $('#ref-library input:checkbox').click(function(){
    var checkedLibs = [];
    $(this).closest('fieldset').find(':checkbox').each(function(){
      var elemVal = $(this).attr('value');
      if(this.checked && elemVal != "all_lib"){
        checkedLibs.push(elemVal);
      }
    });
    $('#ref-selection').load(url+'/checklist',{checkedElem: checkedLibs, allElem: 'r_all_sel', allElemVal: 'all_sel', selector: 'sel', sec: 'r_', elemName: 'sels[]' }, function(){
        $.getScript(url+"/script/checkbox.js");
      } );
  });

  $('#motif-list input:checkbox').click(function(){
    if($('#motifs').is(':visible')){
      $('#motifs').toggle();
    }
    var checkedLists = [];
    $(this).closest('fieldset').find(':checkbox').each(function(){
      var elemVal = $(this).attr('value');
      if(this.checked && elemVal != "all_motl"){
        checkedLists.push(elemVal);
      }
    });
    $.get('mot-checklist', {checkedElem: checkedLists},function(data){
      $('#motifs').html(data);
      $.getScript(url+"/script/initshowtable.js", function(){
        $('#motifs').toggle();
      });

    });
  });

   $('#compdata').submit(function(){
    if($('#comppepresults').is(':visible')){
      $('#comppepresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    $('#compinfos').html("");
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#comppepresults').html(response);
        $.getScript(url+'/script/initshowtable.js', function(){
          $('#comppepresults').toggle();
          $('.loading').toggle();
        });
      }
    });
    return false;
  });

   $('#motsearch').submit(function(){
    if($('#motresults').is(':visible')){
      $('#motresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#motresults').html(response);
        $.getScript(url+'/script/accinit.js', function(){
          $('#motresults').toggle();
          $('.loading').toggle();
        });
      }
    });
    return false;
  });

  $('#cl-search').submit(function(){
    if($('#results').is(':visible')){
      $('#results').toggle();
    }
    if($('#clsearch').is(':visible')){
      $('#clsearch').toggle();
    }
    $('#results').html("");
    $('#clsearchpeps').html("");
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#results').html(response);
        $.getScript(url+'/script/tableinit.js', function(){
          $('#results').toggle();
        });
      }
    });
    return false;
  });

    $('#datatype').change(function(){
      var selected = $(this).children("option:selected").text();
      if(selected == "sequencing dataset"){
        selected = "dataset";
      }
      if(selected == "motif list"){
        selected = "motif";
      }
      $("#dataform").load(url+'/add'+ selected, function(){
        var boxNames = ['#dlibname', '#dselname', '#ddsname', '#dspecies'];

        $.each(boxNames, function(index, value){
          $(value).prop('selectedIndex', -1);
        });

        $('#dspecies').change(function(){
          var valSel = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "tissue", selected1: valSel, table:"targets", where1:"species", boxID:"dtissue"}, function(data){
            $('#dtissue').html(data);
            $('#dtissue').prop('selectedIndex', -1);
            $('#dcell').html('');
          });
        });
        $('#dtissue').change(function(){
          var valSel1 = $('#dspecies').children("option:selected").text();
          var valSel2 = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "cell", selected1: valSel1, selected2: valSel2,table:"targets", where2:"tissue", where1:"species",boxID:"dcell"}, function(data){
            $('#dcell').html(data);
          });
        });
        $('#dlibname').change(function(){
          var valSel = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "selection_name", selected1: valSel, table:"selections", where1:"library_name", boxID:"dselname"}, function(data){
            $('#dselname').html(data);
            $('#dselname').prop('selectedIndex', -1);
            $('#ddsname').prop('selectedIndex', -1);
          });
        });
        $('#dselname').change(function(){
          var valSel1 = $('#dlibname').children("option:selected").text();
          var valSel2 = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "dataset_name", selected1: valSel1, selected2: valSel2, table:"sequencing_datasets", where1:"library_name", where2:"selection_name",boxID:"dselname"}, function(data){
            $('#ddsname').html(data);
            $('#ddsname').prop('selectedIndex', -1);
          });
        });
      });
    });

    $.each(propSelect, function(index, value){
      var paramName = $(value).attr('name');
      if(urlParam(paramName) == ""){
        $(value).prop('selectedIndex', -1);
      }
      $(value).on('beforeunload', function(){
        if ($(this).attr('selectedIndex') == -1){
          $(this).prop('name', '');
        }
        });
      });

    $('#edittype').change(function(){
      var selected = $(this).children("option:selected").val();
      $.get(url+'/editdrop', {table:selected}, function(data){
        $('#elementselection').html(data);
        $.getScript(url+'/script/dropbox.js');
      });
    });

   $('#propsearch').submit(function(){
    if($('#propresults').is(':visible')){
      $('#propresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#propresults').html(response);
        $.getScript(url+'/script/initshowtable.js', function(){
          $('#propresults').toggle();
          $('.loading').toggle();
        });
      }
    });
    return false;
  });
    $.each(species, function(index, value){
      $(value).change(function(){
        var valSel = $(this).children("option:selected").text();
        $.get(url+'/formdrop', {columnname: "tissue", selected1: valSel, table:"targets", where1:"species", boxID:tissue[index].substring(1)}, function(data){
          $(tissue[index]).html(data);
          $(tissue[index]).prop('selectedIndex', -1);
          $(cell[index]).html('');
        });
      });
    });

    $.each(tissue, function(index, value){
      $(value).change(function(){
        var valSel1 = $(species[index]).children("option:selected").text();
        var valSel2 = $(this).children("option:selected").text();
        $.get(url+'/formdrop', {columnname: "cell", selected1: valSel1, selected2: valSel2,table:"targets", where2:"tissue", where1:"species",boxID:cell[index].substring(1)}, function(data){
          $(cell[index]).html(data);
        });
      });

    });

    $('#l').change(function(){
      var valSel = $(this).children("option:selected").text();
      $.get(url+'/formdrop', {columnname: "selection_name", selected1: valSel, table:"selections", where1:"library_name", boxID:"s"}, function(data){
        $('#s').html(data);
        $('#s').prop('selectedIndex', -1);
        $('#ds').html('');
      });
    });
    $('#s').change(function(){
      var valSel1 = $('#l').children("option:selected").text();
      var valSel2 = $(this).children("option:selected").text();
      $.get(url+'/formdrop', {columnname: "dataset_name", selected1: valSel1, selected2: valSel2,table:"sequencing_datasets", where2:"selection_name", where1:"library_name",boxID:"ds"}, function(data){
        $('#ds').html(data);
      });
    });

   $('#compclform').submit(function(){
    if($('#compclresults').is(':visible')){
      $('#compclresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#compclresults').html(response);
        $.getScript(url+'/script/accinit.js', function(){
          $('#compclresults').toggle();
          $('.loading').toggle();
        });
      }
    });
    return false;
  });

    $('#type').change(function(){
      if ($(this).val() == "complete sequence"){
        $('#blossum').show();
        $('#wchelp').hide();
      } else if ($(this).val() == "wildcard sequence"){
        $('#blossum').hide();
        $('#wchelp').show();
      } else {
        $('#blossum').hide();
        $('#wchelp').hide();

      }
    });
    $('#wcicon').tooltip({
      content: function(callback){
        callback($(this).prop('title').replace(/\|/g, '<br />'));
      }
    });

    $('.editlink').click(function(e){
      e.preventDefault();
      var link = $(this).attr('href');
      $.get(link, function(response){
        $('#editusers').html(response);
      });
    })

    /* -----------jsTree configuration------------------- */
    $('#clusterlist').bind("loaded.jstree", function(){
     var opennode = document.location.pathname.split("/").pop();
     $('#' + opennode).parents(".jstree-closed").each(function(){
        $('#clusterlist').jstree("open_node", this, false, true);
      });
    });

    $('#clusterlist').bind('before.jstree', function(event,data){
      switch(data.plugin){
        case 'ui':
          if(!data.inst.is_leaf(data.args[0])){
            return false;
          }
          break;
        default:
          break;
      }
    })
      .jstree( {"themeroller": {"item_leaf": false,
                                "item_clsd": false,
                                "item_open":false  },
                "plugins" : ["html_data",  "themeroller"],})
      .delegate("a", "click", function(event, data){
        if($('#clusterlist_sel').is(':visible')){
          $('#clusterlist_sel').toggle();
        }
        if($('#clusterlist_pep').is(':visible')){
          $('#clusterlist_pep').html("");
        }
        var cluster = $(this).attr('href').split('/')[2];
        $.get(url+'/cluster-infos',{selCl:cluster}, function(data){
          $('#clusterlist_sel').html(data);
          $.getScript(url+'/script/initshowtable.js', function(){
            $('#clusterlist_sel').toggle();
          });
        });
        return false;
     } );

    $('#disp-res').bind("loaded.jstree", function(){
     var opennode = document.location.pathname.split("/").pop();
     $('#' + opennode).parents(".jstree-closed").each(function(){
        $('#disp-res').jstree("open_node", this, false, true);
      });
    });

    $('#disp-res').bind('before.jstree', function(event,data){
      switch(data.plugin){
        case 'ui':
          if(!data.inst.is_leaf(data.args[0])){
            return false;
          }
          break;
        default:
          break;
      }
    })
      .jstree( {"plugins" : ["html_data", "ui", "themeroller"],
                "item_leaf": false, })
      .delegate("a", "click", function(event, data){
     } );

});
<commit_msg>comparative cluster search: better handling for displaying search results<commit_after>// define namespace to prevent loading js files multiple times
var pepdb = pepdb || {};

$.ajaxSetup ({
    // Disable caching of AJAX responses
    cache: false
});

var isFirstLoad = function(namesp, jsFile) {
  var isFirst = namesp.firstLoad === undefined;
  namesp.firstLoad = false;

  return isFirst;
};

function stopTableSorting(e) {
    if (!e) var e = window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
}

/* get url parameter "name" or return "" if does not exist */
function urlParam(name){
  var result = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
  return result && unescape(result[1]) || "";
}

$(document).ready(function(){
  function baseDir(){
    var url = document.location.pathname.split('/')[1];
    if (url == "pepdb"){
      return '/'+url;
    }else{
      return '';
    }
  };

  var url = baseDir();
  var formAll = ["#all_lib", "#all_sel", "#all_ds", "#c_all_lib", "#r_all_lib", "#all_motl"];
  var propSelect = ['#l', '#s', '#ds', '#c', '#ts', '#tt', '#tc', '#ss', '#st', '#sc'];
  var propInput = ['#seq', '#blos', '#pl', '#sr', '#ralt', '#ragt', '#relt', '#regt', '#dlt', '#dgt'];
  var species = ['#ss', '#ts'];
  var tissue = ['#st', '#tt'];
  var cell = ['#sc', '#tc'];

  $('.optbut').button();
  $('#navigation').menu();

  $('#clear-button').click(function(){
    $('body').load(window.location.pathname);
  });

  $.each(formAll, function(index, value){
    $(value).click(function(){
      var marked = this.checked;
      $(this).closest('fieldset').find(':checkbox').each(function(){
        $(this).prop('checked', marked);
      });
    });
  });

  $('#comp-library input:checkbox').click(function(){
    var checkedLibs = [];
    $(this).closest('fieldset').find(':checkbox').each(function(){
      var elemVal = $(this).attr('value');
      if(this.checked && elemVal != "all_lib"){
        checkedLibs.push(elemVal);
      }
    });
    $('#comp-selection').load(url+'/checklist',{checkedElem: checkedLibs, allElem: 'c_all_sel', allElemVal: 'all_sel', selector: 'sel', sec: 'c_', elemName: 'sels[]' }, function(){
        $.getScript(url+"/script/checkbox.js");
      } );
  });

  $('#ref-library input:checkbox').click(function(){
    var checkedLibs = [];
    $(this).closest('fieldset').find(':checkbox').each(function(){
      var elemVal = $(this).attr('value');
      if(this.checked && elemVal != "all_lib"){
        checkedLibs.push(elemVal);
      }
    });
    $('#ref-selection').load(url+'/checklist',{checkedElem: checkedLibs, allElem: 'r_all_sel', allElemVal: 'all_sel', selector: 'sel', sec: 'r_', elemName: 'sels[]' }, function(){
        $.getScript(url+"/script/checkbox.js");
      } );
  });

  $('#motif-list input:checkbox').click(function(){
    if($('#motifs').is(':visible')){
      $('#motifs').toggle();
    }
    var checkedLists = [];
    $(this).closest('fieldset').find(':checkbox').each(function(){
      var elemVal = $(this).attr('value');
      if(this.checked && elemVal != "all_motl"){
        checkedLists.push(elemVal);
      }
    });
    $.get('mot-checklist', {checkedElem: checkedLists},function(data){
      $('#motifs').html(data);
      $.getScript(url+"/script/initshowtable.js", function(){
        $('#motifs').toggle();
      });

    });
  });

   $('#compdata').submit(function(){
    if($('#comppepresults').is(':visible')){
      $('#comppepresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    $('#compinfos').html("");
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#comppepresults').html(response);
        $.getScript(url+'/script/initshowtable.js', function(){
          $('#comppepresults').toggle();
          $('.loading').toggle();
        });
      }
    });
    return false;
  });

   $('#motsearch').submit(function(){
    if($('#motresults').is(':visible')){
      $('#motresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#motresults').html(response);
        $.getScript(url+'/script/accinit.js', function(){
          $('#motresults').toggle();
          $('.loading').toggle();
        });
      }
    });
    return false;
  });

  $('#cl-search').submit(function(){
    if($('#results').is(':visible')){
      $('#results').toggle();
    }
    if($('#clsearch').is(':visible')){
      $('#clsearch').toggle();
    }
    $('#results').html("");
    $('#clsearchpeps').html("");
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#results').html(response);
        $.getScript(url+'/script/tableinit.js', function(){
          $('#results').toggle();
        });
      }
    });
    return false;
  });

    $('#datatype').change(function(){
      var selected = $(this).children("option:selected").text();
      if(selected == "sequencing dataset"){
        selected = "dataset";
      }
      if(selected == "motif list"){
        selected = "motif";
      }
      $("#dataform").load(url+'/add'+ selected, function(){
        var boxNames = ['#dlibname', '#dselname', '#ddsname', '#dspecies'];

        $.each(boxNames, function(index, value){
          $(value).prop('selectedIndex', -1);
        });

        $('#dspecies').change(function(){
          var valSel = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "tissue", selected1: valSel, table:"targets", where1:"species", boxID:"dtissue"}, function(data){
            $('#dtissue').html(data);
            $('#dtissue').prop('selectedIndex', -1);
            $('#dcell').html('');
          });
        });
        $('#dtissue').change(function(){
          var valSel1 = $('#dspecies').children("option:selected").text();
          var valSel2 = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "cell", selected1: valSel1, selected2: valSel2,table:"targets", where2:"tissue", where1:"species",boxID:"dcell"}, function(data){
            $('#dcell').html(data);
          });
        });
        $('#dlibname').change(function(){
          var valSel = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "selection_name", selected1: valSel, table:"selections", where1:"library_name", boxID:"dselname"}, function(data){
            $('#dselname').html(data);
            $('#dselname').prop('selectedIndex', -1);
            $('#ddsname').prop('selectedIndex', -1);
          });
        });
        $('#dselname').change(function(){
          var valSel1 = $('#dlibname').children("option:selected").text();
          var valSel2 = $(this).children("option:selected").text();
          $.get(url+'/formdrop', {columnname: "dataset_name", selected1: valSel1, selected2: valSel2, table:"sequencing_datasets", where1:"library_name", where2:"selection_name",boxID:"dselname"}, function(data){
            $('#ddsname').html(data);
            $('#ddsname').prop('selectedIndex', -1);
          });
        });
      });
    });

    $.each(propSelect, function(index, value){
      var paramName = $(value).attr('name');
      if(urlParam(paramName) == ""){
        $(value).prop('selectedIndex', -1);
      }
      $(value).on('beforeunload', function(){
        if ($(this).attr('selectedIndex') == -1){
          $(this).prop('name', '');
        }
        });
      });

    $('#edittype').change(function(){
      var selected = $(this).children("option:selected").val();
      $.get(url+'/editdrop', {table:selected}, function(data){
        $('#elementselection').html(data);
        $.getScript(url+'/script/dropbox.js');
      });
    });

   $('#propsearch').submit(function(){
    if($('#propresults').is(':visible')){
      $('#propresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#propresults').html(response);
        $.getScript(url+'/script/initshowtable.js', function(){
          $('#propresults').toggle();
          $('.loading').toggle();
        });
      }
    });
    return false;
  });
    $.each(species, function(index, value){
      $(value).change(function(){
        var valSel = $(this).children("option:selected").text();
        $.get(url+'/formdrop', {columnname: "tissue", selected1: valSel, table:"targets", where1:"species", boxID:tissue[index].substring(1)}, function(data){
          $(tissue[index]).html(data);
          $(tissue[index]).prop('selectedIndex', -1);
          $(cell[index]).html('');
        });
      });
    });

    $.each(tissue, function(index, value){
      $(value).change(function(){
        var valSel1 = $(species[index]).children("option:selected").text();
        var valSel2 = $(this).children("option:selected").text();
        $.get(url+'/formdrop', {columnname: "cell", selected1: valSel1, selected2: valSel2,table:"targets", where2:"tissue", where1:"species",boxID:cell[index].substring(1)}, function(data){
          $(cell[index]).html(data);
        });
      });

    });

    $('#l').change(function(){
      var valSel = $(this).children("option:selected").text();
      $.get(url+'/formdrop', {columnname: "selection_name", selected1: valSel, table:"selections", where1:"library_name", boxID:"s"}, function(data){
        $('#s').html(data);
        $('#s').prop('selectedIndex', -1);
        $('#ds').html('');
      });
    });
    $('#s').change(function(){
      var valSel1 = $('#l').children("option:selected").text();
      var valSel2 = $(this).children("option:selected").text();
      $.get(url+'/formdrop', {columnname: "dataset_name", selected1: valSel1, selected2: valSel2,table:"sequencing_datasets", where2:"selection_name", where1:"library_name",boxID:"ds"}, function(data){
        $('#ds').html(data);
      });
    });

   $('#compclform').submit(function(){
    if($('#compclresults').is(':visible')){
      $('#compclresults').toggle();
    }
    if($('.loading').is(':hidden')){
      $('.loading').toggle();
    }
    var radioType = $("#comp-buttons input[type='radio']:checked").val();
    $.ajax({
      data: $(this).serialize(),
      type: $(this).attr('method'),
      url: $(this).attr('action'),
      success: function(response){
        $('#compclresults').html(response);
        if (radioType == "threshold"){
          $.getScript(url+'/script/initshowtable.js', function(){
            $('#compclresults').toggle();
            $('.loading').toggle();
          });

        } else {
          $.getScript(url+'/script/accinit.js', function(){
            $('#compclresults').toggle();
            $('.loading').toggle();
          });
        }
      }
    });
    return false;
  });

    $('#type').change(function(){
      if ($(this).val() == "complete sequence"){
        $('#blossum').show();
        $('#wchelp').hide();
      } else if ($(this).val() == "wildcard sequence"){
        $('#blossum').hide();
        $('#wchelp').show();
      } else {
        $('#blossum').hide();
        $('#wchelp').hide();

      }
    });
    $('#wcicon').tooltip({
      content: function(callback){
        callback($(this).prop('title').replace(/\|/g, '<br />'));
      }
    });

    $('.editlink').click(function(e){
      e.preventDefault();
      var link = $(this).attr('href');
      $.get(link, function(response){
        $('#editusers').html(response);
      });
    })

    /* -----------jsTree configuration------------------- */
    $('#clusterlist').bind("loaded.jstree", function(){
     var opennode = document.location.pathname.split("/").pop();
     $('#' + opennode).parents(".jstree-closed").each(function(){
        $('#clusterlist').jstree("open_node", this, false, true);
      });
    });

    $('#clusterlist').bind('before.jstree', function(event,data){
      switch(data.plugin){
        case 'ui':
          if(!data.inst.is_leaf(data.args[0])){
            return false;
          }
          break;
        default:
          break;
      }
    })
      .jstree( {"themeroller": {"item_leaf": false,
                                "item_clsd": false,
                                "item_open":false  },
                "plugins" : ["html_data",  "themeroller"],})
      .delegate("a", "click", function(event, data){
        if($('#clusterlist_sel').is(':visible')){
          $('#clusterlist_sel').toggle();
        }
        if($('#clusterlist_pep').is(':visible')){
          $('#clusterlist_pep').html("");
        }
        var cluster = $(this).attr('href').split('/')[2];
        $.get(url+'/cluster-infos',{selCl:cluster}, function(data){
          $('#clusterlist_sel').html(data);
          $.getScript(url+'/script/initshowtable.js', function(){
            $('#clusterlist_sel').toggle();
          });
        });
        return false;
     } );

    $('#disp-res').bind("loaded.jstree", function(){
     var opennode = document.location.pathname.split("/").pop();
     $('#' + opennode).parents(".jstree-closed").each(function(){
        $('#disp-res').jstree("open_node", this, false, true);
      });
    });

    $('#disp-res').bind('before.jstree', function(event,data){
      switch(data.plugin){
        case 'ui':
          if(!data.inst.is_leaf(data.args[0])){
            return false;
          }
          break;
        default:
          break;
      }
    })
      .jstree( {"plugins" : ["html_data", "ui", "themeroller"],
                "item_leaf": false, })
      .delegate("a", "click", function(event, data){
     } );

});
<|endoftext|>


<commit_before>/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';

const store = require('./app/store');
const React = require('react-native');
const {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} = React;
const { Provider } = require('react-redux');

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

const LedManager = React.createClass({
  render() {
    return (
      <Provider store={store}>
        <View style={styles.container}>
          <Text style={styles.welcome}>
            Welcome to React Native!
          </Text>
          <Text style={styles.instructions}>
            To get started, edit index.ios.js
          </Text>
          <Text style={styles.instructions}>
            Press Cmd+R to reload,{'\n'}
            Cmd+D or shake for dev menu
          </Text>
        </View>
      </Provider>
    );
  },
});

AppRegistry.registerComponent('LedManager', () => LedManager);
<commit_msg>Copy android index over to ios<commit_after>/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
import store from './app/store';
import React from 'react-native';
const {
  AppRegistry,
  StyleSheet,
  Navigator,
  Text,
  TouchableOpacity,
  Image,
  } = React;
import { Provider } from 'react-redux';
import routes from './app/constants/routes';

import backImage from './app/img/back.png';

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#F5FCFF',
  },
  navBar: {
    marginTop: 5,
  },
  navText: {
    marginTop: 2,
    fontSize: 30,
  },
});

const LedManager = React.createClass({
  render() {
    const routeMapper = {
      LeftButton: (route, navigator, index) => {
        if (index === 0) return;
        return (
          <TouchableOpacity onPress={navigator.pop}>
            <Image source={backImage} width={48} height={42} />
          </TouchableOpacity>
        );
      },
      RightButton: (route, navigator, index, navState) => route.rightElement && route.rightElement(route, navigator, index, navState),
      Title: (route) => {
        return <Text style={styles.navText}>{route.name}</Text>;
      },
    };

    // modify top position for navigator container so it doesn't overlap the navbar
    const navStyles = {
      top: Navigator.NavigationBar.Styles.General.TotalNavHeight,
    };

    return (
      <Provider store={store}>
        <Navigator sceneStyle={[styles.container, navStyles]}
                   initialRoute={routes.root()}
                   renderScene={(route, navigator) => <route.component route={route} navigator={navigator} />}
                   navigationBar={<Navigator.NavigationBar style={styles.navBar} routeMapper={routeMapper} />}
        />
      </Provider>
    );
  },
});

AppRegistry.registerComponent('LedManager', () => LedManager);
<|endoftext|>


<commit_before>// FOUNDATION FOR APPS TEMPLATE GULPFILE
// -------------------------------------
// This file processes all of the assets in the "client" folder, combines them with the Foundation
// for Apps assets, and outputs the finished files in the "build" folder as a finished app.

// 1. LIBRARIES
// - - - - - - - - - - - - - - -

var gulp           = require('gulp'),
    rimraf         = require('rimraf'),
    runSequence    = require('run-sequence'),
    autoprefixer   = require('gulp-autoprefixer'),
    sass           = require('gulp-ruby-sass'),
    uglify         = require('gulp-uglify'),
    concat         = require('gulp-concat'),
    connect        = require('gulp-connect'),
    path           = require('path'),
    coffeescript   = require('coffee-script/register'),
    coffee         = require('gulp-coffee'),
    mochaPhantomJS = require('gulp-mocha-phantomjs');

// 2. SETTINGS VARIABLES
// - - - - - - - - - - - - - - -

// Sass will check these folders for files when you use @import.
var sassPaths = [
  'client/assets/scss',
  'bower_components/foundation-apps/scss',
  'bower_components/font-awesome/scss'
];
// These files include Foundation for Apps and its dependencies
var vendorJS = [
  'bower_components/fastclick/lib/fastclick.js',
  'bower_components/viewport-units-buggyfill/viewport-units-buggyfill.js',
  'bower_components/tether/tether.js',
  'bower_components/lodash/dist/lodash.min.js',
];

var appCoffee = [
  'client/assets/coffee/app.coffee',
  'client/assets/coffee/**/*.coffee'
];

var specCoffee = [
  'spec/spec.coffee',
  'spec/**/*.coffee'
];

// 3. TASKS
// - - - - - - - - - - - - - - -

// Cleans the build directory
gulp.task('clean', function(cb) {
  rimraf('./build', cb);
});

// Copies user-created files and Foundation assets
gulp.task('copy', function() {
  var dirs = [
    './client/**/*.*',
    '!./client/assets/{scss,coffee}/**/*.*'
  ];

  // Everything in the client folder except templates, Sass, and JS
  gulp.src(dirs, {
    base: './client/'
  })
    .pipe(gulp.dest('./build'))
    .pipe(connect.reload());
});

// Compiles Sass
gulp.task('sass', function() {
  return gulp.src('client/assets/scss/app.scss')
    .pipe(sass({
      loadPath: sassPaths,
      style: 'nested',
      bundleExec: true,
      'sourcemap=none': true
    }))
    .on('error', function(e) {
      console.log(e);
    })
    .pipe(autoprefixer({
      browsers: ['last 2 versions', 'ie 10']
    }))
    .pipe(gulp.dest('./build/assets/css/'))
    .pipe(connect.reload());
});

gulp.task('icons', function() {
  return gulp.src('bower_components/font-awesome/fonts/**.*')
    .pipe(gulp.dest('./build/assets/fonts/'));
});

// Compiles and copies the Foundation for Apps JavaScript, as well as your app's custom JS
gulp.task('uglify', function() {
  // Vendor JavaScript
  gulp.src(vendorJS)
    .pipe(uglify({
      beautify: true,
      mangle: false
    }).on('error', function(e) {
      console.log(e);
    }))
    .pipe(concat('vendor.js'))
    .pipe(gulp.dest('./build/assets/js/'))
  ;

  // App JavaScript
  return gulp.src(appCoffee)
    .pipe(coffee({bare: true}))
    .on('error', console.log)
    .pipe(uglify({
      beautify: true,
      mangle: false
    }).on('error', function(e) {
      console.log(e);
    }))
    .pipe(concat('app.js'))
    .pipe(gulp.dest('./build/assets/js/'))
    .pipe(connect.reload())
  ;
});

gulp.task('test:build', function() {
  return gulp.src(specCoffee)
    .pipe(coffee({bare: true}))
    .on('error', console.log)
    .pipe(concat('spec.js'))
    .pipe(gulp.dest('./build/spec/'));
});

gulp.task('test', ['test:build'], function() {
  return gulp.src('./spec/runner.html')
    .pipe(mochaPhantomJS());
});

// Starts a test server, which you can view at http://localhost:8080
gulp.task('server:start', function() {
  connect.server({
    root:       './build',
    livereload: true
  });
});

// Builds your entire app once, without starting a server
gulp.task('build', function() {
  runSequence('clean', ['copy', 'sass', 'icons', 'uglify'], function() {
    console.log("Successfully built.");
  })
});

// Default task: builds your app, starts a server, and recompiles assets when they change
gulp.task('default', ['build', 'server:start'], function() {
  // Watch Sass
  gulp.watch(['./client/assets/scss/**/*', './scss/**/*'], ['sass']);

  // Watch CoffeeScript
  gulp.watch(['./client/assets/coffee/**/*', './coffee/**/*'], ['uglify', 'test']);
  gulp.watch(specCoffee, ['test']);

  // Watch static files
  gulp.watch(['./client/**/*.*', '!./client/templates/**/*.*', '!./client/assets/{scss,js}/**/*.*'], ['copy']);
});
<commit_msg>dont uglify js in dev mode<commit_after>// FOUNDATION FOR APPS TEMPLATE GULPFILE
// -------------------------------------
// This file processes all of the assets in the "client" folder, combines them with the Foundation
// for Apps assets, and outputs the finished files in the "build" folder as a finished app.

// 1. LIBRARIES
// - - - - - - - - - - - - - - -

var gulp           = require('gulp'),
    rimraf         = require('rimraf'),
    runSequence    = require('run-sequence'),
    autoprefixer   = require('gulp-autoprefixer'),
    sass           = require('gulp-ruby-sass'),
    uglify         = require('gulp-uglify'),
    concat         = require('gulp-concat'),
    connect        = require('gulp-connect'),
    path           = require('path'),
    coffeescript   = require('coffee-script/register'),
    coffee         = require('gulp-coffee'),
    mochaPhantomJS = require('gulp-mocha-phantomjs');

// 2. SETTINGS VARIABLES
// - - - - - - - - - - - - - - -

var prodMode = false;

// Sass will check these folders for files when you use @import.
var sassPaths = [
  'client/assets/scss',
  'bower_components/foundation-apps/scss',
  'bower_components/font-awesome/scss'
];
// These files include Foundation for Apps and its dependencies
var vendorJS = [
  'bower_components/fastclick/lib/fastclick.js',
  'bower_components/viewport-units-buggyfill/viewport-units-buggyfill.js',
  'bower_components/tether/tether.js',
  'bower_components/lodash/dist/lodash.min.js',
];

var appCoffee = [
  'client/assets/coffee/app.coffee',
  'client/assets/coffee/**/*.coffee'
];

var specCoffee = [
  'spec/spec.coffee',
  'spec/**/*.coffee'
];

// 3. TASKS
// - - - - - - - - - - - - - - -

// Cleans the build directory
gulp.task('clean', function(cb) {
  rimraf('./build', cb);
});

// Copies user-created files and Foundation assets
gulp.task('copy', function() {
  var dirs = [
    './client/**/*.*',
    '!./client/assets/{scss,coffee}/**/*.*'
  ];

  // Everything in the client folder except templates, Sass, and JS
  gulp.src(dirs, {
    base: './client/'
  })
    .pipe(gulp.dest('./build'))
    .pipe(connect.reload());
});

// Compiles Sass
gulp.task('sass', function() {
  return gulp.src('client/assets/scss/app.scss')
    .pipe(sass({
      loadPath: sassPaths,
      style: 'nested',
      bundleExec: true,
      'sourcemap=none': true
    }))
    .on('error', function(e) {
      console.log(e);
    })
    .pipe(autoprefixer({
      browsers: ['last 2 versions', 'ie 10']
    }))
    .pipe(gulp.dest('./build/assets/css/'))
    .pipe(connect.reload());
});

gulp.task('icons', function() {
  return gulp.src('bower_components/font-awesome/fonts/**.*')
    .pipe(gulp.dest('./build/assets/fonts/'));
});

// Compiles and copies the Foundation for Apps JavaScript, as well as your app's custom JS
gulp.task('uglify', function() {
  // Vendor JavaScript
  gulp.src(vendorJS)
    .pipe(uglify({
      beautify: true,
      mangle: false
    }).on('error', function(e) {
      console.log(e);
    }))
    .pipe(concat('vendor.js'))
    .pipe(gulp.dest('./build/assets/js/'))
  ;

  // App JavaScript
  var coffeeBuild = gulp.src(appCoffee)
    .pipe(coffee({bare: true}))
    .on('error', console.log)
  if (prodMode) {
    coffeeBuild.pipe(uglify({
      mangle: false
    }).on('error', function(e) {
      console.log(e);
    }))
  }
  return coffeeBuild
    .pipe(concat('app.js'))
    .pipe(gulp.dest('./build/assets/js/'))
    .pipe(connect.reload())
  ;
});

gulp.task('test:build', function() {
  return gulp.src(specCoffee)
    .pipe(coffee({bare: true}))
    .on('error', console.log)
    .pipe(concat('spec.js'))
    .pipe(gulp.dest('./build/spec/'));
});

gulp.task('test', ['test:build'], function() {
  return gulp.src('./spec/runner.html')
    .pipe(mochaPhantomJS());
});

// Starts a test server, which you can view at http://localhost:8080
gulp.task('server:start', function() {
  connect.server({
    root:       './build',
    livereload: true
  });
});

// Builds your entire app once, without starting a server
gulp.task('build', function() {
  runSequence('clean', ['copy', 'sass', 'icons', 'uglify'], function() {
    console.log("Successfully built.");
  })
});

// Default task: builds your app, starts a server, and recompiles assets when they change
gulp.task('default', ['build', 'server:start'], function() {
  // Watch Sass
  gulp.watch(['./client/assets/scss/**/*', './scss/**/*'], ['sass']);

  // Watch CoffeeScript
  gulp.watch(['./client/assets/coffee/**/*', './coffee/**/*'], ['uglify', 'test']);
  gulp.watch(specCoffee, ['test']);

  // Watch static files
  gulp.watch(['./client/**/*.*', '!./client/templates/**/*.*', '!./client/assets/{scss,js}/**/*.*'], ['copy']);
});
<|endoftext|>