<commit_before>/**
 * https://webaudio.github.io/web-audio-api/#widl-AnalyserNode-getByteFrequencyData-void-Uint8Array-array
 * getByte: value between 0 and 255.
 * getFloat: dB
 * getTime: waveform
 * getFrequency: after fft https://webaudio.github.io/web-audio-api/#current-frequency-data
 * https://stackoverflow.com/questions/24083349/understanding-getbytetimedomaindata-and-getbytefrequencydata-in-web-audio
 */

function smoothVolume(value) {
    return value / 255;
}

/**
 * Compute the rms (root mean square) of all measured samples
 * given in array. The unit of measured samples in dB units.
 */
function getRmsVolume(analyser, array) {
    analyser.getByteTimeDomainData(array);
    const length = array.length;
    let total = 0;
    for (let i = 0; i < length; i++) {
        total += array[i] * array[i];
    }
    return smoothVolume(Math.sqrt(total / length));
}

/**
 * Returns an object with the getRmsVolume method.
 */
function createAudioMeter(audioContext, mediaStreamSource) {
    var analyser = audioContext.createAnalyser();
    analyser.fftSize = 256;
    var array = new Uint8Array(analyser.fftSize);
    mediaStreamSource.connect(analyser);
    return {analyser: analyser,
            array: array,
            getRmsVolume: function () {
                return getRmsVolume(this.analyser, this.array);
            },
           };
}

/**
 * Creates an audioMeter and starts measuring and displaying
 * measured volume samples.
 * The measuring and displaying can be stopped by calling stop() on the returned
 * object.
 */
function start(audioContext, mediaStreamSource) {
    var meter = createAudioMeter(audioContext, mediaStreamSource);
    var callEveryMs = 100;
    var meterRunner = {
        ended: false,
        meter: meter,
        i: -1,
        plotEvery: 10,
        data: [],
        delay: [],
        formatData: function(x, y) {
            return [x,y];
        },
        pushData: function() {
            var currTime = new Date().getTime();
            var prevIndex = this.data.length - 1;
            if (prevIndex > 0) {
                var delay = currTime - this.data[prevIndex][0]
                this.delay.push(this.formatData(currTime, delay));
            }
            this.data.push(this.formatData(currTime,
                                           this.meter.getRmsVolume()));
        },
        measureAndPlotIfNeeded: function() {
            this.pushData();
            this.i += 1;
            if (this.i % this.plotEvery == 0) {
                var views = chrome.extension.getViews({type: "popup"});
                for (var i = 0; i < views.length; i++) {
                    var view = views[i];
                    if (view.plotData) {
                        view.plotData(this.data, {"title": "volume",
                                                  "yAxisTitle": ""},
                                      "volume");
                        view.plotData(this.delay, {"title": "delay",
                                                   "yAxisTitle": "ms"},
                                      "delay");
                    }
                }
                this.i = 0;
            }
        },
        stop: function () {
            this.ended = true;
            if (this.refreshIntervalId != null) {
                clearInterval(this.refreshIntervalId);
                this.refreshIntervalId = null;
            }
        },
        refreshIntervalId: null,
    };
    this.refreshIntervalId = setInterval(function () {
        meterRunner.measureAndPlotIfNeeded();
    }, callEveryMs);
    return meterRunner;
}
<commit_msg>Only plot the last 100 values<commit_after>/**
 * https://webaudio.github.io/web-audio-api/#widl-AnalyserNode-getByteFrequencyData-void-Uint8Array-array
 * getByte: value between 0 and 255.
 * getFloat: dB
 * getTime: waveform
 * getFrequency: after fft https://webaudio.github.io/web-audio-api/#current-frequency-data
 * https://stackoverflow.com/questions/24083349/understanding-getbytetimedomaindata-and-getbytefrequencydata-in-web-audio
 */

function smoothVolume(value) {
    return value / 255;
}

/**
 * Compute the rms (root mean square) of all measured samples
 * given in array. The unit of measured samples in dB units.
 */
function getRmsVolume(analyser, array) {
    analyser.getByteTimeDomainData(array);
    const length = array.length;
    let total = 0;
    for (let i = 0; i < length; i++) {
        total += array[i] * array[i];
    }
    return smoothVolume(Math.sqrt(total / length));
}

/**
 * Returns an object with the getRmsVolume method.
 */
function createAudioMeter(audioContext, mediaStreamSource) {
    var analyser = audioContext.createAnalyser();
    analyser.fftSize = 256;
    var array = new Uint8Array(analyser.fftSize);
    mediaStreamSource.connect(analyser);
    return {analyser: analyser,
            array: array,
            getRmsVolume: function () {
                return getRmsVolume(this.analyser, this.array);
            },
           };
}

/**
 * Creates an audioMeter and starts measuring and displaying
 * measured volume samples.
 * The measuring and displaying can be stopped by calling stop() on the returned
 * object.
 */
function start(audioContext, mediaStreamSource) {
    var meter = createAudioMeter(audioContext, mediaStreamSource);
    var callEveryMs = 100;
    var meterRunner = {
        ended: false,
        meter: meter,
        i: -1,
        plotEvery: 10,
        data: [],
        plottedWindowSize: 100,
        delay: [],
        formatData: function(x, y) {
            return [x,y];
        },
        manageDataWindow: function() {
            if (this.data.length > this.plottedWindowSize) {
                const toRemove = this.data.length - this.plottedWindowSize
                this.data = this.data.slice(toRemove, this.data.length);
            }
        },
        pushData: function() {
            var currTime = new Date().getTime();
            var prevIndex = this.data.length - 1;
            if (prevIndex > 0) {
                var delay = currTime - this.data[prevIndex][0]
                this.delay.push(this.formatData(currTime, delay));
            }
            this.manageDataWindow();
            this.data.push(this.formatData(currTime,
                                           this.meter.getRmsVolume()));
        },
        measureAndPlotIfNeeded: function() {
            this.pushData();
            this.i += 1;
            if (this.i % this.plotEvery == 0) {
                var views = chrome.extension.getViews({type: "popup"});
                for (var i = 0; i < views.length; i++) {
                    var view = views[i];
                    if (view.plotData) {
                        view.plotData(this.data, {"title": "volume",
                                                  "yAxisTitle": ""},
                                      "volume");
                        view.plotData(this.delay, {"title": "delay",
                                                   "yAxisTitle": "ms"},
                                      "delay");
                    }
                }
                this.i = 0;
            }
        },
        stop: function () {
            this.ended = true;
            if (this.refreshIntervalId != null) {
                clearInterval(this.refreshIntervalId);
                this.refreshIntervalId = null;
            }
        },
        refreshIntervalId: null,
    };
    this.refreshIntervalId = setInterval(function () {
        meterRunner.measureAndPlotIfNeeded();
    }, callEveryMs);
    return meterRunner;
}
<|endoftext|>


<commit_before>import React from 'react';
import { View } from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { addNavigationHelpers, TabNavigator } from 'react-navigation';
import { NavigationComponent } from 'react-native-material-bottom-navigation';
import Icon from 'react-native-vector-icons/MaterialIcons';

import ProfileNavigator from './ProfileNavigator';
import foiRequestsNavigator from './FoiRequestsNavigator';
import { primaryColor, greyDark, greyLight } from '../styles/colors';

// class Requests extends React.Component {
//   static navigationOptions = {
//     tabBarLabel: 'Requests',
//     tabBarIcon: () => (<Icon size={24} color="black" name="list" />)
//   }

//   render() { return <View></View> }
// }

class Search extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'Search',
    tabBarIcon: () => <Icon size={24} color={greyDark} name="search" />,
  };

  render() {
    return <View />;
  }
}

class NewRequest extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'New',
    tabBarIcon: () => <Icon size={24} color={greyDark} name="add" />,
  };

  render() {
    return <View />;
  }
}

export const AppNavigator = TabNavigator(
  {
    Requests: { screen: foiRequestsNavigator },
    Search: { screen: Search },
    NewRequest: { screen: NewRequest },
    Profile: { screen: ProfileNavigator },
  },
  {
    tabBarComponent: NavigationComponent,
    tabBarPosition: 'bottom',
    lazy: true,
    tabBarOptions: {
      bottomNavigationOptions: {
        labelColor: primaryColor,
        rippleColor: 'white',
        backgroundColor: 'white',
        style: {
          borderTopWidth: 1,
          borderTopColor: greyLight,
        },
        tabs: {
          Requests: {
            activeIcon: <Icon size={24} color={primaryColor} name="list" />,
          },
          Search: {
            activeIcon: <Icon size={24} color={primaryColor} name="search" />,
          },
          NewRequest: {
            activeIcon: <Icon size={24} color={primaryColor} name="add" />,
          },
          Profile: {
            activeIcon: <Icon size={24} color={primaryColor} name="person" />,
          },
        },
      },
    },
  }
);

const AppWithNavigationState = ({ dispatch, navigation }) =>
  <AppNavigator
    navigation={addNavigationHelpers({ dispatch, state: navigation })}
  />;

AppWithNavigationState.propTypes = {
  dispatch: PropTypes.func.isRequired,
  navigation: PropTypes.object.isRequired,
};

const mapStateToProps = state => ({
  navigation: state.navigation,
});

export default connect(mapStateToProps)(AppWithNavigationState);
<commit_msg>add support for back button on android<commit_after>import React from 'react';
import { View, BackHandler } from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
  addNavigationHelpers,
  TabNavigator,
  NavigationActions,
} from 'react-navigation';
import { NavigationComponent } from 'react-native-material-bottom-navigation';
import Icon from 'react-native-vector-icons/MaterialIcons';

import ProfileNavigator from './ProfileNavigator';
import foiRequestsNavigator from './FoiRequestsNavigator';
import { primaryColor, greyDark, greyLight } from '../styles/colors';

// class Requests extends React.Component {
//   static navigationOptions = {
//     tabBarLabel: 'Requests',
//     tabBarIcon: () => (<Icon size={24} color="black" name="list" />)
//   }

