<commit_before>// var $ = require('jquery');
// window.$ = $

window.jQuery = $ = require('jquery');
require('bootstrap/dist/js/bootstrap');
require('./js/jquery.easing.min');
require('./js/avatarSection');
var SnackBar = require('node-snackbar/dist/snackbar');

// WOW cloned from 'amd' branch of wowjs
require('./node_modules/wowjs/dist/wow.js');

$(document).ready(function(){
    $('a.page-scroll').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: ($($anchor.attr('href')).offset().top - 50)
        }, 1250, 'easeInOutExpo');
        event.preventDefault();
    });

    $('body').scrollspy({
        target: '.navbar-fixed-top',
        offset: 51
    });

    $('.navbar-collapse ul li a').click(function() {
        $('.navbar-toggle:visible').click();
    });

    $('#mainNav').affix({
        offset: {
            top: 100
        }
    });

    new WOW().init();

    $('.contact-form').on('submit', function(event){
        event.preventDefault();
        $.ajax({
            url: "/contact_email",
            type: "POST",
            data: {
                contact_name: $('.contact-name').val(),
                contact_email: $('.contact-email').val(),
                contact_message: $('.contact-message').val()
            }
        }).done(function (data, textStatus, jqXHR){
            console.log("success! : " + textStatus + ' ' + data.message);

            // WRITE SUCCESSFUL EMAIL LOGIC
            document.getElementById("contact-form").reset();

            SnackBar.show({
                text: data.message,
                textColor: "#f05f40",
                pos: "bottom-right",
                actionText: "Thanks!",
                actionTextColor: "#f05f40",
                backgroundColor: "#333",
                duration: 1100
             });

            console.log("Success finished!");

        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log(`Failed! At : ${textStatus}, ${errorThrown}, ${jqXHR}`);

            SnackBar.show({
                text: `${textStatus.toUpperCase()}! ${errorThrown}! Please try again later!`,
                textColor: "#f05f40",
                pos: "bottom-right",
                actionText: "Thanks!",
                actionTextColor: "#f05f40",
                backgroundColor: "#333",
                duration: 1500
             });
        });
    });

    $('.social-hide-a').bind('click', function(event){
        // $('.roro').css({'transform': 'rotate(180deg)'});
        $('ul.social-icons').toggle({
            duration: 800,
            easing: 'easeInOutExpo',
            complete: function(){
                if($('.roro').css('transform') == 'none'){
                    $('.roro').css({'transform': 'rotate(180deg)'});
                } else {
                    $('.roro').css({'transform': ''});
                }
            }
        });
        event.preventDefault();
    });

});

// {
//     animation: true,
//     container: '.contact-submit',
//     content: data.message,
//     delay: { "show": 800, "hide": 200 },
//     html: false,
//     placement: 'right',
//     title: 'Thank you!'
// }
<commit_msg>update app-client social-hide-a<commit_after>// var $ = require('jquery');
// window.$ = $

window.jQuery = $ = require('jquery');
require('bootstrap/dist/js/bootstrap');
require('./js/jquery.easing.min');
require('./js/avatarSection');
var SnackBar = require('node-snackbar/dist/snackbar');

// WOW cloned from 'amd' branch of wowjs
require('./node_modules/wowjs/dist/wow.js');

$(document).ready(function(){
    $('a.page-scroll').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: ($($anchor.attr('href')).offset().top - 50)
        }, 1250, 'easeInOutExpo');
        event.preventDefault();
    });

    $('body').scrollspy({
        target: '.navbar-fixed-top',
        offset: 51
    });

    $('.navbar-collapse ul li a').click(function() {
        $('.navbar-toggle:visible').click();
    });

    $('#mainNav').affix({
        offset: {
            top: 100
        }
    });

    new WOW().init();

    $('.contact-form').on('submit', function(event){
        event.preventDefault();
        $.ajax({
            url: "/contact_email",
            type: "POST",
            data: {
                contact_name: $('.contact-name').val(),
                contact_email: $('.contact-email').val(),
                contact_message: $('.contact-message').val()
            }
        }).done(function (data, textStatus, jqXHR){
            console.log("success! : " + textStatus + ' ' + data.message);

            // WRITE SUCCESSFUL EMAIL LOGIC
            document.getElementById("contact-form").reset();

            SnackBar.show({
                text: data.message,
                textColor: "#f05f40",
                pos: "bottom-right",
                actionText: "Thanks!",
                actionTextColor: "#f05f40",
                backgroundColor: "#333",
                duration: 1100
             });

            console.log("Success finished!");

        }).fail(function (jqXHR, textStatus, errorThrown) {
            console.log(`Failed! At : ${textStatus}, ${errorThrown}, ${jqXHR}`);

            SnackBar.show({
                text: `${textStatus.toUpperCase()}! ${errorThrown}! Please try again later!`,
                textColor: "#f05f40",
                pos: "bottom-right",
                actionText: "Thanks!",
                actionTextColor: "#f05f40",
                backgroundColor: "#333",
                duration: 1500
             });
        });
    });

    $('.social-hide-a > i').bind('click', function(event){
        // $('.roro').css({'transform': 'rotate(180deg)'});
        $('ul.social-icons').toggle({
            duration: 800,
            easing: 'easeInOutExpo',
            complete: function(){
                if($('.roro').css('transform') == 'none'){
                    $('.roro').css({'transform': 'rotate(180deg)'});
                } else {
                    $('.roro').css({'transform': ''});
                }
            }
        });
        event.preventDefault();
    });

});

// {
//     animation: true,
//     container: '.contact-submit',
//     content: data.message,
//     delay: { "show": 800, "hide": 200 },
//     html: false,
//     placement: 'right',
//     title: 'Thank you!'
// }
<|endoftext|>


<commit_before>var graphite = "http://graphite.mrfjo.org/render/";

var loaded = 0;

$(function() {
    if (loaded === 0) {
        metrics = [ {
            name: "Balkong",
            metricPath: "mrfjo.hjemme.temp.telldus.Balkong",
            type: "temperature",
            suffix: "°C",
            scale: "",
            dashboard: true,
            single: false
        }, {
            name: "Soverom",
            metricPath: "mrfjo.hjemme.temp.telldus.Soverom",
            type: "temperature",
            suffix: "°C",
            dashboard: true,
            scale: "",
            single: ""
        }, {
            name: "Office desk",
            metricPath: "mrfjo.hjemme.temp.28-000002dcb9bc",
            type: "temperature",
            dashboard: false,
            suffix: "°C",
            scale: "0.001",
            single: ""
        }, {
            name: "Outside wall",
            metricPath: "mrfjo.hjemme.temp.28-0000044ddd1d",
            type: "temperature",
            dashboard: false,
            suffix: "°C",
            scale: "0.001",
            single: ""
        }, {
            name: "Barometer",
            metricPath: "mrfjo.hjemme.pressure.bmp085_pressure",
            type: "pressure",
            dashboard: true,
            suffix: "",
            scale: "Pa",
            single: true
        }, {
            name: "Light",
            metricPath: "mrfjo.hjemme.light.tsl2561_lux",
            type: "light",
            dashboard: false,
            suffix: "lx",
            scale: "",
            single: true
        }, {
            name: "Humidity",
            metricPath: "mrfjo.hjemme.humidity.dht11_humidity",
            type: "humidity",
            dashboard: false,
            suffix: "%",
            scale: "",
            single: true
        } ];
        loaded = 1;
    }
});
<commit_msg>Clean up loading of metrics object<commit_after>var graphite = "http://graphite.mrfjo.org/render/";

var metrics = metrics || [ {
    name: "Balkong",
    metricPath: "mrfjo.hjemme.temp.telldus.Balkong",
    type: "temperature",
    suffix: "°C",
    scale: "",
    dashboard: true,
    single: false
}, {
    name: "Soverom",
    metricPath: "mrfjo.hjemme.temp.telldus.Soverom",
    type: "temperature",
    suffix: "°C",
    dashboard: true,
    scale: "",
    single: ""
}, {
    name: "Office desk",
    metricPath: "mrfjo.hjemme.temp.28-000002dcb9bc",
    type: "temperature",
    dashboard: false,
    suffix: "°C",
    scale: "0.001",
    single: ""
}, {
    name: "Outside wall",
    metricPath: "mrfjo.hjemme.temp.28-0000044ddd1d",
    type: "temperature",
    dashboard: false,
    suffix: "°C",
    scale: "0.001",
    single: ""
}, {
    name: "Barometer",
    metricPath: "mrfjo.hjemme.pressure.bmp085_pressure",
    type: "pressure",
    dashboard: true,
    suffix: "",
    scale: "Pa",
    single: true
}, {
    name: "Light",
    metricPath: "mrfjo.hjemme.light.tsl2561_lux",
    type: "light",
    dashboard: false,
    suffix: "lx",
    scale: "",
    single: true
}, {
    name: "Humidity",
    metricPath: "mrfjo.hjemme.humidity.dht11_humidity",
    type: "humidity",
    dashboard: false,
    suffix: "%",
    scale: "",
    single: true
} ];
<|endoftext|>


<commit_before>/*
Copyright 2020 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// app.yaml standard reference: https://cloud.google.com/appengine/docs/standard/nodejs/config/appref
// app.yaml flex reference: https://cloud.google.com/appengine/docs/flexible/nodejs/reference/app-yaml
// service.yaml reference: https://github.com/knative/docs/blob/master/docs/serving/spec/knative-api-specification-1.0.md

/**
 * @param {Object} gaeService - Information about the App Engine service, should at minimum contain {"app.yaml" : {}}
 */
