(function(app) {
  'use strict';

  var Base64 = require('js-base64').Base64;
  var moment = require('moment-timezone');
  var Timezone = app.Timezone || require('./timezone.js');

  var TimezoneList = function() {
    this.KEY_CURRENT_LOCATION = 'Current_Location';
    this.data = {};
    this.selected = [];
  };

  TimezoneList.prototype.get = function() {
    if (Object.keys(this.data).length === 0 || this.selected.length === 0) {
      return [];
    }

    var selected_timezone = this.selected.map(function(key) {
      return [key, this.data[key]];
    }.bind(this));

    return this._getTimelist(selected_timezone);
  };

  TimezoneList.prototype.updateData = function() {
    this.data = this._createTimezoneData();
  };

  TimezoneList.prototype.setCustomTimezoneList = function(list) {
    this._setUrlSearchParam('custom_tzlist', Base64.encodeURI(list.join(',')));
  };

  TimezoneList.prototype.setHiddenTimezoneList = function(list) {
    this._setUrlSearchParam('hidden_tzlist', Base64.encodeURI(list.join(',')));
  };

  TimezoneList.prototype.getLocationName = function(tzName) {
    return tzName.substring(tzName.lastIndexOf('/') + 1).replace(/_/g, ' ');
  };

  TimezoneList.prototype._getTimelist = function(timezone) {
    var date = new Date();
    var currentTime = date.getTime();
    var currentTimezoneOffset = date.getTimezoneOffset();

    return timezone.map(function(item) {
      var name = this.getLocationName(item[0]);
      var time = parseInt(item[1], 10);
      time = new Date(currentTime + time * 1000 + currentTimezoneOffset * 60 * 1000);
      return [name, time];
    }.bind(this));
  };

  TimezoneList.prototype._createTimezoneData = function() {
    var data  = {};
    var now = Date.now();

    Timezone.LOCATION_NAMES.forEach(function(name) {
      data[name] = moment.tz.zone(name.split('#/')[0]).utcOffset(now) * (-60);
    });

    data[this.KEY_CURRENT_LOCATION] = new Date().getTimezoneOffset() * (-60);

    var params = this._getUrlSearchParams();
    this._decodeTimezoneList(params.custom_tzlist).forEach(function(name) {
      if (name in data) {
        return;
      }
      var tz = moment.tz.zone(name.split('#/')[0]);
      if (tz) {
        data[name] = tz.utcOffset(now) * (-60);
      }
    });

    this._decodeTimezoneList(params.hidden_tzlist).forEach(function(name) {
      delete data[name];
    });

    return data;
  };

  TimezoneList.prototype._decodeTimezoneList = function(value) {
    return (value ? Base64.decode(value).split(',') : []);
  };

  TimezoneList.prototype._getUrlSearchParams = function() {
    return location.search.substring(1).split('&').reduce(function(ret, pair) {
      var items = pair.split('=');
      var key = decodeURIComponent(items[0] || '');
      var value = decodeURIComponent(items[1] || '');
      ret[key] = value;
      return ret;
    }, {});
  };

  TimezoneList.prototype._setUrlSearchParam = function(name, value) {
    var params = this._getUrlSearchParams();
    params[name] = value;
    var search = '?' + Object.keys(params).map(function(name) {
      return encodeURIComponent(name) + '=' + encodeURIComponent(params[name]);
    }).join('&');
    history.replaceState(null, null, search + location.hash);
  };

  if (typeof module !== 'undefined' && module.exports) {
    module.exports = TimezoneList;
  } else {
    app.TimezoneList = TimezoneList;
  }
})(this.app || (this.app = {}));

@@ -687,45 +687,275 @@
     
-this.data = this._createTimezoneData(
+var params = this._getUrlSearchParams();%0A    var customList = this._decodeTimezoneList(params.custom_tzlist);%0A    var hiddenList = this._decodeTimezoneList(params.hidden_tzlist);%0A    this.data = this._createTimezoneData(Timezone.LOCATION_NAMES, customList, hiddenList
 );%0A 
@@ -1908,36 +1908,71 @@
 Data = function(
+defaultList, customList, hiddenList
 ) %7B%0A
-
     var data  = 
@@ -2006,39 +2006,27 @@
 );%0A%0A    
-Timezone.LOCATION_NAMES
+defaultList
 .forEach
@@ -2218,99 +2218,18 @@
     
-var params = this._getUrlSearchParams();%0A    this._decodeTimezoneList(params.custom_tzlist)
+customList
 .for
@@ -2441,54 +2441,18 @@
     
-t
 hi
-s._decodeTimezoneList(params.hidden_tzlist)
+ddenList
 .for

Refactor code for creating timezone list