//   render() { return <View></View> }
// }

class Search extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'Search',
    tabBarIcon: () => <Icon size={24} color={greyDark} name="search" />,
  };

  render() {
    return <View />;
  }
}

class NewRequest extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'New',
    tabBarIcon: () => <Icon size={24} color={greyDark} name="add" />,
  };

  render() {
    return <View />;
  }
}

export const AppNavigator = TabNavigator(
  {
    Requests: { screen: foiRequestsNavigator },
    Search: { screen: Search },
    NewRequest: { screen: NewRequest },
    Profile: { screen: ProfileNavigator },
  },
  {
    tabBarComponent: NavigationComponent,
    tabBarPosition: 'bottom',
    lazy: true,
    tabBarOptions: {
      bottomNavigationOptions: {
        labelColor: primaryColor,
        rippleColor: 'white',
        backgroundColor: 'white',
        style: {
          borderTopWidth: 1,
          borderTopColor: greyLight,
        },
        tabs: {
          Requests: {
            activeIcon: <Icon size={24} color={primaryColor} name="list" />,
          },
          Search: {
            activeIcon: <Icon size={24} color={primaryColor} name="search" />,
          },
          NewRequest: {
            activeIcon: <Icon size={24} color={primaryColor} name="add" />,
          },
          Profile: {
            activeIcon: <Icon size={24} color={primaryColor} name="person" />,
          },
        },
      },
    },
  }
);

class AppWithNavigationState extends React.Component {
  componentDidMount() {
    BackHandler.addEventListener('hardwareBackPress', this.onBackPress);
  }

  componentWillUnmount() {
    BackHandler.removeEventListener('hardwareBackPress', this.onBackPress);
  }

  onBackPress = () => {
    const { dispatch, navigation } = this.props;

    // close the app when pressing back button on initial screen
    if (navigation.index === 0 && navigation.routes[0].index === 0) {
      return false;
    }

    dispatch(NavigationActions.back());
    return true;
  };

  render() {
    const { dispatch, navigation } = this.props;

    return (
      <AppNavigator
        navigation={addNavigationHelpers({ dispatch, state: navigation })}
      />
    );
  }
}

AppWithNavigationState.propTypes = {
  dispatch: PropTypes.func.isRequired,
  navigation: PropTypes.object.isRequired,
};

const mapStateToProps = state => ({
  navigation: state.navigation,
});

export default connect(mapStateToProps)(AppWithNavigationState);
<|endoftext|>


<commit_before>/**
 * Comment template.
 * @param {string} foo This is a param with a description too long to fit in
 *     one line.
 * @return {number} This returns something that has a description too long to
 *     fit in one line.
 */

var Gallery = (function() {
  "use strict";

  var Gallery = {

    gatherLinks: function(callback) {
      $.get("http://localhost:8080/uploads", function(data) {
        callback(data);
      //  alert( "Load was performed."+JSON.stringify(data,false,4));
      });
    }
  };

  return Gallery;
}());
<commit_msg>added cors<commit_after>/**
 * Comment template.
 * @param {string} foo This is a param with a description too long to fit in
 *     one line.
 * @return {number} This returns something that has a description too long to
 *     fit in one line.
 */

var Gallery = (function() {
  "use strict";

  var Gallery = {

    gatherLinks: function(callback) {
      $.get("http://127.0.0.1:8080/uploads", function(data) {
        callback(data);
      //  alert( "Load was performed."+JSON.stringify(data,false,4));
      });
    }
  };

  return Gallery;
}());
<|endoftext|>


<commit_before>import React from 'react'
import { Switch, Route } from 'react-router-dom'
import Home from './Home'

var imageStyles = {
    width: '450px',
    height: '350px'
}

const About = () => (

Marvelus - Canvas Group 15

            {/*  */}

Marvelus is for users who want to browse superheros, movies, TV shows, comics, creators, events having to do with the Marvel Universe.

Group Members

 Andrew Martin

Bio:  Andrew Martin is a third year Computer Science student, expecting to graduate at the end of this year. I am also interested in music and linguistics, and I love to travel.

Responsibilities:  TV Shows

No. of Commits: 31

No. of Issues:  6

No. of Unit Tests:  0

 Bhavish Yalamanchi

Bio:  I am a senior studying CS. I am currently exploring my options and figuring out what I want to specialize in. I am currently interested in Data Science and am learning how to use TensorFlow in my freetime. I also love making music and photography. Whether it be photos, videos, or music, I think art is an important outlet that everyone should try.

Responsibilities: Events

No. of Commits: 8

No. of Issues:  4

No. of Commits:  4

No. of Issues:

No. of Unit Tests:  0

Hannah Anees

Bio:  Hannah Anees is in her third year of Computer Science at the University of Texas and will be graduating in 2019 with a Bachelor’s of Science degree. She enjoys conspiracy theories, urban myths and legends and anything else that might make the world seem more interesting. She also is interested in music and TV Shows and only tolerates some of the Marvel creations, most notably Spider-Man.

Responsibilities: Actors

No. of Commits: 21

No. of Issues:  4

No. of Unit Tests:  0

Helen Salgi

Bio: Sophomore majoring in Linguistics. Loves traveling and food and will be graduating in May 2020.

Observer

Sunaina Krishnamoorthy

Bio:  Sunaina Krishnamoorthy is a junior majoring in Computer Science at the University of Texas. She loves travel, photography and music. She will be graduating in May of 2019 with a Bachelor's degree in Computer Science.

Responsibilities: Movies

No. of Commits: 13

No. of Issues:  4

No. of Unit Tests:  0

Tesia Wu

Bio:  Tesia Wu is a junior majoring in Computer Science at the University of Texas. She is a huge fan of the Korean boy band BTS and loves music and movies, especially the Marvel Cinematic Universe. She will be graduating in May of 2019 with a Bachelor's degree in Computer Science.

Responsibilities: Characters and Comics

No. of Commits: 24

No. of Issues:  4

No. of Unit Tests:  0

Statistics

Total No. of Commits:

Total No. of Issues:

Total No. of Unit Tests:  0

Apiary API

GITHUB REPO

TRELLO

Data

                {/*  */}

https://developer.marvel.com/docs

https://comicvine.gamespot.com/api/documentation

The Movie Database

Tools used

            Technical report

)

export default About
<commit_msg>Made the API links clickable and added how we scrape them<commit_after>import React from 'react'
import { Switch, Route } from 'react-router-dom'
import Home from './Home'

var imageStyles = {
    width: '450px',
    height: '350px'
}

const About = () => (

Marvelus - Canvas Group 15

            {/*  */}

Marvelus is for users who want to browse superheros, movies, TV shows, comics, creators, events having to do with the Marvel Universe.

Group Members

 Andrew Martin

Bio:  Andrew Martin is a third year Computer Science student, expecting to graduate at the end of this year. I am also interested in music and linguistics, and I love to travel.

Responsibilities:  TV Shows

No. of Commits: 31

No. of Issues:  6

No. of Unit Tests:  0

 Bhavish Yalamanchi

Bio:  I am a senior studying CS. I am currently exploring my options and figuring out what I want to specialize in. I am currently interested in Data Science and am learning how to use TensorFlow in my freetime. I also love making music and photography. Whether it be photos, videos, or music, I think art is an important outlet that everyone should try.

Responsibilities: Events

No. of Commits: 8

No. of Issues:  4

No. of Commits:  4

No. of Issues:

No. of Unit Tests:  0

Hannah Anees

Bio:  Hannah Anees is in her third year of Computer Science at the University of Texas and will be graduating in 2019 with a Bachelor’s of Science degree. She enjoys conspiracy theories, urban myths and legends and anything else that might make the world seem more interesting. She also is interested in music and TV Shows and only tolerates some of the Marvel creations, most notably Spider-Man.

Responsibilities: Actors

No. of Commits: 21

No. of Issues:  4

No. of Unit Tests:  0

Helen Salgi

Bio: Sophomore majoring in Linguistics. Loves traveling and food and will be graduating in May 2020.

Observer

Sunaina Krishnamoorthy

Bio:  Sunaina Krishnamoorthy is a junior majoring in Computer Science at the University of Texas. She loves travel, photography and music. She will be graduating in May of 2019 with a Bachelor's degree in Computer Science.

Responsibilities: Movies

No. of Commits: 13

No. of Issues:  4

No. of Unit Tests:  0

Tesia Wu

Bio:  Tesia Wu is a junior majoring in Computer Science at the University of Texas. She is a huge fan of the Korean boy band BTS and loves music and movies, especially the Marvel Cinematic Universe. She will be graduating in May of 2019 with a Bachelor's degree in Computer Science.

Responsibilities: Characters and Comics

No. of Commits: 24

No. of Issues:  4

No. of Unit Tests:  0

Statistics

Total No. of Commits:

Total No. of Issues:

Total No. of Unit Tests:  0

Apiary API

GITHUB REPO

TRELLO

Data

                {/*  */}

 Marvel API
 We did not use any specific libraries to scrape the Marvel API, just the python requests module.

The Movie Database
We used the tmdbsimple library to scrape data from the tmdb API

The Movie Database

Tools used

            Technical report

)

export default About
<|endoftext|>