function appToRun(gaeService) {
  let runService = {
    'service.yaml': {
      'apiVersion': 'serving.knative.dev/v1',
      'kind': 'Service',
      'metadata': {
        'name' : 'default'
      },
      'spec': {
        'template': {
          'metadata': {
            'annotations': {
              'migrated-from': 'app-engine'
            }
          },
          'spec': {
            'containers': [
              {
                'image': 'gcr.io/YOUR-PROJECT/image'
              }
            ]
          }
        }
      }
    }
  };

  const extractFunctions = [
    extractRegion,
    extractName,
    extractImageURL,
    extractEnvVars,
    extractProjectIDEnvVar,
    extractMaxInstances,
    extractMinInstances,
    extractConcurrency,
    extractMemory,
    extractCPU,
    extractMigrateToSecondGen,
    extractVPCAccess,
    extractCloudSQL,
    extractBuild,
    extractStatic,
  ]

  for (const extractFunction of extractFunctions) {
    extractFunction(gaeService, runService);
  }

  return runService;
}

const firstGenRuntimes = ['go111', 'python', 'python27', 'php55'];

const firstGenMigrationGuides = {
'go111': 'https://cloud.google.com/appengine/docs/standard/go/go-differences',
'python27': 'https://cloud.google.com/appengine/docs/standard/python/',
'python': 'https://cloud.google.com/appengine/docs/standard/python/',
'php55': 'https://cloud.google.com/appengine/docs/standard/php7/php-differences',
// (Java does not use an app.yaml): 'https://cloud.google.com/appengine/docs/standard/java11/java-differences',
}

function gaeRegionToGCPRegion(region) {
  if(region === 'us-central') { return 'us-central1'; }
  if(region === 'europe-west') { return 'europe-west1'; }
  return region;
}

function extractRegion(gae, run) {
  run['region'] = gaeRegionToGCPRegion(gae['region']) || 'us-central1';

  if(!run['service.yaml']['metadata']['labels']) {
    run['service.yaml']['metadata']['labels'] = {};
  }

  run['service.yaml']['metadata']['labels']['cloud.googleapis.com/location'] = run['region'];
}

function extractName(gae, run) {
  if(gae['app.yaml']['service']) {
    run['service.yaml']['metadata']['name'] = gae['app.yaml']['service'];
   }
}

function extractEnvVars(gae, run) {
  if(gae['app.yaml']['env_variables']) {
    const container = run['service.yaml']['spec']['template']['spec']['containers'][0];
    container['env'] = container['env'] || [];
    for (const key of Object.keys(gae['app.yaml']['env_variables'])) {
      container['env'].push({
        'name': key,
        'value': gae['app.yaml']['env_variables'][key]
      })
    }
   }
}

function extractProjectIDEnvVar(gae, run) {
  if(gae['project-id']) {
    const container = run['service.yaml']['spec']['template']['spec']['containers'][0];
    container['env'] = container['env'] || [];
    container['env'].push({
      'name': 'GOOGLE_CLOUD_PROJECT',
      'value': gae['project-id']
    })
   }
}

function extractMaxInstances(gae, run) {
  if(gae['app.yaml']['automatic_scaling']?.['max_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/maxScale'] = gae['app.yaml']['automatic_scaling']['max_instances'].toString();
  }
  if(gae['app.yaml']['automatic_scaling']?.['max_num_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/maxScale'] = gae['app.yaml']['automatic_scaling']['max_num_instances'].toString();
  }
}

function extractMinInstances(gae, run) {
  if(gae['app.yaml']['automatic_scaling']?.['min_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/minScale'] = gae['app.yaml']['automatic_scaling']['min_instances'].toString();
  }
  if(gae['app.yaml']['automatic_scaling']?.['min_num_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/minScale'] = gae['app.yaml']['automatic_scaling']['min_num_instances'].toString();
  }
}

function extractConcurrency(gae, run) {
  if(gae['app.yaml']['automatic_scaling']?.['max_concurrent_requests']) {
    run['service.yaml']['spec']['template']['spec']['containerConcurrency'] = gae['app.yaml']['automatic_scaling']['max_concurrent_requests'];
  }
}

function extractMemory(gae, run) {
  // see https://cloud.google.com/appengine/docs/standard/#instance_classes

  const instanceClassMemory = {
    'F1': '256Mi',
    'F2': '512Mi',
    'F4': '1Gi',
    'F4_HIGHMEM': '2Gi',
    'F4_1G': '2Gi',
  }

  function flexMemory(memory) {
    // Cloud Run max memory is 2GiB
    return Math.min(memory, 2);
  }

  const container = run['service.yaml']['spec']['template']['spec']['containers'][0];

  if(gae['app.yaml']['instance_class']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['memory'] = instanceClassMemory[gae['app.yaml']['instance_class']];
   }

  if(gae['app.yaml']['resources']?.['memory_gb']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['memory'] = flexMemory(gae['app.yaml']['resources']['memory_gb']) + 'Gi';
  }
}

function extractCPU(gae, run) {
  // see https://cloud.google.com/appengine/docs/standard/#instance_classes

  const instanceClassCPU = {
    'F1': '1',
    'F2': '1',
    'F4': '2',
    'F4_HIGHMEM': '2',
    'F4_1G': '2',
  }

  function flexCPU(cpu) {
    // Flex cpu is an integer.
    // Cloud Run max CPU is 2
    return Math.min(cpu, 2);
  }

  const container = run['service.yaml']['spec']['template']['spec']['containers'][0];

  if(gae['app.yaml']['instance_class']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['cpu'] = instanceClassCPU[gae['app.yaml']['instance_class']];
   }

   if(gae['app.yaml']['resources']?.['cpu']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['cpu'] = flexCPU(gae['app.yaml']['resources']['cpu']);
  }
}

function extractMigrateToSecondGen(gae, run) {
  const runtime = gae['app.yaml']['runtime'];
  // "api_version" was deprecated for secnd gen runtimes
  if(gae['app.yaml']['api_version'] || firstGenRuntimes.includes(runtime)) {
    run['migrate-to-second-gen'] = true;
    if(!run['warnings']) {
      run['warnings'] = [];
    }
    run['warnings'].push({
      'message': 'You are using a first generation App Engine runtime, please migrate to a second generation App Engine runtime before migrating to Cloud Run. ',
      'link': {
        'href': firstGenMigrationGuides[runtime],
        'text': 'Migration guide',
      }
    });
  }
}

function extractBuild(gae, run) {
  run['gcloud'] = `gcloud alpha builds submit --pack image=${run['service.yaml']['spec']['template']['spec']['containers'][0]['image']} && gcloud beta run services replace service.yaml --region ${run['region']} --platform managed`;
}

function extractStatic(gae, run) {
  let useStatic = false;
  if(gae['app.yaml']['handlers']) {
    for( const handler of gae['app.yaml']['handlers']) {
      if(handler.static_dir || handler.static_files) {
        useStatic = true;
      }
    }
  }

  if(useStatic) {
    if(!run['warnings']) {
      run['warnings'] = [];
    }

    run['warnings'].push({
      'message': 'You are using App Engine static file handlers. Cloud Run does not provide support for static file serving. We recommend you to serve your static files from your code.',
    })
  }
}

function extractVPCAccess(gae, run){
  if(gae['app.yaml']['vpc_access_connector']?.['name']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['run.googleapis.com/vpc-access-connector'] = gae['app.yaml']['vpc_access_connector']['name'];
  }
}

function extractCloudSQL(gae, run) {
  if(gae['cloudsql-instance']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['run.googleapis.com/cloudsql-instances'] = [gae['project-id'], run['region'], gae['cloudsql-instance']].join(':');
  }
}

function extractImageURL(gae, run) {
  let imageName = gae['app.yaml']['service'] || 'image';
  let projectName = gae['project-id'] || '<YOUR-PROJECT>';

  run['service.yaml']['spec']['template']['spec']['containers'][0]['image'] = `gcr.io/${projectName}/${imageName}`;
}

export {appToRun}
<commit_msg>move migrated-from to a label on service<commit_after>/*
Copyright 2020 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// app.yaml standard reference: https://cloud.google.com/appengine/docs/standard/nodejs/config/appref
// app.yaml flex reference: https://cloud.google.com/appengine/docs/flexible/nodejs/reference/app-yaml
// service.yaml reference: https://github.com/knative/docs/blob/master/docs/serving/spec/knative-api-specification-1.0.md

/**
 * @param {Object} gaeService - Information about the App Engine service, should at minimum contain {"app.yaml" : {}}
 */
function appToRun(gaeService) {
  let runService = {
    'service.yaml': {
      'apiVersion': 'serving.knative.dev/v1',
      'kind': 'Service',
      'metadata': {
        'name' : 'default',
        'labels': {
          'migrated-from': 'app-engine'
        }
      },
      'spec': {
        'template': {
          'metadata': {},
          'spec': {
            'containers': [
              {
                'image': 'gcr.io/YOUR-PROJECT/image'
              }
            ]
          }
        }
      }
    }
  };

  const extractFunctions = [
    extractRegion,
    extractName,
    extractImageURL,
    extractEnvVars,
    extractProjectIDEnvVar,
    extractMaxInstances,
    extractMinInstances,
    extractConcurrency,
    extractMemory,
    extractCPU,
    extractMigrateToSecondGen,
    extractVPCAccess,
    extractCloudSQL,
    extractBuild,
    extractStatic,
  ]

  for (const extractFunction of extractFunctions) {
    extractFunction(gaeService, runService);
  }

  return runService;
}

const firstGenRuntimes = ['go111', 'python', 'python27', 'php55'];

const firstGenMigrationGuides = {
'go111': 'https://cloud.google.com/appengine/docs/standard/go/go-differences',
'python27': 'https://cloud.google.com/appengine/docs/standard/python/',
'python': 'https://cloud.google.com/appengine/docs/standard/python/',
'php55': 'https://cloud.google.com/appengine/docs/standard/php7/php-differences',
// (Java does not use an app.yaml): 'https://cloud.google.com/appengine/docs/standard/java11/java-differences',
}

function gaeRegionToGCPRegion(region) {
  if(region === 'us-central') { return 'us-central1'; }
  if(region === 'europe-west') { return 'europe-west1'; }
  return region;
}

