Widget / JSCut

Receive Gcode files from JSCut.

HTML

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://www.chilipeppr.com/js/require.js"></script>
<div id="org-jscut-gcode-widget" class="panel panel-default">
    <div class="panel-heading">

        <span class="panel-title" data-toggle="popover">JSCut</span>

        <div class="btn-group pull-right" style="margin-right:0;">
            <div class="dropdown">
                <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
                <ul class="dropdown-menu dropdown-menu-main xdropdown-menu-right" role="menu">
                    <li role="presentation" class="dropdown-header recent-files">Recent JScut Files</li>
                    <!-- <li><a href="javascript:" class="recent-file-delete"><span class="glyphicon glyphicon-trash"></span> Clear Macros</a></li> -->
                    
                </ul>
            </div>
        </div>
        
        <div class="btn-group pull-right" style="margin-right:6px;">
            <button type="button" class="btn btn-xs btn-default jscut-refresh" data-container="body" data-toggle="popover" data-placement="auto" data-content="Refresh file list by querying ChiliPeppr for any JSCut files that have been placed in ChiliPeppr's cloud storage for your login ID" data-trigger="hover" data-delay="800"><span class="glyphicon glyphicon-refresh"></span></button>
        </div>

        <div class="btn-group pull-right" style="margin-right:6px;">
            <a href="http://jscut.org/jscut.html" target="_blank" class="btn btn-xs btn-default jscut-nav" data-container="body" data-toggle="popover" data-placement="auto" data-content="Visit JSCut's website" data-trigger="hover" data-delay="800"><span class="glyphicon glyphicon-link"></span> JSCut</a>
        </div>

            
    </div>
    <div id="org-jscut-gcode-widget-body" class="panel-body">
 
        <div class="alert...

CSS

.lastModifyDate {
    color: silver;
}
#org-jscut-gcode-widget-body {
    max-height:100px;
    overflow:auto;
}

JavaScript

// Test this element. This code is auto-removed by the chilipeppr.load()
cprequire_test(["inline:org-jscut-gcode-widget"], function (macro) {
    console.log("test running of " + macro.id);
    macro.init();
        
} /*end_test*/ );


cpdefine("inline:org-jscut-gcode-widget", ["chilipeppr_ready"], function () {
    
    return {
        id: "org-jscut-gcode-widget",
        url: "http://fiddle.jshell.net/chilipeppr/7ZzSV/show/light/",
        fiddleurl: "http://jsfiddle.net/chilipeppr/7ZzSV/",
        name: "Widget / JSCut",
        desc: "Receive Gcode files from JSCut.",
        publish: {
        },
        subscribe: {},
        foreignPublish: {
        },
        foreignSubscribe: {
        },
        init: function () {

            this.forkSetup();
                        
            // setup del files
            $('#org-jscut-gcode-widget .recent-file-delete').click( this.deleteRecentFiles.bind(this));

            this.buildRecentFileMenu();
                        
            // popovers
            $('#org-jscut-gcode-widget .panel-heading .btn').popover();
            
            this.getFilesFromChiliPepprStorage();
            //jscut-refresh
            $('#org-jscut-gcode-widget .jscut-refresh').click( this.getFilesFromChiliPepprStorage.bind(this));
            
            this.checkIfUrlParamToAutoLoad();
            
            console.log(this.name + " done loading.");
        },
        getUrlParameterByName: function(name) {
            var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
            return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
        },
        checkIfUrlParamToAutoLoad: function() {
            var loadJscut = this.getUrlParameterByName('loadJscut');
            console.log("checkIfUrlParamToAutoLoad. loadJscut:", loadJscut);
            
            // see if they gave us the key or just a true
            if (loadJscut != null && (loadJscut == true || loadJscut ==...