<commit_before>define(['jquery', 'backbone', 'underscore', 'moxie.conf', 'places/views/ItemView', 'hbs!places/templates/search', 'hbs!places/templates/facets', 'core/views/InfiniteScrollView'],
    function($, Backbone, _, MoxieConf, ItemView, searchTemplate, facetTemplate, InfiniteScrollView){

    var SearchView = InfiniteScrollView.extend({

        // View constructor
        initialize: function() {
            _.bindAll(this);
            this.collection.followUser();
            this.collection.on("reset", this.render, this);
            this.collection.on("add", this.addResult, this);
        },

        manage: true,

        // Event Handlers
        events: {
            'keypress :input': "searchEvent",
            'click .deleteicon': "clearSearch",
            'click .facet-list > li[data-category]': "clickFacet"
        },

        clearSearch: function(e) {
            this.$('.search-input input').val('').focus();
        },

        clickFacet: function(e) {
            e.preventDefault();
            this.collection.query.type = $(e.target).data('category');
            this.collection.geoFetch();
            Backbone.history.navigate('/places/search?'+$.param(this.collection.query).replace(/\+/g, "%20"), {trigger: false});
        },

        searchEvent: function(ev) {
            if (ev.which === 13) {
                this.collection.query.q = ev.target.value;
                this.collection.geoFetch();
                Backbone.history.navigate('/places/search?'+$.param(this.collection.query).replace(/\+/g, "%20"), {trigger: false});
            }
        },

        addResult: function(model) {
            var view = new ItemView({model: model});
            this.insertView("ul.results-list", view);
            view.render();
        },

        template: searchTemplate,
        serialize: function() {
            var context = {query: this.collection.query, facets: [], hasResults: Boolean(this.collection.length)};
            if (this.collection.query.q || this.collection.query.type) {
                context.facets = this.collection.facets;
            }
            return context;
        },

        beforeRender: function() {
            Backbone.trigger('domchange:title', "Search for Places of Interest");
            if (this.collection.length) {
                var views = [];
                this.collection.each(function(model) { views.push(new ItemView({model: model})); });
                this.insertViews({"ul.results-list": views});
            }
        },

        afterRender: function() {
            var options = {windowScroll: true, scrollElement: this.el, scrollThreshold: 0.7};
            InfiniteScrollView.prototype.initScroll.apply(this, [options]);
        },

        scrollCallbacks: [function() {
            this.collection.fetchNextPage();
        }],

        extendPOIs: function(data) {
            // Used when the collection is extended through infinite scrolling
            this.next_results = data._links['hl:next'];
            this.infiniteScrollEnabled = Boolean(this.next_results);
            this.collection.facets = data._links['hl:types'];
            this.collection.add(data._embedded);
            this.setMapBounds();
        },

        cleanup: function() {
            this.collection.unfollowUser();
            InfiniteScrollView.prototype.onClose.apply(this);
        }
    });

    // Returns the View class
    return SearchView;
});
<commit_msg>Only show facets if we have more than one<commit_after>define(['jquery', 'backbone', 'underscore', 'moxie.conf', 'places/views/ItemView', 'hbs!places/templates/search', 'hbs!places/templates/facets', 'core/views/InfiniteScrollView'],
    function($, Backbone, _, MoxieConf, ItemView, searchTemplate, facetTemplate, InfiniteScrollView){

    var SearchView = InfiniteScrollView.extend({

        // View constructor
        initialize: function() {
            _.bindAll(this);
            this.collection.followUser();
            this.collection.on("reset", this.render, this);
            this.collection.on("add", this.addResult, this);
        },

        manage: true,

        // Event Handlers
        events: {
            'keypress :input': "searchEvent",
            'click .deleteicon': "clearSearch",
            'click .facet-list > li[data-category]': "clickFacet"
        },

        clearSearch: function(e) {
            this.$('.search-input input').val('').focus();
        },

        clickFacet: function(e) {
            e.preventDefault();
            this.collection.query.type = $(e.target).data('category');
            this.collection.geoFetch();
            Backbone.history.navigate('/places/search?'+$.param(this.collection.query).replace(/\+/g, "%20"), {trigger: false});
        },

        searchEvent: function(ev) {
            if (ev.which === 13) {
                this.collection.query.q = ev.target.value;
                this.collection.geoFetch();
                Backbone.history.navigate('/places/search?'+$.param(this.collection.query).replace(/\+/g, "%20"), {trigger: false});
            }
        },

        addResult: function(model) {
            var view = new ItemView({model: model});
            this.insertView("ul.results-list", view);
            view.render();
        },

        template: searchTemplate,
        serialize: function() {
            var context = {query: this.collection.query, facets: [], hasResults: Boolean(this.collection.length)};
            if (this.collection.facets && (this.collection.query.q || this.collection.query.type) && this.collection.facets.length > 1) {
                context.facets = this.collection.facets;
            }
            return context;
        },

        beforeRender: function() {
            Backbone.trigger('domchange:title', "Search for Places of Interest");
            if (this.collection.length) {
                var views = [];
                this.collection.each(function(model) { views.push(new ItemView({model: model})); });
                this.insertViews({"ul.results-list": views});
            }
        },

        afterRender: function() {
            var options = {windowScroll: true, scrollElement: this.el, scrollThreshold: 0.7};
            InfiniteScrollView.prototype.initScroll.apply(this, [options]);
        },

        scrollCallbacks: [function() {
            this.collection.fetchNextPage();
        }],

        extendPOIs: function(data) {
            // Used when the collection is extended through infinite scrolling
            this.next_results = data._links['hl:next'];
            this.infiniteScrollEnabled = Boolean(this.next_results);
            this.collection.facets = data._links['hl:types'];
            this.collection.add(data._embedded);
            this.setMapBounds();
        },

        cleanup: function() {
            this.collection.unfollowUser();
            InfiniteScrollView.prototype.onClose.apply(this);
        }
    });

    // Returns the View class
    return SearchView;
});
<|endoftext|>


<commit_before>import EventEmitter from 'events';
import { EASING } from './easing';

/**
 * Base class for creating other animations.
 * Each custom animation must extends from this class.
 *
 * @since 1.0.0
 */
export default class Basic extends EventEmitter {
  /**
   * Creates animation class that has {@link animate} method for animating properties in the shape.
   *
   * @constructor
   * @param {Object} [options]
   * @param {Number} [options.duration=1000]
   * @param {String} [options.easing='outQuad']
   */
  constructor(options = {}) {
    super();

    this.EASING = EASING;
    this._options = options;

    this.setDuration(options.duration);
    this.setEasing(options.easing);
  }

  /**
   * Get option value.
   *
   * @param {String} path Path can be set with dot-notation
   * @returns {*}
   */
  get(path) {
    return path.split('.').reduce((obj, key) => obj && obj[key], this._options);
  }

  /**
   * Set new option value.
   *
   * @param {String} path Path can be set with dot-notation
   * @param {*} value Value that need to be written to the options object
   * @returns {Basic}
   */
  set(path, value) {
    let obj = this._options;
    let tags = path.split('.');
    let len = tags.length - 1;

    for (let i = 0; i < len; i++) {
      if (typeof obj[tags[i]] === 'undefined') obj[tags[i]] = {};
      obj = obj[tags[i]];
    }

    obj[tags[len]] = value;

    return this;
  }

  /**
   * Get animation duration in ms.
   *
   * @returns {Number}
   */
  getDuration() {
    return this.get('duration');
  }

  /**
   * Set new animation duration in ms.
   *
   * @param {Number} [duration=1000]
   * @returns {Basic}
   */
  setDuration(duration = 1000) {
    return this.set('duration', duration);
  }

  /**
   * Get easing name.
   *
   * @returns {String}
   */
  getEasing() {
    return this.get('easing');
  }

  /**
   * Set new easing for animation.
   *
   * @param {String} [easing='outQuad']
   * @returns {Basic}
   */
  setEasing(easing = 'outQuad') {
    return this.set('easing', easing);
  }

  /**
   * Method accepts shape and cursor instances.
   *
   * @abstract
   * @param {Shape} shape Shape instance that need to be animated
   * @param {Cursor} cursor Cursor instance that you can use for rendering other stuff
   */
  animate(shape, cursor) {
    throw new Error('You must implement animate() method');
  }

  /**
   * Animates property in object.
   * Each time when property animates, it emits tick event.
   *
   * @param {Object} options
   * @param {Object} options.shape Target object where property is need to be animated
   * @param {String} options.property Property name that need to be animated
   * @param {Number} [options.startValue] Start value for animation, by default it takes from obj[property]
   * @param {Number} [options.endValue] End value for animation, by default it 100
   * @param {Number} [options.byValue] Step value for easing
   * @param {Number} [options.duration] Duration of the animation in ms, by default it takes from Animation options
   * @param {String} [options.easing] Easing that need to apply to animation, by default easing from Animation options
   */
  animateProperty(options = {}) {
    const shape = options.shape;
    const property = options.property;
    const startValue = options.startValue || shape.get(property);
    const endValue = options.endValue || 100;
    const byValue = options.byValue || (endValue - startValue);
    const duration = options.duration || this.getDuration();
    const easing = options.easing || this.getEasing();
    const delay = duration / (endValue - startValue);
    const start = Date.now();
    const end = start + duration;

    setTimeout(function tick() {
      let time = Date.now();
      let currentTime = time > end ? duration : (time - start);

      if (time > end) {
        this.emit('end', shape, property);
      } else {
        let newValue = Math.round(this.EASING[easing](currentTime, startValue, byValue, duration));
        shape.set(property, newValue);
        this.emit('tick', shape, property, newValue);
        setTimeout(tick.bind(this), delay);
      }
    }.bind(this), delay);

    return this;
  }
}
<commit_msg>feat(animation): Implement check if easing is not exists<commit_after>import EventEmitter from 'events';
import { EASING } from './easing';

/**
 * Base class for creating other animations.
 * Each custom animation must extends from this class.
 *
 * @since 1.0.0
 */
export default class Basic extends EventEmitter {
  /**
   * Creates animation class that has {@link animate} method for animating properties in the shape.
   *
   * @constructor
   * @param {Object} [options]
   * @param {Number} [options.duration=1000]
   * @param {String} [options.easing='outQuad']
   */
  constructor(options = {}) {
    super();

    this.EASING = EASING;
    this._options = options;

    this.setDuration(options.duration);
    this.setEasing(options.easing);
  }

  /**
   * Get option value.
   *
   * @param {String} path Path can be set with dot-notation
   * @returns {*}
   */
  get(path) {
    return path.split('.').reduce((obj, key) => obj && obj[key], this._options);
  }