function extractRegion(gae, run) {
  run['region'] = gaeRegionToGCPRegion(gae['region']) || 'us-central1';

  if(!run['service.yaml']['metadata']['labels']) {
    run['service.yaml']['metadata']['labels'] = {};
  }

  run['service.yaml']['metadata']['labels']['cloud.googleapis.com/location'] = run['region'];
}

function extractName(gae, run) {
  if(gae['app.yaml']['service']) {
    run['service.yaml']['metadata']['name'] = gae['app.yaml']['service'];
   }
}

function extractEnvVars(gae, run) {
  if(gae['app.yaml']['env_variables']) {
    const container = run['service.yaml']['spec']['template']['spec']['containers'][0];
    container['env'] = container['env'] || [];
    for (const key of Object.keys(gae['app.yaml']['env_variables'])) {
      container['env'].push({
        'name': key,
        'value': gae['app.yaml']['env_variables'][key]
      })
    }
   }
}

function extractProjectIDEnvVar(gae, run) {
  if(gae['project-id']) {
    const container = run['service.yaml']['spec']['template']['spec']['containers'][0];
    container['env'] = container['env'] || [];
    container['env'].push({
      'name': 'GOOGLE_CLOUD_PROJECT',
      'value': gae['project-id']
    })
   }
}

function extractMaxInstances(gae, run) {
  if(gae['app.yaml']['automatic_scaling']?.['max_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/maxScale'] = gae['app.yaml']['automatic_scaling']['max_instances'].toString();
  }
  if(gae['app.yaml']['automatic_scaling']?.['max_num_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/maxScale'] = gae['app.yaml']['automatic_scaling']['max_num_instances'].toString();
  }
}

function extractMinInstances(gae, run) {
  if(gae['app.yaml']['automatic_scaling']?.['min_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/minScale'] = gae['app.yaml']['automatic_scaling']['min_instances'].toString();
  }
  if(gae['app.yaml']['automatic_scaling']?.['min_num_instances']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['autoscaling.knative.dev/minScale'] = gae['app.yaml']['automatic_scaling']['min_num_instances'].toString();
  }
}

function extractConcurrency(gae, run) {
  if(gae['app.yaml']['automatic_scaling']?.['max_concurrent_requests']) {
    run['service.yaml']['spec']['template']['spec']['containerConcurrency'] = gae['app.yaml']['automatic_scaling']['max_concurrent_requests'];
  }
}

function extractMemory(gae, run) {
  // see https://cloud.google.com/appengine/docs/standard/#instance_classes

  const instanceClassMemory = {
    'F1': '256Mi',
    'F2': '512Mi',
    'F4': '1Gi',
    'F4_HIGHMEM': '2Gi',
    'F4_1G': '2Gi',
  }

  function flexMemory(memory) {
    // Cloud Run max memory is 2GiB
    return Math.min(memory, 2);
  }

  const container = run['service.yaml']['spec']['template']['spec']['containers'][0];

  if(gae['app.yaml']['instance_class']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['memory'] = instanceClassMemory[gae['app.yaml']['instance_class']];
   }

  if(gae['app.yaml']['resources']?.['memory_gb']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['memory'] = flexMemory(gae['app.yaml']['resources']['memory_gb']) + 'Gi';
  }
}

function extractCPU(gae, run) {
  // see https://cloud.google.com/appengine/docs/standard/#instance_classes

  const instanceClassCPU = {
    'F1': '1',
    'F2': '1',
    'F4': '2',
    'F4_HIGHMEM': '2',
    'F4_1G': '2',
  }

  function flexCPU(cpu) {
    // Flex cpu is an integer.
    // Cloud Run max CPU is 2
    return Math.min(cpu, 2);
  }

  const container = run['service.yaml']['spec']['template']['spec']['containers'][0];

  if(gae['app.yaml']['instance_class']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['cpu'] = instanceClassCPU[gae['app.yaml']['instance_class']];
   }

   if(gae['app.yaml']['resources']?.['cpu']) {
    container['resources'] = container['resources'] || {'limits': {}};
    container['resources']['limits']['cpu'] = flexCPU(gae['app.yaml']['resources']['cpu']);
  }
}

function extractMigrateToSecondGen(gae, run) {
  const runtime = gae['app.yaml']['runtime'];
  // "api_version" was deprecated for secnd gen runtimes
  if(gae['app.yaml']['api_version'] || firstGenRuntimes.includes(runtime)) {
    run['migrate-to-second-gen'] = true;
    if(!run['warnings']) {
      run['warnings'] = [];
    }
    run['warnings'].push({
      'message': 'You are using a first generation App Engine runtime, please migrate to a second generation App Engine runtime before migrating to Cloud Run. ',
      'link': {
        'href': firstGenMigrationGuides[runtime],
        'text': 'Migration guide',
      }
    });
  }
}

function extractBuild(gae, run) {
  run['gcloud'] = `gcloud alpha builds submit --pack image=${run['service.yaml']['spec']['template']['spec']['containers'][0]['image']} && gcloud beta run services replace service.yaml --region ${run['region']} --platform managed`;
}

function extractStatic(gae, run) {
  let useStatic = false;
  if(gae['app.yaml']['handlers']) {
    for( const handler of gae['app.yaml']['handlers']) {
      if(handler.static_dir || handler.static_files) {
        useStatic = true;
      }
    }
  }

  if(useStatic) {
    if(!run['warnings']) {
      run['warnings'] = [];
    }

    run['warnings'].push({
      'message': 'You are using App Engine static file handlers. Cloud Run does not provide support for static file serving. We recommend you to serve your static files from your code.',
    })
  }
}

function extractVPCAccess(gae, run){
  if(gae['app.yaml']['vpc_access_connector']?.['name']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['run.googleapis.com/vpc-access-connector'] = gae['app.yaml']['vpc_access_connector']['name'];
  }
}

function extractCloudSQL(gae, run) {
  if(gae['cloudsql-instance']) {
    run['service.yaml']['spec']['template']['metadata']['annotations']['run.googleapis.com/cloudsql-instances'] = [gae['project-id'], run['region'], gae['cloudsql-instance']].join(':');
  }
}

function extractImageURL(gae, run) {
  let imageName = gae['app.yaml']['service'] || 'image';
  let projectName = gae['project-id'] || '<YOUR-PROJECT>';

  run['service.yaml']['spec']['template']['spec']['containers'][0]['image'] = `gcr.io/${projectName}/${imageName}`;
}

export {appToRun}
<|endoftext|>


<commit_before>/**
 * ------------------------------------------ START OF LICENSE -----------------------------------------
 *
 * Deep-Space
 *
 * Copyright (c) Microsoft Corporation
 *
 * All rights reserved.
 *
 * MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the ""Software""), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * ----------------------------------------------- END OF LICENSE ------------------------------------------
 */
fsDirectives.directive('flyingStars', function($window) {
  'use strict';

  return {
    restrict: 'EAC',
    replace: true,
    scope: {
      speed: '=',
      stars: '=',
      images: '='
    },
    template: '
' +
                '
 <canvas id="flyingStarsCanvas"> </canvas>
' +
                '
 Zooming Speed:

' +
                // Uncomment the following line to add a slider for number of stars
                // '
 Number of Stars:

' +
              '
',
    link: function (scope, element, attribute) {

      /* Flying objects */
      var Star = function() {
        //make initial star spread across the entire screen
        this.position = initialPosition(random(edgeDistance));
        this.brightness = random(100);

        this.reset = function() {
          this.position = initialPosition(random(100));
        }

        this.updatePosition = function () {
          this.position.distance *= distanceScaling;
        }

        this.isInBoundary = function(x, y) {
          // x and y are negative to give some room to fall off the screen completely
          return x >= -200 && x <= canvas.width && y >= -200 && y <= canvas.height;
        }

        this.getX = function()  {
          return this.position.distance * Math.cos(this.position.thetaX) + origin.x;
        }

        this.getY = function()  {
          return this.position.distance * Math.cos(this.position.thetaY) + origin.y;
        }

        this.calculatePositionAndSize = function(ctx, callback) {
          var x = this.getX();
          var y = this.getY();

          if (this.isInBoundary(x, y)) {
            var distanceScaleFactor = this.position.distance/edgeDistance;
            var size = Math.min(6 * distanceScaleFactor, maxStarSize);

            callback.call(this, x, y, size);
          } else {
            this.reset();
          }
        }

        this.drawOnCanvas = function(ctx) {
          this.calculatePositionAndSize(ctx, function(x, y, size) {
            ctx.fillStyle = getGrayShade(Math.floor(255 * size) + 100 + this.brightness);
            ctx.fillRect(x, y, size, size);
          });
        }
      }

      var FlyingImage = function() {
        Star.apply(this);

        this.reset = function() {
          // switch to next image
          var nextImage = scope.images[fsImgIdx % scope.images.length];
          fsImgIdx += 1;
          this.image = new Image();
          this.image.src = nextImage.src;
          this.imageRatio = nextImage.width / nextImage.height;
          this.position = initialPosition(50);
          this.imgScale = 50;
        }

        this.drawOnCanvas = function(ctx) {
          this.calculatePositionAndSize(ctx, function(x, y, size) {
            ctx.drawImage(this.image, x, y, size * this.imgScale * this.imageRatio,  size * this.imgScale);
          });
        }

        this.reset();
      }

      /* sliders for speed and number of stars */
      var updateSpeed = function() {
        scope.speed = $("#speedSlider").slider("value");
        $("#speedText").text(scope.speed);
        if (intervalId !== -1) {
          clearInterval(intervalId);
          updateTick(scope.speed);
        }
      }

      var updateStars = function() {
        scope.stars = $("#starsSlider").slider("value");
        $("#starsText").text(scope.stars);
        if (scope.stars < stars.length) {
          stars = stars.slice(0, scope.stars);
        } else {
          while(stars.length < scope.stars) {
            stars.push(new Star());
          }
        }
      }

      $("#speedSlider").slider({
         orientation: "horizontal",
         range: "min",
         max: 100, //max speed
         value: scope.speed,
         slide: updateSpeed,
         change: updateSpeed
      });

      $("#starsSlider").slider({
         orientation: "horizontal",
         range: "min",
         max: 500, //max num of stars
         value: scope.stars,
         slide: updateStars,
         change: updateStars
      });

      function random(max) {
          return Math.floor(Math.random() * max) + 1;
      }

      function getGrayShade(c) {
        return "rgb("+c+","+c+","+c+")";
      }

      function initialPosition(distace) {
        return {
          thetaX: random(180) * Math.PI / 180,
          thetaY: random(180) * Math.PI / 180,
          distance: distace
        }
      }

      function initStars() {
        stars = [];

        for(var i = 0; i < scope.stars; ++i) {
          stars.push(new Star());
        }
      }

      function initImages() {
        images = [];

        if (scope.images && scope.images.length > 0) {
          images.push(new FlyingImage());
        }
      }

      function init() {
        initStars();
        initImages();
      }

      function updatePositions() {
        //black background, redraw all objects every tick
        ctx.fillStyle = getGrayShade(0);
        ctx.fillRect(0, 0, canvas.width, canvas.height);

        // update object's position on canvas
        $.each(stars.concat(images), function(i, flyObject){
          flyObject.updatePosition();
          flyObject.drawOnCanvas(ctx);
        });
      }

      function updateTick(speed) {
         var interval = 100 - speed;
          if (interval === 100) {
            clearInterval(intervalId);
          } else {
            intervalId = setInterval(updatePositions, interval);
          }
      }

      function updateCanvasSize(canvas) {
          var parentDiv = canvas.parentElement;
          //fill parent
          canvas.height = parentDiv.clientHeight;
          canvas.width = parentDiv.clientWidth;

          origin = {
            x: canvas.width / 2,
            y: canvas.height / 2
          };

          edgeDistance = Math.sqrt(Math.pow(origin.x, 2) + Math.pow(origin.y, 2));
      }

      function draw() {
        if (intervalId !== -1) {
          clearInterval(intervalId);
        }

        if (canvas && canvas.getContext) {
          ctx = canvas.getContext("2d");
          init();
          updateTick(scope.speed);
        }
      }

      scope.$watch('images', function(oldVal, newVal) {
        initImages();
      }, true);

      /* setup coordinates */
      var canvas = $('#flyingStarsCanvas')[0];

      var win = angular.element($window);
      win.bind('resize', function() {
          updateCanvasSize(canvas);
      });

      var origin, edgeDistance;

      var distanceScaling = 1.03;
      var maxStarSize = 4;

      var ctx;
      var stars, images;
      var intervalId = -1;
      var fsImgIdx = 0;

      updateCanvasSize(canvas);
      draw();
    }
  };
});
<commit_msg>Update FlyingStars.js<commit_after>/**
 * ------------------------------------------ START OF LICENSE -----------------------------------------
 *
 * Deep-Space
 *
 * Copyright (c) Microsoft Corporation
 *
 * All rights reserved.
 *
 * MIT License
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the ""Software""), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * ----------------------------------------------- END OF LICENSE ------------------------------------------
 */
fsDirectives.directive('flyingStars', function($window) {
  'use strict';

  return {
    restrict: 'EAC',
    replace: true,
    scope: {
      speed: '=',
      stars: '=',
      images: '='
    },
    template: '
' +
                '
 <canvas id="flyingStarsCanvas"> </canvas>
' +
                '
 Zooming Speed:

' +
                // Uncomment the following line to add a slider for number of stars
                '
 Number of Stars:

' +
              '
',
    link: function (scope, element, attribute) {

      /* Flying objects */
      var Star = function() {
        //make initial star spread across the entire screen
        this.position = initialPosition(random(edgeDistance));
        this.brightness = random(100);

        this.reset = function() {
          this.position = initialPosition(random(100));
        }

        this.updatePosition = function () {
          this.position.distance *= distanceScaling;
        }

        this.isInBoundary = function(x, y) {
          // x and y are negative to give some room to fall off the screen completely
          return x >= -200 && x <= canvas.width && y >= -200 && y <= canvas.height;
        }

        this.getX = function()  {
          return this.position.distance * Math.cos(this.position.thetaX) + origin.x;
        }

        this.getY = function()  {
          return this.position.distance * Math.cos(this.position.thetaY) + origin.y;
        }

        this.calculatePositionAndSize = function(ctx, callback) {
          var x = this.getX();
          var y = this.getY();

          if (this.isInBoundary(x, y)) {
            var distanceScaleFactor = this.position.distance/edgeDistance;
            var size = Math.min(6 * distanceScaleFactor, maxStarSize);

            callback.call(this, x, y, size);
          } else {
            this.reset();
          }
        }

        this.drawOnCanvas = function(ctx) {
          this.calculatePositionAndSize(ctx, function(x, y, size) {
            ctx.fillStyle = getGrayShade(Math.floor(255 * size) + 100 + this.brightness);
            ctx.fillRect(x, y, size, size);
          });
        }
      }

      var FlyingImage = function() {
        Star.apply(this);

        this.reset = function() {
          // switch to next image
          var nextImage = scope.images[fsImgIdx % scope.images.length];
          fsImgIdx += 1;
          this.image = new Image();
          this.image.src = nextImage.src;
          this.imageRatio = nextImage.width / nextImage.height;
          this.position = initialPosition(50);
          this.imgScale = 50;
        }

        this.drawOnCanvas = function(ctx) {
          this.calculatePositionAndSize(ctx, function(x, y, size) {
            ctx.drawImage(this.image, x, y, size * this.imgScale * this.imageRatio,  size * this.imgScale);
          });
        }

        this.reset();
      }

      /* sliders for speed and number of stars */
      var updateSpeed = function() {
        scope.speed = $("#speedSlider").slider("value");
        $("#speedText").text(scope.speed);
        if (intervalId !== -1) {
          clearInterval(intervalId);
          updateTick(scope.speed);
        }
      }

      var updateStars = function() {
        scope.stars = $("#starsSlider").slider("value");
        $("#starsText").text(scope.stars);
        if (scope.stars < stars.length) {
          stars = stars.slice(0, scope.stars);
        } else {
          while(stars.length < scope.stars) {
            stars.push(new Star());
          }
        }
      }

      $("#speedSlider").slider({
         orientation: "horizontal",
         range: "min",
         max: 100, //max speed
         value: scope.speed,
         slide: updateSpeed,
         change: updateSpeed
      });

      $("#starsSlider").slider({
         orientation: "horizontal",
         range: "min",
         max: 500, //max num of stars
         value: scope.stars,
         slide: updateStars,
         change: updateStars
      });

      function random(max) {
          return Math.floor(Math.random() * max) + 1;
      }

      function getGrayShade(c) {
        return "rgb("+c+","+c+","+c+")";
      }

      function initialPosition(distace) {
        return {
          thetaX: random(180) * Math.PI / 180,
          thetaY: random(180) * Math.PI / 180,
          distance: distace
        }
      }

      function initStars() {
        stars = [];

        for(var i = 0; i < scope.stars; ++i) {
          stars.push(new Star());
        }
      }

      function initImages() {
        images = [];

        if (scope.images && scope.images.length > 0) {
          images.push(new FlyingImage());
        }
      }

      function init() {
        initStars();
        initImages();
      }

      function updatePositions() {
        //black background, redraw all objects every tick
        ctx.fillStyle = getGrayShade(0);
        ctx.fillRect(0, 0, canvas.width, canvas.height);

        // update object's position on canvas
        $.each(stars.concat(images), function(i, flyObject){
          flyObject.updatePosition();
          flyObject.drawOnCanvas(ctx);
        });
      }

      function updateTick(speed) {
         var interval = 100 - speed;
          if (interval === 100) {
            clearInterval(intervalId);
          } else {
            intervalId = setInterval(updatePositions, interval);
          }
      }

      function updateCanvasSize(canvas) {
          var parentDiv = canvas.parentElement;
          //fill parent
          canvas.height = parentDiv.clientHeight;
          canvas.width = parentDiv.clientWidth;

          origin = {
            x: canvas.width / 2,
            y: canvas.height / 2
          };

          edgeDistance = Math.sqrt(Math.pow(origin.x, 2) + Math.pow(origin.y, 2));
      }

      function draw() {
        if (intervalId !== -1) {
          clearInterval(intervalId);
        }

        if (canvas && canvas.getContext) {
          ctx = canvas.getContext("2d");
          init();
          updateTick(scope.speed);
        }
      }

      scope.$watch('images', function(oldVal, newVal) {
        initImages();
      }, true);

      /* setup coordinates */
      var canvas = $('#flyingStarsCanvas')[0];

      var win = angular.element($window);
      win.bind('resize', function() {
          updateCanvasSize(canvas);
      });

      var origin, edgeDistance;

      var distanceScaling = 1.03;
      var maxStarSize = 4;

      var ctx;
      var stars, images;
      var intervalId = -1;
      var fsImgIdx = 0;

      updateCanvasSize(canvas);
      draw();
    }
  };
});
<|endoftext|>


<commit_before>$.ajaxSetup({timeout: 30000})