  /**
   * Set new option value.
   *
   * @param {String} path Path can be set with dot-notation
   * @param {*} value Value that need to be written to the options object
   * @returns {Basic}
   */
  set(path, value) {
    let obj = this._options;
    let tags = path.split('.');
    let len = tags.length - 1;

    for (let i = 0; i < len; i++) {
      if (typeof obj[tags[i]] === 'undefined') obj[tags[i]] = {};
      obj = obj[tags[i]];
    }

    obj[tags[len]] = value;

    return this;
  }

  /**
   * Get animation duration in ms.
   *
   * @returns {Number}
   */
  getDuration() {
    return this.get('duration');
  }

  /**
   * Set new animation duration in ms.
   *
   * @param {Number} [duration=1000]
   * @returns {Basic}
   */
  setDuration(duration = 1000) {
    return this.set('duration', duration);
  }

  /**
   * Get easing name.
   *
   * @returns {String}
   */
  getEasing() {
    return this.get('easing');
  }

  /**
   * Set new easing for animation.
   *
   * @param {String} [easing='outQuad']
   * @returns {Basic}
   */
  setEasing(easing = 'outQuad') {
    if (typeof this.EASING[easing] !== 'function') throw new Error(`Unknown easing: ${easing}`);
    return this.set('easing', easing);
  }

  /**
   * Method accepts shape and cursor instances.
   *
   * @abstract
   * @param {Shape} shape Shape instance that need to be animated
   * @param {Cursor} cursor Cursor instance that you can use for rendering other stuff
   */
  animate(shape, cursor) {
    throw new Error('You must implement animate() method');
  }

  /**
   * Animates property in object.
   * Each time when property animates, it emits tick event.
   *
   * @param {Object} options
   * @param {Object} options.shape Target object where property is need to be animated
   * @param {String} options.property Property name that need to be animated
   * @param {Number} [options.startValue] Start value for animation, by default it takes from obj[property]
   * @param {Number} [options.endValue] End value for animation, by default it 100
   * @param {Number} [options.byValue] Step value for easing
   * @param {Number} [options.duration] Duration of the animation in ms, by default it takes from Animation options
   * @param {String} [options.easing] Easing that need to apply to animation, by default easing from Animation options
   */
  animateProperty(options = {}) {
    const shape = options.shape;
    const property = options.property;
    const startValue = options.startValue || shape.get(property);
    const endValue = options.endValue || 100;
    const byValue = options.byValue || (endValue - startValue);
    const duration = options.duration || this.getDuration();
    const easing = options.easing || this.getEasing();
    const delay = duration / (endValue - startValue);
    const start = Date.now();
    const end = start + duration;

    setTimeout(function tick() {
      let time = Date.now();
      let currentTime = time > end ? duration : (time - start);

      if (time > end) {
        this.emit('end', shape, property);
      } else {
        let newValue = Math.round(this.EASING[easing](currentTime, startValue, byValue, duration));
        shape.set(property, newValue);
        this.emit('tick', shape, property, newValue);
        setTimeout(tick.bind(this), delay);
      }
    }.bind(this), delay);

    return this;
  }
}
<|endoftext|>


<commit_before>/*
* Cepat Sembuh v1.0
* Copyright 2016 Cepat Sembuh
*/

document.addEventListener('deviceready', function () {
    Firebase.goOnline();
});

// Example faskes action
$('#not-available').on('click', function() {
	alert('Faskes is not available.')
})

function getNoAntri(tipe, username, name) {
  grease = '../poli/' + username + '.html';
  window.location.href = grease;
}

function tempatTidur(tipe, username) {
  // Firebase URL
  brea = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/tempat_tidur');

  // Waiting message
  wait = 'Getting data..';
  console.log(wait);
  alert(wait);

  // Get the data
  brea.on('value', function(snapshot) {
    satu = snapshot.val().satu;
    dua = snapshot.val().dua;
    tiga = snapshot.val().tiga;

    alert('Kelas I: ' + Number(satu) + '\n' + 'Kelas II: ' + Number(dua) + '\n' + 'Kelas III: ' + Number(tiga)); // Show user the data's
  })
}

function doctorProfile(nama, lulusan, tahun) {
  giant = 'Lulusan: ' + lulusan + '\n' + 'Tahun: ' + tahun; // Doctor content
  name = 'dr. ' + nama; // Doctor name

  alert(name + '\n' + giant); // Pop-up
}

function pilihPoli(username) {
  var nama = $('#nama').val(),
      nik = $('#nik').val(),
      dipper = $('#durasi').val(),
      poli = $('#poli').val();

  dipcifica = new Firebase('https://cepatsembuh.firebaseio.com/puskesmas/faskes/' + username),

  date = new Date(),
  year = date.getFullYear(),
  month = date.getMonth() + 1,
  day = date.getDate(),
  hour = date.getHours(),
  minute = date.getMinutes(),
  right_now = year + '-' + month + '-' + day,
  today = dipcifica.child(right_now),

  hour = dipcifica.child('jam'),
  minute = dipcifica.child('menit'),

  bpu = dipcifica.child('bpu'),
  bpg = dipcifica.child('bpg'),
  kia = dipcifica.child('kia'),

  bpu_pasien = today.child('bpu-pasien'),
  bpg_pasien = today.child('bpg-pasien'),
  kia_pasien = today.child('kia-pasien');

  if (username !== 'kelapa_gading') {
    alert('Fitur ini tidak tersedia di puskesmas anda')
  } else {
    if (nama === '' || nik.length != 16) {
      alert('Input tidak valid')
    } else {
      minute.transaction(function(currentRank){
        currentData = Number(currentRank) + Number(dipper);
        return currentData;
      })
      switch (poli) {
        // BPU
        case 'bpu':
          bpu.transaction(function(currentRank) {
            currentData = currentRank + 1;

            return currentData;
            }, function(error, committed, snapshot) {
                if (error) {
                    // Error message
                    alert('Terjadi kesahalah saat mengambil data');
                } else {
                    // Send the Data
                    alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                    // Push the prompt data
                    bpu_pasien.push().set({
                      nama: nama,
                      nik: nik,
                      no_antri: snapshot.val(),
                      poli: 'BPU',
                      jam: hour,
                      menit: minute
                    })
                }
            });
          break;

        // BPG
        case 'bpg':
          bpg.transaction(function(currentRank) {
            currentData = currentRank + 1;

            return currentData;
            }, function(error, committed, snapshot) {
                if (error) {
                    // Error message
                    alert('Terjadi kesahalah saat mengambil data');
                } else {
                    // Send the Data
                    alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                    // Push the prompt data
                    bpg_pasien.push().set({
                      nama: nama,
                      nik: nik,
                      no_antri: snapshot.val(),
                      poli: 'BPG',
                      jam: hour,
                      menit: minute
                    })
                }
            });
          break;

        // KIA
        case 'kia':
          kia.transaction(function(currentRank) {
            currentData = currentRank + 1;

            return currentData;
            }, function(error, committed, snapshot) {
                if (error) {
                    // Error message
                    alert('Terjadi kesahalah saat mengambil data');
                } else {
                    // Send the Data
                    alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                    // Push the prompt data
                    kia_pasien.push().set({
                      nama: nama,
                      nik: nik,
                      no_antri: snapshot.val(),
                      poli: 'KIA',
                      jam: hour,
                      menit: minute
                    })
                }
            });
          break;

          // Null handler
          case null:
            alert('Anda belum memilih poli');
            break;
      }
    }
  }
}
<commit_msg>Friendly message while getting data<commit_after>/*
* Cepat Sembuh v1.0
* Copyright 2016 Cepat Sembuh
*/

document.addEventListener('deviceready', function () {
    Firebase.goOnline();
});

// Example faskes action
$('#not-available').on('click', function() {
	alert('Faskes is not available.')
})

function getNoAntri(tipe, username, name) {
  grease = '../poli/' + username + '.html';
  window.location.href = grease;
}

function tempatTidur(tipe, username) {
  // Firebase URL
  brea = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/tempat_tidur');

  // Waiting message
  wait = 'Getting data..';
  console.log(wait);
  alert(wait);

  // Get the data
  brea.on('value', function(snapshot) {
    satu = snapshot.val().satu;
    dua = snapshot.val().dua;
    tiga = snapshot.val().tiga;

    alert('Kelas I: ' + Number(satu) + '\n' + 'Kelas II: ' + Number(dua) + '\n' + 'Kelas III: ' + Number(tiga)); // Show user the data's
  })
}

function doctorProfile(nama, lulusan, tahun) {
  giant = 'Lulusan: ' + lulusan + '\n' + 'Tahun: ' + tahun; // Doctor content
  name = 'dr. ' + nama; // Doctor name

  alert(name + '\n' + giant); // Pop-up
}