$(document).ready(function () {
    path = window.location.pathname.split('/')
    $('#nav-'+path[1]).addClass('active')

    $('.carousel').carousel()
    $(".table-sortable").tablesorter()
    $('.tabs').tab()
    $(window).on('hashchange', function() {
        if (location.hash) {
            $('a[href='+location.hash+']').tab('show');
        } else {
            $('a[data-toggle="tab"]:first').tab('show')
        }
    })

    $('a[data-toggle="tab"]').on('click', function(e) {
        var yScroll = $(window).scrollTop()
        location.hash = $(e.target).attr('href')
        $(window).scrollTop(yScroll)
    })
    $('form.disabled').submit(function(e) {
        e.preventDefault()
    })
    $('a.ajax-link').click(function (e) {
        e.preventDefault()
        var link = $(this)
        $.getJSON(link.attr('href'), function(data) {
            notify(link.text(), data, 'success')
        })
    })
    $('a.ajax-confirm').click(function (e) {
        e.preventDefault()
        var link = $(this)
        if (confirm(link.attr('title') + '?')) {
            $.getJSON(link.attr('href'), function(data){
                notify(link.attr('title'), data, 'info')
            })
        }
    })
    $('a.confirm').click(function (e) {
        return(confirm($(this).attr('title') + '?'))
    })

    $('.btn-check-update').click(function (e) {
        e.preventDefault()
        notify('Update','Checking for update.','info')

        $.ajax({
            dataType: "json",
            timeout: 10000,
            url: WEBDIR + 'update/',
            success: function(data) {
                if ($.isNumeric(data.versionsBehind) && data.versionsBehind == 0) {
                    notify('Update', 'Already running latest version.', 'success')
                } else if (data.updateNeeded) {
                    if (confirm('Your are '+data.versionsBehind+' versions behind. Update need. Update to latest version?')) {
                        $.post(WEBDIR + 'update/', function (data) {
                            if (data == 1) {
                                showModal('Installing update', '

','')
                            } else {
                                notify('Update', 'An error occured while updating!', 'error')
                            }
                        }, 'json').always(function() {
                            checkUpdate()
                        })
                    }
                } else {
                    notify('Update', 'Failed. Check errorlog.', 'error')
                }
            }
        });
    })

    $('#modal_dialog').on('hidden', function () {
        $('#modal_dialog .modal-body').empty()
        $('#modal_dialog .trans').removeClass('trans')
        $('#modal_dialog .modal-fanart').css('background', '#fff')
    })
})

function makeIcon(iconClass, title) {
    return $('')
        .addClass(iconClass)
        .attr('title', title)
        .css('cursor', 'pointer')
        .tooltip({placement: 'right'})
}
function shortenText(string, length) {
    return string.substr(0,length)+(string.length>length?'…':'')
}
function pad(str, max) {
  return str.toString().length < max ? pad("0"+str, max) : str
}
function bytesToSize(bytes, precision) {
    var sizes = ['B', 'KB', 'MB', 'GB', 'TB']
    var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)))
    return (bytes / Math.pow(1024, i)).toFixed(precision) + ' ' + sizes[i]
}
function parseDate(sec) {
    var date = new Date(sec*1000)
    var year = pad(date.getFullYear(), 2)
    var month = pad(date.getMonth(), 2)
    var day = pad(date.getDate(), 2)
    var hour = pad(date.getHours(), 2)
    var min = pad(date.getMinutes(), 2)
    return year+'-'+month+'-'+day+' '+hour+':'+min
}
function parseSec(sec) {
    if (sec==undefined) return '0.00'
    var h = Math.floor(sec / 3600)
    var m = Math.floor(sec % 3600 / 60)
    var s = pad(Math.floor(sec % 60), 2)
    return ((h>0) ? h+':'+pad(m, 2) : m) + ':' + s
}
function notify(title, text, type, time) {
    $.pnotify({
        title: title,
        text: text,
        type: type,
        history: false,
        sticker: false,
        closer_hover: false,
        addclass: "stack-bottomright",
        stack: {"dir1": "up", "dir2": "left", push: 'top'}
    })
}
function showModal(title, content, buttons) {
    $('#modal_dialog .modal-h3').html(title)
    $('#modal_dialog .modal-body').html(content)
    var footer = $('#modal_dialog .modal-footer').empty()
    $.each(buttons, function (name, action) {
        footer.append(
            $('<button>').html(name).addClass('btn btn-primary').click(function() {
                $(action)
            })
        )
    })

    footer.append(
        $('<button>').html('Close').addClass('btn').click(function() {
            $(hideModal)
        })
    )

    $('#modal_dialog').modal({show: true, backdrop: true})
}
function hideModal() {
    $('#modal_dialog').modal('hide')
}
function checkUpdate() {
    $.getJSON(WEBDIR + 'update/status', function (data) {
        if (data != 0) {
            setTimeout(checkUpdate, 1000)
        } else {
            location.reload()
        }
    }).error(function() {
        setTimeout(checkUpdate, 1000)
    })
}
<commit_msg>Fix other links on small devices<commit_after>$.ajaxSetup({timeout: 30000})

$(document).ready(function () {
    path = window.location.pathname.split('/')
    $('#nav-'+path[1]).addClass('active')

    $('.carousel').carousel()
    $(".table-sortable").tablesorter()
    $('.tabs').tab()
    $(window).on('hashchange', function() {
        if (location.hash) {
            $('a[href='+location.hash+']').tab('show');
        } else {
            $('a[data-toggle="tab"]:first').tab('show')
        }
    })

    $('a[data-toggle="tab"]').on('click', function(e) {
        var yScroll = $(window).scrollTop()
        location.hash = $(e.target).attr('href')
        $(window).scrollTop(yScroll)
    })
    $('form.disabled').submit(function(e) {
        e.preventDefault()
    })
    $('a.ajax-link').click(function (e) {
        e.preventDefault()
        var link = $(this)
        $.getJSON(link.attr('href'), function(data) {
            notify(link.text(), data, 'success')
        })
    })
    $('a.ajax-confirm').click(function (e) {
        e.preventDefault()
        var link = $(this)
        if (confirm(link.attr('title') + '?')) {
            $.getJSON(link.attr('href'), function(data){
                notify(link.attr('title'), data, 'info')
            })
        }
    })
    $('a.confirm').click(function (e) {
        return(confirm($(this).attr('title') + '?'))
    })

    $('.btn-check-update').click(function (e) {
        e.preventDefault()
        notify('Update','Checking for update.','info')

        $.ajax({
            dataType: "json",
            timeout: 10000,
            url: WEBDIR + 'update/',
            success: function(data) {
                if ($.isNumeric(data.versionsBehind) && data.versionsBehind == 0) {
                    notify('Update', 'Already running latest version.', 'success')
                } else if (data.updateNeeded) {
                    if (confirm('Your are '+data.versionsBehind+' versions behind. Update need. Update to latest version?')) {
                        $.post(WEBDIR + 'update/', function (data) {
                            if (data == 1) {
                                showModal('Installing update', '

','')
                            } else {
                                notify('Update', 'An error occured while updating!', 'error')
                            }
                        }, 'json').always(function() {
                            checkUpdate()
                        })
                    }
                } else {
                    notify('Update', 'Failed. Check errorlog.', 'error')
                }
            }
        });
    })

    $('#modal_dialog').on('hidden', function () {
        $('#modal_dialog .modal-body').empty()
        $('#modal_dialog .trans').removeClass('trans')
        $('#modal_dialog .modal-fanart').css('background', '#fff')
    })
})

function makeIcon(iconClass, title) {
    return $('')
        .addClass(iconClass)
        .attr('title', title)
        .css('cursor', 'pointer')
        .tooltip({placement: 'right'})
}
function shortenText(string, length) {
    return string.substr(0,length)+(string.length>length?'…':'')
}
function pad(str, max) {
  return str.toString().length < max ? pad("0"+str, max) : str
}
function bytesToSize(bytes, precision) {
    var sizes = ['B', 'KB', 'MB', 'GB', 'TB']
    var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)))
    return (bytes / Math.pow(1024, i)).toFixed(precision) + ' ' + sizes[i]
}
function parseDate(sec) {
    var date = new Date(sec*1000)
    var year = pad(date.getFullYear(), 2)
    var month = pad(date.getMonth(), 2)
    var day = pad(date.getDate(), 2)
    var hour = pad(date.getHours(), 2)
    var min = pad(date.getMinutes(), 2)
    return year+'-'+month+'-'+day+' '+hour+':'+min
}
function parseSec(sec) {
    if (sec==undefined) return '0.00'
    var h = Math.floor(sec / 3600)
    var m = Math.floor(sec % 3600 / 60)
    var s = pad(Math.floor(sec % 60), 2)
    return ((h>0) ? h+':'+pad(m, 2) : m) + ':' + s
}
function notify(title, text, type, time) {
    $.pnotify({
        title: title,
        text: text,
        type: type,
        history: false,
        sticker: false,
        closer_hover: false,
        addclass: "stack-bottomright",
        stack: {"dir1": "up", "dir2": "left", push: 'top'}
    })
}
function showModal(title, content, buttons) {
    $('#modal_dialog .modal-h3').html(title)
    $('#modal_dialog .modal-body').html(content)
    var footer = $('#modal_dialog .modal-footer').empty()
    $.each(buttons, function (name, action) {
        footer.append(
            $('<button>').html(name).addClass('btn btn-primary').click(function() {
                $(action)
            })
        )
    })

    footer.append(
        $('<button>').html('Close').addClass('btn').click(function() {
            $(hideModal)
        })
    )

    $('#modal_dialog').modal({show: true, backdrop: true})
}
function hideModal() {
    $('#modal_dialog').modal('hide')
}
function checkUpdate() {
    $.getJSON(WEBDIR + 'update/status', function (data) {
        if (data != 0) {
            setTimeout(checkUpdate, 1000)
        } else {
            location.reload()
        }
    }).error(function() {
        setTimeout(checkUpdate, 1000)
    })
}

// Fix for dropdown menu on small devices. Credits https://github.com/twbs/bootstrap/issues/4550#issuecomment-21361314
$('.dropdown-toggle').click(function(e) {
  e.preventDefault();
  setTimeout($.proxy(function() {
    if ('ontouchstart' in document.documentElement) {
      $(this).siblings('.dropdown-backdrop').off().remove();
    }
  }, this), 0);
});
<|endoftext|>


<commit_before>/**
 * 系统配置文件
 */
const path = require('path');

const config = {
  // 本地调试模式
  debug: true,
  // 网站名称
  sitename: 'EasyClub',
  // 板块列表
  tags: ['原创', '转载', '提问', '站务'],
  // 论坛管理员，username
  admins: ['dylan'],
  // 每页主题数量
  pageSize: 20,
  // 积分设置
  score: {
    topic: 5, // 发表一个主题
    reply: 1  // 一个回复
  },
  // 显示页码数量
  showPageNum: 5,
  // 数据库连接
  mongodb: {
    username: '',
    password: '',
    host: '127.0.0.1',
    port: 27017,
    database: 'easyclub'
  },
  default_avatar: '/images/photo.png', // 默认头像
  upload: {
    path: path.join(__dirname, 'public/upload/'),
    url: '/public/upload',
    extnames: ['jpeg', 'jpg', 'gif', 'png'],
    fileSize: 1024 * 1024
  }
}

module.exports = config;<commit_msg>删除config.js配置文件<commit_after><|endoftext|>


<commit_before>
var FormParser = Class.extend({

	init : function(settings) {
		this.settings = settings;
	},

	parseInputs : function(formValues) {
		var inputs = [];
		var inputNameToPosition = {};

		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "input_")) {
				// only add input elements with non-emtpy value:
				if(prop.value) {
					var j = inputs.length;
					inputs[j] = {};
					inputs[j].identifier = prop.name.substring(6, prop.name.lastIndexOf("_"));
					inputs[j].value = prop.value;
					inputNameToPosition[prop.name] = j;
				}
			}
		}

		/*
		 * look for each input's type
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "type_input")) {
				var originalInputName = prop.name.substring(5, prop.name.length);

				// check if input is set before setting the type
				if(inputNameToPosition[originalInputName] != null) {
					inputs[inputNameToPosition[originalInputName]].type = prop.value;

					if (stringStartsWith(prop.value, "complex")) {
						inputs[inputNameToPosition[originalInputName]].complexPayload = inputs[inputNameToPosition[originalInputName]].value;
					}
					else if (stringStartsWith(prop.value, "bbox")) {
						this.parseBboxValue(inputs[inputNameToPosition[originalInputName]].value, inputs[inputNameToPosition[originalInputName]]);
					}
				}
			}
		}

		/*
		 * check asReference flag
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "checkbox_input")) {
				var originalInputName = prop.name.substring(9, prop.name.length);
				/*
				 * its only present in the array if checked
				 */
				inputs[inputNameToPosition[originalInputName]].asReference = true;
			}
		}

		/*
		 * look for each input's format
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "format_input")) {
				var originalInputName = prop.name.substring(7, prop.name.length);
				if (inputNameToPosition[originalInputName] != null) {
					var formatObject = JSON.parse(prop.value);
					this.parseFormatObject(formatObject, inputs[inputNameToPosition[originalInputName]]);
				}
			}
		}

		return inputs;
	},

	parseBboxValue : function(bboxString, targetObject) {
		var array = bboxString.split(",");

		if (array.length < 4) {
			for (var i = array.length; i < 4; i++) {
				/*
				 * bad input, fill it with zero
				 * TODO: do validation in prior
				 */
				array[i] = "0.0";
			}
		}

		targetObject.lowerCorner = jQuery.trim(array[0]) + " " + jQuery.trim(array[1]);
		targetObject.upperCorner = jQuery.trim(array[2]) + " " + jQuery.trim(array[3]);
	},

	parseOutputs : function(formValues) {
		var outputs = [];
		var outputNameToPosition = {};

		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "output_")) {
				var j = outputs.length;
				outputs[j] = {};
				outputs[j].identifier = prop.name.substring(7, prop.name.length);

				//set asReference flag to false as default
				outputs[j].asReference = false;
				outputNameToPosition[prop.name] = j;
			}
		}

		/*
		 * look for each outputs type
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "type_output")) {
				var originalName = prop.name.substring(5, prop.name.length);

				// only set output properties for selected outputs
				if(outputNameToPosition[originalName] != null) {
					outputs[outputNameToPosition[originalName]].type = prop.value;
				}
			}
		}

		/*
		 * look for each outputs format
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "format_output")) {
				var originalName = prop.name.substring(7, prop.name.length);
				var formatObject = JSON.parse(prop.value);

				if(outputNameToPosition[originalName] != null) {
					this.parseFormatObject(formatObject, outputs[outputNameToPosition[originalName]]);
				}
			}
		}

		/*
		 * check asReference flag
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "checkbox_output")) {
				var originalOutputName = prop.name.substring(9, prop.name.length);
				/*
				 * its only present in the array if checked
				 */
				outputs[outputNameToPosition[originalOutputName]].asReference = true;
			}
		}

		return outputs;
	},

	parseFormatObject : function(formatObject, targetObject) {
		if (formatObject.mimeType) {
			targetObject.mimeType = formatObject.mimeType;
		}

		if (formatObject.schema) {
			targetObject.schema = formatObject.schema;
		}

		if (formatObject.encoding) {
			targetObject.encoding = formatObject.encoding;
		}
	},

	parseProcessIdentifier : function(formValues) {
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (equalsString(prop.name, "processIdentifier")) {
				return prop.value;
			}
		}
		return "";
	},

	parseOutputStyle : function(formValues) {
		return {
			   storeExecuteResponse: true,
			   lineage: false,
			   status: true
		   };
	}

});
<commit_msg>This should fix #63<commit_after>
var FormParser = Class.extend({

	init : function(settings) {
		this.settings = settings;
	},

	parseInputs : function(formValues) {
		var inputs = [];
		var inputNameToPosition = {};

		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "input_")) {
				// only add input elements with non-emtpy value:
				if(prop.value) {
					var j = inputs.length;
					inputs[j] = {};
					if(prop.name.lastIndexOf("_") > 5){
					    inputs[j].identifier = prop.name.substring(6, prop.name.lastIndexOf("_"));
					}else{
					    inputs[j].identifier = prop.name.substring(6, prop.name.length);
					}
					inputs[j].value = prop.value;
					inputNameToPosition[prop.name] = j;
				}
			}
		}

		/*
		 * look for each input's type
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "type_input")) {
				var originalInputName = prop.name.substring(5, prop.name.length);

				// check if input is set before setting the type
				if(inputNameToPosition[originalInputName] != null) {
					inputs[inputNameToPosition[originalInputName]].type = prop.value;

					if (stringStartsWith(prop.value, "complex")) {
						inputs[inputNameToPosition[originalInputName]].complexPayload = inputs[inputNameToPosition[originalInputName]].value;
					}
					else if (stringStartsWith(prop.value, "bbox")) {
						this.parseBboxValue(inputs[inputNameToPosition[originalInputName]].value, inputs[inputNameToPosition[originalInputName]]);
					}
				}
			}
		}

		/*
		 * check asReference flag
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "checkbox_input")) {
				var originalInputName = prop.name.substring(9, prop.name.length);
				/*
				 * its only present in the array if checked
				 */
				inputs[inputNameToPosition[originalInputName]].asReference = true;
			}
		}

		/*
		 * look for each input's format
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "format_input")) {
				var originalInputName = prop.name.substring(7, prop.name.length);
				if (inputNameToPosition[originalInputName] != null) {
					var formatObject = JSON.parse(prop.value);
					this.parseFormatObject(formatObject, inputs[inputNameToPosition[originalInputName]]);
				}
			}
		}

		return inputs;
	},

	parseBboxValue : function(bboxString, targetObject) {
		var array = bboxString.split(",");

		if (array.length < 4) {
			for (var i = array.length; i < 4; i++) {
				/*
				 * bad input, fill it with zero
				 * TODO: do validation in prior
				 */
				array[i] = "0.0";
			}
		}

		targetObject.lowerCorner = jQuery.trim(array[0]) + " " + jQuery.trim(array[1]);
		targetObject.upperCorner = jQuery.trim(array[2]) + " " + jQuery.trim(array[3]);
	},

	parseOutputs : function(formValues) {
		var outputs = [];
		var outputNameToPosition = {};

		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "output_")) {
				var j = outputs.length;
				outputs[j] = {};
				outputs[j].identifier = prop.name.substring(7, prop.name.length);

				//set asReference flag to false as default
				outputs[j].asReference = false;
				outputNameToPosition[prop.name] = j;
			}
		}

		/*
		 * look for each outputs type
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "type_output")) {
				var originalName = prop.name.substring(5, prop.name.length);

				// only set output properties for selected outputs
				if(outputNameToPosition[originalName] != null) {
					outputs[outputNameToPosition[originalName]].type = prop.value;
				}
			}
		}

		/*
		 * look for each outputs format
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "format_output")) {
				var originalName = prop.name.substring(7, prop.name.length);
				var formatObject = JSON.parse(prop.value);

				if(outputNameToPosition[originalName] != null) {
					this.parseFormatObject(formatObject, outputs[outputNameToPosition[originalName]]);
				}
			}
		}

		/*
		 * check asReference flag
		 */
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (stringStartsWith(prop.name, "checkbox_output")) {
				var originalOutputName = prop.name.substring(9, prop.name.length);
				/*
				 * its only present in the array if checked
				 */
				outputs[outputNameToPosition[originalOutputName]].asReference = true;
			}
		}

		return outputs;
	},

	parseFormatObject : function(formatObject, targetObject) {
		if (formatObject.mimeType) {
			targetObject.mimeType = formatObject.mimeType;
		}

		if (formatObject.schema) {
			targetObject.schema = formatObject.schema;
		}

		if (formatObject.encoding) {
			targetObject.encoding = formatObject.encoding;
		}
	},

	parseProcessIdentifier : function(formValues) {
		for (var i = 0; i < formValues.length; i++) {
			var prop = formValues[i];
			if (equalsString(prop.name, "processIdentifier")) {
				return prop.value;
			}
		}
		return "";
	},

	parseOutputStyle : function(formValues) {
		return {
			   storeExecuteResponse: true,
			   lineage: false,
			   status: true
		   };
	}

});
<|endoftext|>


<commit_before>import { Component } from 'react';
import format from 'date-fns/format';

const trans = {
  'Monday': 'Man',
  'Tuesday': 'Tirs',
  'Wednesday': 'Ons',
  'Thursday': 'Tors',
  'Friday': 'Fre',
  'Saturday': 'Lør',
  'Sunday': 'Søn'
};