function pilihPoli(username) {
  var nama = $('#nama').val(),
      nik = $('#nik').val(),
      dipper = $('#durasi').val(),
      poli = $('#poli').val();

  dipcifica = new Firebase('https://cepatsembuh.firebaseio.com/puskesmas/faskes/' + username),

  date = new Date(),
  year = date.getFullYear(),
  month = date.getMonth() + 1,
  day = date.getDate(),
  hour = date.getHours(),
  minute = date.getMinutes(),
  right_now = year + '-' + month + '-' + day,
  today = dipcifica.child(right_now),

  hour = dipcifica.child('jam'),
  minute = dipcifica.child('menit'),

  bpu = dipcifica.child('bpu'),
  bpg = dipcifica.child('bpg'),
  kia = dipcifica.child('kia'),

  bpu_pasien = today.child('bpu-pasien'),
  bpg_pasien = today.child('bpg-pasien'),
  kia_pasien = today.child('kia-pasien');

  if (username !== 'kelapa_gading') {
    alert('Fitur ini tidak tersedia di puskesmas anda')
  } else {
    if (nama === '' || nik.length != 16) {
      alert('Input tidak valid')
    } else {
      minute.transaction(function(currentRank){
        currentData = Number(currentRank) + Number(dipper);
        return currentData;
      })
      switch (poli) {
        // BPU
        case 'bpu':
          // Friendly message
          alert('Mendaftarkan anda..')

          bpu.transaction(function(currentRank) {
            currentData = currentRank + 1;

            return currentData;
            }, function(error, committed, snapshot) {
                if (error) {
                    // Error message
                    alert('Terjadi kesahalah saat mengambil data');
                } else {
                    // Send the Data
                    alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                    // Push the prompt data
                    bpu_pasien.push().set({
                      nama: nama,
                      nik: nik,
                      no_antri: snapshot.val(),
                      poli: 'BPU',
                      jam: hour,
                      menit: minute
                    })
                }
            });
          break;

        // BPG
        case 'bpg':
          // Friendly message
          alert('Mendaftarkan anda..')

          bpg.transaction(function(currentRank) {
            currentData = currentRank + 1;

            return currentData;
            }, function(error, committed, snapshot) {
                if (error) {
                    // Error message
                    alert('Terjadi kesahalah saat mengambil data');
                } else {
                    // Send the Data
                    alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                    // Push the prompt data
                    bpg_pasien.push().set({
                      nama: nama,
                      nik: nik,
                      no_antri: snapshot.val(),
                      poli: 'BPG',
                      jam: hour,
                      menit: minute
                    })
                }
            });
          break;

        // KIA
        case 'kia':
          // Friendly message
          alert('Mendaftarkan anda..')

          kia.transaction(function(currentRank) {
            currentData = currentRank + 1;

            return currentData;
            }, function(error, committed, snapshot) {
                if (error) {
                    // Error message
                    alert('Terjadi kesahalah saat mengambil data');
                } else {
                    // Send the Data
                    alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                    // Push the prompt data
                    kia_pasien.push().set({
                      nama: nama,
                      nik: nik,
                      no_antri: snapshot.val(),
                      poli: 'KIA',
                      jam: hour,
                      menit: minute
                    })
                }
            });
          break;

          // Null handler
          case null:
            alert('Anda belum memilih poli');
            break;
      }
    }
  }
}
<|endoftext|>


<commit_before>Discourse.SelectLocationModalController = Discourse.Controller.extend(Discourse.ModalFunctionality, {
  needs: ['map'],

  // readyToSelect: function() {
  //   if (this.get('locationObject.title')) {
  //     return true;
  //   } else {
  //     return false;
  //   }
  // }.property('locationObject.title'),

  defaultLocation: function() {
    if (this.get('model.locationObject')) {
      return this.get('model.locationObject');
    }
    // if this is a reply to a topic we will use that topics location
    else if (this.get('model.topic.location')) {
      return this.get('model.topic.location');
    } else {
      // if user has browsed map, we will have a currentCity
      if (this.get('controllers.map.currentCity')) {
        var currentCity = this.get('controllers.map.currentCity');
        var selectionItems = Discourse.SiteSettings.maptopic.citySelectionItems;
        return selectionItems.findBy('value', currentCity);
      } else {
        // fuck it
        return {
          city_name: "madrid",
          longitude: "-3.7037902",
          latitude: "40.4167754"
        };
      }
    }
  }.property('model', 'model.locationObject'),

  actions: {
    // both topic and composer controllers are set to respond to
    // locationObject being changed on their model

    // below moved into selectable map:
    // locationSelected: function(latlng, geocodedLocation) {
    //   var locationObject = Discourse.Location.locationFromGmap(geocodedLocation);
    //   this.set('locationObject', locationObject);
    // },
    // called when i select infowindow from search result - TODO - allow editing of item in infowindow
    // locationFinalized: function(placeSearchResult, city) {
    //   var locationObject = Discourse.Location.locationFromPlaceSearch(placeSearchResult, city);
    //   this.set('model.locationObject', locationObject);
    //   this.send('closeModal');
    // },
    addLocationToTopic: function(locationObject) {
      this.set('model.locationObject', locationObject);
      this.send('closeModal');
    }
  }
});
<commit_msg>Fix bug in selection modal<commit_after>Discourse.SelectLocationModalController = Discourse.Controller.extend(Discourse.ModalFunctionality, {
  needs: ['map'],

  // readyToSelect: function() {
  //   if (this.get('locationObject.title')) {
  //     return true;
  //   } else {
  //     return false;
  //   }
  // }.property('locationObject.title'),

  defaultLocation: function() {
    if (this.get('model.locationObject')) {
      debugger;
      return this.get('model.locationObject');
    }
    // if this is a post or topic, use that location location
    else if (this.get('model.topic.location') || this.get('model.location')) {
      return this.get('model.topic.location') || this.get('model.location');
    } else {
      // should not get to this:
      debugger;
      // if user has browsed map, we will have a currentCity
      if (this.get('controllers.map.currentCity')) {
        var currentCity = this.get('controllers.map.currentCity');
        var selectionItems = Discourse.SiteSettings.maptopic.citySelectionItems;
        return selectionItems.findBy('value', currentCity);
      } else {
        // fuck it
        return {
          city_name: "madrid",
          longitude: "-3.7037902",
          latitude: "40.4167754"
        };
      }
    }
  }.property('model', 'model.locationObject'),

  actions: {
    // both topic and composer controllers are set to respond to
    // locationObject being changed on their model

    // below moved into selectable map:
    // locationSelected: function(latlng, geocodedLocation) {
    //   var locationObject = Discourse.Location.locationFromGmap(geocodedLocation);
    //   this.set('locationObject', locationObject);
    // },
    // called when i select infowindow from search result - TODO - allow editing of item in infowindow
    // locationFinalized: function(placeSearchResult, city) {
    //   var locationObject = Discourse.Location.locationFromPlaceSearch(placeSearchResult, city);
    //   this.set('model.locationObject', locationObject);
    //   this.send('closeModal');
    // },
    addLocationToTopic: function(locationObject) {
      this.set('model.locationObject', locationObject);
      this.send('closeModal');
    }
  }
});
<|endoftext|>


<commit_before>// https://github.com/wizard04wsu/Class

(function (){

	"use strict";

	let _initializing = false;

	/*** helper functions ***/

	function defineProperty(object, propertyName, value, isWritable, isEnumerable, isConfigurable){
		Object.defineProperty(object, propertyName, { value:value, writable:isWritable, enumerable:isEnumerable, configurable:isConfigurable });
	}
	function isPrimitive(o){ let t = typeof o; return (t !== "object" && t !== "function" ) || o === null; };
	function warn(msg){ if(window && window.console) (window.console.warn || window.console.log)(msg); }

	function classNameIsValid(className){
	//checks if the specified classname is valid (note: this doesn't check for reserved words)
		return className !== (void 0) && /^[a-z_$][a-z0-9_$]*$/i.test(className);
	}

	/*** shared functions ***/

	function _constructorFn(Super){ Super.apply(null, [].slice.call(arguments, 1)); }
	function _emptyFn(){}
	let _classToString = function toString(){ return "function Class() { [custom code] }"; };
	let _instanceToString = function toString(){
		if(classNameIsValid(this.constructor.name)) return "[instance of "+this.constructor.name+"]";
		return "[instance of Class]";
	};
	let _extendToString = function toString(){ return "function extend() { [custom code] }"; };

	//Stores a getter and a setter (at least one, if not both), allowing a subclass' constructorFn to access a variable or function that is inside the new class' constructorFn.
	function addProtectedMember(constructed, protectedObj, name, getter, setter){
		if(constructed) throw new Error("protected members cannot be added outside of the constructor");	//in case the function is referenced elsewhere
		if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");
		if(getter !== (void 0) && typeof(getter) !== "function") throw new TypeError("argument 'getter' is not a function");
		if(setter !== (void 0) && typeof(setter) !== "function") throw new TypeError("argument 'setter' is not a function");
		if(!getter && !setter) return;

		protectedObj[name] = {get:getter, set:setter};
	}

	//Removes a stored getter & setter, preventing a subclass' constructorFn from accessing the (now private) member.
	function removeProtectedMember(constructed, protectedObj, name){
		if(constructed) throw new Error("protected members cannot be removed outside of the constructor");	//in case the function is referenced elsewhere
		if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");

		delete protectedObj[name];
	}

	/*** base class ***/

	//the base Class constructor; it will have two static methods, 'extend' and 'noConflict'
	function Class(){}

	defineProperty(Class.prototype, "toString", _instanceToString, true, false, true);
	defineProperty(Class, "toString", _classToString, true, false, true);

	/**
	 * Creates a new class that inherits from the parent class.
	 *
	 * @param {object} [options]
	 * @param {string} [options.className] - Used as .name for the class function and in .toString() for instances of the class.
	 * @param {function} [options.constructorFn] - Initializes new instances of the class. A function is passed as the first argument, used to initialize the instance using the parent class' constructor; be sure to call it inside constructorFn (before using `this` or protected members).
	 * @param {function} [options.returnFn] - Returns a value when the constructor is called without using the 'new' keyword.
	 * @param {object} [options.extensions] - Additional and overriding properties and methods for the prototype of the class.
	 * @return {function} - The new class.
	 */
	let extendFn = function extend(options){

		if(options === void 0) options = {};
		else if(isPrimitive(options)) throw new TypeError("argument 'options' is not an object");

		/*** create the new constructor ***/

		let constructorFn = typeof(options.constructorFn) === "function" ? options.constructorFn : _constructorFn;
		let returnFn = typeof(options.returnFn) === "function" ? options.returnFn : _emptyFn;

		let newClass = function Class(){

			if(this && this instanceof newClass && (this.constructor === newClass.prototype.constructor || _initializing)){
			//A new instance is being created; initialize it.
			//This condition will be true in these cases:
			//  1) The 'new' operator was used to instantiate this class
			//  2) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() calls its first argument (the bound superFn)
			//  3) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() includes something like `MySuperClass.call(this)`
			//  4) Possibly if the prototype chain has been screwed with

				let newInstance = this;

				if(newInstance.constructor === newClass.prototype.constructor){
				//this function is the constructor of the new instance (i.e., it's not a parent class' constructor)

					defineProperty(newInstance, "constructor", newClass, true, false, true);
				}

				let _protected,
					superFnCalled = false,
					constructed = false;
				let superFn = function Super(){

					if(superFnCalled) return;	//don't initialize it more than once
					superFnCalled = true;

					//initialize the instance using the parent class
					_protected = newClass.prototype.constructor.apply(newInstance, arguments) || {};

					//add the protected getters/setters to superFn
					for(name in _protected){
						if(Object.prototype.hasOwnProperty.call(_protected, name)){
							Object.defineProperty(superFn, name, {
								get:(_protected[name].get ? _protected[name].get.bind(newInstance) : void 0),
								set:(_protected[name].set ? _protected[name].set.bind(newInstance) : void 0),
								enumerable:true, configurable:true
							});
						}
					}

					defineProperty(superFn, "addProtectedMember", addProtectedMember.bind(null, constructed, _protected), false, false, true);
					defineProperty(superFn, "removeProtectedMember", removeProtectedMember.bind(null, constructed, _protected), false, false, true);

				}

				let className = newClass.name;	//store the provided class name in case the constructor changes the .name attribute

				//construct the new instance
				_initializing = true;
				//constructorFn.bind(newInstance, superFn).apply(null, arguments);
				constructorFn.apply(newInstance, [superFn].concat([].slice.call(arguments)));	//(This method doesn't create another new function every time a constructor is run.)
				_initializing = false;

				constructed = true;

				if(!superFnCalled) warn(className+" constructor does not include a call to the 'Super' argument");

				if(newInstance.constructor === newClass){
				//this function is the constructor of the new instance

					//In case the 'Super' argument gets referenced elsewhere, remove these since they're not allowed to be used outside of the constructor anyway.
					delete superFn.addProtectedMember;
					delete superFn.removeProtectedMember;
				}
				else{
				//this function is the constructor of a super-class

					return _protected;
				}
				//else return this

			}
			else{
			//the 'new' operator was not used; it was just called as a function

				return returnFn.apply(null, arguments);

			}

		}

		//override .name
		defineProperty(newClass, "name",
			classNameIsValid(options.className) ? options.className : classNameIsValid(this.name) ? this.name /*parent class' name*/ : "Class",
			false, false, true);

		//override .toString()
		defineProperty(newClass, "toString", _classToString, true, false, true);

		if(this.extend === extendFn){
		//the 'extend' method of the parent class was not modified

			//make extend() a static method of the new class
			defineProperty(newClass, "extend", extendFn, true, false, true);
		}

		/*** create the new prototype ***/

		//An uninitialized instance of the parent class will be the prototype of the new class.
		//To create an instance without initializing it, we'll temporarily use an empty function as the constructor.
		let emptyFn = function (){};
		emptyFn.prototype = this.prototype;
		let newPrototype = new emptyFn();
		emptyFn = null;
		emptyFn = null;
		defineProperty(newPrototype, "constructor", this, true, false, true);

		//override .toString()
		defineProperty(newPrototype, "toString", _instanceToString, true, false, true);

		defineProperty(newClass, "prototype", newPrototype, false, false, false);

		/*** add the new & overriding properties to the prototype ***/

		for(name in options.extensions){
			if(Object.prototype.hasOwnProperty.call(options.extensions, name)){
				newPrototype[name] = options.extensions[name];
			}
		}

		return newClass;

	}

	defineProperty(extendFn, "toString", _extendToString, true, false, true);

	//make extend() a static method of Class
	defineProperty(Class, "extend", extendFn, true, false, true);

	let context = this,
		oldClass = context.Class;

	/**
	 * Restores 'Class' to what it was before this script replaced it.
	 *
	 * @return {function} - The base Class constructor.
	 */
	function noConflict(){
		context.Class = oldClass;
		context = oldClass = null;
		delete Class.noConflict;
		return Class;
	}
	//make noConflict() a static method of Class
	defineProperty(Class, "noConflict", noConflict, true, false, true);

	context.Class = Class;

}).call(window);
<commit_msg>Update Class.js<commit_after>/* eslint-env es6 */
// https://github.com/wizard04wsu/Class