const Circle = ({ children, size = 50, style, ...props }) => (
  <button className="root selected" style={{
    width: size,
    height: size,
    borderRadius: size / 2,
    backgroundColor: '#b11b11',
    ...style
  }} {...props}>
    {children}

  </button>
);

class Day extends Component {
  state = {
    selectedIndex: 0
  };

  render() {
    const { day, events } = this.props;

    const date = events[0].startsAt;

    return (

{trans[day]}

          {format(date, 'DD.MM')}

            {events.map((event, index) => {
              const hour = format(event.startsAt, 'H');
              return (
                <Circle
                  key={index}
                  onClick={() => this.setState({ selectedIndex: index })}
                  size={index === this.state.selectedIndex ? 60 : 40}
                  style={{
                    transform: `translateX(${hour/24 * 700}px)`
                  }}
                >
                  {hour}
                </Circle>
              );
            })}

{events[this.state.selectedIndex].title}

            {events[this.state.selectedIndex].description}

    );
  }
}

export default ({ events }) => (

    {Object.entries(events).map(([day, events]) => (
      <Day key={day} day={day} events={events} />
    ))}

);
<commit_msg>tweaks<commit_after>import { Component } from 'react';
import format from 'date-fns/format';

const trans = {
  'Monday': 'Man',
  'Tuesday': 'Tirs',
  'Wednesday': 'Ons',
  'Thursday': 'Tors',
  'Friday': 'Fre',
  'Saturday': 'Lør',
  'Sunday': 'Søn'
};

const Circle = ({
  children,
  size = 50,
  style,
  selected,
  ...props
}) => (
  <button className="root selected" style={{
    width: size,
    height: size,
    borderRadius: size / 2,
    ...style
  }} {...props}>
    {children}

  </button>
);

class Day extends Component {
  state = {
    selectedIndex: 0
  };

  render() {
    const { day, events } = this.props;

    const date = events[0].startsAt;

    return (

{trans[day]}

          {format(date, 'DD.MM')}

            {events.map((event, index) => {
              const hour = format(event.startsAt, 'H');
              const selected = index === this.state.selectedIndex;
              return (
                <Circle
                  key={index}
                  onClick={() => this.setState({ selectedIndex: index })}
                  size={40}
                  style={{
                    transform: `translateX(${hour/24 * 700}px) scale(${selected ? 1.5 : 1})`
                  }}
                >
                  {hour}
                </Circle>
              );
            })}

{events[this.state.selectedIndex].title}

            {events[this.state.selectedIndex].description}

    );
  }
}

export default ({ events }) => (

    {Object.entries(events).map(([day, events]) => (
      <Day key={day} day={day} events={events} />
    ))}

);
<|endoftext|>


<commit_before>System.config({
  defaultJSExtensions: true,
  transpiler: "babel",
  babelOptions: {
    "optional": [
      "runtime",
      "optimisation.modules.system"
    ]
  },
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

  map: {
    "aurelia-binding": "npm:aurelia-binding@1.0.0-rc.1.0.0",
    "aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0-rc.1.0.0",
    "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
    "aurelia-pal-browser": "npm:aurelia-pal-browser@1.0.0-rc.1.0.0",
    "aurelia-polyfills": "npm:aurelia-polyfills@1.0.0-rc.1.0.0",
    "aurelia-task-queue": "npm:aurelia-task-queue@1.0.0-rc.1.0.0",
    "aurelia-templating": "npm:aurelia-templating@1.0.0-rc.1.0.0",
    "babel": "npm:babel-core@5.8.38",
    "babel-runtime": "npm:babel-runtime@5.8.38",
    "core-js": "npm:core-js@1.2.6",
    "validate.js": "npm:validate.js@0.9.0",
    "github:jspm/nodelibs-assert@0.1.0": {
      "assert": "npm:assert@1.4.1"
    },
    "github:jspm/nodelibs-buffer@0.1.0": {
      "buffer": "npm:buffer@3.6.0"
    },
    "github:jspm/nodelibs-path@0.1.0": {
      "path-browserify": "npm:path-browserify@0.0.0"
    },
    "github:jspm/nodelibs-process@0.1.2": {
      "process": "npm:process@0.11.5"
    },
    "github:jspm/nodelibs-util@0.1.0": {
      "util": "npm:util@0.10.3"
    },
    "github:jspm/nodelibs-vm@0.1.0": {
      "vm-browserify": "npm:vm-browserify@0.0.4"
    },
    "npm:assert@1.4.1": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "util": "npm:util@0.10.3"
    },
    "npm:aurelia-binding@1.0.0-rc.1.0.0": {
      "aurelia-logging": "npm:aurelia-logging@1.0.0-rc.1.0.0",
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0",
      "aurelia-task-queue": "npm:aurelia-task-queue@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-dependency-injection@1.0.0-rc.1.0.0": {
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-loader@1.0.0-rc.1.0.0": {
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-path": "npm:aurelia-path@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-metadata@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-pal-browser@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-polyfills@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-task-queue@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-templating@1.0.0-rc.1.0.0": {
      "aurelia-binding": "npm:aurelia-binding@1.0.0-rc.1.0.0",
      "aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0-rc.1.0.0",
      "aurelia-loader": "npm:aurelia-loader@1.0.0-rc.1.0.0",
      "aurelia-logging": "npm:aurelia-logging@1.0.0-rc.1.0.0",
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0",
      "aurelia-path": "npm:aurelia-path@1.0.0-rc.1.0.0",
      "aurelia-task-queue": "npm:aurelia-task-queue@1.0.0-rc.1.0.0"
    },
    "npm:babel-runtime@5.8.38": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:buffer@3.6.0": {
      "base64-js": "npm:base64-js@0.0.8",
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "ieee754": "npm:ieee754@1.1.6",
      "isarray": "npm:isarray@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:core-js@1.2.6": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "systemjs-json": "github:systemjs/plugin-json@0.1.2"
    },
    "npm:inherits@2.0.1": {
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:path-browserify@0.0.0": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:process@0.11.5": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "vm": "github:jspm/nodelibs-vm@0.1.0"
    },
    "npm:util@0.10.3": {
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:validate.js@0.9.0": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:vm-browserify@0.0.4": {
      "indexof": "npm:indexof@0.0.1"
    }
  }
});
<commit_msg>chore(config): remove old babel config<commit_after>System.config({
  defaultJSExtensions: true,
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

  map: {
    "aurelia-binding": "npm:aurelia-binding@1.0.0-rc.1.0.0",
    "aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0-rc.1.0.0",
    "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
    "aurelia-pal-browser": "npm:aurelia-pal-browser@1.0.0-rc.1.0.0",
    "aurelia-polyfills": "npm:aurelia-polyfills@1.0.0-rc.1.0.0",
    "aurelia-task-queue": "npm:aurelia-task-queue@1.0.0-rc.1.0.0",
    "aurelia-templating": "npm:aurelia-templating@1.0.0-rc.1.0.0",
    "babel": "npm:babel-core@5.8.38",
    "babel-runtime": "npm:babel-runtime@5.8.38",
    "core-js": "npm:core-js@1.2.6",
    "validate.js": "npm:validate.js@0.9.0",
    "github:jspm/nodelibs-assert@0.1.0": {
      "assert": "npm:assert@1.4.1"
    },
    "github:jspm/nodelibs-buffer@0.1.0": {
      "buffer": "npm:buffer@3.6.0"
    },
    "github:jspm/nodelibs-path@0.1.0": {
      "path-browserify": "npm:path-browserify@0.0.0"
    },
    "github:jspm/nodelibs-process@0.1.2": {
      "process": "npm:process@0.11.5"
    },
    "github:jspm/nodelibs-util@0.1.0": {
      "util": "npm:util@0.10.3"
    },
    "github:jspm/nodelibs-vm@0.1.0": {
      "vm-browserify": "npm:vm-browserify@0.0.4"
    },
    "npm:assert@1.4.1": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "buffer": "github:jspm/nodelibs-buffer@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "util": "npm:util@0.10.3"
    },
    "npm:aurelia-binding@1.0.0-rc.1.0.0": {
      "aurelia-logging": "npm:aurelia-logging@1.0.0-rc.1.0.0",
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0",
      "aurelia-task-queue": "npm:aurelia-task-queue@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-dependency-injection@1.0.0-rc.1.0.0": {
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-loader@1.0.0-rc.1.0.0": {
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-path": "npm:aurelia-path@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-metadata@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-pal-browser@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-polyfills@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-task-queue@1.0.0-rc.1.0.0": {
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0"
    },
    "npm:aurelia-templating@1.0.0-rc.1.0.0": {
      "aurelia-binding": "npm:aurelia-binding@1.0.0-rc.1.0.0",
      "aurelia-dependency-injection": "npm:aurelia-dependency-injection@1.0.0-rc.1.0.0",
      "aurelia-loader": "npm:aurelia-loader@1.0.0-rc.1.0.0",
      "aurelia-logging": "npm:aurelia-logging@1.0.0-rc.1.0.0",
      "aurelia-metadata": "npm:aurelia-metadata@1.0.0-rc.1.0.0",
      "aurelia-pal": "npm:aurelia-pal@1.0.0-rc.1.0.0",
      "aurelia-path": "npm:aurelia-path@1.0.0-rc.1.0.0",
      "aurelia-task-queue": "npm:aurelia-task-queue@1.0.0-rc.1.0.0"
    },
    "npm:babel-runtime@5.8.38": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:buffer@3.6.0": {
      "base64-js": "npm:base64-js@0.0.8",
      "child_process": "github:jspm/nodelibs-child_process@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "ieee754": "npm:ieee754@1.1.6",
      "isarray": "npm:isarray@1.0.0",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:core-js@1.2.6": {
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "path": "github:jspm/nodelibs-path@0.1.0",
      "process": "github:jspm/nodelibs-process@0.1.2",
      "systemjs-json": "github:systemjs/plugin-json@0.1.2"
    },
    "npm:inherits@2.0.1": {
      "util": "github:jspm/nodelibs-util@0.1.0"
    },
    "npm:path-browserify@0.0.0": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:process@0.11.5": {
      "assert": "github:jspm/nodelibs-assert@0.1.0",
      "fs": "github:jspm/nodelibs-fs@0.1.2",
      "vm": "github:jspm/nodelibs-vm@0.1.0"
    },
    "npm:util@0.10.3": {
      "inherits": "npm:inherits@2.0.1",
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:validate.js@0.9.0": {
      "process": "github:jspm/nodelibs-process@0.1.2"
    },
    "npm:vm-browserify@0.0.4": {
      "indexof": "npm:indexof@0.0.1"
    }
  }
});
<|endoftext|>