(function (){

	"use strict";

	let _initializing = false;

	/*** helper functions ***/

	function defineProperty(object, propertyName, value, isWritable, isEnumerable, isConfigurable){
		Object.defineProperty(object, propertyName, { value:value, writable:isWritable, enumerable:isEnumerable, configurable:isConfigurable });
	}
	function isPrimitive(o){ let t = typeof o; return (t !== "object" && t !== "function" ) || o === null; }
	function warn(msg){ if(window && window.console) (window.console.warn || window.console.log)(msg); }

	function classNameIsValid(className){
	//checks if the specified classname is valid (note: this doesn't check for reserved words)
		return className !== (void 0) && /^[a-z_$][a-z0-9_$]*$/i.test(className);
	}

	/*** shared functions ***/

	function _constructorFn(Super){ Super.apply(null, [].slice.call(arguments, 1)); }
	function _emptyFn(){}
	let _classToString = function toString(){ return "function Class() { [custom code] }"; };
	let _instanceToString = function toString(){
		if(classNameIsValid(this.constructor.name)) return "[instance of "+this.constructor.name+"]";
		return "[instance of Class]";
	};
	let _extendToString = function toString(){ return "function extend() { [custom code] }"; };

	//Stores a getter and a setter (at least one, if not both), allowing a subclass' constructorFn to access a variable or function that is inside the new class' constructorFn.
	function addProtectedMember(constructed, protectedObj, name, getter, setter){
		if(constructed) throw new Error("protected members cannot be added outside of the constructor");	//in case the function is referenced elsewhere
		if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");
		if(getter !== (void 0) && typeof(getter) !== "function") throw new TypeError("argument 'getter' is not a function");
		if(setter !== (void 0) && typeof(setter) !== "function") throw new TypeError("argument 'setter' is not a function");
		if(!getter && !setter) return;

		protectedObj[name] = {get:getter, set:setter};
	}

	//Removes a stored getter & setter, preventing a subclass' constructorFn from accessing the (now private) member.
	function removeProtectedMember(constructed, protectedObj, name){
		if(constructed) throw new Error("protected members cannot be removed outside of the constructor");	//in case the function is referenced elsewhere
		if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");

		delete protectedObj[name];
	}

	/*** base class ***/

	//the base Class constructor; it will have two static methods, 'extend' and 'noConflict'
	function Class(){}

	defineProperty(Class.prototype, "toString", _instanceToString, true, false, true);
	defineProperty(Class, "toString", _classToString, true, false, true);

	/**
	 * Creates a new class that inherits from the parent class.
	 *
	 * @param {object} [options]
	 * @param {string} [options.className] - Used as .name for the class function and in .toString() for instances of the class.
	 * @param {function} [options.constructorFn] - Initializes new instances of the class. A function is passed as the first argument, used to initialize the instance using the parent class' constructor; be sure to call it inside constructorFn (before using `this` or protected members).
	 * @param {function} [options.returnFn] - Returns a value when the constructor is called without using the 'new' keyword.
	 * @param {object} [options.extensions] - Additional and overriding properties and methods for the prototype of the class.
	 * @return {function} - The new class.
	 */
	let extendFn = function extend(options){

		if(options === void 0) options = {};
		else if(isPrimitive(options)) throw new TypeError("argument 'options' is not an object");

		/*** create the new constructor ***/

		let constructorFn = typeof(options.constructorFn) === "function" ? options.constructorFn : _constructorFn;
		let returnFn = typeof(options.returnFn) === "function" ? options.returnFn : _emptyFn;

		let newClass = function Class(){

			if(this && this instanceof newClass && (this.constructor === newClass.prototype.constructor || _initializing)){
			//A new instance is being created; initialize it.
			//This condition will be true in these cases:
			//  1) The 'new' operator was used to instantiate this class
			//  2) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() calls its first argument (the bound superFn)
			//  3) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() includes something like `MySuperClass.call(this)`
			//  4) Possibly if the prototype chain has been screwed with

				let newInstance = this;

				if(newInstance.constructor === newClass.prototype.constructor){
				//this function is the constructor of the new instance (i.e., it's not a parent class' constructor)

					defineProperty(newInstance, "constructor", newClass, true, false, true);
				}

				let _protected,
					superFnCalled = false,
					constructed = false;
				let superFn = function Super(){

					if(superFnCalled) return;	//don't initialize it more than once
					superFnCalled = true;

					//initialize the instance using the parent class
					_protected = newClass.prototype.constructor.apply(newInstance, arguments) || {};

					//add the protected getters/setters to superFn
					let name;
					for(name in _protected){
						if(Object.prototype.hasOwnProperty.call(_protected, name)){
							Object.defineProperty(superFn, name, {
								get:(_protected[name].get ? _protected[name].get.bind(newInstance) : void 0),
								set:(_protected[name].set ? _protected[name].set.bind(newInstance) : void 0),
								enumerable:true, configurable:true
							});
						}
					}

					defineProperty(superFn, "addProtectedMember", addProtectedMember.bind(null, constructed, _protected), false, false, true);
					defineProperty(superFn, "removeProtectedMember", removeProtectedMember.bind(null, constructed, _protected), false, false, true);

				}

				let className = newClass.name;	//store the provided class name in case the constructor changes the .name attribute

				//construct the new instance
				_initializing = true;
				//constructorFn.bind(newInstance, superFn).apply(null, arguments);
				constructorFn.apply(newInstance, [superFn].concat([].slice.call(arguments)));	//(This method doesn't create another new function every time a constructor is run.)
				_initializing = false;

				constructed = true;

				if(!superFnCalled) warn(className+" constructor does not include a call to the 'Super' argument");

				if(newInstance.constructor === newClass){
				//this function is the constructor of the new instance

					//In case the 'Super' argument gets referenced elsewhere, remove these since they're not allowed to be used outside of the constructor anyway.
					delete superFn.addProtectedMember;
					delete superFn.removeProtectedMember;
				}
				else{
				//this function is the constructor of a super-class

					return _protected;
				}
				//else return this

			}
			else{
			//the 'new' operator was not used; it was just called as a function

				return returnFn.apply(null, arguments);

			}

		}

		//override .name
		defineProperty(newClass, "name",
			classNameIsValid(options.className) ? options.className : classNameIsValid(this.name) ? this.name /*parent class' name*/ : "Class",
			false, false, true);

		//override .toString()
		defineProperty(newClass, "toString", _classToString, true, false, true);

		if(this.extend === extendFn){
		//the 'extend' method of the parent class was not modified

			//make extend() a static method of the new class
			defineProperty(newClass, "extend", extendFn, true, false, true);
		}

		/*** create the new prototype ***/

		//An uninitialized instance of the parent class will be the prototype of the new class.
		//To create an instance without initializing it, we'll temporarily use an empty function as the constructor.
		let emptyFn = function (){};
		emptyFn.prototype = this.prototype;
		let newPrototype = new emptyFn();
		emptyFn = null;
		emptyFn = null;
		defineProperty(newPrototype, "constructor", this, true, false, true);

		//override .toString()
		defineProperty(newPrototype, "toString", _instanceToString, true, false, true);

		defineProperty(newClass, "prototype", newPrototype, false, false, false);

		/*** add the new & overriding properties to the prototype ***/

		let name;
		for(name in options.extensions){
			if(Object.prototype.hasOwnProperty.call(options.extensions, name)){
				newPrototype[name] = options.extensions[name];
			}
		}

		return newClass;

	}

	defineProperty(extendFn, "toString", _extendToString, true, false, true);

	//make extend() a static method of Class
	defineProperty(Class, "extend", extendFn, true, false, true);

	let context = this,
		oldClass = context.Class;

	/**
	 * Restores 'Class' to what it was before this script replaced it.
	 *
	 * @return {function} - The base Class constructor.
	 */
	function noConflict(){
		context.Class = oldClass;
		context = oldClass = null;
		delete Class.noConflict;
		return Class;
	}
	//make noConflict() a static method of Class
	defineProperty(Class, "noConflict", noConflict, true, false, true);

	context.Class = Class;

}).call(window);
<|endoftext|>