<commit_before>/* global define */

/*  Module to add Common Gauge Behaviors
 *  ====================================
 *
 *  * Spinner animation on sync events
 *  * animations for gauges to disappear and reappear
 *  * bindings to target object
 *  * lifecycle behaviors for a gauge widget
 *
 */
define(['jquery', 'underscore', 'backbone', 'templates', 'humanize', 'helpers/animation', 'marionette'], function($, _, Backbone, JST, humanize, animation) {
    'use strict';
    /*jshint validthis:true */

    function expand(callback) {
        this.$el.css('display', 'block');
        if (callback) {
            callback.apply(this);
        }
    }

    function collapse(callback) {
        this.$el.css('display', 'none');
        if (callback) {
            callback.apply(this);
        }
    }

    function disappear(callback) {
        return this._disappearAnimation(this.$el, function() {
            this.$el.css('visibility', 'hidden');
            if (callback) {
                callback.apply(this);
            }
        });
    }

    function reappear(callback) {
        this.$el.css('visibility', 'visible');
        return this._reappearAnimation(this.$el, callback);
    }
    var colors = 'ok warn fail';
    var icons = 'fa-check fa-warning fa-exclamation-circle';

    function makeIconEventHandler(colorClass, iconClass) {
        return function() {
            if (this.ui && this.ui.statusIcon) {
                this.ui.statusIcon.removeClass(colors).addClass(colorClass).find('.fa-stack-1x').removeClass(icons).addClass(iconClass);
            }
        };
    }

    var okEvent = makeIconEventHandler('ok', 'fa-check');
    var warningEvent = makeIconEventHandler('warn', 'fa-warning');
    var failEvent = makeIconEventHandler('fail', 'fa-exclamation-circle');

    function initializeHelper(target, watched) {
        if (target.listenTo) {
            target._okEvent = okEvent;
            target._warningEvent = warningEvent;
            target._failEvent = failEvent;
            _.bindAll(target, '_okEvent', '_warningEvent', '_failEvent');
            target.listenTo(target, 'status:ok', target._okEvent);
            target.listenTo(target, 'status:warn', target._warningEvent);
            target.listenTo(target, 'status:fail', target._failEvent);
            if (target.ui) {
                target.ui.statusIcon = '.card-status-icon';
            }
        }
        if (target.App.vent) {
            /* Assign functions */
            target._expand = expand;
            target._collapse = collapse;
            target._disappear = disappear;
            target._reappear = reappear;
            target._disappearAnimation = animation.single('fadeOutUpAnim');
            target._reappearAnimation = animation.single('fadeInDownAnim');

            /* bind new functions to target */
            _.bindAll(target, '_expand', '_collapse', '_disappear', '_reappear', '_disappearAnimation', '_reappearAnimation');

            /* Attach to App and View events */
            target.listenTo(target.App.vent, 'gauges:disappear', target._disappear);
            target.listenTo(target.App.vent, 'gauges:reappear', target._reappear);
            target.listenTo(target.App.vent, 'gauges:collapse', target._collapse);
            target.listenTo(target.App.vent, 'gauges:expand', target._expand);

            /* Defer adding UI events until render is complete */
            target.listenToOnce(target, 'render', function() {
                target.listenTo(target.App.vent, watched + ':request', function() {
                    target.ui.spinner.css('visibility', 'visible');
                });
                target.listenTo(target.App.vent, watched + ':sync ' + watched + ':error', function() {
                    setTimeout(function() {
                        target.ui.spinner.css('visibility', 'hidden');
                    }, 250);
                });
            });
        }
    }

    return initializeHelper;
});
<commit_msg>Avoid crashing on App object<commit_after>/* global define */

/*  Module to add Common Gauge Behaviors
 *  ====================================
 *
 *  * Spinner animation on sync events
 *  * animations for gauges to disappear and reappear
 *  * bindings to target object
 *  * lifecycle behaviors for a gauge widget
 *
 */
define(['jquery', 'underscore', 'backbone', 'templates', 'humanize', 'helpers/animation', 'marionette'], function($, _, Backbone, JST, humanize, animation) {
    'use strict';
    /*jshint validthis:true */

    function expand(callback) {
        this.$el.css('display', 'block');
        if (callback) {
            callback.apply(this);
        }
    }

    function collapse(callback) {
        this.$el.css('display', 'none');
        if (callback) {
            callback.apply(this);
        }
    }

    function disappear(callback) {
        return this._disappearAnimation(this.$el, function() {
            this.$el.css('visibility', 'hidden');
            if (callback) {
                callback.apply(this);
            }
        });
    }

    function reappear(callback) {
        this.$el.css('visibility', 'visible');
        return this._reappearAnimation(this.$el, callback);
    }
    var colors = 'ok warn fail';
    var icons = 'fa-check fa-warning fa-exclamation-circle';

    function makeIconEventHandler(colorClass, iconClass) {
        return function() {
            if (this.ui && this.ui.statusIcon) {
                this.ui.statusIcon.removeClass(colors).addClass(colorClass).find('.fa-stack-1x').removeClass(icons).addClass(iconClass);
            }
        };
    }

    var okEvent = makeIconEventHandler('ok', 'fa-check');
    var warningEvent = makeIconEventHandler('warn', 'fa-warning');
    var failEvent = makeIconEventHandler('fail', 'fa-exclamation-circle');

    function initializeHelper(target, watched) {
        if (target.listenTo) {
            target._okEvent = okEvent;
            target._warningEvent = warningEvent;
            target._failEvent = failEvent;
            _.bindAll(target, '_okEvent', '_warningEvent', '_failEvent');
            target.listenTo(target, 'status:ok', target._okEvent);
            target.listenTo(target, 'status:warn', target._warningEvent);
            target.listenTo(target, 'status:fail', target._failEvent);
            if (target.ui) {
                target.ui.statusIcon = '.card-status-icon';
            }
        }
        if (target.App && target.App.vent) {
            /* Assign functions */
            target._expand = expand;
            target._collapse = collapse;
            target._disappear = disappear;
            target._reappear = reappear;
            target._disappearAnimation = animation.single('fadeOutUpAnim');
            target._reappearAnimation = animation.single('fadeInDownAnim');

            /* bind new functions to target */
            _.bindAll(target, '_expand', '_collapse', '_disappear', '_reappear', '_disappearAnimation', '_reappearAnimation');

            /* Attach to App and View events */
            target.listenTo(target.App.vent, 'gauges:disappear', target._disappear);
            target.listenTo(target.App.vent, 'gauges:reappear', target._reappear);
            target.listenTo(target.App.vent, 'gauges:collapse', target._collapse);
            target.listenTo(target.App.vent, 'gauges:expand', target._expand);

            /* Defer adding UI events until render is complete */
            target.listenToOnce(target, 'render', function() {
                target.listenTo(target.App.vent, watched + ':request', function() {
                    target.ui.spinner.css('visibility', 'visible');
                });
                target.listenTo(target.App.vent, watched + ':sync ' + watched + ':error', function() {
                    setTimeout(function() {
                        target.ui.spinner.css('visibility', 'hidden');
                    }, 250);
                });
            });
        } else {
            console.log(target, ' is missing App or App.vent object');
        }
    }

    return initializeHelper;
});
<|endoftext|>


<commit_before>/*
 * debugger.io: An interactive web scripting sandbox
 */

/**
 * jQuery
 *
 * Includes: Transit, nanoScroller.js, transitIn/transitOut, jQuery.cookie,
 * jQuery Storage API
 */
define(['jqueryjs', 'transit', 'nano', 'cookie', 'storage'],
function($) {
  // jQuery.transit fallback to $.fn.animate
  if (!$.support.transition) { $.fn.transition = $.fn.animate; }

  $.fn.transitIn = function(speed, easing, callback) {
    this.css({ display: 'block' });
    this.transition({ opacity: 1 }, speed, easing, function() {
      typeof callback === 'function' && callback.call(this);
    });
  };

  $.fn.transitOut = function(speed, easing, callback) {
    this.transition({ opacity: 0 }, speed, easing, function() {
    this.css({ display: 'none' });
      typeof callback === 'function' && callback.call(this);
    });
  };

  return $; // $.noConflict(false);
});
<commit_msg>Use jQuery UI<commit_after>/*
 * debugger.io: An interactive web scripting sandbox
 */

/**
 * jQuery
 *
 * Includes: Transit, nanoScroller.js, transitIn/transitOut, jQuery.cookie,
 * jQuery Storage API, jQuery UI
 */
define(['jqueryjs', 'transit', 'nano', 'cookie', 'storage', 'ui'],
function($) {
  // jQuery.transit fallback to $.fn.animate
  if (!$.support.transition) { $.fn.transition = $.fn.animate; }

  $.fn.transitIn = function(speed, easing, callback) {
    this.css({ display: 'block' });
    this.transition({ opacity: 1 }, speed, easing, function() {
      typeof callback === 'function' && callback.call(this);
    });
  };

  $.fn.transitOut = function(speed, easing, callback) {
    this.transition({ opacity: 0 }, speed, easing, function() {
    this.css({ display: 'none' });
      typeof callback === 'function' && callback.call(this);
    });
  };

  return $; // $.noConflict(false);
});
<|endoftext|>