<commit_before>/*
* Cepat Sembuh v1.0
* Copyright 2016 Cepat Sembuh
*/

document.addEventListener('deviceready', function () {
    Firebase.goOnline();
});

$('#not-available').on('click', function() {
	alert('Faskes is not available.')
})

function getNoAntri(tipe, username, name) {
  breanna = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username),
  antri = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/antrian');
  pasien = breanna.child("pasien"),
  // Date
  date = new Date(),
  year = date.getFullYear(),
  month = date.getMonth() + 1,
  day = date.getDate(),
  right_now = year + '-' + month + '-' + day,
  today = breanna.child(right_now),

  get = 'Getting data..';
  console.log(get);

  var nama = prompt("Nama: "),
      nik = prompt("NIK: ");

  if (nama === '' || nik.length != 16 || typeof Number(nik) !== 'number' || Number(nik) == 'NaN') {
    alert('Input tidak valid');
  } else {
    antri.transaction(function(currentRank) {
        currentData = currentRank + 1;

        return currentData;
    }, function(error, committed, snapshot) {
        if (error) {
            alert('Koneksi anda tidak stabil' + error);
        } else {
            alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Screenshot ini dan tunjukan ke faskes anda');
            today.push().set({
              nama: nama,
              nik: nik,
              no_antri: snapshot.val()
            })
        }
    });
  }
  console.log('Data is ready');
}

function tempatTidur(tipe, username) {
  brea = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/tempat_tidur');

  wait = 'Getting data..';
  console.log(wait);
  alert(wait);

  brea.on('value', function(snapshot) {
    satu = snapshot.val().satu;
    dua = snapshot.val().dua;
    tiga = snapshot.val().tiga;

    alert('Kelas I: ' + satu + '\n' + 'Kelas II: ' + dua + '\n' + 'Kelas III: ' + tiga); // Show user the data's
  })
}

function doctorProfile(nama, lulusan, tahun) {
  giant = 'Lulusan: ' + lulusan + '\n' + 'Tahun: ' + tahun;
  name = 'dr. ' + nama;

  alert(name + '\n' + giant); // Pop-up
}
<commit_msg>More comments<commit_after>/*
* Cepat Sembuh v1.0
* Copyright 2016 Cepat Sembuh
*/

document.addEventListener('deviceready', function () {
    Firebase.goOnline();
});

// Example faskes action
$('#not-available').on('click', function() {
	alert('Faskes is not available.')
})

function getNoAntri(tipe, username, name) {
  breanna = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username),
  antri = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/antrian');
  pasien = breanna.child("pasien"),

  // Date
  date = new Date(),
  year = date.getFullYear(),
  month = date.getMonth() + 1,
  day = date.getDate(),
  right_now = year + '-' + month + '-' + day,
  today = breanna.child(right_now),

  // Get data
  get = 'Getting data..';
  console.log(get);

  // Prompt
  var nama = prompt("Nama: "),
      nik = prompt("NIK: ");

  if (nama === '' || nik.length != 16 || typeof Number(nik) !== 'number' || Number(nik) == 'NaN') {
    alert('Input tidak valid');
  } else {
    antri.transaction(function(currentRank) {
        currentData = currentRank + 1;

        return currentData;
    }, function(error, committed, snapshot) {
        if (error) {
            // Error message
            alert('Koneksi anda tidak stabil' + error);
        } else {
            // Send the Data
            alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Screenshot ini dan tunjukan ke faskes anda');

            // Push the prompt data
            today.push().set({
              nama: nama,
              nik: nik,
              no_antri: snapshot.val()
            })
        }
    });
  }
  console.log('Data is ready');
}

function tempatTidur(tipe, username) {
  // Firebase URL
  brea = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/tempat_tidur');

  // Waiting message
  wait = 'Getting data..';
  console.log(wait);
  alert(wait);

  // Get the data
  brea.on('value', function(snapshot) {
    satu = snapshot.val().satu;
    dua = snapshot.val().dua;
    tiga = snapshot.val().tiga;

    alert('Kelas I: ' + satu + '\n' + 'Kelas II: ' + dua + '\n' + 'Kelas III: ' + tiga); // Show user the data's
  })
}

function doctorProfile(nama, lulusan, tahun) {
  giant = 'Lulusan: ' + lulusan + '\n' + 'Tahun: ' + tahun; // Doctor content
  name = 'dr. ' + nama; // Doctor name

  alert(name + '\n' + giant); // Pop-up
}
<|endoftext|>


<commit_before>
/*********************\
  TARGETING FUNCTIONS
\*********************/

//h = hook ([data-jshook="xxx"])
//c = class (".xxx")
//s = span ("xxx")
//id = id ("#xxx")

//sets up the default module targets variable that gets overwritten in every module
var module = '';
var moduleTargets = {};

//returns a CLASS (dot added) eg. ".module-element--modifier-JS"
var Class = function (key,classSet){
	classSet = defaultTo(classSet, moduleTargets[module]);

	var selectorFull = '';

	if ( key.constructor === Array){
		$.each(key, function(i, string){
			var comma = (i == 0) ? '' : ', ';
			selectorFull = selectorFull + comma + '.'+classSet[string];
		});
	} else {
		selectorFull = '.'+classSet[key];
	};

	return selectorFull;
}

//returns a SPAN (nothing added) eg. "module-element--modifier-JS"
//does not accept arrays
var Span = function (key,classSet){
	classSet = defaultTo(classSet, moduleTargets[module]);
	return classSet[key];
};

//returns a HOOK (an attribute selector)
var Hook = function(key,classSet){

	classSet = defaultTo(classSet, moduleTargets[module]);

	var selectorFull = '';

//if an array, merge into a single selector
	if ( key.constructor === Array){
		$.each(key, function(i, string){
			var comma = (i == 0) ? '' : ', ';
			selectorFull = selectorFull + comma + '[data-jshook^="'+classSet[string]+' "], [data-jshook*=" '+classSet[string]+' "], [data-jshook$=" '+classSet[string]+'"], [data-jshook="'+classSet[string]+'"]';
		});
//else just output a single copy of the selector
	} else {
		selectorFull = '[data-jshook^="'+classSet[key]+' "], [data-jshook*=" '+classSet[key]+' "], [data-jshook$=" '+classSet[key]+'"], [data-jshook="'+classSet[key]+'"]';
	};

	return selectorFull;
}

//returns an ID (hash added) eg. "#js-module-element"
var id = function (key,classSet){
	classSet = defaultTo(classSet, moduleTargets[module]);

	var selectorFull = '';

	if ( key.constructor === Array){
		$.each(key, function(i, string){
			var comma = (i == 0) ? '' : ', ';
			selectorFull = selectorFull + comma + '#'+classSet[string];
		});
	} else {
		selectorFull = '#'+classSet[key];
	};

	return selectorFull;
};

<commit_msg>Major update to the Hook targeting function<commit_after>
/*********************\
  TARGETING FUNCTIONS
\*********************/

//h = hook ([data-jshook="xxx"])
//c = class (".xxx")
//s = span ("xxx")
//id = id ("#xxx")

//sets up the default module targets variable that gets overwritten in every module
var module = '';
var moduleTargets = {};

//returns a CLASS (dot added) eg. ".module-element--modifier-JS"
var Class = function (key,classSet){
	classSet = defaultTo(classSet, moduleTargets[module]);

	var selectorFull = '';

	if ( key.constructor === Array){
		$.each(key, function(i, string){
			var comma = (i == 0) ? '' : ', ';
			selectorFull = selectorFull + comma + '.'+classSet[string];
		});
	} else {
		selectorFull = '.'+classSet[key];
	};

	return selectorFull;
}

//returns a SPAN (nothing added) eg. "module-element--modifier-JS"
//does not accept arrays
var Span = function (key,classSet){
	classSet = defaultTo(classSet, moduleTargets[module]);
	return classSet[key];
};

//returns a HOOK (an attribute selector)
var Hook = function(key,classSet){

	classSet = defaultTo(classSet, moduleTargets[module]);

	var selectorFull = '';
	var selectorFullArray = [];

	var hookPart = function(number, key){
		switch(number){
			case 0: var partial = '[data-jshook^="'+classSet[key]+' "]'; break;
			case 1: var partial = '[data-jshook*=" '+classSet[key]+' "]'; break;
			case 2: var partial = '[data-jshook$=" '+classSet[key]+'"]'; break;
			case 3: var partial = '[data-jshook="'+classSet[key]+'"]'; break;

			//simplified but less strict
			case 4: var partial = '[data-jshook*="'+classSet[key]+'"]'; break;
		}

		return partial;
	}

	var singleHook = function (key) {
		return hookPart(0,key)+','+hookPart(1,key)+','+hookPart(2,key)+','+hookPart(3,key);
	}

//if an array, merge into a single selector as an "or" statement
	if ( key.constructor === Array){
		$.each(key, function(i, string){
			var selectorPartial = '';
			//if inside a second array, merge them into an "and" statement
			if( string.constructor === Array) {
				$.each(string, function(x, finalString){
					selectorPartial = selectorPartial + hookPart(4,finalString);
				})
				selectorFullArray[i] = selectorPartial;
			} else {
				//or statement
				var comma = (i == 0) ? '' : ', ';
				selectorFull = selectorFull + comma + singleHook(string);
			}
		});
		$.each(selectorFullArray, function(index, string){
			var comma = (index == 0) ? '' : ', ';
			selectorFull = selectorFull + comma + string;
		})
//else just output a single copy of the selector
	} else {
		selectorFull = singleHook(key);
	};

	return selectorFull;
}

//returns an ID (hash added) eg. "#js-module-element"
var id = function (key,classSet){
	classSet = defaultTo(classSet, moduleTargets[module]);

	var selectorFull = '';

	if ( key.constructor === Array){
		$.each(key, function(i, string){
			var comma = (i == 0) ? '' : ', ';
			selectorFull = selectorFull + comma + '#'+classSet[string];
		});
	} else {
		selectorFull = '#'+classSet[key];
	};

	return selectorFull;
};

<|endoftext|>


<commit_before>/*
* Cepat Sembuh v1.0
* Copyright 2016 Cepat Sembuh
*/

document.addEventListener('deviceready', function () {
    Firebase.goOnline();
});

// Example faskes action
$('#not-available').on('click', function() {
	alert('Faskes is not available.')
})

function getNoAntri(tipe, username, name) {
  grease = '../poli/' + username + '.html';
  window.location.href = grease;
}

function tempatTidur(tipe, username) {
  // Firebase URL
  brea = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/tempat_tidur');

  // Waiting message
  wait = 'Getting data..';
  console.log(wait);
  alert(wait);

  // Get the data
  brea.on('value', function(snapshot) {
    satu = snapshot.val().satu;
    dua = snapshot.val().dua;
    tiga = snapshot.val().tiga;

    alert('Kelas I: ' + Number(satu) + '\n' + 'Kelas II: ' + Number(dua) + '\n' + 'Kelas III: ' + Number(tiga)); // Show user the data's
  })
}

function doctorProfile(nama, lulusan, tahun) {
  giant = 'Lulusan: ' + lulusan + '\n' + 'Tahun: ' + tahun; // Doctor content
  name = 'dr. ' + nama; // Doctor name

  alert(name + '\n' + giant); // Pop-up
}

function pilihPoli(username) {
  var nama = $('#nama').val(),
      nik = $('#nik').val(),
      dipper = $('#durasi').val(),
      poli = $('#poli').val();

  dipcifica = new Firebase('https://cepatsembuh.firebaseio.com/puskesmas/faskes/' + username),

  date = new Date(),
  year = date.getFullYear(),
  month = date.getMonth() + 1,
  day = date.getDate(),
  right_now = year + '-' + month + '-' + day,
  today = dipcifica.child(right_now),

  bpu = dipcifica.child('bpu'),
  bpg = dipcifica.child('bpg'),
  kia = dipcifica.child('kia'),

  bpu_pasien = today.child('bpu-pasien'),
  bpg_pasien = today.child('bpg-pasien'),
  kia_pasien = today.child('kia-pasien');

  if (nama === '' || nik.length != 16) {
    alert('Input tidak valid')
  } else {
    switch (poli) {
      // BPU
      case 'bpu':
        bpu.transaction(function(currentRank) {
          currentData = currentRank + 1;

          return currentData;
          }, function(error, committed, snapshot) {
              if (error) {
                  // Error message
                  alert('Koneksi anda tidak stabil' + error);
              } else {
                  // Send the Data
                  alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                  // Push the prompt data
                  bpu_pasien.push().set({
                    nama: nama,
                    nik: nik,
                    no_antri: snapshot.val(),
                    poli: 'BPU'
                  })
              }
          });
        break;
      // BPG
      case 'bpg':
        bpg.transaction(function(currentRank) {
          currentData = currentRank + 1;

          return currentData;
          }, function(error, committed, snapshot) {
              if (error) {
                  // Error message
                  alert('Koneksi anda tidak stabil' + error);
              } else {
                  // Send the Data
                  alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                  // Push the prompt data
                  bpg_pasien.push().set({
                    nama: nama,
                    nik: nik,
                    no_antri: snapshot.val(),
                    poli: 'BPG'
                  })
              }
          });
        break;
      // KIA
      case 'kia':
        kia.transaction(function(currentRank) {
          currentData = currentRank + 1;

          return currentData;
          }, function(error, committed, snapshot) {
              if (error) {
                  // Error message
                  alert('Koneksi anda tidak stabil' + error);
              } else {
                  // Send the Data
                  alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                  // Push the prompt data
                  kia_pasien.push().set({
                    nama: nama,
                    nik: nik,
                    no_antri: snapshot.val(),
                    poli: 'KIA'
                  })
              }
          });
        break;

        // Null handler
        case null:
          alert('Anda belum memilih poli');
          break;
    }
  }
}
<commit_msg>Spaces between breaks<commit_after>/*
* Cepat Sembuh v1.0
* Copyright 2016 Cepat Sembuh
*/

document.addEventListener('deviceready', function () {
    Firebase.goOnline();
});

// Example faskes action
$('#not-available').on('click', function() {
	alert('Faskes is not available.')
})

function getNoAntri(tipe, username, name) {
  grease = '../poli/' + username + '.html';
  window.location.href = grease;
}

function tempatTidur(tipe, username) {
  // Firebase URL
  brea = new Firebase('http://cepatsembuh.firebaseio.com/' + tipe + '/faskes/' + username + '/tempat_tidur');

  // Waiting message
  wait = 'Getting data..';
  console.log(wait);
  alert(wait);

  // Get the data
  brea.on('value', function(snapshot) {
    satu = snapshot.val().satu;
    dua = snapshot.val().dua;
    tiga = snapshot.val().tiga;

    alert('Kelas I: ' + Number(satu) + '\n' + 'Kelas II: ' + Number(dua) + '\n' + 'Kelas III: ' + Number(tiga)); // Show user the data's
  })
}

function doctorProfile(nama, lulusan, tahun) {
  giant = 'Lulusan: ' + lulusan + '\n' + 'Tahun: ' + tahun; // Doctor content
  name = 'dr. ' + nama; // Doctor name

  alert(name + '\n' + giant); // Pop-up
}

function pilihPoli(username) {
  var nama = $('#nama').val(),
      nik = $('#nik').val(),
      dipper = $('#durasi').val(),
      poli = $('#poli').val();

  dipcifica = new Firebase('https://cepatsembuh.firebaseio.com/puskesmas/faskes/' + username),

  date = new Date(),
  year = date.getFullYear(),
  month = date.getMonth() + 1,
  day = date.getDate(),
  right_now = year + '-' + month + '-' + day,
  today = dipcifica.child(right_now),

  bpu = dipcifica.child('bpu'),
  bpg = dipcifica.child('bpg'),
  kia = dipcifica.child('kia'),

  bpu_pasien = today.child('bpu-pasien'),
  bpg_pasien = today.child('bpg-pasien'),
  kia_pasien = today.child('kia-pasien');

  if (nama === '' || nik.length != 16) {
    alert('Input tidak valid')
  } else {
    switch (poli) {
      // BPU
      case 'bpu':
        bpu.transaction(function(currentRank) {
          currentData = currentRank + 1;

          return currentData;
          }, function(error, committed, snapshot) {
              if (error) {
                  // Error message
                  alert('Koneksi anda tidak stabil' + error);
              } else {
                  // Send the Data
                  alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                  // Push the prompt data
                  bpu_pasien.push().set({
                    nama: nama,
                    nik: nik,
                    no_antri: snapshot.val(),
                    poli: 'BPU'
                  })
              }
          });
        break;

      // BPG
      case 'bpg':
        bpg.transaction(function(currentRank) {
          currentData = currentRank + 1;

          return currentData;
          }, function(error, committed, snapshot) {
              if (error) {
                  // Error message
                  alert('Koneksi anda tidak stabil' + error);
              } else {
                  // Send the Data
                  alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                  // Push the prompt data
                  bpg_pasien.push().set({
                    nama: nama,
                    nik: nik,
                    no_antri: snapshot.val(),
                    poli: 'BPG'
                  })
              }
          });
        break;

      // KIA
      case 'kia':
        kia.transaction(function(currentRank) {
          currentData = currentRank + 1;

          return currentData;
          }, function(error, committed, snapshot) {
              if (error) {
                  // Error message
                  alert('Koneksi anda tidak stabil' + error);
              } else {
                  // Send the Data
                  alert('Nomor Antrian: ' + snapshot.val() + '\n' + 'Datanglah pada: ' + String(right_now) + '\n' + '\n' + '*Harap screenshot ini dan tunjukan ke faskes anda');

                  // Push the prompt data
                  kia_pasien.push().set({
                    nama: nama,
                    nik: nik,
                    no_antri: snapshot.val(),
                    poli: 'KIA'
                  })
              }
          });
        break;

        // Null handler
        case null:
          alert('Anda belum memilih poli');
          break;
    }
  }
}
<|endoftext|>