diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.hbs deleted file mode 100644 index 3fe1991ac4..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.hbs +++ /dev/null @@ -1,541 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} -{{unit "cdmf.unit.ui.title" pageTitle="Device Management"}} - -{{unit "cdmf.unit.data-tables-extended"}} -{{unit "cdmf.unit.lib.ui-permissions-utility"}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • - {{#if group}} -
  • - - Groups - -
  • -
  • - - {{group.name}} - -
  • - {{else}} -
  • - - Devices - -
  • - {{/if}} -{{/zone}} - -{{#zone "navbarActions"}} - {{#if group}} -
  • - - - - - - Assign from My Devices - -
  • - - {{else}} - {{#if permissions.enroll}} -
  • - - - - - - Enroll Device - -
  • - {{/if}} - {{/if}} -{{/zone}} - -{{#zone "content"}} - {{#if group}} -

    - {{group.name}} group -

    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - Overview -
    - - - - - - - - - - - - - - - - - - - -
    Owner{{group.owner}}
    Shared with roles - {{#each roles}} - {{this}}
    - {{/each}} -
    Device Count{{deviceCount}}
    Description{{group.description}}
    -
    -
    -
    -
    -
    -

    - Devices in {{group.name}} group -

    - {{/if}} -
    -
    -
    -
    - - {{unit "cdmf.unit.device.operation-mod"}} - {{#if deviceCount}} -
    - - Loading devices . . . -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    -
    - - {{else}} -
    - -
    - {{/if}} - -
    - - - -
    - -
    - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    -
    -
    -
    -{{/zone}} - -{{#zone "bottomJs"}} - - {{js "js/listing.js"}} -{{/zone}} - -{{#zone "topCss"}} - -{{/zone}} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.js deleted file mode 100644 index c973d07985..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var constants = require("/app/modules/constants.js"); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; - - var groupId = request.getParameter("groupId"); - - var viewModel = {}; - var title = "Devices"; - if (groupId) { - var group = groupModule.getGroup(groupId); - if (group) { - title = group.name + " " + title; - viewModel.roles = groupModule.getRolesOfGroup(groupId); - viewModel.group = group; - } - } - viewModel.title = title; - var currentUser = session.get(constants.USER_SESSION_KEY); - if (currentUser) { - viewModel.permissions = {}; - var uiPermissions = userModule.getUIPermissions(); - viewModel.permissions.list = stringify(uiPermissions); - if (uiPermissions.ADD_DEVICE) { - viewModel.permissions.enroll = true; - } - viewModel.currentUser = currentUser; - var deviceCount = 0; - if (groupId) { - deviceCount = groupModule.getGroupDeviceCount(groupId); - } else { - deviceCount = deviceModule.getDevicesCount(); - } - if (deviceCount > 0) { - viewModel.deviceCount = deviceCount; - var utility = require("/app/modules/utility.js").utility; - var typesListResponse = deviceModule.getDeviceTypes(); - var deviceTypes = []; - if (typesListResponse["status"] == "success") { - var data = typesListResponse.content.deviceTypes; - if (data) { - for (var i = 0; i < data.length; i++) { - var config = utility.getDeviceTypeConfig(data[i]); - var category = "iot"; - var label = data[i]; - var analyticsEnabled = "false"; - var groupingEnabled = "true"; - var analyticsView = null; - if (config) { - var deviceType = config.deviceType; - category = deviceType.category; - label = deviceType.label; - analyticsEnabled = deviceType.analyticsEnabled; - groupingEnabled = deviceType.groupingEnabled; - analyticsView = deviceType.analyticsView; - } - - deviceTypes.push({ - "type": data[i], - "category": category, - "label": label, - "thumb": utility.getDeviceThumb(data[i]), - "analyticsEnabled": analyticsEnabled, - "groupingEnabled": groupingEnabled, - "analyticsView" : analyticsView - }); - } - } - } - viewModel.deviceTypes = stringify(deviceTypes); - } - } - - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var serverUrl = mdmProps["httpsURL"]; - var portalUrl = mdmProps["portalURL"]; - var userDomain = context.user.domain; - viewModel.serverUrl = serverUrl; - viewModel.portalUrl = portalUrl; - viewModel.userDomain = userDomain; - return viewModel; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.json deleted file mode 100644 index cba60e495a..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/devices.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/devices", - "layout": "cdmf.layout.default" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/public/js/listing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/public/js/listing.js deleted file mode 100644 index 0d5ce68aab..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devices/public/js/listing.js +++ /dev/null @@ -1,959 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Following function would execute - * when a user clicks on the list item - * initial mode and with out select mode. - */ -function InitiateViewOption(url) { - if ($(".select-enable-btn").text() == "Select" && !$(this).hasClass("btn")) { - url = $(this).parent().data("url"); - $(location).attr('href', url); - } -} - -(function () { - var cache = {}; - var validateAndReturn = function (value) { - return (value == undefined || value == null) ? "Unspecified" : value; - }; - Handlebars.registerHelper("deviceMap", function (device) { - device.owner = validateAndReturn(device.owner); - device.ownership = validateAndReturn(device.ownership); - var arr = device.properties; - if (arr) { - device.properties = arr.reduce(function (total, current) { - total[current.name] = validateAndReturn(current.value); - return total; - }, {}); - } - }); -})(); - -/* - * Setting-up global variables. - */ -var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; -var assetContainer = "#ast-container"; - -var deviceListing, currentUser, groupId; - -/* - * DOM ready functions. - */ -$(document).ready(function () { - - var permissionSet = {}; - $.setPermission = function (permission) { - permissionSet[permission] = true; - }; - - $.hasPermission = function (permission) { - return permissionSet[permission]; - }; - - deviceListing = $("#device-listing"); - currentUser = deviceListing.data("current-user"); - - groupId = getParameterByName("groupId"); - - /* Adding selected class for selected devices */ - $(deviceCheckbox).each(function () { - addDeviceSelectedClass(this); - }); - - /* for device list sorting drop down */ - $(".ctrl-filter-type-switcher").popover({ - html: true, - content: function () { - return $("#content-filter-types").html(); - } - }); -}); - -/* - * On Select All Device button click function. - * - * @param button: Select All Device button - */ -function selectAllDevices(button) { - if (!$(button).data('select')) { - $(deviceCheckbox).each(function (index) { - $(this).prop('checked', true); - addDeviceSelectedClass(this); - }); - $(button).data('select', true); - $(button).html('Deselect All Devices'); - } else { - $(deviceCheckbox).each(function (index) { - $(this).prop('checked', false); - addDeviceSelectedClass(this); - }); - $(button).data('select', false); - $(button).html('Select All Devices'); - } -} - -/* - * On listing layout toggle buttons click function. - * - * @param view: Selected view type - * @param selection: Selection button - */ -function changeDeviceView(view, selection) { - $(".view-toggle").each(function () { - $(this).removeClass("selected"); - }); - $(selection).addClass("selected"); - if (view == "list") { - $(assetContainer).addClass("list-view"); - } else { - $(assetContainer).removeClass("list-view"); - } -} - -/* - * Add selected style class to the parent element function. - * - * @param checkbox: Selected checkbox - */ -function addDeviceSelectedClass(checkbox) { - if ($(checkbox).is(":checked")) { - $(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select"); - } else { - $(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select"); - } -} - -function toTitleCase(str) { - return str.replace(/\w\S*/g, function (txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - }); -} - -function loadDevices(searchType, searchParam) { - var serviceURL; - if (groupId && $.hasPermission("LIST_OWN_DEVICES")) { - serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices"; - } else if ($.hasPermission("LIST_DEVICES")) { - serviceURL = "/api/device-mgt/v1.0/devices"; - } else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) { - //Get authenticated users devices - serviceURL = "/api/device-mgt/v1.0/devices?user=" + currentUser; - } else { - $("#loading-content").remove(); - $('#device-table').addClass('hidden'); - $('#device-listing-status-msg').text('Permission denied.'); - $("#device-listing-status").removeClass(' hidden'); - return; - } - - function getPropertyValue(deviceProperties, propertyName) { - if (!deviceProperties) { - return; - } - var property; - for (var i = 0; i < deviceProperties.length; i++) { - property = deviceProperties[i]; - if (property.name == propertyName) { - return property.value; - } - } - return {}; - } - - function getDeviceTypeLabel(type) { - var deviceTypes = deviceListing.data("deviceTypes"); - for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes[i].type == type) { - return deviceTypes[i].label; - } - } - return type; - } - - function getDeviceTypeCategory(type) { - var deviceTypes = deviceListing.data("deviceTypes"); - for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes[i].type == type) { - return deviceTypes[i].category; - } - } - return type; - } - - function getDeviceTypeThumb(type) { - var deviceTypes = deviceListing.data("deviceTypes"); - for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes[i].type == type) { - return deviceTypes[i].thumb; - } - } - return type; - } - - function analyticsEnabled(type) { - var deviceTypes = deviceListing.data("deviceTypes"); - for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes[i].type == type) { - var analyticsEnabled = deviceTypes[i].analyticsEnabled; - if (analyticsEnabled == undefined) { - // By default it should be enabled - return true; - } - // In JS Boolean("false") returns TRUE => http://stackoverflow.com/a/264037/1560536 - return (analyticsEnabled == "true"); - } - } - return true; - } - - // Read "analyticsView" from config.json and return value if exists - function getAnalyticsView(type) { - var deviceTypes = deviceListing.data("deviceTypes"); - for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes[i].type == type) { - var analyticsView = deviceTypes[i].analyticsView; - if (analyticsEnabled == undefined) { - // if undefined go to default analytics view - return "none"; - } - return analyticsView; - } - } - return "none"; - } - - function groupingEnabled(type) { - var deviceTypes = deviceListing.data("deviceTypes"); - for (var i = 0; i < deviceTypes.length; i++) { - if (deviceTypes[i].type == type) { - var groupingEnabled = deviceTypes[i].groupingEnabled; - if (groupingEnabled == undefined) { - // By default it should be enabled - return true; - } - // In JS Boolean("false") returns TRUE => http://stackoverflow.com/a/264037/1560536 - return (groupingEnabled == "true"); - } - } - return true; - } - - var columns = [ - { - targets: 0, - data: 'name', - class: 'remove-padding icon-only content-fill viewEnabledIcon', - render: function (data, type, row, meta) { - return '
    '; - } - }, - { - targets: 1, - data: 'name', - class: 'viewEnabledIcon', - render: function (name, type, row, meta) { - var model = getPropertyValue(row.properties, 'DEVICE_MODEL'); - var vendor = getPropertyValue(row.properties, 'VENDOR'); - var html = '

    ' + name + '

    '; - if (model) { - html += '
    (' + vendor + '-' + model + ')
    '; - } - return html; - } - }, - { - targets: 2, - data: 'userPattern', - class: 'remove-padding-top viewEnabledIcon' - }, - { - targets: 3, - data: 'status', - class: 'remove-padding-top viewEnabledIcon', - render: function (status, type, row, meta) { - var html; - switch (status) { - case 'ACTIVE' : - html = ' Active'; - break; - case 'INACTIVE' : - html = ' Inactive'; - break; - case 'BLOCKED' : - html = ' Blocked'; - break; - case 'REMOVED' : - html = ' Removed'; - break; - case 'UNREACHABLE' : - html = ' Unreachable'; - break; - } - return html; - } - }, - { - targets: 4, - data: 'type', - class: 'remove-padding-top viewEnabledIcon', - render: function (status, type, row, meta) { - return getDeviceTypeLabel(row.deviceType); - } - }, - { - targets: 5, - data: 'ownership', - class: 'remove-padding-top viewEnabledIcon', - render: function (status, type, row, meta) { - if (getDeviceTypeCategory(row.deviceType) == 'mobile') { - return row.ownership; - } else { - return null; - } - } - }, - { - targets: 6, - data: 'action-buttons', - class: 'text-right content-fill text-left-on-grid-view no-wrap tooltip-overflow-fix', - render: function (status, type, row, meta) { - var deviceType = row.deviceType; - var deviceIdentifier = row.deviceIdentifier; - var html = ''; - var portalUrl = $("#device-listing").data("portal-url"); - var serverUrl = $("#device-listing").data("server-url"); - var userDomain = $("#device-listing").data("userDomain"); - var statURL; - if (status != 'REMOVED') { - html = ''; - - if (analyticsEnabled(row.deviceType)) { - - // redirecting to respective analytics view depending on device configs - switch (getAnalyticsView(deviceType)) { - case "DAS" : { statURL =portalUrl + "/portal/t/"+ userDomain+ "/dashboards/android-iot/battery?owner=" +currentUser+"&deviceId=";break;} - default : {statURL=context+ "/device/" + row.deviceType +"/analytics?deviceId="} - } - - html += '' + - '' + - ''; - } - - if (!groupId && groupingEnabled(row.deviceType)) { - html += - '' + - '' + - ''; - } - - html += - '' - + '' - + '' - + ''; - var groupOwner = $('#group_owner').text(); - if (groupId && groupOwner != "wso2.system.user") { - html += - '' - + '' - + '' - + ''; - } else { - html += - '' - + '' - + '' - + ''; - } - } - return html; - } - } - ]; - - var fnCreatedRow = function (row, data, dataIndex) { - - if(data.status != "REMOVED"){ - $(row).attr('data-type', 'selectable'); - }else{ - $(row).attr('data-type', 'non-selectable'); - } - - $(row).attr('data-deviceid', htmlspecialchars(data.deviceIdentifier)); - $(row).attr('data-devicetype', htmlspecialchars(data.deviceType)); - $(row).attr('data-url', context + '/device/' + htmlspecialchars(data.deviceType) + '?id=' + htmlspecialchars(data.deviceIdentifier)); - var model = htmlspecialchars(getPropertyValue(data.properties, 'DEVICE_MODEL')); - var vendor = htmlspecialchars(getPropertyValue(data.properties, 'VENDOR')); - var owner = htmlspecialchars(data.userPattern); - var status = htmlspecialchars(data.status); - var ownership = htmlspecialchars(data.ownership); - var deviceType = htmlspecialchars(data.deviceType); - var category = getDeviceTypeCategory(deviceType); - $.each($('td', row), function (colIndex) { - switch (colIndex) { - case 1: - $(this).attr('data-search', model + ',' + vendor); - $(this).attr('data-display', model); - break; - case 2: - $(this).attr('data-grid-label', "Owner"); - $(this).attr('data-search', owner); - $(this).attr('data-display', owner); - break; - case 3: - $(this).attr('data-grid-label', "Status"); - $(this).attr('data-search', status); - $(this).attr('data-display', status); - break; - case 4: - $(this).attr('data-grid-label', "Type"); - $(this).attr('data-search', deviceType); - $(this).attr('data-display', getDeviceTypeLabel(deviceType)); - break; - case 5: - if (category == 'mobile') { - $(this).attr('data-grid-label', "Ownership"); - $(this).attr('data-search', ownership); - $(this).attr('data-display', ownership); - } - break; - } - }); - }; - - function htmlspecialchars(text) { - return jQuery('
    ').text(text).html(); - } - - var dataFilter = function (data) { - data = JSON.parse(data); - var objects = []; - - $(data.devices).each(function (index) { - objects.push( - { - model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"), - vendor: getPropertyValue(data.devices[index].properties, "VENDOR"), - userPattern: data.devices[index].enrolmentInfo.owner, - status: data.devices[index].enrolmentInfo.status, - ownership: data.devices[index].enrolmentInfo.ownership, - deviceType: data.devices[index].type, - deviceIdentifier: data.devices[index].deviceIdentifier, - name: data.devices[index].name - } - ); - }); - - var json = { - "recordsTotal": data.count, - "recordsFiltered": data.count, - "data": objects - }; - return JSON.stringify(json); - }; - - $('#device-grid').datatables_extended_serverside_paging( - null, - serviceURL, - dataFilter, - columns, - fnCreatedRow, - function () { - $(".icon .text").res_text(0.2); - $('#device-grid').removeClass('hidden'); - $("#loading-content").remove(); - attachDeviceEvents(); - - - // if ($('.advance-search').length < 1) { - // $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input') - // .after('Advance Search'); - // } - - }, { - "placeholder": "Search By Device Name", - "searchKey": "name" - } - ); - - $(deviceCheckbox).click(function () { - addDeviceSelectedClass(this); - }); -} - -function openCollapsedNav() { - $('.wr-hidden-nav-toggle-btn').addClass('active'); - $('#hiddenNav').slideToggle('slideDown', function () { - if ($(this).css('display') == 'none') { - $('.wr-hidden-nav-toggle-btn').removeClass('active'); - } - }); -} - -/* - * DOM ready functions. - */ -$(document).ready(function () { - /* Adding selected class for selected devices */ - $(deviceCheckbox).each(function () { - addDeviceSelectedClass(this); - }); - - var permissionList = $("#permission").data("permission"); - for (var key in permissionList) { - if (permissionList.hasOwnProperty(key)) { - $.setPermission(key); - } - } - - loadDevices(); - - /* for device list sorting drop down */ - $(".ctrl-filter-type-switcher").popover({ - html: true, - content: function () { - return $("#content-filter-types").html(); - } - }); - - /* for data tables*/ - $('[data-toggle="tooltip"]').tooltip(); - - $("[data-toggle=popover]").popover(); - - $(".ctrl-filter-type-switcher").popover({ - html: true, - content: function () { - return $('#content-filter-types').html(); - } - }); - - $('#nav').affix({ - offset: { - top: $('header').height() - } - }); - -}); - -var modalPopup = ".modal"; -var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-content"; -var body = "body"; - -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - $(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(""); - $(modalPopupContent).removeClass("operation-data"); - $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right', '0px'); - $('.modal-backdrop').remove(); -} - -function markAlreadyAssignedGroups(deviceId, deviceType) { - var successCallback = function (data, textStatus, xhr) { - data = JSON.parse(data); - if (xhr.status == 200) { - if (data.length > 0) { - var selectedValues = []; - for (var i = 0; i < data.length; i++) { - if (data[i].owner != "wso2.system.user") { - selectedValues.push(data[i].id); - } - } - $("#groups").val(selectedValues).trigger("change"); - } - } else { - displayErrors(xhr); - } - }; - - invokerUtil.get("/api/device-mgt/v1.0/groups/device?deviceId=" + deviceId + "&deviceType=" + deviceType, - successCallback, function (message) { - displayErrors(message); - }); -} - -/** - * Following functions should be triggered after AJAX request is made. - */ -function attachDeviceEvents() { - - /** - * Following click function would execute - * when a user clicks on "Group" link - * on Device Management page in WSO2 DeviceMgt Console. - */ - if ($("a.group-device-link").length > 0) { - $("a.group-device-link").click(function () { - var deviceId = $(this).data("deviceid"); - var deviceType = $(this).data("devicetype"); - $(modalPopupContent).html($('#group-device-modal-content').html()); - $('#user-groups').html( - '
    '); - $("a#group-device-update-link").hide(); - showPopup(); - - var serviceURL; - if ($.hasPermission("LIST_ALL_GROUPS")) { - serviceURL = "/api/device-mgt/v1.0/admin/groups?limit=100"; - } else if ($.hasPermission("LIST_GROUPS")) { - //Get authenticated users groups - serviceURL = "/api/device-mgt/v1.0/groups?limit=100"; - } - - invokerUtil.get(serviceURL, function (data) { - $("a#group-device-add-link").hide(); - var groups = JSON.parse(data); - var html = ''; - var hasGroups = false; - for (var i = 0; i < groups.deviceGroups.length; i++) { - if (groups.deviceGroups[i].owner != "wso2.system.user") { - html += ''; - hasGroups = true; - } - } - if (hasGroups) { - html = '

    Please select device group(s)


    ' + - '
    ' + - '
    '; - markAlreadyAssignedGroups(deviceId, deviceType); - $("a#group-device-update-link").show(); - $("a#group-add-link").hide(); - } else { - $("a#group-device-update-link").hide(); - $("a#group-add-link").show(); - html += '

    You don\'t have any existing device groups. Please add new device group first.

    ' - } - $('#user-groups').html(html); - $("select.select2[multiple=multiple]").select2({ - tags: false - }); - $("a#group-device-update-link").click(function () { - var deviceIdentifier = {"id": deviceId, "type": deviceType}; - var deviceGroupIds = $("#groups").val(); - if (!deviceGroupIds) { - deviceGroupIds = []; - } - var deviceToGroupsAssignment = { - deviceIdentifier: deviceIdentifier, - deviceGroupIds: deviceGroupIds - }; - serviceURL = "/api/device-mgt/v1.0/groups/device/assign"; - invokerUtil.post(serviceURL, deviceToGroupsAssignment, function (data) { - $(modalPopupContent).html($('#group-associate-device-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - }, function (jqXHR) { - displayDeviceErrors(jqXHR); - }); - }); - }, function (jqXHR) { - if (jqXHR.status == 404) { - $(modalPopupContent).html($('#group-404-content').html()); - $("a#cancel-link").click(function () { - hidePopup(); - }); - } else { - displayDeviceErrors(jqXHR); - } - }); - - $("a#group-device-cancel-link").click(function () { - hidePopup(); - }); - }); - - } - - /** - * Following click function would execute - * when a user clicks on "Remove" link - * on Device Management page in WSO2 MDM Console. - */ - $("a.remove-device-link").click(function () { - var deviceIdentifiers = []; - var deviceId = $(this).data("deviceid"); - var deviceType = $(this).data("devicetype"); - - if (deviceId && deviceType) { - deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; - } else { - deviceIdentifiers = getSelectedDevices(); - } - - if (deviceIdentifiers.length == 0) { - $(modalPopupContent).html($('#no-device-selected').html()); - $("a#no-device-selected-link").click(function () { - hidePopup(); - }); - showPopup(); - return; - } - - $(modalPopupContent).html($('#remove-device-modal-content').html()); - showPopup(); - - $("a#remove-device-yes-link").click(function () { - if (groupId) { - var serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove"; - invokerUtil.post(serviceURL, deviceIdentifiers, function (message) { - $(modalPopupContent).html($('#remove-device-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - }, function (jqXHR) { - displayDeviceErrors(jqXHR); - }); - } else { - removeDevices(deviceIdentifiers); - } - }); - - $("a#remove-device-cancel-link").click(function () { - hidePopup(); - }); - }); - - /** - * Following click function would execute - * when a user clicks on "Edit" link - * on Device Management page in WSO2 MDM Console. - */ - $("a.edit-device-link").click(function () { - var deviceId = $(this).data("deviceid"); - var deviceType = $(this).data("devicetype"); - var deviceName = $(this).data("devicename"); - var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceType + "/id/" + deviceId + "/rename"; - - $(modalPopupContent).html($('#edit-device-modal-content').html()); - $('#edit-device-name').val(deviceName); - showPopup(); - - $("a#edit-device-yes-link").click(function () { - var newDeviceName = $('#edit-device-name').val(); - var request = {}; - request['name'] = newDeviceName; - invokerUtil.post(serviceURL, request, function (message) { - $(modalPopupContent).html($('#edit-device-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - }, function (jqXHR) { - displayDeviceErrors(jqXHR); - }); - }); - - $("a#edit-device-cancel-link").click(function () { - hidePopup(); - }); - }); - - /** - * Following click function would execute - * when a user clicks on "Add to Group" link - * on Device Management page in WSO2 devicemgt Console. - */ - $("a.add-devices-to-group-link").click(function () { - $("a#group-device-update-link").hide(); - var deviceIdentifiers = getSelectedDevices(); - if (deviceIdentifiers.length == 0) { - $(modalPopupContent).html($('#no-device-selected').html()); - $("a#no-device-selected-link").click(function () { - hidePopup(); - }); - showPopup(); - return; - } - - $(modalPopupContent).html($('#group-device-modal-content').html()); - $('#user-groups').html( - '
    '); - $("a#group-device-add-link").hide(); - showPopup(); - - var serviceURL; - if ($.hasPermission("LIST_ALL_GROUPS")) { - serviceURL = "/api/device-mgt/v1.0/admin/groups?limit=100"; - } else if ($.hasPermission("LIST_GROUPS")) { - //Get authenticated users groups - serviceURL = "/api/device-mgt/v1.0/groups?limit=100"; - } - - invokerUtil.get(serviceURL, function (data) { - var groups = JSON.parse(data); - var html = ''; - var hasGroups = false; - for (var i = 0; i < groups.deviceGroups.length; i++) { - if (groups.deviceGroups[i].owner != "wso2.system.user") { - html += ''; - hasGroups = true; - } - } - if (hasGroups) { - html = '
    '; - $("a#group-add-link").hide(); - $("a#group-device-add-link").show(); - } else { - html += '

    You don\'t have any existing device groups. Please add new device group first.

    '; - $("a#group-add-link").show(); - $("a#group-device-add-link").hide(); - } - $('#user-groups').html(html); - $("a#group-device-add-link").click(function () { - var selectedGroup = $('#assign-group-selector').val(); - serviceURL = "/api/device-mgt/v1.0/groups/id/" + selectedGroup + "/devices/add"; - invokerUtil.post(serviceURL, deviceIdentifiers, function (data) { - $(modalPopupContent).html($('#group-associate-device-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - }, function (jqXHR) { - displayDeviceErrors(jqXHR); - }); - }); - }, function (jqXHR) { - if (jqXHR.status == 404) { - $(modalPopupContent).html($('#group-404-content').html()); - $("a#cancel-link").click(function () { - hidePopup(); - }); - } else { - displayDeviceErrors(jqXHR); - } - }); - - $("a#group-device-cancel-link").click(function () { - hidePopup(); - }); - }); -} - -function removeDevices(deviceIdentifiers) { - var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceIdentifiers[0].type + "/id/" + deviceIdentifiers[0].id; - invokerUtil.delete(serviceURL, function (message) { - if (deviceIdentifiers.length > 1) { - deviceIdentifiers.slice(1, deviceIdentifiers.length); - removeDevices(deviceIdentifiers); - } else { - $(modalPopupContent).html($('#remove-device-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - } - }, function (jqXHR) { - displayDeviceErrors(jqXHR); - }); -} - -function displayDeviceErrors(jqXHR) { - showPopup(); - if (jqXHR.status == 400) { - $(modalPopupContent).html($('#device-400-content').html()); - $("a#device-400-link").click(function () { - hidePopup(); - }); - } else if (jqXHR.status == 403) { - $(modalPopupContent).html($('#device-403-content').html()); - $("a#device-403-link").click(function () { - hidePopup(); - }); - } else if (jqXHR.status == 409) { - $(modalPopupContent).html($('#device-409-content').html()); - $("a#device-409-link").click(function () { - hidePopup(); - }); - } else { - $(modalPopupContent).html($('#device-unexpected-error-content').html()); - $("a#device-unexpected-error-link").click(function () { - hidePopup(); - }); - console.log("Error code: " + jqXHR.status); - } -} - -function getParameterByName(name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); -} - -/* - * Function to get selected devices. - */ -function getSelectedDevices() { - var deviceList = []; - var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); - thisTable.api().rows().every(function () { - if ($(this.node()).hasClass('DTTT_selected')) { - deviceList.push( - { - "id": $(thisTable.api().row(this).node()).data('deviceid'), - "type": $(thisTable.api().row(this).node()).data('devicetype') - } - ); - } - }); - - return deviceList; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.hbs deleted file mode 100644 index e59b248e4f..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.hbs +++ /dev/null @@ -1,114 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} - -{{unit "cdmf.unit.ui.title" pageTitle="Device Type Management"}} -{{unit "cdmf.unit.data-tables-extended"}} -{{unit "cdmf.unit.ui.modal"}} - -{{#zone "topCss"}} - {{css "css/custom.css"}} -{{/zone}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • -
  • - - - Device Types - -
  • -{{/zone}} - -{{#zone "navbarActions"}} - {{#unless isCloud}} -
  • - - - - - - - Create Device Type - -
  • - {{/unless}} -{{/zone}} - -{{#zone "content"}} - {{#if hasDeviceTypes}} -
    - - - Loading device types . . . -
    -
    - -
    - - - - - - - - - - -
    By Device Type Name
    -
    - - - - {{else}} - -
    -
    -

    You Haven't created device types yet.

    -
    Please click "Create a Device Type", if you wish to create a device type. -
    - - - - - - - Create Device Type - -
    -
    - - {{/if}} -{{/zone}} - -{{#zone "bottomJs"}} - - - {{js "js/devicetype-listing.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.js deleted file mode 100644 index 4fb1980df5..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - - context["permissions"] = userModule.getUIPermissions(); - if (userModule.isAuthorized("/permission/admin/device-mgt/admin/device-type")) { - context["editPermitted"] = true; - } - var deviceTypeCount = deviceModule.getDeviceTypeCount(); - - if (deviceTypeCount > 0) { - context["hasDeviceTypes"] = true; - } else { - context["hasDeviceTypes"] = false; - } - - return context; -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.json deleted file mode 100644 index 4dfd684380..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/devicetypes.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/device-types", - "layout": "cdmf.layout.default" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/css/custom.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/css/custom.css deleted file mode 100644 index 094068472f..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/css/custom.css +++ /dev/null @@ -1,3 +0,0 @@ -#devicetype-table .dataTablesTop{ - Display : none; -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/js/devicetype-listing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/js/devicetype-listing.js deleted file mode 100644 index 6dfe99b268..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/js/devicetype-listing.js +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var loadDeviceTypeBasedActionURL = function (action, deviceTypeName) { - href = $("#ast-container").data("app-context") + "device-type/" + action + "?type=" + encodeURIComponent(deviceTypeName); - $(location).attr('href', href); -}; - -$(function () { - var sortableElem = '.wr-sortable'; - $(sortableElem).sortable({ - beforeStop: function () { - $(this).sortable('toArray'); - } - }); - $(sortableElem).disableSelection(); -}); - -var apiBasePath = "/api/device-mgt/v1.0"; -var modalPopup = ".modal"; -var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-content"; -var body = "body"; -var isInit = true; -var isCloud = false; - - -/** - * - * Fires the res_text when ever a data table redraw occurs making - * the font icons change the size to respective screen resolution. - * - */ -$(document).on('draw.dt', function () { - $(".icon .text").res_text(0.2); -}); - - -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - $(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); - //setPopupMaxHeight(); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(''); - $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right', '0px'); - $('.modal-backdrop').remove(); -} - - -/** - * Following function would execute - * when a user clicks on the list item - * initial mode and with out select mode. - */ -function InitiateViewOption() { - // $(location).attr('href', $(this).data("url")); -} - -function htmlspecialchars(text) { - return jQuery('
    ').text(text).html(); -} - -function loadDeviceTypes() { - var loadingContent = $("#loading-content"); - loadingContent.show(); - - var dataFilter = function (data) { - data = JSON.parse(data); - var objects = []; - $(data).each(function (index) { - objects.push( - { - name: htmlspecialchars(data[index].name), - DT_RowId: "devicetype-" + htmlspecialchars(data[index].name), - metaDefinition: (data[index].deviceTypeMetaDefinition ? true : false) - } - ) - }); - - var json = { - "recordsTotal": data.length, - "recordsFiltered": data.length, - "data": objects - }; - - return JSON.stringify(json); - }; - - //noinspection JSUnusedLocalSymbols - var fnCreatedRow = function (nRow, aData, iDataIndex) { - $(nRow).attr('data-type', 'selectable'); - }; - - //noinspection JSUnusedLocalSymbols - var columns = [ - { - class: "remove-padding content-fill", - data: null, - defaultContent: "
    " + - "" + - "
    " - }, - { - class: "", - data: "name", - render: function (name, type, row, meta) { - return '

    ' + name.replace("devicemgt", "") + '

    '; - } - }, - { - class: "text-right content-fill text-left-on-grid-view no-wrap", - data: null, - render: function (data, type, row, meta) { - var isCloud = false; - if ($('#is-cloud').length > 0) { - isCloud = true; - } - - var innerhtml = ''; - if (data.metaDefinition) { - - var editLink = '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''; - - var editEventLink = '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''; - - innerhtml = editLink + editEventLink; - } - return innerhtml; - } - } - ]; - - var options = { - "placeholder": "Search By Device Type Name", - "searchKey": "filter", - "searching": false - }; - var settings = { - "sorting": false - }; - var deviceTypeApiUrl = '/api/device-mgt/v1.0/admin/device-types'; - - $('#devicetype-grid').datatables_extended_serverside_paging(settings, deviceTypeApiUrl, dataFilter, columns, fnCreatedRow, null, options); - loadingContent.hide(); - -} - -$(document).ready(function () { - loadDeviceTypes(); -}); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/templates/devicetype-listing.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/templates/devicetype-listing.hbs deleted file mode 100644 index 6835f28e9c..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.devicetypes/public/templates/devicetype-listing.hbs +++ /dev/null @@ -1,44 +0,0 @@ -{{#each deviceTypes}} - - -
    - -
    - - {{deviceTypeName}} - - - {{#if canEdit}} - - - - - - - - - - - - - - - - - - - - - - - - - {{/if}} - - -{{/each}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.hbs deleted file mode 100644 index 4fbf555f53..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.hbs +++ /dev/null @@ -1,43 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file - except in compliance with the License. You may - obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} - -{{unit "cdmf.unit.ui.title" pageTitle="Policy Management | View Policy"}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • -
  • - - - Policies - -
  • -
  • - - View - -
  • -{{/zone}} - -{{#zone "content"}} - {{unit "cdmf.unit.device.operation-mod"}} - {{unit "cdmf.unit.effective-policy.view"}} -{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.js deleted file mode 100644 index 46b4ed70b7..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var utility = require("/app/modules/utility.js")["utility"]; - var deviceType = context.uriParams.deviceType; - var deviceId = context.uriParams.deviceId; - return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, deviceId,"policy-view")}; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.json deleted file mode 100644 index ec79d2b203..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.effective-policy.view/view.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/policy/effective-policy/", - "layout": "cdmf.layout.default" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.hbs deleted file mode 100644 index 645d05b0ed..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.hbs +++ /dev/null @@ -1,420 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} -{{unit "cdmf.unit.ui.title" pageTitle="Group Management"}} -{{unit "cdmf.unit.ui.content.title" pageHeader="Groups"}} - -{{unit "cdmf.unit.lib.service-invoker-utility"}} -{{unit "cdmf.unit.data-tables-extended"}} -{{unit "cdmf.unit.lib.ui-permissions-utility"}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • -
  • - - Groups - -
  • -{{/zone}} - -{{#zone "navbarActions"}} - {{#if permissions.ADD_GROUP}} -
  • - - - - - - Add Group - -
  • - {{/if}} -{{/zone}} - -{{#zone "content"}} -
    -
    -
    -
    - - - {{#if groupCount}} -
    - - - - - - - - - - - - - - - - -
    By Owner
    -
    - {{else}} -
    - -
    - {{/if}} - -
    - - - -
    - -
    - - - -
    - -
    -
    -
    -
    -

    Group successfully updated.

    -
    - Do you want to manage users? - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -

    New Role was successfully created.

    -
    - Do you need to Add / Remove users from the chosen roles? - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Do you really want to remove this group from your Group List?

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group was successfully removed.

    -
    -
    -
    -
    - -
    - - - -
    - -
    -
    -
    -
    -

    Group was successfully updated.

    -
    -
    -
    -
    - -
    -
    -
    -
    -

    Bad Request. Please contact your administrator.

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Operation not permitted.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Not found.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Group does not exist.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Unexpected error occurred!

    - - -
    -
    -
    -
    -
    -
    -
    -{{/zone}} - -{{#zone "bottomJs"}} - {{#if groupCount}} - {{js "js/listing.js"}} - {{/if}} -{{/zone}} - -{{#zone "topCss"}} - -{{/zone}} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.js deleted file mode 100644 index ec940f9e98..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var constants = require("/app/modules/constants.js"); - var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var currentUser = session.get(constants.USER_SESSION_KEY); - var page = {}; - if (currentUser) { - page.permissions = userModule.getUIPermissions(); - page.permissions.list = stringify(page.permissions); - page.currentUser = currentUser; - var groupCount = groupModule.getGroupCount(); - if (groupCount > 0) { - page.groupCount = groupCount; - } - } - page.isCloud = deviceMgtProps.isCloud; - return page; -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.json deleted file mode 100644 index 4c9f556503..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/groups.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/groups", - "layout": "cdmf.layout.default" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/public/images/group-icon.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/public/images/group-icon.png deleted file mode 100644 index 156fbc6edc..0000000000 Binary files a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/public/images/group-icon.png and /dev/null differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/public/js/listing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/public/js/listing.js deleted file mode 100644 index 4c8cf8ec66..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.groups/public/js/listing.js +++ /dev/null @@ -1,646 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Following function would execute - * when a user clicks on the list item - * initial mode and with out select mode. - */ -function InitiateViewOption(url) { - if ($(".select-enable-btn").text() == "Select") { - url = $(this).parent().data("url"); - $(location).attr('href', url); - } -} - -(function () { - var cache = {}; - var validateAndReturn = function (value) { - return (value == undefined || value == null) ? "Unspecified" : value; - }; - Handlebars.registerHelper("deviceMap", function (device) { - device.owner = validateAndReturn(device.owner); - device.ownership = validateAndReturn(device.ownership); - var arr = device.properties; - if (arr) { - device.properties = arr.reduce(function (total, current) { - total[current.name] = validateAndReturn(current.value); - return total; - }, {}); - } - }); -})(); - -/* - * Setting-up global variables. - */ -var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; -var assetContainer = "#ast-container"; - -/* - * On Select All Groups button click function. - * - * @param button: Select All Groups button - */ -function selectAllDevices(button) { - if (!$(button).data('select')) { - $(groupCheckbox).each(function (index) { - $(this).prop('checked', true); - addGroupSelectedClass(this); - }); - $(button).data('select', true); - $(button).html('Deselect All Groups'); - } else { - $(groupCheckbox).each(function (index) { - $(this).prop('checked', false); - addGroupSelectedClass(this); - }); - $(button).data('select', false); - $(button).html('Select All Groups'); - } -} - -/* - * On listing layout toggle buttons click function. - * - * @param view: Selected view type - * @param selection: Selection button - */ -function changeDeviceView(view, selection) { - $(".view-toggle").each(function () { - $(this).removeClass("selected"); - }); - $(selection).addClass("selected"); - if (view == "list") { - $(assetContainer).addClass("list-view"); - } else { - $(assetContainer).removeClass("list-view"); - } -} - -/* - * Add selected style class to the parent element function. - * - * @param checkbox: Selected checkbox - */ -function addGroupSelectedClass(checkbox) { - if ($(checkbox).is(":checked")) { - $(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select"); - } else { - $(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select"); - } -} - -function toTitleCase(str) { - return str.replace(/\w\S*/g, function (txt) { - return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); - }); -} - -function htmlspecialchars(text) { - return jQuery('
    ').text(text).html(); -} - -function loadGroups() { - var groupListing = $("#group-listing"); - var currentUser = groupListing.data("currentUser"); - var serviceURL; - if ($.hasPermission("LIST_ALL_GROUPS")) { - serviceURL = "/api/device-mgt/v1.0/admin/groups"; - } else if ($.hasPermission("LIST_GROUPS")) { - //Get authenticated users groups - serviceURL = "/api/device-mgt/v1.0/groups"; - } else { - $("#loading-content").remove(); - $('#device-table').addClass('hidden'); - $('#device-listing-status-msg').text('Permission denied.'); - $("#device-listing-status").removeClass(' hidden'); - return; - } - - var dataFilter = function (data) { - data = JSON.parse(data); - var objects = []; - $(data.deviceGroups).each(function (index) { - objects.push({ - groupId: htmlspecialchars(data.deviceGroups[index].id), - name: htmlspecialchars(data.deviceGroups[index].name), - description: htmlspecialchars(data.deviceGroups[index].description), - owner: htmlspecialchars(data.deviceGroups[index].owner) - }) - }); - var json = { - "recordsTotal": data.count, - "recordsFiltered": data.count, - "data": objects - }; - return JSON.stringify(json); - }; - - var columns = [ - { - targets: 0, - data: 'id', - class: 'remove-padding icon-only content-fill viewEnabledIcon', - render: function (data, type, row, meta) { - return '
    '; - } - }, - { - targets: 1, - data: 'name', - class: 'viewEnabledIcon' - }, - { - targets: 2, - data: 'owner', - class: 'remove-padding-top viewEnabledIcon' - }, - { - targets: 3, - data: 'description', - class: 'remove-padding-top viewEnabledIcon' - }, - { - targets: 4, - data: 'id', - class: 'text-right content-fill text-left-on-grid-view no-wrap tooltip-overflow-fix', - render: function (id, type, row, meta) { - var html = ''; - if ($.hasPermission("VIEW_GROUP_DEVICES")) { - /*html += '' + - '' - + - '';*/ - } - if (row.owner != "wso2.system.user") { - if ($.hasPermission("SHARE_GROUP")) { - html += - ''; - } - if ($.hasPermission("UPDATE_GROUP")) { - html += - '' + - ''; - } - if ($.hasPermission("REMOVE_GROUP")) { - html += - '' - + - ''; - } - } - return html; - } - } - ]; - - var fnCreatedRow = function (row, data) { - $(row).attr('data-type', 'selectable'); - if ($.hasPermission("VIEW_GROUP_DEVICES")) { - $(row).attr('data-url', 'devices?groupId=' + data.groupId + '&groupName=' + data.name); - } - $.each($('td', row), function (colIndex) { - switch (colIndex) { - case 1: - //TODO : The following line encodes html entities. - //Should check for a better solution since it only changes the presentation layer - $(this).text($("").html(this.innerText).text()) - $(this).attr('data-grid-label', "Name"); - $(this).attr('data-search', data.name); - $(this).attr('data-display', data.name); - break; - case 2: - $(this).attr('data-grid-label', "Owner"); - $(this).attr('data-search', data.owner); - $(this).attr('data-display', data.owner); - break; - case 3: - $(this).attr('data-grid-label', "Description"); - $(this).attr('data-search', data.description); - $(this).attr('data-display', data.description); - break; - } - }); - }; - - $('#group-grid').datatables_extended_serverside_paging( - null, - serviceURL, - dataFilter, - columns, - fnCreatedRow, - function (oSettings) { - $(".icon .text").res_text(0.2); - attachEvents(); - var thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable(); - thisTable.removeClass("table-selectable"); - }, - { - "placeholder": "Search By Group Name", - "searchKey": "name" - } - ); - $(groupCheckbox).click(function () { - addGroupSelectedClass(this); - }); -} - -function openCollapsedNav() { - $('.wr-hidden-nav-toggle-btn').addClass('active'); - $('#hiddenNav').slideToggle('slideDown', function () { - if ($(this).css('display') == 'none') { - $('.wr-hidden-nav-toggle-btn').removeClass('active'); - } - }); -} - -/* - * DOM ready functions. - */ -$(document).ready(function () { - - /* Adding selected class for selected devices */ - $(groupCheckbox).each(function () { - addGroupSelectedClass(this); - }); - - var permissionSet = {}; - - //This method is used to setup permission for device listing - $.setPermission = function (permission) { - permissionSet[permission] = true; - }; - - $.hasPermission = function (permission) { - return permissionSet[permission]; - }; - - var permissionList = $("#permission").data("permission"); - for (var key in permissionList) { - if (permissionList.hasOwnProperty(key)) { - $.setPermission(key); - } - } - - loadGroups(); - //$('#device-grid').datatables_extended(); - - /* for device list sorting drop down */ - $(".ctrl-filter-type-switcher").popover( - { - html: true, - content: function () { - return $("#content-filter-types").html(); - } - } - ); - - /* for data tables*/ - $('[data-toggle="tooltip"]').tooltip(); - - $("[data-toggle=popover]").popover(); - - $(".ctrl-filter-type-switcher").popover( - { - html: true, - content: function () { - return $('#content-filter-types').html(); - } - } - ); - - $('#nav').affix( - { - offset: { - top: $('header').height() - } - } - ); - -}); - -var modalPopup = ".modal"; -var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-content"; -var body = "body"; - -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - $(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(""); - $(modalPopupContent).removeClass("operation-data"); - $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right', '0px'); - $('.modal-backdrop').remove(); -} - -/** - * Following functions should be triggered after AJAX request is made. - */ -function attachEvents() { - /** - * Following click function would execute - * when a user clicks on "Share" link - * on Group Management page in WSO2 Device Management Server Console. - */ - $("a.share-group-link").click(function () { - var groupId = $(this).data("group-id"); - var groupOwner = $(this).data("group-owner"); - - $(modalPopupContent).html($('#share-group-w1-modal-content').html()); - showPopup(); - - listAllRoles(groupId); - var shareGroupNextLink = $("a#share-group-next-link"); - shareGroupNextLink.click(function () { - var roles = $("#roles").val(); - updateGroupShare(groupId, roles); - }); - - var shareGroupNewRoleFromSelectionLink = $("a#share-group-new-role-from-selection"); - shareGroupNewRoleFromSelectionLink.click(function () { - var roles = $("#roles").val(); - if (roles && roles.length >= 2) { - addNewRole(roles); - } else { - var errorMsgWrapper = "#notification-error-msg"; - var errorMsg = "#notification-error-msg span"; - $(errorMsg).text("To create a new role with the combination of roles, at least two roles should be" + - " selected."); - $(errorMsgWrapper).removeClass("hidden"); - } - }); - }); - - /** - * Following click function would execute - * when a user clicks on "Remove" link - * on Group Management page in WSO2 IoT Server Console. - */ - $("a.remove-group-link").click(function () { - var groupId = $(this).data("group-id"); - var groupOwner = $(this).data("group-owner"); - - $(modalPopupContent).html($('#remove-group-modal-content').html()); - showPopup(); - - $("a#remove-group-yes-link").click(function () { - var successCallback = function (data, textStatus, xhr) { - if (xhr.status == 200) { - $(modalPopupContent).html($('#remove-group-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - } else { - displayErrors(xhr); - } - }; - - invokerUtil.delete("/api/device-mgt/v1.0/groups/id/" + groupId, - successCallback, function (message) { - displayErrors(message); - }); - }); - - $("a#remove-group-cancel-link").click(function () { - hidePopup(); - }); - - }); - - /** - * Following click function would execute - * when a user clicks on "Edit" link - * on Device Management page in WSO2 MDM Console. - */ - $("a.edit-group-link").click(function () { - var groupId = $(this).data("group-id"); - var groupName = $(this).data("group-name"); - var groupOwner = $(this).data("group-owner"); - var groupDescription = $(this).data("group-description"); - - $(modalPopupContent).html($('#edit-group-modal-content').html()); - $('#edit-group-name').val(groupName); - $('#edit-group-description').val(groupDescription); - showPopup(); - - $("a#edit-group-yes-link").click(function () { - var newGroupName = $('#edit-group-name').val(); - var newGroupDescription = $('#edit-group-description').val(); - var group = {"name": newGroupName, "description": newGroupDescription, "owner": groupOwner}; - - var successCallback = function (data, textStatus, xhr) { - if (xhr.status == 200) { - $(modalPopupContent).html($('#edit-group-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - } else { - displayErrors(xhr); - } - }; - - invokerUtil.put("/api/device-mgt/v1.0/groups/id/" + groupId, group, - successCallback, function (message) { - displayErrors(message); - }); - }); - - $("a#edit-group-cancel-link").click(function () { - hidePopup(); - }); - }); -} - -function markAlreadySavedUsersRoles(groupId) { - var successCallback = function (data, textStatus, xhr) { - data = JSON.parse(data); - if (xhr.status == 200) { - if (data.roles.length > 0) { - var selectedValues = []; - for (var i = 0; i < data.roles.length; i++) { - selectedValues.push(data.roles[i]); - } - $("#roles").val(selectedValues).trigger("change"); - } else { - return; - } - } else { - displayErrors(xhr); - } - }; - - invokerUtil.get("/api/device-mgt/v1.0/groups/id/" + groupId + "/roles", - successCallback, function (message) { - displayErrors(message); - }); -} - -function listAllRoles(groupId) { - var successCallback = function (data, textStatus, xhr) { - data = JSON.parse(data); - if (xhr.status == 200) { - if (data.roles.length > 0) { - var html = ''; - $("#rolesListing").html(html); - markAlreadySavedUsersRoles(groupId); - $("select.select2[multiple=multiple]").select2({tags: false}).on("select2:select", function () { - $("#notification-error-msg").addClass("hidden"); - }); - } else { - $("#rolesListing").html("No roles available"); - } - } else { - displayErrors(xhr); - } - }; - - invokerUtil.get("/api/device-mgt/v1.0/roles?offset=0&limit=100&user-store=all", - successCallback, function (message) { - displayErrors(message); - }); -} - -function addNewRole(roles) { - $(modalPopupContent).html($('#share-group-w3-modal-content').html()); - $("a#share-group-w3-yes-link").click(function () { - var roleName = $('#group-sharing-role-name').val(); - if (roleName) { - createNewCombinedRole(roleName, roles); - } else { - var errorMsgWrapper = "#notification-error-msg"; - var errorMsg = "#notification-error-msg span"; - $(errorMsg).text("Role name cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } - }); - $("a#share-group-w3-cancel-link").click(function () { - hidePopup(); - }); -} - -function togglePermissionAction(element) { - $(element).data('value', 'checked'); - var icon = $(element).find("i")[1]; - if ($(icon).hasClass('fw-minus')) { - $(icon).removeClass('fw-minus'); - $(icon).addClass('fw-add'); - $(element).data('value', 'unchecked'); - } else { - $(icon).removeClass('fw-add'); - $(icon).addClass('fw-minus'); - $(element).data('value', 'checked'); - } -} - -function updateGroupShare(groupId, roles) { - var successCallback = function (data) { - $(modalPopupContent).html($('#share-group-200-content').html()); - }; - - invokerUtil.post("/api/device-mgt/v1.0/groups/id/" + groupId + "/share", - roles, successCallback, function (message) { - displayErrors(message); - }); -} - -function createNewCombinedRole(roleName, roleList) { - var successCallback = function (data, status, jqXHR, isLast) { - $(modalPopupContent).html($('#create-combined-role-200-content').html()); - showPopup(); - }; - invokerUtil.post("/api/device-mgt/v1.0/roles/create-combined-role/" + roleName, roleList, - successCallback, function (message) { - displayErrors(message); - }); -} - -function displayErrors(jqXHR) { - showPopup(); - if (jqXHR.status == 400) { - $(modalPopupContent).html($('#group-400-content').html()); - if (jqXHR.responseText) { - $('#error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), "")); - } - $("a#group-400-link").click(function () { - hidePopup(); - }); - } else if (jqXHR.status == 403) { - $(modalPopupContent).html($('#group-403-content').html()); - $("a#group-403-link").click(function () { - hidePopup(); - }); - } else if (jqXHR.status == 404) { - $(modalPopupContent).html($('#group-404-content').html()); - $("#group-404-message").html(jqXHR.responseText); - $("a#group-404-link").click(function () { - hidePopup(); - }); - } else if (jqXHR.status == 409) { - $(modalPopupContent).html($('#group-409-content').html()); - $("a#group-409-link").click(function () { - hidePopup(); - }); - } else { - $(modalPopupContent).html($('#group-unexpected-error-content').html()); - if (jqXHR.responseText) { - $('#unexp-error-msg').html(jqXHR.responseText.replace(new RegExp("\"", 'g'), "")); - } - $("a#group-unexpected-error-link").click(function () { - hidePopup(); - }); - console.log("Error code: " + jqXHR.status); - } -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/public/js/role-listing.js deleted file mode 100644 index 516aacb7b5..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/public/js/role-listing.js +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var loadRoleBasedActionURL = function (action, rolename) { - href = $("#ast-container").data("app-context") + "role/" + action + "/?rolename=" + encodeURIComponent(rolename); - $(location).attr('href', href); -}; - -$(function () { - var sortableElem = '.wr-sortable'; - $(sortableElem).sortable({ - beforeStop: function () { - $(this).sortable('toArray'); - } - }); - $(sortableElem).disableSelection(); -}); - -var apiBasePath = "/api/device-mgt/v1.0"; -var modalPopup = ".modal"; -var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-content"; -var body = "body"; -var isInit = true; -var isCloud = false; - - -/** - * - * Fires the res_text when ever a data table redraw occurs making - * the font icons change the size to respective screen resolution. - * - */ -$(document).on('draw.dt', function () { - $(".icon .text").res_text(0.2); -}); - - -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - $(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); - //setPopupMaxHeight(); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(''); - $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right', '0px'); - $('.modal-backdrop').remove(); -} - - -/** - * Following function would execute - * when a user clicks on the list item - * initial mode and with out select mode. - */ -function InitiateViewOption() { - // $(location).attr('href', $(this).data("url")); -} - -function htmlspecialchars(text) { - return jQuery('
    ').text(text).html(); -} - -function loadRoles() { - isCloud = $("#role-table").data("cloud"); - var loadingContent = $("#loading-content"); - loadingContent.show(); - - var dataFilter = function (data) { - data = JSON.parse(data); - var objects = []; - var count = 0; - $(data.roles).each(function (index) { - objects.push( - { - name: htmlspecialchars(data.roles[index]), - DT_RowId: "role-" + htmlspecialchars(data.roles[index]) - } - ) - }); - - var json = { - "recordsTotal": data.count, - "recordsFiltered": data.count, - "data": objects - }; - - return JSON.stringify(json); - }; - - //noinspection JSUnusedLocalSymbols - var fnCreatedRow = function (nRow, aData, iDataIndex) { - $(nRow).attr('data-type', 'selectable'); - }; - - //noinspection JSUnusedLocalSymbols - var columns = [ - { - class: "remove-padding icon-only content-fill", - data: null, - defaultContent: "
    " + - "" + - "
    " - }, - { - class: "", - data: "name", - render: function (name, type, row, meta) { - return '

    ' + name.replace("devicemgt", ""); + '

    '; - } - }, - { - class: "text-right content-fill text-left-on-grid-view no-wrap", - data: null, - render: function (data, type, row, meta) { - var isCloud = false; - if ($('#is-cloud').length > 0) { - isCloud = true; - } - - var innerhtml = ''; - - var editLink = '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''; - - var editPermissionLink = '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''; - - var removeLink = '' + - '' + - '' + - '' + - '' + - '' + - ''; - - if (!isCloud) { - innerhtml = editLink + editPermissionLink + removeLink; - } - return innerhtml; - } - } - ]; - - var options = { - "placeholder": "Search By Role Name", - "searchKey": "filter" - }; - var settings = { - "sorting": false - }; - var roleApiUrl = '/api/device-mgt/v1.0/roles?user-store=all'; - if (isCloud) { - roleApiUrl = '/api/device-mgt/v1.0/roles/filter/devicemgt?user-store=all'; - } - - $('#role-grid').datatables_extended_serverside_paging(settings, roleApiUrl, dataFilter, columns, fnCreatedRow, null, options); - loadingContent.hide(); - -} - - -/** - * Following click function would execute - * when a user clicks on "Remove" link - * on Role Listing page in WSO2 Devicemgt Console. - */ -$("#role-grid").on("click", ".remove-role-link", function () { - var role = $(this).data("role"); - var userStore; - if (role.indexOf('/') > 0) { - userStore = role.substr(0, role.indexOf('/')); - role = role.substr(role.indexOf('/') + 1); - } - var removeRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(role); - if (userStore) { - removeRoleAPI += "?user-store=" + encodeURIComponent(userStore); - } - modalDialog.header('Do you really want to remove this role ?'); - modalDialog.footer(''); - modalDialog.show(); - - $("a#remove-role-yes-link").click(function () { - invokerUtil.delete( - removeRoleAPI, - function () { - if (userStore) { - role = userStore + '/' + role; - } - $('[id="role-' + role + '"]').remove(); - modalDialog.header('Done. Role was successfully removed.'); - modalDialog.footer(''); - $("a#remove-role-success-link").click(function () { - modalDialog.hide(); - }); - }, - function () { - // $(modalPopupContent).html($('#remove-role-error-content').html()); - modalDialog.header('An unexpected error occurred. Please try again later.'); - modalDialog.footer(''); - modalDialog.showAsError(); - $("a#remove-role-error-link").click(function () { - modalDialog.hide(); - }); - } - ); - }); - - $("a#remove-role-cancel-link").click(function () { - modalDialog.hide(); - }); -}); - -$(document).ready(function () { - loadRoles(); -}); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/public/templates/role-listing.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/public/templates/role-listing.hbs deleted file mode 100644 index 3f752a185a..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/public/templates/role-listing.hbs +++ /dev/null @@ -1,56 +0,0 @@ -{{#each roles}} - - -
    - -
    - - {{roleName}} - - - {{#unequal adminRole roleName }} - {{#if canEdit}} - - - - - - - - - - - - - - - - - - - - - - - - - {{/if}} - {{#if canRemove}} - - - - - - - - {{/if}} - {{/unequal}} - - -{{/each}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.hbs deleted file mode 100644 index 5476c743dd..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.hbs +++ /dev/null @@ -1,120 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} - -{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}} -{{unit "cdmf.unit.data-tables-extended"}} -{{unit "cdmf.unit.ui.modal"}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • -
  • - - - Roles - -
  • -{{/zone}} - -{{#zone "navbarActions"}} - {{#unless isCloud}} -
  • - - - - - - - Add Role - -
  • - {{/unless}} -{{/zone}} - -{{#zone "content"}} - {{#if hasRoles}} -
    - {{#unless isCloud}} - {{#if removePermitted}} - - {{/if}} - {{#if editPermitted}} - - {{/if}} - {{/unless}} - {{#if isCloud}} - - {{/if}} - - Loading roles . . . -
    -
    - -
    - - - - - - - - - - -
    By Role Name
    -
    - - - - {{else}} - -
    -
    -

    You Haven't created roles yet.

    -
    Please click "Add A New Role", if you wish to add a role. -
    - - - - - - - Add Role - -
    -
    - - {{/if}} -{{/zone}} - -{{#zone "bottomJs"}} - - - {{js "js/role-listing.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.js deleted file mode 100644 index 145d39ee4e..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - - context["permissions"] = userModule.getUIPermissions(); - if (userModule.isAuthorized("/permission/admin/device-mgt/roles/delete")) { - context["removePermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/roles/update")) { - context["editPermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/roles/remove")) { - context["removePermitted"] = true; - } - - context["adminRole"] = deviceMgtProps["adminRole"]; - context["isCloud"] = deviceMgtProps["isCloud"]; - var roleCount = userModule.getRolesCount() - if (deviceMgtProps["isCloud"]) { - roleCount = userModule.getFilteredRoles("devicemgt").content.count; - } - - if (roleCount > 0) { - context["hasRoles"] = true; - } else { - context["hasRoles"] = false; - } - - return context; -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.json deleted file mode 100644 index 44d4ee20c8..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/pages/cdmf.page.roles/roles.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/roles", - "layout": "cdmf.layout.default" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.hbs deleted file mode 100644 index 6a7f2bb962..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.hbs +++ /dev/null @@ -1,48 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} -{{#zone "topCss"}} - {{css "css/daterangepicker.css"}} -{{/zone}} - -
    -
    -
    - - - - - -
    -
    -
    -{{#zone "bottomJs"}} - {{js "js/moment.js"}} - {{js "js/jquery.daterangepicker.js"}} - {{js "js/date-picker.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.js deleted file mode 100644 index 9dc92ccdb3..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var deviceTypes = context.unit.params.deviceTypes; - var deviceType = context.uriParams.deviceType; - - var deviceTypesList = []; - if (deviceTypes) { - for (var i = 0; i < deviceTypes.length; i++) { - deviceTypesList.push(deviceTypes[i].type); - } - } else if (deviceType) { - deviceTypesList.push(deviceType); - } - return {"deviceTypes": stringify(deviceTypesList)}; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.json deleted file mode 100644 index 688e939808..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/date-range-picker.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/css/daterangepicker.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/css/daterangepicker.css deleted file mode 100644 index b1b44916b4..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/css/daterangepicker.css +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -.date-picker { - width: 170px; - height: 25px; - padding: 0; - border: 0; - line-height: 25px; - padding-left: 10px; - font-size: 12px; - font-family: Arial; - font-weight: bold; - cursor: pointer; - color: #303030; - position: relative; - z-index: 2; -} - -.date-picker-wrapper { - position: absolute; - z-index: 1; - border: 1px solid #bfbfbf; - background-color: #efefef; - width: 448px; - padding: 5px 12px; - font-size: 12px; - line-height: 20px; - color: #aaa; - font-family: Arial; - box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5); -} - -.date-picker-wrapper.single-date { - width: auto; -} - -.date-picker-wrapper.no-shortcuts { - padding-bottom: 12px; -} - -.date-picker-wrapper .footer { - display: none; - font-size: 11px; - padding-top: 3px; -} - -.date-picker-wrapper b { - color: #666; - font-weight: 700; -} - -.date-picker-wrapper a { - color: rgb(107, 180, 214); - text-decoration: underline; -} - -.date-picker-wrapper .month-wrapper { - border: 1px solid #bfbfbf; - border-radius: 3px; - background-color: #fff; - padding: 5px; - cursor: default; - position: relative; - _overflow: hidden; -} - -.date-picker-wrapper .month-wrapper table { - width: 190px; - float: left; -} - -.date-picker-wrapper .month-wrapper table.month2 { - width: 190px; - float: right; -} - -.date-picker-wrapper .month-wrapper table th, -.date-picker-wrapper .month-wrapper table td { - vertical-align: middle; - text-align: center; - line-height: 14px; - margin: 0px; - padding: 0px; -} - -.date-picker-wrapper .month-wrapper table .day { - height: 19px; - line-height: 19px; - font-size: 12px; - margin-bottom: 1px; - color: #999; - cursor: default; -} - -.date-picker-wrapper .month-wrapper table div.day.lastMonth, -.date-picker-wrapper .month-wrapper table div.day.nextMonth { - color: #999; - cursor: default; -} - -.date-picker-wrapper .month-wrapper table .day.checked { - background-color: rgb(156, 219, 247); -} - -.date-picker-wrapper .month-wrapper table .week-name { - height: 20px; - line-height: 20px; - font-weight: 100; -} - -.date-picker-wrapper .month-wrapper table .day.has-tooltip { - cursor: help !important; -} - -.date-picker-wrapper .month-wrapper table .day.toMonth.valid { - color: #333; - cursor: pointer; -} - -.date-picker-wrapper .month-wrapper table .day.real-today { - background-color: rgb(255, 230, 132); -} - -.date-picker-wrapper .month-wrapper table .day.real-today.checked { - background-color: rgb(112, 204, 213); -} - -.date-picker-wrapper table .caption { - height: 40px; -} - -.date-picker-wrapper table .caption .next, -.date-picker-wrapper table .caption .prev { - padding: 0 5px; - cursor: pointer; -} - -.date-picker-wrapper table .caption .next:hover, -.date-picker-wrapper table .caption .prev:hover { - background-color: #ccc; - color: white; -} - -.date-picker-wrapper .gap { - position: absolute; - display: none; - top: 0px; - left: 204px; - z-index: 1; - width: 15px; - height: 100%; - background-color: red; - font-size: 0; - line-height: 0; -} - -.date-picker-wrapper .gap .gap-lines { - height: 100%; - overflow: hidden; -} - -.date-picker-wrapper .gap .gap-line { - height: 15px; - width: 15px; - position: relative; -} - -.date-picker-wrapper .gap .gap-line .gap-1 { - z-index: 1; - height: 0; - border-left: 8px solid white; - border-top: 8px solid #eee; - border-bottom: 8px solid #eee; -} - -.date-picker-wrapper .gap .gap-line .gap-2 { - position: absolute; - right: 0; - top: 0px; - z-index: 2; - height: 0; - border-left: 8px solid transparent; - border-top: 8px solid white; -} - -.date-picker-wrapper .gap .gap-line .gap-3 { - position: absolute; - right: 0; - top: 8px; - z-index: 2; - height: 0; - border-left: 8px solid transparent; - border-bottom: 8px solid white; -} - -.date-picker-wrapper .gap .gap-top-mask { - width: 6px; - height: 1px; - position: absolute; - top: -1px; - left: 1px; - background-color: #eee; - z-index: 3; -} - -.date-picker-wrapper .gap .gap-bottom-mask { - width: 6px; - height: 1px; - position: absolute; - bottom: -1px; - left: 7px; - background-color: #eee; - z-index: 3; -} - -.date-picker-wrapper .selected-days { - display: none; -} - -.date-picker-wrapper .drp_top-bar { - line-height: 40px; - height: 40px; - position: relative; -} - -.date-picker-wrapper .drp_top-bar .error-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar .normal-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar .default-top { - display: block; -} - -.date-picker-wrapper .drp_top-bar.error .default-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar.error .error-top { - display: block; - color: red; -} - -.date-picker-wrapper .drp_top-bar.normal .default-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar.normal .normal-top { - display: block; -} - -.date-picker-wrapper .drp_top-bar .apply-btn { - position: absolute; - right: 0px; - top: 6px; - padding: 3px 5px; - margin: 0; - font-size: 12px; - border-radius: 4px; - cursor: pointer; - - color: #d9eef7; - border: solid 1px #0076a3; - background: #0095cd; - background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5)); - background: -moz-linear-gradient(top, #00adee, #0078a5); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5'); - color: white; -} - -.date-picker-wrapper .drp_top-bar .apply-btn.disabled { - pointer-events: none; - color: #606060; - border: solid 1px #b7b7b7; - background: #fff; - background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed)); - background: -moz-linear-gradient(top, #fff, #ededed); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed'); -} - -/*time styling*/ -.time { - position: relative; -} - -.time input[type=range] { - vertical-align: middle; -} - -.time1, .time2 { - width: 180px; - padding: 0 5px; - text-align: center; -} - -.time1 { - float: left; -} - -.time2 { - float: right; -} - -.hour, .minute { - text-align: left; -} - -.hide { - display: none; -} - -input.hour-range, input.minute-range { - width: 150px; -} - -#dateRangePickerContainer .date-range, #dateRangePickerContainer .input-append { - background: none !important; -} - -#date-range { - padding-right: 30px; - width: 300px; - height: 100%; - display: inline-block; -} - -#dateRangePickerContainer { - float: right; -} - -.date-range { - border: 1px solid #ccc; -} - -#dateRangePickerContainer button.active { - background-color: #e6e6e6 !important; -} - -#dateRangePickerContainer .btn-default:hover { - background-color: #b2b2b2; - border-color: #000000; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/date-picker.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/date-picker.js deleted file mode 100644 index 5a8ac270be..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/date-picker.js +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var fromDate, toDate, currentDay = new Date(); -var startDate = new Date(currentDay.getTime() - (60 * 60 * 24 * 100)); -var endDate = new Date(currentDay.getTime()); - -function initDate() { - currentDay = new Date(); -} - -var DateRange = convertDate(startDate) + " to " + convertDate(endDate); - -$(document).ready(function () { - initDate(); - var configObject = { - startOfWeek: 'monday', - separator: ' to ', - format: 'YYYY-MM-DD HH:mm', - autoClose: false, - time: { - enabled: true - }, - shortcuts: 'hide', - endDate: currentDay, - maxDays: 2, - getValue: function () { - return this.value; - }, - setValue: function (s) { - this.value = s; - } - }; - $('#date-range').html(DateRange); - $('#date-range').dateRangePicker(configObject) - .bind('datepicker-apply', function (event, dateRange) { - $(this).addClass('active'); - $(this).siblings().removeClass('active'); - fromDate = dateRange.date1 != "Invalid Date" ? dateRange.date1.getTime() / 1000 : null; - toDate = dateRange.date2 != "Invalid Date" ? dateRange.date2.getTime() / 1000 : null; - drawGraph(fromDate, toDate); - } - ); - setDateTime(currentDay.getTime() - 3600000, currentDay.getTime()); - $('#hour-btn').addClass('active'); -}); - -//hour -$('#hour-btn').on('click', function () { - initDate(); - setDateTime(currentDay.getTime() - 3600000, currentDay.getTime()); -}); - -//12 hours -$('#h12-btn').on('click', function () { - initDate(); - setDateTime(currentDay.getTime() - (3600000 * 12), currentDay.getTime()); -}); - -//24 hours -$('#h24-btn').on('click', function () { - initDate(); - setDateTime(currentDay.getTime() - (3600000 * 24), currentDay.getTime()); -}); - -//48 hours -$('#h48-btn').on('click', function () { - initDate(); - setDateTime(currentDay.getTime() - (3600000 * 48), currentDay.getTime()); -}); - -$('body').on('click', '.btn-group button', function (e) { - $(this).addClass('active'); - $(this).siblings().removeClass('active'); -}); - -function setDateTime(from, to) { - fromDate = from; - toDate = to; - startDate = new Date(from); - endDate = new Date(to); - DateRange = convertDate(startDate) + " to " + convertDate(endDate); - $('#date-range').html(DateRange); - var tzOffset = new Date().getTimezoneOffset() * 60 / 1000; - from += tzOffset; - to += tzOffset; - - // Implement drawGraph_ method in your UI unit for analytics. - var deviceTypes = $("#device-type-details").data("devicetypes"); - for (var i = 0; i < deviceTypes.length; i++){ - try{ - window["drawGraph_" + deviceTypes](parseInt(from / 1000), parseInt(to / 1000)); - }catch(e){ - } - try{ - window["drawTable"](parseInt(from / 1000), parseInt(to / 1000)); - }catch(e){ - } - } -} - -function convertDate(date) { - var month = date.getMonth() + 1; - var day = date.getDate(); - var hour = date.getHours(); - var minute = date.getMinutes(); - return date.getFullYear() + '-' + (('' + month).length < 2 ? '0' : '') + month + '-' + - (('' + day).length < 2 ? '0' : '') + day + " " + (('' + hour).length < 2 ? '0' : '') + - hour + ":" + (('' + minute).length < 2 ? '0' : '') + minute; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/jquery-ui-timepicker-addon.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/jquery-ui-timepicker-addon.js deleted file mode 100644 index acd3479075..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/jquery-ui-timepicker-addon.js +++ /dev/null @@ -1,2220 +0,0 @@ -(function ($) { - - /* - * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded" - */ - $.ui.timepicker = $.ui.timepicker || {}; - if ($.ui.timepicker.version) { - return; - } - - /* - * Extend jQueryUI, get it started with our version number - */ - $.extend($.ui, { - timepicker: { - version: "1.5.0" - } - }); - - /* - * Timepicker manager. - * Use the singleton instance of this class, $.timepicker, to interact with the time picker. - * Settings for (groups of) time pickers are maintained in an instance object, - * allowing multiple different settings on the same page. - */ - var Timepicker = function () { - this.regional = []; // Available regional settings, indexed by language code - this.regional[''] = { // Default regional settings - currentText: 'Now', - closeText: 'Done', - amNames: ['AM', 'A'], - pmNames: ['PM', 'P'], - timeFormat: 'HH:mm', - timeSuffix: '', - timeOnlyTitle: 'Choose Time', - timeText: 'Time', - hourText: 'Hour', - minuteText: 'Minute', - secondText: 'Second', - millisecText: 'Millisecond', - microsecText: 'Microsecond', - timezoneText: 'Time Zone', - isRTL: false - }; - this._defaults = { // Global defaults for all the datetime picker instances - showButtonPanel: true, - timeOnly: false, - timeOnlyShowDate: false, - showHour: null, - showMinute: null, - showSecond: null, - showMillisec: null, - showMicrosec: null, - showTimezone: null, - showTime: true, - stepHour: 1, - stepMinute: 1, - stepSecond: 1, - stepMillisec: 1, - stepMicrosec: 1, - hour: 0, - minute: 0, - second: 0, - millisec: 0, - microsec: 0, - timezone: null, - hourMin: 0, - minuteMin: 0, - secondMin: 0, - millisecMin: 0, - microsecMin: 0, - hourMax: 23, - minuteMax: 59, - secondMax: 59, - millisecMax: 999, - microsecMax: 999, - minDateTime: null, - maxDateTime: null, - maxTime: null, - minTime: null, - onSelect: null, - hourGrid: 0, - minuteGrid: 0, - secondGrid: 0, - millisecGrid: 0, - microsecGrid: 0, - alwaysSetTime: true, - separator: ' ', - altFieldTimeOnly: true, - altTimeFormat: null, - altSeparator: null, - altTimeSuffix: null, - altRedirectFocus: true, - pickerTimeFormat: null, - pickerTimeSuffix: null, - showTimepicker: true, - timezoneList: null, - addSliderAccess: false, - sliderAccessArgs: null, - controlType: 'slider', - defaultValue: null, - parse: 'strict' - }; - $.extend(this._defaults, this.regional['']); - }; - - $.extend(Timepicker.prototype, { - $input: null, - $altInput: null, - $timeObj: null, - inst: null, - hour_slider: null, - minute_slider: null, - second_slider: null, - millisec_slider: null, - microsec_slider: null, - timezone_select: null, - maxTime: null, - minTime: null, - hour: 0, - minute: 0, - second: 0, - millisec: 0, - microsec: 0, - timezone: null, - hourMinOriginal: null, - minuteMinOriginal: null, - secondMinOriginal: null, - millisecMinOriginal: null, - microsecMinOriginal: null, - hourMaxOriginal: null, - minuteMaxOriginal: null, - secondMaxOriginal: null, - millisecMaxOriginal: null, - microsecMaxOriginal: null, - ampm: '', - formattedDate: '', - formattedTime: '', - formattedDateTime: '', - timezoneList: null, - units: ['hour', 'minute', 'second', 'millisec', 'microsec'], - support: {}, - control: null, - - /* - * Override the default settings for all instances of the time picker. - * @param {Object} settings object - the new settings to use as defaults (anonymous object) - * @return {Object} the manager object - */ - setDefaults: function (settings) { - extendRemove(this._defaults, settings || {}); - return this; - }, - - /* - * Create a new Timepicker instance - */ - _newInst: function ($input, opts) { - var tp_inst = new Timepicker(), - inlineSettings = {}, - fns = {}, - overrides, i; - - for (var attrName in this._defaults) { - if (this._defaults.hasOwnProperty(attrName)) { - var attrValue = $input.attr('time:' + attrName); - if (attrValue) { - try { - inlineSettings[attrName] = eval(attrValue); - } catch (err) { - inlineSettings[attrName] = attrValue; - } - } - } - } - - overrides = { - beforeShow: function (input, dp_inst) { - if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) { - return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst); - } - }, - onChangeMonthYear: function (year, month, dp_inst) { - // Update the time as well : this prevents the time from disappearing from the $input field. - tp_inst._updateDateTime(dp_inst); - if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) { - tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst); - } - }, - onClose: function (dateText, dp_inst) { - if (tp_inst.timeDefined === true && $input.val() !== '') { - tp_inst._updateDateTime(dp_inst); - } - if ($.isFunction(tp_inst._defaults.evnts.onClose)) { - tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst); - } - } - }; - for (i in overrides) { - if (overrides.hasOwnProperty(i)) { - fns[i] = opts[i] || null; - } - } - - tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, opts, overrides, { - evnts: fns, - timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); - }); - tp_inst.amNames = $.map(tp_inst._defaults.amNames, function (val) { - return val.toUpperCase(); - }); - tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function (val) { - return val.toUpperCase(); - }); - - // detect which units are supported - tp_inst.support = detectSupport( - tp_inst._defaults.timeFormat + - (tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') + - (tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : '')); - - // controlType is string - key to our this._controls - if (typeof(tp_inst._defaults.controlType) === 'string') { - if (tp_inst._defaults.controlType === 'slider' && typeof($.ui.slider) === 'undefined') { - tp_inst._defaults.controlType = 'select'; - } - tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType]; - } - // controlType is an object and must implement create, options, value methods - else { - tp_inst.control = tp_inst._defaults.controlType; - } - - // prep the timezone options - var timezoneList = [-720, -660, -600, -570, -540, -480, -420, -360, -300, -270, -240, -210, -180, -120, -60, - 0, 60, 120, 180, 210, 240, 270, 300, 330, 345, 360, 390, 420, 480, 525, 540, 570, 600, 630, 660, 690, 720, 765, 780, 840]; - if (tp_inst._defaults.timezoneList !== null) { - timezoneList = tp_inst._defaults.timezoneList; - } - var tzl = timezoneList.length, tzi = 0, tzv = null; - if (tzl > 0 && typeof timezoneList[0] !== 'object') { - for (; tzi < tzl; tzi++) { - tzv = timezoneList[tzi]; - timezoneList[tzi] = { value: tzv, label: $.timepicker.timezoneOffsetString(tzv, tp_inst.support.iso8601) }; - } - } - tp_inst._defaults.timezoneList = timezoneList; - - // set the default units - tp_inst.timezone = tp_inst._defaults.timezone !== null ? $.timepicker.timezoneOffsetNumber(tp_inst._defaults.timezone) : - ((new Date()).getTimezoneOffset() * -1); - tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin ? tp_inst._defaults.hourMin : - tp_inst._defaults.hour > tp_inst._defaults.hourMax ? tp_inst._defaults.hourMax : tp_inst._defaults.hour; - tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin ? tp_inst._defaults.minuteMin : - tp_inst._defaults.minute > tp_inst._defaults.minuteMax ? tp_inst._defaults.minuteMax : tp_inst._defaults.minute; - tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin ? tp_inst._defaults.secondMin : - tp_inst._defaults.second > tp_inst._defaults.secondMax ? tp_inst._defaults.secondMax : tp_inst._defaults.second; - tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin ? tp_inst._defaults.millisecMin : - tp_inst._defaults.millisec > tp_inst._defaults.millisecMax ? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec; - tp_inst.microsec = tp_inst._defaults.microsec < tp_inst._defaults.microsecMin ? tp_inst._defaults.microsecMin : - tp_inst._defaults.microsec > tp_inst._defaults.microsecMax ? tp_inst._defaults.microsecMax : tp_inst._defaults.microsec; - tp_inst.ampm = ''; - tp_inst.$input = $input; - - if (tp_inst._defaults.altField) { - tp_inst.$altInput = $(tp_inst._defaults.altField); - if (tp_inst._defaults.altRedirectFocus === true) { - tp_inst.$altInput.css({ - cursor: 'pointer' - }).focus(function () { - $input.trigger("focus"); - }); - } - } - - if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) { - tp_inst._defaults.minDate = new Date(); - } - if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) { - tp_inst._defaults.maxDate = new Date(); - } - - // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime.. - if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) { - tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime()); - } - if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) { - tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime()); - } - if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) { - tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime()); - } - if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) { - tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime()); - } - tp_inst.$input.bind('focus', function () { - tp_inst._onFocus(); - }); - - return tp_inst; - }, - - /* - * add our sliders to the calendar - */ - _addTimePicker: function (dp_inst) { - var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val(); - - this.timeDefined = this._parseTime(currDT); - this._limitMinMaxDateTime(dp_inst, false); - this._injectTimePicker(); - }, - - /* - * parse the time string from input value or _setTime - */ - _parseTime: function (timeString, withDate) { - if (!this.inst) { - this.inst = $.datepicker._getInst(this.$input[0]); - } - - if (withDate || !this._defaults.timeOnly) { - var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); - try { - var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults); - if (!parseRes.timeObj) { - return false; - } - $.extend(this, parseRes.timeObj); - } catch (err) { - $.timepicker.log("Error parsing the date/time string: " + err + - "\ndate/time string = " + timeString + - "\ntimeFormat = " + this._defaults.timeFormat + - "\ndateFormat = " + dp_dateFormat); - return false; - } - return true; - } else { - var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults); - if (!timeObj) { - return false; - } - $.extend(this, timeObj); - return true; - } - }, - - /* - * generate and inject html for timepicker into ui datepicker - */ - _injectTimePicker: function () { - var $dp = this.inst.dpDiv, - o = this.inst.settings, - tp_inst = this, - litem = '', - uitem = '', - show = null, - max = {}, - gridSize = {}, - size = null, - i = 0, - l = 0; - - // Prevent displaying twice - if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { - var noDisplay = ' style="display:none;"', - html = '
    ' + '
    ' + o.timeText + '
    ' + - '
    '; - - // Create the markup - for (i = 0, l = this.units.length; i < l; i++) { - litem = this.units[i]; - uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1); - show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem]; - - // Added by Peter Medeiros: - // - Figure out what the hour/minute/second max should be based on the step values. - // - Example: if stepMinute is 15, then minMax is 45. - max[litem] = parseInt((o[litem + 'Max'] - ((o[litem + 'Max'] - o[litem + 'Min']) % o['step' + uitem])), 10); - gridSize[litem] = 0; - - html += '
    ' + o[litem + 'Text'] + '
    ' + - '
    '; - - if (show && o[litem + 'Grid'] > 0) { - html += '
    '; - - if (litem === 'hour') { - for (var h = o[litem + 'Min']; h <= max[litem]; h += parseInt(o[litem + 'Grid'], 10)) { - gridSize[litem]++; - var tmph = $.datepicker.formatTime(this.support.ampm ? 'hht' : 'HH', {hour: h}, o); - html += ''; - } - } - else { - for (var m = o[litem + 'Min']; m <= max[litem]; m += parseInt(o[litem + 'Grid'], 10)) { - gridSize[litem]++; - html += ''; - } - } - - html += '
    ' + tmph + '' + ((m < 10) ? '0' : '') + m + '
    '; - } - html += '
    '; - } - - // Timezone - var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone; - html += '
    ' + o.timezoneText + '
    '; - html += '
    '; - - // Create the elements from string - html += '
    '; - var $tp = $(html); - - // if we only want time picker... - if (o.timeOnly === true) { - $tp.prepend('
    ' + '
    ' + o.timeOnlyTitle + '
    ' + '
    '); - $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide(); - } - - // add sliders, adjust grids, add events - for (i = 0, l = tp_inst.units.length; i < l; i++) { - litem = tp_inst.units[i]; - uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1); - show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem]; - - // add the slider - tp_inst[litem + '_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_' + litem + '_slider'), litem, tp_inst[litem], o[litem + 'Min'], max[litem], o['step' + uitem]); - - // adjust the grid and add click event - if (show && o[litem + 'Grid'] > 0) { - size = 100 * gridSize[litem] * o[litem + 'Grid'] / (max[litem] - o[litem + 'Min']); - $tp.find('.ui_tpicker_' + litem + ' table').css({ - width: size + "%", - marginLeft: o.isRTL ? '0' : ((size / (-2 * gridSize[litem])) + "%"), - marginRight: o.isRTL ? ((size / (-2 * gridSize[litem])) + "%") : '0', - borderCollapse: 'collapse' - }).find("td").click(function (e) { - var $t = $(this), - h = $t.html(), - n = parseInt(h.replace(/[^0-9]/g), 10), - ap = h.replace(/[^apm]/ig), - f = $t.data('for'); // loses scope, so we use data-for - - if (f === 'hour') { - if (ap.indexOf('p') !== -1 && n < 12) { - n += 12; - } - else { - if (ap.indexOf('a') !== -1 && n === 12) { - n = 0; - } - } - } - - tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n); - - tp_inst._onTimeChange(); - tp_inst._onSelectHandler(); - }).css({ - cursor: 'pointer', - width: (100 / gridSize[litem]) + '%', - textAlign: 'center', - overflow: 'hidden' - }); - } // end if grid > 0 - } // end for loop - - // Add timezone options - this.timezone_select = $tp.find('.ui_tpicker_timezone').append('').find("select"); - $.fn.append.apply(this.timezone_select, - $.map(o.timezoneList, function (val, idx) { - return $("
    '; - - - return $(html); - } - - function getHideClass() - { - if (opt.autoClose === true) { - return 'hide'; - } - return ''; - } - - function getWeekHead() - { - if (opt.startOfWeek == 'monday') - { - return ''+lang('week-1')+'\ - '+lang('week-2')+'\ - '+lang('week-3')+'\ - '+lang('week-4')+'\ - '+lang('week-5')+'\ - '+lang('week-6')+'\ - '+lang('week-7')+''; - } - else - { - return ''+lang('week-7')+'\ - '+lang('week-1')+'\ - '+lang('week-2')+'\ - '+lang('week-3')+'\ - '+lang('week-4')+'\ - '+lang('week-5')+'\ - '+lang('week-6')+''; - } - } - function isMonthOutOfBounds(month) - { - var month = moment(month); - if (opt.startDate && month.endOf('month').isBefore(opt.startDate)) - { - return true; - } - if (opt.endDate && month.startOf('month').isAfter(opt.endDate)) - { - return true; - } - return false; - } - - function getGapHTML() - { - var html = ['
    ']; - for(var i=0;i<20;i++) - { - html.push('
    \ -
    \ -
    \ -
    \ -
    '); - } - html.push('
    '); - return html.join(''); - } - - function createMonthHTML(d) - { - var days = []; - d.setDate(1); - var lastMonth = new Date(d.getTime() - 86400000); - var now = new Date(); - - var dayOfWeek = d.getDay(); - if((dayOfWeek == 0) && (opt.startOfWeek == 'monday')) { - // add one week - dayOfWeek = 7; - } - - if (dayOfWeek > 0) - { - for (var i = dayOfWeek; i > 0; i--) - { - var day = new Date(d.getTime() - 86400000*i); - var valid = true; - if (opt.startDate && compare_day(day,opt.startDate) < 0) valid = false; - if (opt.endDate && compare_day(day,opt.endDate) > 0) valid = false; - days.push({type:'lastMonth',day: day.getDate(),time:day.getTime(), valid:valid }); - } - } - var toMonth = d.getMonth(); - for(var i=0; i<40; i++) - { - var today = moment(d).add(i,'days').toDate(); - var valid = true; - if (opt.startDate && compare_day(today,opt.startDate) < 0) valid = false; - if (opt.endDate && compare_day(today,opt.endDate) > 0) valid = false; - days.push({type: today.getMonth() == toMonth ? 'toMonth' : 'nextMonth',day: today.getDate(),time:today.getTime(), valid:valid }); - } - var html = []; - for(var week=0; week<6; week++) - { - if (days[week*7].type == 'nextMonth') break; - html.push(''); - for(var day = 0; day<7; day++) - { - var _day = (opt.startOfWeek == 'monday') ? day+1 : day; - var today = days[week*7+_day]; - var highlightToday = moment(today.time).format('L') == moment(now).format('L'); - today.extraClass = ''; - today.tooltip = ''; - if(opt.beforeShowDay && typeof opt.beforeShowDay == 'function') - { - var _r = opt.beforeShowDay(moment(today.time).toDate()); - today.valid = _r[0]; - today.extraClass = _r[1] || ''; - today.tooltip = _r[2] || ''; - if (today.tooltip != '') today.extraClass += ' has-tooltip '; - } - html.push('
    '+today.day+'
    '); - } - html.push(''); - } - return html.join(''); - } - - function getLanguages() - { - if (opt.language == 'auto') - { - var language = navigator.language ? navigator.language : navigator.browserLanguage; - if (!language) return $.dateRangePickerLanguages['en']; - var language = language.toLowerCase(); - for(var key in $.dateRangePickerLanguages) - { - if (language.indexOf(key) != -1) - { - return $.dateRangePickerLanguages[key]; - } - } - return $.dateRangePickerLanguages['en']; - } - else if ( opt.language && opt.language in $.dateRangePickerLanguages) - { - return $.dateRangePickerLanguages[opt.language]; - } - else - { - return $.dateRangePickerLanguages['en']; - } - } - - function lang(t) - { - return (t in langs)? langs[t] : t; - } - - - }; -})(jQuery); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/moment.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/moment.js deleted file mode 100644 index ed94e44a1e..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.analytics.date-range-picker/public/js/moment.js +++ /dev/null @@ -1,4040 +0,0 @@ -//! moment.js -//! version : 2.13.0 -//! authors : Tim Wood, Iskren Chernev, Moment.js contributors -//! license : MIT -//! momentjs.com - -;(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - global.moment = factory() -}(this, function () { 'use strict'; - - var hookCallback; - - function utils_hooks__hooks () { - return hookCallback.apply(null, arguments); - } - - // This is done to register the method called with moment() - // without creating circular dependencies. - function setHookCallback (callback) { - hookCallback = callback; - } - - function isArray(input) { - return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]'; - } - - function isDate(input) { - return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]'; - } - - function map(arr, fn) { - var res = [], i; - for (i = 0; i < arr.length; ++i) { - res.push(fn(arr[i], i)); - } - return res; - } - - function hasOwnProp(a, b) { - return Object.prototype.hasOwnProperty.call(a, b); - } - - function extend(a, b) { - for (var i in b) { - if (hasOwnProp(b, i)) { - a[i] = b[i]; - } - } - - if (hasOwnProp(b, 'toString')) { - a.toString = b.toString; - } - - if (hasOwnProp(b, 'valueOf')) { - a.valueOf = b.valueOf; - } - - return a; - } - - function create_utc__createUTC (input, format, locale, strict) { - return createLocalOrUTC(input, format, locale, strict, true).utc(); - } - - function defaultParsingFlags() { - // We need to deep clone this object. - return { - empty : false, - unusedTokens : [], - unusedInput : [], - overflow : -2, - charsLeftOver : 0, - nullInput : false, - invalidMonth : null, - invalidFormat : false, - userInvalidated : false, - iso : false, - parsedDateParts : [], - meridiem : null - }; - } - - function getParsingFlags(m) { - if (m._pf == null) { - m._pf = defaultParsingFlags(); - } - return m._pf; - } - - var some; - if (Array.prototype.some) { - some = Array.prototype.some; - } else { - some = function (fun) { - var t = Object(this); - var len = t.length >>> 0; - - for (var i = 0; i < len; i++) { - if (i in t && fun.call(this, t[i], i, t)) { - return true; - } - } - - return false; - }; - } - - function valid__isValid(m) { - if (m._isValid == null) { - var flags = getParsingFlags(m); - var parsedParts = some.call(flags.parsedDateParts, function (i) { - return i != null; - }); - m._isValid = !isNaN(m._d.getTime()) && - flags.overflow < 0 && - !flags.empty && - !flags.invalidMonth && - !flags.invalidWeekday && - !flags.nullInput && - !flags.invalidFormat && - !flags.userInvalidated && - (!flags.meridiem || (flags.meridiem && parsedParts)); - - if (m._strict) { - m._isValid = m._isValid && - flags.charsLeftOver === 0 && - flags.unusedTokens.length === 0 && - flags.bigHour === undefined; - } - } - return m._isValid; - } - - function valid__createInvalid (flags) { - var m = create_utc__createUTC(NaN); - if (flags != null) { - extend(getParsingFlags(m), flags); - } - else { - getParsingFlags(m).userInvalidated = true; - } - - return m; - } - - function isUndefined(input) { - return input === void 0; - } - - // Plugins that add properties should also add the key here (null value), - // so we can properly clone ourselves. - var momentProperties = utils_hooks__hooks.momentProperties = []; - - function copyConfig(to, from) { - var i, prop, val; - - if (!isUndefined(from._isAMomentObject)) { - to._isAMomentObject = from._isAMomentObject; - } - if (!isUndefined(from._i)) { - to._i = from._i; - } - if (!isUndefined(from._f)) { - to._f = from._f; - } - if (!isUndefined(from._l)) { - to._l = from._l; - } - if (!isUndefined(from._strict)) { - to._strict = from._strict; - } - if (!isUndefined(from._tzm)) { - to._tzm = from._tzm; - } - if (!isUndefined(from._isUTC)) { - to._isUTC = from._isUTC; - } - if (!isUndefined(from._offset)) { - to._offset = from._offset; - } - if (!isUndefined(from._pf)) { - to._pf = getParsingFlags(from); - } - if (!isUndefined(from._locale)) { - to._locale = from._locale; - } - - if (momentProperties.length > 0) { - for (i in momentProperties) { - prop = momentProperties[i]; - val = from[prop]; - if (!isUndefined(val)) { - to[prop] = val; - } - } - } - - return to; - } - - var updateInProgress = false; - - // Moment prototype object - function Moment(config) { - copyConfig(this, config); - this._d = new Date(config._d != null ? config._d.getTime() : NaN); - // Prevent infinite loop in case updateOffset creates new moment - // objects. - if (updateInProgress === false) { - updateInProgress = true; - utils_hooks__hooks.updateOffset(this); - updateInProgress = false; - } - } - - function isMoment (obj) { - return obj instanceof Moment || (obj != null && obj._isAMomentObject != null); - } - - function absFloor (number) { - if (number < 0) { - return Math.ceil(number); - } else { - return Math.floor(number); - } - } - - function toInt(argumentForCoercion) { - var coercedNumber = +argumentForCoercion, - value = 0; - - if (coercedNumber !== 0 && isFinite(coercedNumber)) { - value = absFloor(coercedNumber); - } - - return value; - } - - // compare two arrays, return the number of differences - function compareArrays(array1, array2, dontConvert) { - var len = Math.min(array1.length, array2.length), - lengthDiff = Math.abs(array1.length - array2.length), - diffs = 0, - i; - for (i = 0; i < len; i++) { - if ((dontConvert && array1[i] !== array2[i]) || - (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) { - diffs++; - } - } - return diffs + lengthDiff; - } - - function warn(msg) { - if (utils_hooks__hooks.suppressDeprecationWarnings === false && - (typeof console !== 'undefined') && console.warn) { - console.warn('Deprecation warning: ' + msg); - } - } - - function deprecate(msg, fn) { - var firstTime = true; - - return extend(function () { - if (utils_hooks__hooks.deprecationHandler != null) { - utils_hooks__hooks.deprecationHandler(null, msg); - } - if (firstTime) { - warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack); - firstTime = false; - } - return fn.apply(this, arguments); - }, fn); - } - - var deprecations = {}; - - function deprecateSimple(name, msg) { - if (utils_hooks__hooks.deprecationHandler != null) { - utils_hooks__hooks.deprecationHandler(name, msg); - } - if (!deprecations[name]) { - warn(msg); - deprecations[name] = true; - } - } - - utils_hooks__hooks.suppressDeprecationWarnings = false; - utils_hooks__hooks.deprecationHandler = null; - - function isFunction(input) { - return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]'; - } - - function isObject(input) { - return Object.prototype.toString.call(input) === '[object Object]'; - } - - function locale_set__set (config) { - var prop, i; - for (i in config) { - prop = config[i]; - if (isFunction(prop)) { - this[i] = prop; - } else { - this['_' + i] = prop; - } - } - this._config = config; - // Lenient ordinal parsing accepts just a number in addition to - // number + (possibly) stuff coming from _ordinalParseLenient. - this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source); - } - - function mergeConfigs(parentConfig, childConfig) { - var res = extend({}, parentConfig), prop; - for (prop in childConfig) { - if (hasOwnProp(childConfig, prop)) { - if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { - res[prop] = {}; - extend(res[prop], parentConfig[prop]); - extend(res[prop], childConfig[prop]); - } else if (childConfig[prop] != null) { - res[prop] = childConfig[prop]; - } else { - delete res[prop]; - } - } - } - return res; - } - - function Locale(config) { - if (config != null) { - this.set(config); - } - } - - var keys; - - if (Object.keys) { - keys = Object.keys; - } else { - keys = function (obj) { - var i, res = []; - for (i in obj) { - if (hasOwnProp(obj, i)) { - res.push(i); - } - } - return res; - }; - } - - // internal storage for locale config files - var locales = {}; - var globalLocale; - - function normalizeLocale(key) { - return key ? key.toLowerCase().replace('_', '-') : key; - } - - // pick the locale from the array - // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each - // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root - function chooseLocale(names) { - var i = 0, j, next, locale, split; - - while (i < names.length) { - split = normalizeLocale(names[i]).split('-'); - j = split.length; - next = normalizeLocale(names[i + 1]); - next = next ? next.split('-') : null; - while (j > 0) { - locale = loadLocale(split.slice(0, j).join('-')); - if (locale) { - return locale; - } - if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) { - //the next array item is better than a shallower substring of this one - break; - } - j--; - } - i++; - } - return null; - } - - function loadLocale(name) { - var oldLocale = null; - // TODO: Find a better way to register and load all the locales in Node - if (!locales[name] && (typeof module !== 'undefined') && - module && module.exports) { - try { - oldLocale = globalLocale._abbr; - require('./locale/' + name); - // because defineLocale currently also sets the global locale, we - // want to undo that for lazy loaded locales - locale_locales__getSetGlobalLocale(oldLocale); - } catch (e) { } - } - return locales[name]; - } - - // This function will load locale and then set the global locale. If - // no arguments are passed in, it will simply return the current global - // locale key. - function locale_locales__getSetGlobalLocale (key, values) { - var data; - if (key) { - if (isUndefined(values)) { - data = locale_locales__getLocale(key); - } - else { - data = defineLocale(key, values); - } - - if (data) { - // moment.duration._locale = moment._locale = data; - globalLocale = data; - } - } - - return globalLocale._abbr; - } - - function defineLocale (name, config) { - if (config !== null) { - config.abbr = name; - if (locales[name] != null) { - deprecateSimple('defineLocaleOverride', - 'use moment.updateLocale(localeName, config) to change ' + - 'an existing locale. moment.defineLocale(localeName, ' + - 'config) should only be used for creating a new locale'); - config = mergeConfigs(locales[name]._config, config); - } else if (config.parentLocale != null) { - if (locales[config.parentLocale] != null) { - config = mergeConfigs(locales[config.parentLocale]._config, config); - } else { - // treat as if there is no base config - deprecateSimple('parentLocaleUndefined', - 'specified parentLocale is not defined yet'); - } - } - locales[name] = new Locale(config); - - // backwards compat for now: also set the locale - locale_locales__getSetGlobalLocale(name); - - return locales[name]; - } else { - // useful for testing - delete locales[name]; - return null; - } - } - - function updateLocale(name, config) { - if (config != null) { - var locale; - if (locales[name] != null) { - config = mergeConfigs(locales[name]._config, config); - } - locale = new Locale(config); - locale.parentLocale = locales[name]; - locales[name] = locale; - - // backwards compat for now: also set the locale - locale_locales__getSetGlobalLocale(name); - } else { - // pass null for config to unupdate, useful for tests - if (locales[name] != null) { - if (locales[name].parentLocale != null) { - locales[name] = locales[name].parentLocale; - } else if (locales[name] != null) { - delete locales[name]; - } - } - } - return locales[name]; - } - - // returns locale data - function locale_locales__getLocale (key) { - var locale; - - if (key && key._locale && key._locale._abbr) { - key = key._locale._abbr; - } - - if (!key) { - return globalLocale; - } - - if (!isArray(key)) { - //short-circuit everything else - locale = loadLocale(key); - if (locale) { - return locale; - } - key = [key]; - } - - return chooseLocale(key); - } - - function locale_locales__listLocales() { - return keys(locales); - } - - var aliases = {}; - - function addUnitAlias (unit, shorthand) { - var lowerCase = unit.toLowerCase(); - aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit; - } - - function normalizeUnits(units) { - return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined; - } - - function normalizeObjectUnits(inputObject) { - var normalizedInput = {}, - normalizedProp, - prop; - - for (prop in inputObject) { - if (hasOwnProp(inputObject, prop)) { - normalizedProp = normalizeUnits(prop); - if (normalizedProp) { - normalizedInput[normalizedProp] = inputObject[prop]; - } - } - } - - return normalizedInput; - } - - function makeGetSet (unit, keepTime) { - return function (value) { - if (value != null) { - get_set__set(this, unit, value); - utils_hooks__hooks.updateOffset(this, keepTime); - return this; - } else { - return get_set__get(this, unit); - } - }; - } - - function get_set__get (mom, unit) { - return mom.isValid() ? - mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN; - } - - function get_set__set (mom, unit, value) { - if (mom.isValid()) { - mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); - } - } - - // MOMENTS - - function getSet (units, value) { - var unit; - if (typeof units === 'object') { - for (unit in units) { - this.set(unit, units[unit]); - } - } else { - units = normalizeUnits(units); - if (isFunction(this[units])) { - return this[units](value); - } - } - return this; - } - - function zeroFill(number, targetLength, forceSign) { - var absNumber = '' + Math.abs(number), - zerosToFill = targetLength - absNumber.length, - sign = number >= 0; - return (sign ? (forceSign ? '+' : '') : '-') + - Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber; - } - - var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g; - - var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g; - - var formatFunctions = {}; - - var formatTokenFunctions = {}; - - // token: 'M' - // padded: ['MM', 2] - // ordinal: 'Mo' - // callback: function () { this.month() + 1 } - function addFormatToken (token, padded, ordinal, callback) { - var func = callback; - if (typeof callback === 'string') { - func = function () { - return this[callback](); - }; - } - if (token) { - formatTokenFunctions[token] = func; - } - if (padded) { - formatTokenFunctions[padded[0]] = function () { - return zeroFill(func.apply(this, arguments), padded[1], padded[2]); - }; - } - if (ordinal) { - formatTokenFunctions[ordinal] = function () { - return this.localeData().ordinal(func.apply(this, arguments), token); - }; - } - } - - function removeFormattingTokens(input) { - if (input.match(/\[[\s\S]/)) { - return input.replace(/^\[|\]$/g, ''); - } - return input.replace(/\\/g, ''); - } - - function makeFormatFunction(format) { - var array = format.match(formattingTokens), i, length; - - for (i = 0, length = array.length; i < length; i++) { - if (formatTokenFunctions[array[i]]) { - array[i] = formatTokenFunctions[array[i]]; - } else { - array[i] = removeFormattingTokens(array[i]); - } - } - - return function (mom) { - var output = '', i; - for (i = 0; i < length; i++) { - output += array[i] instanceof Function ? array[i].call(mom, format) : array[i]; - } - return output; - }; - } - - // format date using native date object - function formatMoment(m, format) { - if (!m.isValid()) { - return m.localeData().invalidDate(); - } - - format = expandFormat(format, m.localeData()); - formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format); - - return formatFunctions[format](m); - } - - function expandFormat(format, locale) { - var i = 5; - - function replaceLongDateFormatTokens(input) { - return locale.longDateFormat(input) || input; - } - - localFormattingTokens.lastIndex = 0; - while (i >= 0 && localFormattingTokens.test(format)) { - format = format.replace(localFormattingTokens, replaceLongDateFormatTokens); - localFormattingTokens.lastIndex = 0; - i -= 1; - } - - return format; - } - - var match1 = /\d/; // 0 - 9 - var match2 = /\d\d/; // 00 - 99 - var match3 = /\d{3}/; // 000 - 999 - var match4 = /\d{4}/; // 0000 - 9999 - var match6 = /[+-]?\d{6}/; // -999999 - 999999 - var match1to2 = /\d\d?/; // 0 - 99 - var match3to4 = /\d\d\d\d?/; // 999 - 9999 - var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999 - var match1to3 = /\d{1,3}/; // 0 - 999 - var match1to4 = /\d{1,4}/; // 0 - 9999 - var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999 - - var matchUnsigned = /\d+/; // 0 - inf - var matchSigned = /[+-]?\d+/; // -inf - inf - - var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z - var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z - - var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123 - - // any word (or two) characters or numbers including two/three word month in arabic. - // includes scottish gaelic two word and hyphenated months - var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i; - - - var regexes = {}; - - function addRegexToken (token, regex, strictRegex) { - regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) { - return (isStrict && strictRegex) ? strictRegex : regex; - }; - } - - function getParseRegexForToken (token, config) { - if (!hasOwnProp(regexes, token)) { - return new RegExp(unescapeFormat(token)); - } - - return regexes[token](config._strict, config._locale); - } - - // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript - function unescapeFormat(s) { - return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { - return p1 || p2 || p3 || p4; - })); - } - - function regexEscape(s) { - return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); - } - - var tokens = {}; - - function addParseToken (token, callback) { - var i, func = callback; - if (typeof token === 'string') { - token = [token]; - } - if (typeof callback === 'number') { - func = function (input, array) { - array[callback] = toInt(input); - }; - } - for (i = 0; i < token.length; i++) { - tokens[token[i]] = func; - } - } - - function addWeekParseToken (token, callback) { - addParseToken(token, function (input, array, config, token) { - config._w = config._w || {}; - callback(input, config._w, config, token); - }); - } - - function addTimeToArrayFromToken(token, input, config) { - if (input != null && hasOwnProp(tokens, token)) { - tokens[token](input, config._a, config, token); - } - } - - var YEAR = 0; - var MONTH = 1; - var DATE = 2; - var HOUR = 3; - var MINUTE = 4; - var SECOND = 5; - var MILLISECOND = 6; - var WEEK = 7; - var WEEKDAY = 8; - - var indexOf; - - if (Array.prototype.indexOf) { - indexOf = Array.prototype.indexOf; - } else { - indexOf = function (o) { - // I know - var i; - for (i = 0; i < this.length; ++i) { - if (this[i] === o) { - return i; - } - } - return -1; - }; - } - - function daysInMonth(year, month) { - return new Date(Date.UTC(year, month + 1, 0)).getUTCDate(); - } - - // FORMATTING - - addFormatToken('M', ['MM', 2], 'Mo', function () { - return this.month() + 1; - }); - - addFormatToken('MMM', 0, 0, function (format) { - return this.localeData().monthsShort(this, format); - }); - - addFormatToken('MMMM', 0, 0, function (format) { - return this.localeData().months(this, format); - }); - - // ALIASES - - addUnitAlias('month', 'M'); - - // PARSING - - addRegexToken('M', match1to2); - addRegexToken('MM', match1to2, match2); - addRegexToken('MMM', function (isStrict, locale) { - return locale.monthsShortRegex(isStrict); - }); - addRegexToken('MMMM', function (isStrict, locale) { - return locale.monthsRegex(isStrict); - }); - - addParseToken(['M', 'MM'], function (input, array) { - array[MONTH] = toInt(input) - 1; - }); - - addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { - var month = config._locale.monthsParse(input, token, config._strict); - // if we didn't find a month name, mark the date as invalid. - if (month != null) { - array[MONTH] = month; - } else { - getParsingFlags(config).invalidMonth = input; - } - }); - - // LOCALES - - var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s+)+MMMM?/; - var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'); - function localeMonths (m, format) { - return isArray(this._months) ? this._months[m.month()] : - this._months[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()]; - } - - var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'); - function localeMonthsShort (m, format) { - return isArray(this._monthsShort) ? this._monthsShort[m.month()] : - this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()]; - } - - function units_month__handleStrictParse(monthName, format, strict) { - var i, ii, mom, llc = monthName.toLocaleLowerCase(); - if (!this._monthsParse) { - // this is not used - this._monthsParse = []; - this._longMonthsParse = []; - this._shortMonthsParse = []; - for (i = 0; i < 12; ++i) { - mom = create_utc__createUTC([2000, i]); - this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase(); - this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); - } - } - - if (strict) { - if (format === 'MMM') { - ii = indexOf.call(this._shortMonthsParse, llc); - return ii !== -1 ? ii : null; - } else { - ii = indexOf.call(this._longMonthsParse, llc); - return ii !== -1 ? ii : null; - } - } else { - if (format === 'MMM') { - ii = indexOf.call(this._shortMonthsParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._longMonthsParse, llc); - return ii !== -1 ? ii : null; - } else { - ii = indexOf.call(this._longMonthsParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._shortMonthsParse, llc); - return ii !== -1 ? ii : null; - } - } - } - - function localeMonthsParse (monthName, format, strict) { - var i, mom, regex; - - if (this._monthsParseExact) { - return units_month__handleStrictParse.call(this, monthName, format, strict); - } - - if (!this._monthsParse) { - this._monthsParse = []; - this._longMonthsParse = []; - this._shortMonthsParse = []; - } - - // TODO: add sorting - // Sorting makes sure if one month (or abbr) is a prefix of another - // see sorting in computeMonthsParse - for (i = 0; i < 12; i++) { - // make the regex if we don't have it already - mom = create_utc__createUTC([2000, i]); - if (strict && !this._longMonthsParse[i]) { - this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i'); - this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i'); - } - if (!strict && !this._monthsParse[i]) { - regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); - this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); - } - // test the regex - if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) { - return i; - } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) { - return i; - } else if (!strict && this._monthsParse[i].test(monthName)) { - return i; - } - } - } - - // MOMENTS - - function setMonth (mom, value) { - var dayOfMonth; - - if (!mom.isValid()) { - // No op - return mom; - } - - if (typeof value === 'string') { - if (/^\d+$/.test(value)) { - value = toInt(value); - } else { - value = mom.localeData().monthsParse(value); - // TODO: Another silent failure? - if (typeof value !== 'number') { - return mom; - } - } - } - - dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value)); - mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); - return mom; - } - - function getSetMonth (value) { - if (value != null) { - setMonth(this, value); - utils_hooks__hooks.updateOffset(this, true); - return this; - } else { - return get_set__get(this, 'Month'); - } - } - - function getDaysInMonth () { - return daysInMonth(this.year(), this.month()); - } - - var defaultMonthsShortRegex = matchWord; - function monthsShortRegex (isStrict) { - if (this._monthsParseExact) { - if (!hasOwnProp(this, '_monthsRegex')) { - computeMonthsParse.call(this); - } - if (isStrict) { - return this._monthsShortStrictRegex; - } else { - return this._monthsShortRegex; - } - } else { - return this._monthsShortStrictRegex && isStrict ? - this._monthsShortStrictRegex : this._monthsShortRegex; - } - } - - var defaultMonthsRegex = matchWord; - function monthsRegex (isStrict) { - if (this._monthsParseExact) { - if (!hasOwnProp(this, '_monthsRegex')) { - computeMonthsParse.call(this); - } - if (isStrict) { - return this._monthsStrictRegex; - } else { - return this._monthsRegex; - } - } else { - return this._monthsStrictRegex && isStrict ? - this._monthsStrictRegex : this._monthsRegex; - } - } - - function computeMonthsParse () { - function cmpLenRev(a, b) { - return b.length - a.length; - } - - var shortPieces = [], longPieces = [], mixedPieces = [], - i, mom; - for (i = 0; i < 12; i++) { - // make the regex if we don't have it already - mom = create_utc__createUTC([2000, i]); - shortPieces.push(this.monthsShort(mom, '')); - longPieces.push(this.months(mom, '')); - mixedPieces.push(this.months(mom, '')); - mixedPieces.push(this.monthsShort(mom, '')); - } - // Sorting makes sure if one month (or abbr) is a prefix of another it - // will match the longer piece. - shortPieces.sort(cmpLenRev); - longPieces.sort(cmpLenRev); - mixedPieces.sort(cmpLenRev); - for (i = 0; i < 12; i++) { - shortPieces[i] = regexEscape(shortPieces[i]); - longPieces[i] = regexEscape(longPieces[i]); - mixedPieces[i] = regexEscape(mixedPieces[i]); - } - - this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); - this._monthsShortRegex = this._monthsRegex; - this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); - this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); - } - - function checkOverflow (m) { - var overflow; - var a = m._a; - - if (a && getParsingFlags(m).overflow === -2) { - overflow = - a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : - a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : - a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR : - a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : - a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : - a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : - -1; - - if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) { - overflow = DATE; - } - if (getParsingFlags(m)._overflowWeeks && overflow === -1) { - overflow = WEEK; - } - if (getParsingFlags(m)._overflowWeekday && overflow === -1) { - overflow = WEEKDAY; - } - - getParsingFlags(m).overflow = overflow; - } - - return m; - } - - // iso 8601 regex - // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) - var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/; - var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?/; - - var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/; - - var isoDates = [ - ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], - ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], - ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], - ['GGGG-[W]WW', /\d{4}-W\d\d/, false], - ['YYYY-DDD', /\d{4}-\d{3}/], - ['YYYY-MM', /\d{4}-\d\d/, false], - ['YYYYYYMMDD', /[+-]\d{10}/], - ['YYYYMMDD', /\d{8}/], - // YYYYMM is NOT allowed by the standard - ['GGGG[W]WWE', /\d{4}W\d{3}/], - ['GGGG[W]WW', /\d{4}W\d{2}/, false], - ['YYYYDDD', /\d{7}/] - ]; - - // iso time formats and regexes - var isoTimes = [ - ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], - ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], - ['HH:mm:ss', /\d\d:\d\d:\d\d/], - ['HH:mm', /\d\d:\d\d/], - ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], - ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], - ['HHmmss', /\d\d\d\d\d\d/], - ['HHmm', /\d\d\d\d/], - ['HH', /\d\d/] - ]; - - var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i; - - // date from iso format - function configFromISO(config) { - var i, l, - string = config._i, - match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), - allowTime, dateFormat, timeFormat, tzFormat; - - if (match) { - getParsingFlags(config).iso = true; - - for (i = 0, l = isoDates.length; i < l; i++) { - if (isoDates[i][1].exec(match[1])) { - dateFormat = isoDates[i][0]; - allowTime = isoDates[i][2] !== false; - break; - } - } - if (dateFormat == null) { - config._isValid = false; - return; - } - if (match[3]) { - for (i = 0, l = isoTimes.length; i < l; i++) { - if (isoTimes[i][1].exec(match[3])) { - // match[2] should be 'T' or space - timeFormat = (match[2] || ' ') + isoTimes[i][0]; - break; - } - } - if (timeFormat == null) { - config._isValid = false; - return; - } - } - if (!allowTime && timeFormat != null) { - config._isValid = false; - return; - } - if (match[4]) { - if (tzRegex.exec(match[4])) { - tzFormat = 'Z'; - } else { - config._isValid = false; - return; - } - } - config._f = dateFormat + (timeFormat || '') + (tzFormat || ''); - configFromStringAndFormat(config); - } else { - config._isValid = false; - } - } - - // date from iso format or fallback - function configFromString(config) { - var matched = aspNetJsonRegex.exec(config._i); - - if (matched !== null) { - config._d = new Date(+matched[1]); - return; - } - - configFromISO(config); - if (config._isValid === false) { - delete config._isValid; - utils_hooks__hooks.createFromInputFallback(config); - } - } - - utils_hooks__hooks.createFromInputFallback = deprecate( - 'moment construction falls back to js Date. This is ' + - 'discouraged and will be removed in upcoming major ' + - 'release. Please refer to ' + - 'https://github.com/moment/moment/issues/1407 for more info.', - function (config) { - config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); - } - ); - - function createDate (y, m, d, h, M, s, ms) { - //can't just apply() to create a date: - //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply - var date = new Date(y, m, d, h, M, s, ms); - - //the date constructor remaps years 0-99 to 1900-1999 - if (y < 100 && y >= 0 && isFinite(date.getFullYear())) { - date.setFullYear(y); - } - return date; - } - - function createUTCDate (y) { - var date = new Date(Date.UTC.apply(null, arguments)); - - //the Date.UTC function remaps years 0-99 to 1900-1999 - if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) { - date.setUTCFullYear(y); - } - return date; - } - - // FORMATTING - - addFormatToken('Y', 0, 0, function () { - var y = this.year(); - return y <= 9999 ? '' + y : '+' + y; - }); - - addFormatToken(0, ['YY', 2], 0, function () { - return this.year() % 100; - }); - - addFormatToken(0, ['YYYY', 4], 0, 'year'); - addFormatToken(0, ['YYYYY', 5], 0, 'year'); - addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); - - // ALIASES - - addUnitAlias('year', 'y'); - - // PARSING - - addRegexToken('Y', matchSigned); - addRegexToken('YY', match1to2, match2); - addRegexToken('YYYY', match1to4, match4); - addRegexToken('YYYYY', match1to6, match6); - addRegexToken('YYYYYY', match1to6, match6); - - addParseToken(['YYYYY', 'YYYYYY'], YEAR); - addParseToken('YYYY', function (input, array) { - array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input); - }); - addParseToken('YY', function (input, array) { - array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input); - }); - addParseToken('Y', function (input, array) { - array[YEAR] = parseInt(input, 10); - }); - - // HELPERS - - function daysInYear(year) { - return isLeapYear(year) ? 366 : 365; - } - - function isLeapYear(year) { - return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; - } - - // HOOKS - - utils_hooks__hooks.parseTwoDigitYear = function (input) { - return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); - }; - - // MOMENTS - - var getSetYear = makeGetSet('FullYear', true); - - function getIsLeapYear () { - return isLeapYear(this.year()); - } - - // start-of-first-week - start-of-year - function firstWeekOffset(year, dow, doy) { - var // first-week day -- which january is always in the first week (4 for iso, 1 for other) - fwd = 7 + dow - doy, - // first-week day local weekday -- which local weekday is fwd - fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; - - return -fwdlw + fwd - 1; - } - - //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday - function dayOfYearFromWeeks(year, week, weekday, dow, doy) { - var localWeekday = (7 + weekday - dow) % 7, - weekOffset = firstWeekOffset(year, dow, doy), - dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, - resYear, resDayOfYear; - - if (dayOfYear <= 0) { - resYear = year - 1; - resDayOfYear = daysInYear(resYear) + dayOfYear; - } else if (dayOfYear > daysInYear(year)) { - resYear = year + 1; - resDayOfYear = dayOfYear - daysInYear(year); - } else { - resYear = year; - resDayOfYear = dayOfYear; - } - - return { - year: resYear, - dayOfYear: resDayOfYear - }; - } - - function weekOfYear(mom, dow, doy) { - var weekOffset = firstWeekOffset(mom.year(), dow, doy), - week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, - resWeek, resYear; - - if (week < 1) { - resYear = mom.year() - 1; - resWeek = week + weeksInYear(resYear, dow, doy); - } else if (week > weeksInYear(mom.year(), dow, doy)) { - resWeek = week - weeksInYear(mom.year(), dow, doy); - resYear = mom.year() + 1; - } else { - resYear = mom.year(); - resWeek = week; - } - - return { - week: resWeek, - year: resYear - }; - } - - function weeksInYear(year, dow, doy) { - var weekOffset = firstWeekOffset(year, dow, doy), - weekOffsetNext = firstWeekOffset(year + 1, dow, doy); - return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; - } - - // Pick the first defined of two or three arguments. - function defaults(a, b, c) { - if (a != null) { - return a; - } - if (b != null) { - return b; - } - return c; - } - - function currentDateArray(config) { - // hooks is actually the exported moment object - var nowValue = new Date(utils_hooks__hooks.now()); - if (config._useUTC) { - return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()]; - } - return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; - } - - // convert an array to a date. - // the array should mirror the parameters below - // note: all values past the year are optional and will default to the lowest possible value. - // [year, month, day , hour, minute, second, millisecond] - function configFromArray (config) { - var i, date, input = [], currentDate, yearToUse; - - if (config._d) { - return; - } - - currentDate = currentDateArray(config); - - //compute day of the year from weeks and weekdays - if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { - dayOfYearFromWeekInfo(config); - } - - //if the day of the year is set, figure out what it is - if (config._dayOfYear) { - yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); - - if (config._dayOfYear > daysInYear(yearToUse)) { - getParsingFlags(config)._overflowDayOfYear = true; - } - - date = createUTCDate(yearToUse, 0, config._dayOfYear); - config._a[MONTH] = date.getUTCMonth(); - config._a[DATE] = date.getUTCDate(); - } - - // Default to current date. - // * if no year, month, day of month are given, default to today - // * if day of month is given, default month and year - // * if month is given, default only year - // * if year is given, don't default anything - for (i = 0; i < 3 && config._a[i] == null; ++i) { - config._a[i] = input[i] = currentDate[i]; - } - - // Zero out whatever was not defaulted, including time - for (; i < 7; i++) { - config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i]; - } - - // Check for 24:00:00.000 - if (config._a[HOUR] === 24 && - config._a[MINUTE] === 0 && - config._a[SECOND] === 0 && - config._a[MILLISECOND] === 0) { - config._nextDay = true; - config._a[HOUR] = 0; - } - - config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input); - // Apply timezone offset from input. The actual utcOffset can be changed - // with parseZone. - if (config._tzm != null) { - config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); - } - - if (config._nextDay) { - config._a[HOUR] = 24; - } - } - - function dayOfYearFromWeekInfo(config) { - var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow; - - w = config._w; - if (w.GG != null || w.W != null || w.E != null) { - dow = 1; - doy = 4; - - // TODO: We need to take the current isoWeekYear, but that depends on - // how we interpret now (local, utc, fixed offset). So create - // a now version of current config (take local/utc/offset flags, and - // create now). - weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year); - week = defaults(w.W, 1); - weekday = defaults(w.E, 1); - if (weekday < 1 || weekday > 7) { - weekdayOverflow = true; - } - } else { - dow = config._locale._week.dow; - doy = config._locale._week.doy; - - weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year); - week = defaults(w.w, 1); - - if (w.d != null) { - // weekday -- low day numbers are considered next week - weekday = w.d; - if (weekday < 0 || weekday > 6) { - weekdayOverflow = true; - } - } else if (w.e != null) { - // local weekday -- counting starts from begining of week - weekday = w.e + dow; - if (w.e < 0 || w.e > 6) { - weekdayOverflow = true; - } - } else { - // default to begining of week - weekday = dow; - } - } - if (week < 1 || week > weeksInYear(weekYear, dow, doy)) { - getParsingFlags(config)._overflowWeeks = true; - } else if (weekdayOverflow != null) { - getParsingFlags(config)._overflowWeekday = true; - } else { - temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy); - config._a[YEAR] = temp.year; - config._dayOfYear = temp.dayOfYear; - } - } - - // constant that refers to the ISO standard - utils_hooks__hooks.ISO_8601 = function () {}; - - // date from string and format string - function configFromStringAndFormat(config) { - // TODO: Move this to another part of the creation flow to prevent circular deps - if (config._f === utils_hooks__hooks.ISO_8601) { - configFromISO(config); - return; - } - - config._a = []; - getParsingFlags(config).empty = true; - - // This array is used to make a Date, either with `new Date` or `Date.UTC` - var string = '' + config._i, - i, parsedInput, tokens, token, skipped, - stringLength = string.length, - totalParsedInputLength = 0; - - tokens = expandFormat(config._f, config._locale).match(formattingTokens) || []; - - for (i = 0; i < tokens.length; i++) { - token = tokens[i]; - parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; - // console.log('token', token, 'parsedInput', parsedInput, - // 'regex', getParseRegexForToken(token, config)); - if (parsedInput) { - skipped = string.substr(0, string.indexOf(parsedInput)); - if (skipped.length > 0) { - getParsingFlags(config).unusedInput.push(skipped); - } - string = string.slice(string.indexOf(parsedInput) + parsedInput.length); - totalParsedInputLength += parsedInput.length; - } - // don't parse if it's not a known token - if (formatTokenFunctions[token]) { - if (parsedInput) { - getParsingFlags(config).empty = false; - } - else { - getParsingFlags(config).unusedTokens.push(token); - } - addTimeToArrayFromToken(token, parsedInput, config); - } - else if (config._strict && !parsedInput) { - getParsingFlags(config).unusedTokens.push(token); - } - } - - // add remaining unparsed input length to the string - getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength; - if (string.length > 0) { - getParsingFlags(config).unusedInput.push(string); - } - - // clear _12h flag if hour is <= 12 - if (getParsingFlags(config).bigHour === true && - config._a[HOUR] <= 12 && - config._a[HOUR] > 0) { - getParsingFlags(config).bigHour = undefined; - } - - getParsingFlags(config).parsedDateParts = config._a.slice(0); - getParsingFlags(config).meridiem = config._meridiem; - // handle meridiem - config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem); - - configFromArray(config); - checkOverflow(config); - } - - - function meridiemFixWrap (locale, hour, meridiem) { - var isPm; - - if (meridiem == null) { - // nothing to do - return hour; - } - if (locale.meridiemHour != null) { - return locale.meridiemHour(hour, meridiem); - } else if (locale.isPM != null) { - // Fallback - isPm = locale.isPM(meridiem); - if (isPm && hour < 12) { - hour += 12; - } - if (!isPm && hour === 12) { - hour = 0; - } - return hour; - } else { - // this is not supposed to happen - return hour; - } - } - - // date from string and array of format strings - function configFromStringAndArray(config) { - var tempConfig, - bestMoment, - - scoreToBeat, - i, - currentScore; - - if (config._f.length === 0) { - getParsingFlags(config).invalidFormat = true; - config._d = new Date(NaN); - return; - } - - for (i = 0; i < config._f.length; i++) { - currentScore = 0; - tempConfig = copyConfig({}, config); - if (config._useUTC != null) { - tempConfig._useUTC = config._useUTC; - } - tempConfig._f = config._f[i]; - configFromStringAndFormat(tempConfig); - - if (!valid__isValid(tempConfig)) { - continue; - } - - // if there is any input that was not parsed add a penalty for that format - currentScore += getParsingFlags(tempConfig).charsLeftOver; - - //or tokens - currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; - - getParsingFlags(tempConfig).score = currentScore; - - if (scoreToBeat == null || currentScore < scoreToBeat) { - scoreToBeat = currentScore; - bestMoment = tempConfig; - } - } - - extend(config, bestMoment || tempConfig); - } - - function configFromObject(config) { - if (config._d) { - return; - } - - var i = normalizeObjectUnits(config._i); - config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) { - return obj && parseInt(obj, 10); - }); - - configFromArray(config); - } - - function createFromConfig (config) { - var res = new Moment(checkOverflow(prepareConfig(config))); - if (res._nextDay) { - // Adding is smart enough around DST - res.add(1, 'd'); - res._nextDay = undefined; - } - - return res; - } - - function prepareConfig (config) { - var input = config._i, - format = config._f; - - config._locale = config._locale || locale_locales__getLocale(config._l); - - if (input === null || (format === undefined && input === '')) { - return valid__createInvalid({nullInput: true}); - } - - if (typeof input === 'string') { - config._i = input = config._locale.preparse(input); - } - - if (isMoment(input)) { - return new Moment(checkOverflow(input)); - } else if (isArray(format)) { - configFromStringAndArray(config); - } else if (format) { - configFromStringAndFormat(config); - } else if (isDate(input)) { - config._d = input; - } else { - configFromInput(config); - } - - if (!valid__isValid(config)) { - config._d = null; - } - - return config; - } - - function configFromInput(config) { - var input = config._i; - if (input === undefined) { - config._d = new Date(utils_hooks__hooks.now()); - } else if (isDate(input)) { - config._d = new Date(input.valueOf()); - } else if (typeof input === 'string') { - configFromString(config); - } else if (isArray(input)) { - config._a = map(input.slice(0), function (obj) { - return parseInt(obj, 10); - }); - configFromArray(config); - } else if (typeof(input) === 'object') { - configFromObject(config); - } else if (typeof(input) === 'number') { - // from milliseconds - config._d = new Date(input); - } else { - utils_hooks__hooks.createFromInputFallback(config); - } - } - - function createLocalOrUTC (input, format, locale, strict, isUTC) { - var c = {}; - - if (typeof(locale) === 'boolean') { - strict = locale; - locale = undefined; - } - // object construction must be done this way. - // https://github.com/moment/moment/issues/1423 - c._isAMomentObject = true; - c._useUTC = c._isUTC = isUTC; - c._l = locale; - c._i = input; - c._f = format; - c._strict = strict; - - return createFromConfig(c); - } - - function local__createLocal (input, format, locale, strict) { - return createLocalOrUTC(input, format, locale, strict, false); - } - - var prototypeMin = deprecate( - 'moment().min is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548', - function () { - var other = local__createLocal.apply(null, arguments); - if (this.isValid() && other.isValid()) { - return other < this ? this : other; - } else { - return valid__createInvalid(); - } - } - ); - - var prototypeMax = deprecate( - 'moment().max is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548', - function () { - var other = local__createLocal.apply(null, arguments); - if (this.isValid() && other.isValid()) { - return other > this ? this : other; - } else { - return valid__createInvalid(); - } - } - ); - - // Pick a moment m from moments so that m[fn](other) is true for all - // other. This relies on the function fn to be transitive. - // - // moments should either be an array of moment objects or an array, whose - // first element is an array of moment objects. - function pickBy(fn, moments) { - var res, i; - if (moments.length === 1 && isArray(moments[0])) { - moments = moments[0]; - } - if (!moments.length) { - return local__createLocal(); - } - res = moments[0]; - for (i = 1; i < moments.length; ++i) { - if (!moments[i].isValid() || moments[i][fn](res)) { - res = moments[i]; - } - } - return res; - } - - // TODO: Use [].sort instead? - function min () { - var args = [].slice.call(arguments, 0); - - return pickBy('isBefore', args); - } - - function max () { - var args = [].slice.call(arguments, 0); - - return pickBy('isAfter', args); - } - - var now = function () { - return Date.now ? Date.now() : +(new Date()); - }; - - function Duration (duration) { - var normalizedInput = normalizeObjectUnits(duration), - years = normalizedInput.year || 0, - quarters = normalizedInput.quarter || 0, - months = normalizedInput.month || 0, - weeks = normalizedInput.week || 0, - days = normalizedInput.day || 0, - hours = normalizedInput.hour || 0, - minutes = normalizedInput.minute || 0, - seconds = normalizedInput.second || 0, - milliseconds = normalizedInput.millisecond || 0; - - // representation for dateAddRemove - this._milliseconds = +milliseconds + - seconds * 1e3 + // 1000 - minutes * 6e4 + // 1000 * 60 - hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 - // Because of dateAddRemove treats 24 hours as different from a - // day when working around DST, we need to store them separately - this._days = +days + - weeks * 7; - // It is impossible translate months into days without knowing - // which months you are are talking about, so we have to store - // it separately. - this._months = +months + - quarters * 3 + - years * 12; - - this._data = {}; - - this._locale = locale_locales__getLocale(); - - this._bubble(); - } - - function isDuration (obj) { - return obj instanceof Duration; - } - - // FORMATTING - - function offset (token, separator) { - addFormatToken(token, 0, 0, function () { - var offset = this.utcOffset(); - var sign = '+'; - if (offset < 0) { - offset = -offset; - sign = '-'; - } - return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2); - }); - } - - offset('Z', ':'); - offset('ZZ', ''); - - // PARSING - - addRegexToken('Z', matchShortOffset); - addRegexToken('ZZ', matchShortOffset); - addParseToken(['Z', 'ZZ'], function (input, array, config) { - config._useUTC = true; - config._tzm = offsetFromString(matchShortOffset, input); - }); - - // HELPERS - - // timezone chunker - // '+10:00' > ['10', '00'] - // '-1530' > ['-15', '30'] - var chunkOffset = /([\+\-]|\d\d)/gi; - - function offsetFromString(matcher, string) { - var matches = ((string || '').match(matcher) || []); - var chunk = matches[matches.length - 1] || []; - var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; - var minutes = +(parts[1] * 60) + toInt(parts[2]); - - return parts[0] === '+' ? minutes : -minutes; - } - - // Return a moment from input, that is local/utc/zone equivalent to model. - function cloneWithOffset(input, model) { - var res, diff; - if (model._isUTC) { - res = model.clone(); - diff = (isMoment(input) || isDate(input) ? input.valueOf() : local__createLocal(input).valueOf()) - res.valueOf(); - // Use low-level api, because this fn is low-level api. - res._d.setTime(res._d.valueOf() + diff); - utils_hooks__hooks.updateOffset(res, false); - return res; - } else { - return local__createLocal(input).local(); - } - } - - function getDateOffset (m) { - // On Firefox.24 Date#getTimezoneOffset returns a floating point. - // https://github.com/moment/moment/pull/1871 - return -Math.round(m._d.getTimezoneOffset() / 15) * 15; - } - - // HOOKS - - // This function will be called whenever a moment is mutated. - // It is intended to keep the offset in sync with the timezone. - utils_hooks__hooks.updateOffset = function () {}; - - // MOMENTS - - // keepLocalTime = true means only change the timezone, without - // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> - // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset - // +0200, so we adjust the time as needed, to be valid. - // - // Keeping the time actually adds/subtracts (one hour) - // from the actual represented time. That is why we call updateOffset - // a second time. In case it wants us to change the offset again - // _changeInProgress == true case, then we have to adjust, because - // there is no such time in the given timezone. - function getSetOffset (input, keepLocalTime) { - var offset = this._offset || 0, - localAdjust; - if (!this.isValid()) { - return input != null ? this : NaN; - } - if (input != null) { - if (typeof input === 'string') { - input = offsetFromString(matchShortOffset, input); - } else if (Math.abs(input) < 16) { - input = input * 60; - } - if (!this._isUTC && keepLocalTime) { - localAdjust = getDateOffset(this); - } - this._offset = input; - this._isUTC = true; - if (localAdjust != null) { - this.add(localAdjust, 'm'); - } - if (offset !== input) { - if (!keepLocalTime || this._changeInProgress) { - add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false); - } else if (!this._changeInProgress) { - this._changeInProgress = true; - utils_hooks__hooks.updateOffset(this, true); - this._changeInProgress = null; - } - } - return this; - } else { - return this._isUTC ? offset : getDateOffset(this); - } - } - - function getSetZone (input, keepLocalTime) { - if (input != null) { - if (typeof input !== 'string') { - input = -input; - } - - this.utcOffset(input, keepLocalTime); - - return this; - } else { - return -this.utcOffset(); - } - } - - function setOffsetToUTC (keepLocalTime) { - return this.utcOffset(0, keepLocalTime); - } - - function setOffsetToLocal (keepLocalTime) { - if (this._isUTC) { - this.utcOffset(0, keepLocalTime); - this._isUTC = false; - - if (keepLocalTime) { - this.subtract(getDateOffset(this), 'm'); - } - } - return this; - } - - function setOffsetToParsedOffset () { - if (this._tzm) { - this.utcOffset(this._tzm); - } else if (typeof this._i === 'string') { - this.utcOffset(offsetFromString(matchOffset, this._i)); - } - return this; - } - - function hasAlignedHourOffset (input) { - if (!this.isValid()) { - return false; - } - input = input ? local__createLocal(input).utcOffset() : 0; - - return (this.utcOffset() - input) % 60 === 0; - } - - function isDaylightSavingTime () { - return ( - this.utcOffset() > this.clone().month(0).utcOffset() || - this.utcOffset() > this.clone().month(5).utcOffset() - ); - } - - function isDaylightSavingTimeShifted () { - if (!isUndefined(this._isDSTShifted)) { - return this._isDSTShifted; - } - - var c = {}; - - copyConfig(c, this); - c = prepareConfig(c); - - if (c._a) { - var other = c._isUTC ? create_utc__createUTC(c._a) : local__createLocal(c._a); - this._isDSTShifted = this.isValid() && - compareArrays(c._a, other.toArray()) > 0; - } else { - this._isDSTShifted = false; - } - - return this._isDSTShifted; - } - - function isLocal () { - return this.isValid() ? !this._isUTC : false; - } - - function isUtcOffset () { - return this.isValid() ? this._isUTC : false; - } - - function isUtc () { - return this.isValid() ? this._isUTC && this._offset === 0 : false; - } - - // ASP.NET json date format regex - var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/; - - // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html - // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere - // and further modified to allow for strings containing both week and day - var isoRegex = /^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/; - - function create__createDuration (input, key) { - var duration = input, - // matching against regexp is expensive, do it on demand - match = null, - sign, - ret, - diffRes; - - if (isDuration(input)) { - duration = { - ms : input._milliseconds, - d : input._days, - M : input._months - }; - } else if (typeof input === 'number') { - duration = {}; - if (key) { - duration[key] = input; - } else { - duration.milliseconds = input; - } - } else if (!!(match = aspNetRegex.exec(input))) { - sign = (match[1] === '-') ? -1 : 1; - duration = { - y : 0, - d : toInt(match[DATE]) * sign, - h : toInt(match[HOUR]) * sign, - m : toInt(match[MINUTE]) * sign, - s : toInt(match[SECOND]) * sign, - ms : toInt(match[MILLISECOND]) * sign - }; - } else if (!!(match = isoRegex.exec(input))) { - sign = (match[1] === '-') ? -1 : 1; - duration = { - y : parseIso(match[2], sign), - M : parseIso(match[3], sign), - w : parseIso(match[4], sign), - d : parseIso(match[5], sign), - h : parseIso(match[6], sign), - m : parseIso(match[7], sign), - s : parseIso(match[8], sign) - }; - } else if (duration == null) {// checks for null or undefined - duration = {}; - } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) { - diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to)); - - duration = {}; - duration.ms = diffRes.milliseconds; - duration.M = diffRes.months; - } - - ret = new Duration(duration); - - if (isDuration(input) && hasOwnProp(input, '_locale')) { - ret._locale = input._locale; - } - - return ret; - } - - create__createDuration.fn = Duration.prototype; - - function parseIso (inp, sign) { - // We'd normally use ~~inp for this, but unfortunately it also - // converts floats to ints. - // inp may be undefined, so careful calling replace on it. - var res = inp && parseFloat(inp.replace(',', '.')); - // apply sign while we're at it - return (isNaN(res) ? 0 : res) * sign; - } - - function positiveMomentsDifference(base, other) { - var res = {milliseconds: 0, months: 0}; - - res.months = other.month() - base.month() + - (other.year() - base.year()) * 12; - if (base.clone().add(res.months, 'M').isAfter(other)) { - --res.months; - } - - res.milliseconds = +other - +(base.clone().add(res.months, 'M')); - - return res; - } - - function momentsDifference(base, other) { - var res; - if (!(base.isValid() && other.isValid())) { - return {milliseconds: 0, months: 0}; - } - - other = cloneWithOffset(other, base); - if (base.isBefore(other)) { - res = positiveMomentsDifference(base, other); - } else { - res = positiveMomentsDifference(other, base); - res.milliseconds = -res.milliseconds; - res.months = -res.months; - } - - return res; - } - - function absRound (number) { - if (number < 0) { - return Math.round(-1 * number) * -1; - } else { - return Math.round(number); - } - } - - // TODO: remove 'name' arg after deprecation is removed - function createAdder(direction, name) { - return function (val, period) { - var dur, tmp; - //invert the arguments, but complain about it - if (period !== null && !isNaN(+period)) { - deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).'); - tmp = val; val = period; period = tmp; - } - - val = typeof val === 'string' ? +val : val; - dur = create__createDuration(val, period); - add_subtract__addSubtract(this, dur, direction); - return this; - }; - } - - function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) { - var milliseconds = duration._milliseconds, - days = absRound(duration._days), - months = absRound(duration._months); - - if (!mom.isValid()) { - // No op - return; - } - - updateOffset = updateOffset == null ? true : updateOffset; - - if (milliseconds) { - mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding); - } - if (days) { - get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding); - } - if (months) { - setMonth(mom, get_set__get(mom, 'Month') + months * isAdding); - } - if (updateOffset) { - utils_hooks__hooks.updateOffset(mom, days || months); - } - } - - var add_subtract__add = createAdder(1, 'add'); - var add_subtract__subtract = createAdder(-1, 'subtract'); - - function moment_calendar__calendar (time, formats) { - // We want to compare the start of today, vs this. - // Getting start-of-today depends on whether we're local/utc/offset or not. - var now = time || local__createLocal(), - sod = cloneWithOffset(now, this).startOf('day'), - diff = this.diff(sod, 'days', true), - format = diff < -6 ? 'sameElse' : - diff < -1 ? 'lastWeek' : - diff < 0 ? 'lastDay' : - diff < 1 ? 'sameDay' : - diff < 2 ? 'nextDay' : - diff < 7 ? 'nextWeek' : 'sameElse'; - - var output = formats && (isFunction(formats[format]) ? formats[format]() : formats[format]); - - return this.format(output || this.localeData().calendar(format, this, local__createLocal(now))); - } - - function clone () { - return new Moment(this); - } - - function isAfter (input, units) { - var localInput = isMoment(input) ? input : local__createLocal(input); - if (!(this.isValid() && localInput.isValid())) { - return false; - } - units = normalizeUnits(!isUndefined(units) ? units : 'millisecond'); - if (units === 'millisecond') { - return this.valueOf() > localInput.valueOf(); - } else { - return localInput.valueOf() < this.clone().startOf(units).valueOf(); - } - } - - function isBefore (input, units) { - var localInput = isMoment(input) ? input : local__createLocal(input); - if (!(this.isValid() && localInput.isValid())) { - return false; - } - units = normalizeUnits(!isUndefined(units) ? units : 'millisecond'); - if (units === 'millisecond') { - return this.valueOf() < localInput.valueOf(); - } else { - return this.clone().endOf(units).valueOf() < localInput.valueOf(); - } - } - - function isBetween (from, to, units, inclusivity) { - inclusivity = inclusivity || '()'; - return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) && - (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units)); - } - - function isSame (input, units) { - var localInput = isMoment(input) ? input : local__createLocal(input), - inputMs; - if (!(this.isValid() && localInput.isValid())) { - return false; - } - units = normalizeUnits(units || 'millisecond'); - if (units === 'millisecond') { - return this.valueOf() === localInput.valueOf(); - } else { - inputMs = localInput.valueOf(); - return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf(); - } - } - - function isSameOrAfter (input, units) { - return this.isSame(input, units) || this.isAfter(input,units); - } - - function isSameOrBefore (input, units) { - return this.isSame(input, units) || this.isBefore(input,units); - } - - function diff (input, units, asFloat) { - var that, - zoneDelta, - delta, output; - - if (!this.isValid()) { - return NaN; - } - - that = cloneWithOffset(input, this); - - if (!that.isValid()) { - return NaN; - } - - zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; - - units = normalizeUnits(units); - - if (units === 'year' || units === 'month' || units === 'quarter') { - output = monthDiff(this, that); - if (units === 'quarter') { - output = output / 3; - } else if (units === 'year') { - output = output / 12; - } - } else { - delta = this - that; - output = units === 'second' ? delta / 1e3 : // 1000 - units === 'minute' ? delta / 6e4 : // 1000 * 60 - units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60 - units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst - units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst - delta; - } - return asFloat ? output : absFloor(output); - } - - function monthDiff (a, b) { - // difference in months - var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()), - // b is in (anchor - 1 month, anchor + 1 month) - anchor = a.clone().add(wholeMonthDiff, 'months'), - anchor2, adjust; - - if (b - anchor < 0) { - anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); - // linear across the month - adjust = (b - anchor) / (anchor - anchor2); - } else { - anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); - // linear across the month - adjust = (b - anchor) / (anchor2 - anchor); - } - - //check for negative zero, return zero if negative zero - return -(wholeMonthDiff + adjust) || 0; - } - - utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; - utils_hooks__hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; - - function toString () { - return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); - } - - function moment_format__toISOString () { - var m = this.clone().utc(); - if (0 < m.year() && m.year() <= 9999) { - if (isFunction(Date.prototype.toISOString)) { - // native implementation is ~50x faster, use it when we can - return this.toDate().toISOString(); - } else { - return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); - } - } else { - return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); - } - } - - function format (inputString) { - if (!inputString) { - inputString = this.isUtc() ? utils_hooks__hooks.defaultFormatUtc : utils_hooks__hooks.defaultFormat; - } - var output = formatMoment(this, inputString); - return this.localeData().postformat(output); - } - - function from (time, withoutSuffix) { - if (this.isValid() && - ((isMoment(time) && time.isValid()) || - local__createLocal(time).isValid())) { - return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix); - } else { - return this.localeData().invalidDate(); - } - } - - function fromNow (withoutSuffix) { - return this.from(local__createLocal(), withoutSuffix); - } - - function to (time, withoutSuffix) { - if (this.isValid() && - ((isMoment(time) && time.isValid()) || - local__createLocal(time).isValid())) { - return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix); - } else { - return this.localeData().invalidDate(); - } - } - - function toNow (withoutSuffix) { - return this.to(local__createLocal(), withoutSuffix); - } - - // If passed a locale key, it will set the locale for this - // instance. Otherwise, it will return the locale configuration - // variables for this instance. - function locale (key) { - var newLocaleData; - - if (key === undefined) { - return this._locale._abbr; - } else { - newLocaleData = locale_locales__getLocale(key); - if (newLocaleData != null) { - this._locale = newLocaleData; - } - return this; - } - } - - var lang = deprecate( - 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', - function (key) { - if (key === undefined) { - return this.localeData(); - } else { - return this.locale(key); - } - } - ); - - function localeData () { - return this._locale; - } - - function startOf (units) { - units = normalizeUnits(units); - // the following switch intentionally omits break keywords - // to utilize falling through the cases. - switch (units) { - case 'year': - this.month(0); - /* falls through */ - case 'quarter': - case 'month': - this.date(1); - /* falls through */ - case 'week': - case 'isoWeek': - case 'day': - case 'date': - this.hours(0); - /* falls through */ - case 'hour': - this.minutes(0); - /* falls through */ - case 'minute': - this.seconds(0); - /* falls through */ - case 'second': - this.milliseconds(0); - } - - // weeks are a special case - if (units === 'week') { - this.weekday(0); - } - if (units === 'isoWeek') { - this.isoWeekday(1); - } - - // quarters are also special - if (units === 'quarter') { - this.month(Math.floor(this.month() / 3) * 3); - } - - return this; - } - - function endOf (units) { - units = normalizeUnits(units); - if (units === undefined || units === 'millisecond') { - return this; - } - - // 'date' is an alias for 'day', so it should be considered as such. - if (units === 'date') { - units = 'day'; - } - - return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms'); - } - - function to_type__valueOf () { - return this._d.valueOf() - ((this._offset || 0) * 60000); - } - - function unix () { - return Math.floor(this.valueOf() / 1000); - } - - function toDate () { - return this._offset ? new Date(this.valueOf()) : this._d; - } - - function toArray () { - var m = this; - return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()]; - } - - function toObject () { - var m = this; - return { - years: m.year(), - months: m.month(), - date: m.date(), - hours: m.hours(), - minutes: m.minutes(), - seconds: m.seconds(), - milliseconds: m.milliseconds() - }; - } - - function toJSON () { - // new Date(NaN).toJSON() === null - return this.isValid() ? this.toISOString() : null; - } - - function moment_valid__isValid () { - return valid__isValid(this); - } - - function parsingFlags () { - return extend({}, getParsingFlags(this)); - } - - function invalidAt () { - return getParsingFlags(this).overflow; - } - - function creationData() { - return { - input: this._i, - format: this._f, - locale: this._locale, - isUTC: this._isUTC, - strict: this._strict - }; - } - - // FORMATTING - - addFormatToken(0, ['gg', 2], 0, function () { - return this.weekYear() % 100; - }); - - addFormatToken(0, ['GG', 2], 0, function () { - return this.isoWeekYear() % 100; - }); - - function addWeekYearFormatToken (token, getter) { - addFormatToken(0, [token, token.length], 0, getter); - } - - addWeekYearFormatToken('gggg', 'weekYear'); - addWeekYearFormatToken('ggggg', 'weekYear'); - addWeekYearFormatToken('GGGG', 'isoWeekYear'); - addWeekYearFormatToken('GGGGG', 'isoWeekYear'); - - // ALIASES - - addUnitAlias('weekYear', 'gg'); - addUnitAlias('isoWeekYear', 'GG'); - - // PARSING - - addRegexToken('G', matchSigned); - addRegexToken('g', matchSigned); - addRegexToken('GG', match1to2, match2); - addRegexToken('gg', match1to2, match2); - addRegexToken('GGGG', match1to4, match4); - addRegexToken('gggg', match1to4, match4); - addRegexToken('GGGGG', match1to6, match6); - addRegexToken('ggggg', match1to6, match6); - - addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) { - week[token.substr(0, 2)] = toInt(input); - }); - - addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { - week[token] = utils_hooks__hooks.parseTwoDigitYear(input); - }); - - // MOMENTS - - function getSetWeekYear (input) { - return getSetWeekYearHelper.call(this, - input, - this.week(), - this.weekday(), - this.localeData()._week.dow, - this.localeData()._week.doy); - } - - function getSetISOWeekYear (input) { - return getSetWeekYearHelper.call(this, - input, this.isoWeek(), this.isoWeekday(), 1, 4); - } - - function getISOWeeksInYear () { - return weeksInYear(this.year(), 1, 4); - } - - function getWeeksInYear () { - var weekInfo = this.localeData()._week; - return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); - } - - function getSetWeekYearHelper(input, week, weekday, dow, doy) { - var weeksTarget; - if (input == null) { - return weekOfYear(this, dow, doy).year; - } else { - weeksTarget = weeksInYear(input, dow, doy); - if (week > weeksTarget) { - week = weeksTarget; - } - return setWeekAll.call(this, input, week, weekday, dow, doy); - } - } - - function setWeekAll(weekYear, week, weekday, dow, doy) { - var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), - date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); - - this.year(date.getUTCFullYear()); - this.month(date.getUTCMonth()); - this.date(date.getUTCDate()); - return this; - } - - // FORMATTING - - addFormatToken('Q', 0, 'Qo', 'quarter'); - - // ALIASES - - addUnitAlias('quarter', 'Q'); - - // PARSING - - addRegexToken('Q', match1); - addParseToken('Q', function (input, array) { - array[MONTH] = (toInt(input) - 1) * 3; - }); - - // MOMENTS - - function getSetQuarter (input) { - return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3); - } - - // FORMATTING - - addFormatToken('w', ['ww', 2], 'wo', 'week'); - addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); - - // ALIASES - - addUnitAlias('week', 'w'); - addUnitAlias('isoWeek', 'W'); - - // PARSING - - addRegexToken('w', match1to2); - addRegexToken('ww', match1to2, match2); - addRegexToken('W', match1to2); - addRegexToken('WW', match1to2, match2); - - addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) { - week[token.substr(0, 1)] = toInt(input); - }); - - // HELPERS - - // LOCALES - - function localeWeek (mom) { - return weekOfYear(mom, this._week.dow, this._week.doy).week; - } - - var defaultLocaleWeek = { - dow : 0, // Sunday is the first day of the week. - doy : 6 // The week that contains Jan 1st is the first week of the year. - }; - - function localeFirstDayOfWeek () { - return this._week.dow; - } - - function localeFirstDayOfYear () { - return this._week.doy; - } - - // MOMENTS - - function getSetWeek (input) { - var week = this.localeData().week(this); - return input == null ? week : this.add((input - week) * 7, 'd'); - } - - function getSetISOWeek (input) { - var week = weekOfYear(this, 1, 4).week; - return input == null ? week : this.add((input - week) * 7, 'd'); - } - - // FORMATTING - - addFormatToken('D', ['DD', 2], 'Do', 'date'); - - // ALIASES - - addUnitAlias('date', 'D'); - - // PARSING - - addRegexToken('D', match1to2); - addRegexToken('DD', match1to2, match2); - addRegexToken('Do', function (isStrict, locale) { - return isStrict ? locale._ordinalParse : locale._ordinalParseLenient; - }); - - addParseToken(['D', 'DD'], DATE); - addParseToken('Do', function (input, array) { - array[DATE] = toInt(input.match(match1to2)[0], 10); - }); - - // MOMENTS - - var getSetDayOfMonth = makeGetSet('Date', true); - - // FORMATTING - - addFormatToken('d', 0, 'do', 'day'); - - addFormatToken('dd', 0, 0, function (format) { - return this.localeData().weekdaysMin(this, format); - }); - - addFormatToken('ddd', 0, 0, function (format) { - return this.localeData().weekdaysShort(this, format); - }); - - addFormatToken('dddd', 0, 0, function (format) { - return this.localeData().weekdays(this, format); - }); - - addFormatToken('e', 0, 0, 'weekday'); - addFormatToken('E', 0, 0, 'isoWeekday'); - - // ALIASES - - addUnitAlias('day', 'd'); - addUnitAlias('weekday', 'e'); - addUnitAlias('isoWeekday', 'E'); - - // PARSING - - addRegexToken('d', match1to2); - addRegexToken('e', match1to2); - addRegexToken('E', match1to2); - addRegexToken('dd', function (isStrict, locale) { - return locale.weekdaysMinRegex(isStrict); - }); - addRegexToken('ddd', function (isStrict, locale) { - return locale.weekdaysShortRegex(isStrict); - }); - addRegexToken('dddd', function (isStrict, locale) { - return locale.weekdaysRegex(isStrict); - }); - - addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { - var weekday = config._locale.weekdaysParse(input, token, config._strict); - // if we didn't get a weekday name, mark the date as invalid - if (weekday != null) { - week.d = weekday; - } else { - getParsingFlags(config).invalidWeekday = input; - } - }); - - addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { - week[token] = toInt(input); - }); - - // HELPERS - - function parseWeekday(input, locale) { - if (typeof input !== 'string') { - return input; - } - - if (!isNaN(input)) { - return parseInt(input, 10); - } - - input = locale.weekdaysParse(input); - if (typeof input === 'number') { - return input; - } - - return null; - } - - // LOCALES - - var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'); - function localeWeekdays (m, format) { - return isArray(this._weekdays) ? this._weekdays[m.day()] : - this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()]; - } - - var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'); - function localeWeekdaysShort (m) { - return this._weekdaysShort[m.day()]; - } - - var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'); - function localeWeekdaysMin (m) { - return this._weekdaysMin[m.day()]; - } - - function day_of_week__handleStrictParse(weekdayName, format, strict) { - var i, ii, mom, llc = weekdayName.toLocaleLowerCase(); - if (!this._weekdaysParse) { - this._weekdaysParse = []; - this._shortWeekdaysParse = []; - this._minWeekdaysParse = []; - - for (i = 0; i < 7; ++i) { - mom = create_utc__createUTC([2000, 1]).day(i); - this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase(); - this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase(); - this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); - } - } - - if (strict) { - if (format === 'dddd') { - ii = indexOf.call(this._weekdaysParse, llc); - return ii !== -1 ? ii : null; - } else if (format === 'ddd') { - ii = indexOf.call(this._shortWeekdaysParse, llc); - return ii !== -1 ? ii : null; - } else { - ii = indexOf.call(this._minWeekdaysParse, llc); - return ii !== -1 ? ii : null; - } - } else { - if (format === 'dddd') { - ii = indexOf.call(this._weekdaysParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._shortWeekdaysParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._minWeekdaysParse, llc); - return ii !== -1 ? ii : null; - } else if (format === 'ddd') { - ii = indexOf.call(this._shortWeekdaysParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._weekdaysParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._minWeekdaysParse, llc); - return ii !== -1 ? ii : null; - } else { - ii = indexOf.call(this._minWeekdaysParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._weekdaysParse, llc); - if (ii !== -1) { - return ii; - } - ii = indexOf.call(this._shortWeekdaysParse, llc); - return ii !== -1 ? ii : null; - } - } - } - - function localeWeekdaysParse (weekdayName, format, strict) { - var i, mom, regex; - - if (this._weekdaysParseExact) { - return day_of_week__handleStrictParse.call(this, weekdayName, format, strict); - } - - if (!this._weekdaysParse) { - this._weekdaysParse = []; - this._minWeekdaysParse = []; - this._shortWeekdaysParse = []; - this._fullWeekdaysParse = []; - } - - for (i = 0; i < 7; i++) { - // make the regex if we don't have it already - - mom = create_utc__createUTC([2000, 1]).day(i); - if (strict && !this._fullWeekdaysParse[i]) { - this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i'); - this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i'); - this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i'); - } - if (!this._weekdaysParse[i]) { - regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, ''); - this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); - } - // test the regex - if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) { - return i; - } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) { - return i; - } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) { - return i; - } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { - return i; - } - } - } - - // MOMENTS - - function getSetDayOfWeek (input) { - if (!this.isValid()) { - return input != null ? this : NaN; - } - var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); - if (input != null) { - input = parseWeekday(input, this.localeData()); - return this.add(input - day, 'd'); - } else { - return day; - } - } - - function getSetLocaleDayOfWeek (input) { - if (!this.isValid()) { - return input != null ? this : NaN; - } - var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; - return input == null ? weekday : this.add(input - weekday, 'd'); - } - - function getSetISODayOfWeek (input) { - if (!this.isValid()) { - return input != null ? this : NaN; - } - // behaves the same as moment#day except - // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) - // as a setter, sunday should belong to the previous week. - return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7); - } - - var defaultWeekdaysRegex = matchWord; - function weekdaysRegex (isStrict) { - if (this._weekdaysParseExact) { - if (!hasOwnProp(this, '_weekdaysRegex')) { - computeWeekdaysParse.call(this); - } - if (isStrict) { - return this._weekdaysStrictRegex; - } else { - return this._weekdaysRegex; - } - } else { - return this._weekdaysStrictRegex && isStrict ? - this._weekdaysStrictRegex : this._weekdaysRegex; - } - } - - var defaultWeekdaysShortRegex = matchWord; - function weekdaysShortRegex (isStrict) { - if (this._weekdaysParseExact) { - if (!hasOwnProp(this, '_weekdaysRegex')) { - computeWeekdaysParse.call(this); - } - if (isStrict) { - return this._weekdaysShortStrictRegex; - } else { - return this._weekdaysShortRegex; - } - } else { - return this._weekdaysShortStrictRegex && isStrict ? - this._weekdaysShortStrictRegex : this._weekdaysShortRegex; - } - } - - var defaultWeekdaysMinRegex = matchWord; - function weekdaysMinRegex (isStrict) { - if (this._weekdaysParseExact) { - if (!hasOwnProp(this, '_weekdaysRegex')) { - computeWeekdaysParse.call(this); - } - if (isStrict) { - return this._weekdaysMinStrictRegex; - } else { - return this._weekdaysMinRegex; - } - } else { - return this._weekdaysMinStrictRegex && isStrict ? - this._weekdaysMinStrictRegex : this._weekdaysMinRegex; - } - } - - - function computeWeekdaysParse () { - function cmpLenRev(a, b) { - return b.length - a.length; - } - - var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [], - i, mom, minp, shortp, longp; - for (i = 0; i < 7; i++) { - // make the regex if we don't have it already - mom = create_utc__createUTC([2000, 1]).day(i); - minp = this.weekdaysMin(mom, ''); - shortp = this.weekdaysShort(mom, ''); - longp = this.weekdays(mom, ''); - minPieces.push(minp); - shortPieces.push(shortp); - longPieces.push(longp); - mixedPieces.push(minp); - mixedPieces.push(shortp); - mixedPieces.push(longp); - } - // Sorting makes sure if one weekday (or abbr) is a prefix of another it - // will match the longer piece. - minPieces.sort(cmpLenRev); - shortPieces.sort(cmpLenRev); - longPieces.sort(cmpLenRev); - mixedPieces.sort(cmpLenRev); - for (i = 0; i < 7; i++) { - shortPieces[i] = regexEscape(shortPieces[i]); - longPieces[i] = regexEscape(longPieces[i]); - mixedPieces[i] = regexEscape(mixedPieces[i]); - } - - this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); - this._weekdaysShortRegex = this._weekdaysRegex; - this._weekdaysMinRegex = this._weekdaysRegex; - - this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i'); - this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i'); - this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i'); - } - - // FORMATTING - - addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); - - // ALIASES - - addUnitAlias('dayOfYear', 'DDD'); - - // PARSING - - addRegexToken('DDD', match1to3); - addRegexToken('DDDD', match3); - addParseToken(['DDD', 'DDDD'], function (input, array, config) { - config._dayOfYear = toInt(input); - }); - - // HELPERS - - // MOMENTS - - function getSetDayOfYear (input) { - var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1; - return input == null ? dayOfYear : this.add((input - dayOfYear), 'd'); - } - - // FORMATTING - - function hFormat() { - return this.hours() % 12 || 12; - } - - function kFormat() { - return this.hours() || 24; - } - - addFormatToken('H', ['HH', 2], 0, 'hour'); - addFormatToken('h', ['hh', 2], 0, hFormat); - addFormatToken('k', ['kk', 2], 0, kFormat); - - addFormatToken('hmm', 0, 0, function () { - return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); - }); - - addFormatToken('hmmss', 0, 0, function () { - return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) + - zeroFill(this.seconds(), 2); - }); - - addFormatToken('Hmm', 0, 0, function () { - return '' + this.hours() + zeroFill(this.minutes(), 2); - }); - - addFormatToken('Hmmss', 0, 0, function () { - return '' + this.hours() + zeroFill(this.minutes(), 2) + - zeroFill(this.seconds(), 2); - }); - - function meridiem (token, lowercase) { - addFormatToken(token, 0, 0, function () { - return this.localeData().meridiem(this.hours(), this.minutes(), lowercase); - }); - } - - meridiem('a', true); - meridiem('A', false); - - // ALIASES - - addUnitAlias('hour', 'h'); - - // PARSING - - function matchMeridiem (isStrict, locale) { - return locale._meridiemParse; - } - - addRegexToken('a', matchMeridiem); - addRegexToken('A', matchMeridiem); - addRegexToken('H', match1to2); - addRegexToken('h', match1to2); - addRegexToken('HH', match1to2, match2); - addRegexToken('hh', match1to2, match2); - - addRegexToken('hmm', match3to4); - addRegexToken('hmmss', match5to6); - addRegexToken('Hmm', match3to4); - addRegexToken('Hmmss', match5to6); - - addParseToken(['H', 'HH'], HOUR); - addParseToken(['a', 'A'], function (input, array, config) { - config._isPm = config._locale.isPM(input); - config._meridiem = input; - }); - addParseToken(['h', 'hh'], function (input, array, config) { - array[HOUR] = toInt(input); - getParsingFlags(config).bigHour = true; - }); - addParseToken('hmm', function (input, array, config) { - var pos = input.length - 2; - array[HOUR] = toInt(input.substr(0, pos)); - array[MINUTE] = toInt(input.substr(pos)); - getParsingFlags(config).bigHour = true; - }); - addParseToken('hmmss', function (input, array, config) { - var pos1 = input.length - 4; - var pos2 = input.length - 2; - array[HOUR] = toInt(input.substr(0, pos1)); - array[MINUTE] = toInt(input.substr(pos1, 2)); - array[SECOND] = toInt(input.substr(pos2)); - getParsingFlags(config).bigHour = true; - }); - addParseToken('Hmm', function (input, array, config) { - var pos = input.length - 2; - array[HOUR] = toInt(input.substr(0, pos)); - array[MINUTE] = toInt(input.substr(pos)); - }); - addParseToken('Hmmss', function (input, array, config) { - var pos1 = input.length - 4; - var pos2 = input.length - 2; - array[HOUR] = toInt(input.substr(0, pos1)); - array[MINUTE] = toInt(input.substr(pos1, 2)); - array[SECOND] = toInt(input.substr(pos2)); - }); - - // LOCALES - - function localeIsPM (input) { - // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays - // Using charAt should be more compatible. - return ((input + '').toLowerCase().charAt(0) === 'p'); - } - - var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i; - function localeMeridiem (hours, minutes, isLower) { - if (hours > 11) { - return isLower ? 'pm' : 'PM'; - } else { - return isLower ? 'am' : 'AM'; - } - } - - - // MOMENTS - - // Setting the hour should keep the time, because the user explicitly - // specified which hour he wants. So trying to maintain the same hour (in - // a new timezone) makes sense. Adding/subtracting hours does not follow - // this rule. - var getSetHour = makeGetSet('Hours', true); - - // FORMATTING - - addFormatToken('m', ['mm', 2], 0, 'minute'); - - // ALIASES - - addUnitAlias('minute', 'm'); - - // PARSING - - addRegexToken('m', match1to2); - addRegexToken('mm', match1to2, match2); - addParseToken(['m', 'mm'], MINUTE); - - // MOMENTS - - var getSetMinute = makeGetSet('Minutes', false); - - // FORMATTING - - addFormatToken('s', ['ss', 2], 0, 'second'); - - // ALIASES - - addUnitAlias('second', 's'); - - // PARSING - - addRegexToken('s', match1to2); - addRegexToken('ss', match1to2, match2); - addParseToken(['s', 'ss'], SECOND); - - // MOMENTS - - var getSetSecond = makeGetSet('Seconds', false); - - // FORMATTING - - addFormatToken('S', 0, 0, function () { - return ~~(this.millisecond() / 100); - }); - - addFormatToken(0, ['SS', 2], 0, function () { - return ~~(this.millisecond() / 10); - }); - - addFormatToken(0, ['SSS', 3], 0, 'millisecond'); - addFormatToken(0, ['SSSS', 4], 0, function () { - return this.millisecond() * 10; - }); - addFormatToken(0, ['SSSSS', 5], 0, function () { - return this.millisecond() * 100; - }); - addFormatToken(0, ['SSSSSS', 6], 0, function () { - return this.millisecond() * 1000; - }); - addFormatToken(0, ['SSSSSSS', 7], 0, function () { - return this.millisecond() * 10000; - }); - addFormatToken(0, ['SSSSSSSS', 8], 0, function () { - return this.millisecond() * 100000; - }); - addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { - return this.millisecond() * 1000000; - }); - - - // ALIASES - - addUnitAlias('millisecond', 'ms'); - - // PARSING - - addRegexToken('S', match1to3, match1); - addRegexToken('SS', match1to3, match2); - addRegexToken('SSS', match1to3, match3); - - var token; - for (token = 'SSSS'; token.length <= 9; token += 'S') { - addRegexToken(token, matchUnsigned); - } - - function parseMs(input, array) { - array[MILLISECOND] = toInt(('0.' + input) * 1000); - } - - for (token = 'S'; token.length <= 9; token += 'S') { - addParseToken(token, parseMs); - } - // MOMENTS - - var getSetMillisecond = makeGetSet('Milliseconds', false); - - // FORMATTING - - addFormatToken('z', 0, 0, 'zoneAbbr'); - addFormatToken('zz', 0, 0, 'zoneName'); - - // MOMENTS - - function getZoneAbbr () { - return this._isUTC ? 'UTC' : ''; - } - - function getZoneName () { - return this._isUTC ? 'Coordinated Universal Time' : ''; - } - - var momentPrototype__proto = Moment.prototype; - - momentPrototype__proto.add = add_subtract__add; - momentPrototype__proto.calendar = moment_calendar__calendar; - momentPrototype__proto.clone = clone; - momentPrototype__proto.diff = diff; - momentPrototype__proto.endOf = endOf; - momentPrototype__proto.format = format; - momentPrototype__proto.from = from; - momentPrototype__proto.fromNow = fromNow; - momentPrototype__proto.to = to; - momentPrototype__proto.toNow = toNow; - momentPrototype__proto.get = getSet; - momentPrototype__proto.invalidAt = invalidAt; - momentPrototype__proto.isAfter = isAfter; - momentPrototype__proto.isBefore = isBefore; - momentPrototype__proto.isBetween = isBetween; - momentPrototype__proto.isSame = isSame; - momentPrototype__proto.isSameOrAfter = isSameOrAfter; - momentPrototype__proto.isSameOrBefore = isSameOrBefore; - momentPrototype__proto.isValid = moment_valid__isValid; - momentPrototype__proto.lang = lang; - momentPrototype__proto.locale = locale; - momentPrototype__proto.localeData = localeData; - momentPrototype__proto.max = prototypeMax; - momentPrototype__proto.min = prototypeMin; - momentPrototype__proto.parsingFlags = parsingFlags; - momentPrototype__proto.set = getSet; - momentPrototype__proto.startOf = startOf; - momentPrototype__proto.subtract = add_subtract__subtract; - momentPrototype__proto.toArray = toArray; - momentPrototype__proto.toObject = toObject; - momentPrototype__proto.toDate = toDate; - momentPrototype__proto.toISOString = moment_format__toISOString; - momentPrototype__proto.toJSON = toJSON; - momentPrototype__proto.toString = toString; - momentPrototype__proto.unix = unix; - momentPrototype__proto.valueOf = to_type__valueOf; - momentPrototype__proto.creationData = creationData; - - // Year - momentPrototype__proto.year = getSetYear; - momentPrototype__proto.isLeapYear = getIsLeapYear; - - // Week Year - momentPrototype__proto.weekYear = getSetWeekYear; - momentPrototype__proto.isoWeekYear = getSetISOWeekYear; - - // Quarter - momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter; - - // Month - momentPrototype__proto.month = getSetMonth; - momentPrototype__proto.daysInMonth = getDaysInMonth; - - // Week - momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek; - momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek; - momentPrototype__proto.weeksInYear = getWeeksInYear; - momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear; - - // Day - momentPrototype__proto.date = getSetDayOfMonth; - momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek; - momentPrototype__proto.weekday = getSetLocaleDayOfWeek; - momentPrototype__proto.isoWeekday = getSetISODayOfWeek; - momentPrototype__proto.dayOfYear = getSetDayOfYear; - - // Hour - momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour; - - // Minute - momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute; - - // Second - momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond; - - // Millisecond - momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond; - - // Offset - momentPrototype__proto.utcOffset = getSetOffset; - momentPrototype__proto.utc = setOffsetToUTC; - momentPrototype__proto.local = setOffsetToLocal; - momentPrototype__proto.parseZone = setOffsetToParsedOffset; - momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset; - momentPrototype__proto.isDST = isDaylightSavingTime; - momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted; - momentPrototype__proto.isLocal = isLocal; - momentPrototype__proto.isUtcOffset = isUtcOffset; - momentPrototype__proto.isUtc = isUtc; - momentPrototype__proto.isUTC = isUtc; - - // Timezone - momentPrototype__proto.zoneAbbr = getZoneAbbr; - momentPrototype__proto.zoneName = getZoneName; - - // Deprecations - momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth); - momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth); - momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear); - momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone); - - var momentPrototype = momentPrototype__proto; - - function moment__createUnix (input) { - return local__createLocal(input * 1000); - } - - function moment__createInZone () { - return local__createLocal.apply(null, arguments).parseZone(); - } - - var defaultCalendar = { - sameDay : '[Today at] LT', - nextDay : '[Tomorrow at] LT', - nextWeek : 'dddd [at] LT', - lastDay : '[Yesterday at] LT', - lastWeek : '[Last] dddd [at] LT', - sameElse : 'L' - }; - - function locale_calendar__calendar (key, mom, now) { - var output = this._calendar[key]; - return isFunction(output) ? output.call(mom, now) : output; - } - - var defaultLongDateFormat = { - LTS : 'h:mm:ss A', - LT : 'h:mm A', - L : 'MM/DD/YYYY', - LL : 'MMMM D, YYYY', - LLL : 'MMMM D, YYYY h:mm A', - LLLL : 'dddd, MMMM D, YYYY h:mm A' - }; - - function longDateFormat (key) { - var format = this._longDateFormat[key], - formatUpper = this._longDateFormat[key.toUpperCase()]; - - if (format || !formatUpper) { - return format; - } - - this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) { - return val.slice(1); - }); - - return this._longDateFormat[key]; - } - - var defaultInvalidDate = 'Invalid date'; - - function invalidDate () { - return this._invalidDate; - } - - var defaultOrdinal = '%d'; - var defaultOrdinalParse = /\d{1,2}/; - - function ordinal (number) { - return this._ordinal.replace('%d', number); - } - - function preParsePostFormat (string) { - return string; - } - - var defaultRelativeTime = { - future : 'in %s', - past : '%s ago', - s : 'a few seconds', - m : 'a minute', - mm : '%d minutes', - h : 'an hour', - hh : '%d hours', - d : 'a day', - dd : '%d days', - M : 'a month', - MM : '%d months', - y : 'a year', - yy : '%d years' - }; - - function relative__relativeTime (number, withoutSuffix, string, isFuture) { - var output = this._relativeTime[string]; - return (isFunction(output)) ? - output(number, withoutSuffix, string, isFuture) : - output.replace(/%d/i, number); - } - - function pastFuture (diff, output) { - var format = this._relativeTime[diff > 0 ? 'future' : 'past']; - return isFunction(format) ? format(output) : format.replace(/%s/i, output); - } - - var prototype__proto = Locale.prototype; - - prototype__proto._calendar = defaultCalendar; - prototype__proto.calendar = locale_calendar__calendar; - prototype__proto._longDateFormat = defaultLongDateFormat; - prototype__proto.longDateFormat = longDateFormat; - prototype__proto._invalidDate = defaultInvalidDate; - prototype__proto.invalidDate = invalidDate; - prototype__proto._ordinal = defaultOrdinal; - prototype__proto.ordinal = ordinal; - prototype__proto._ordinalParse = defaultOrdinalParse; - prototype__proto.preparse = preParsePostFormat; - prototype__proto.postformat = preParsePostFormat; - prototype__proto._relativeTime = defaultRelativeTime; - prototype__proto.relativeTime = relative__relativeTime; - prototype__proto.pastFuture = pastFuture; - prototype__proto.set = locale_set__set; - - // Month - prototype__proto.months = localeMonths; - prototype__proto._months = defaultLocaleMonths; - prototype__proto.monthsShort = localeMonthsShort; - prototype__proto._monthsShort = defaultLocaleMonthsShort; - prototype__proto.monthsParse = localeMonthsParse; - prototype__proto._monthsRegex = defaultMonthsRegex; - prototype__proto.monthsRegex = monthsRegex; - prototype__proto._monthsShortRegex = defaultMonthsShortRegex; - prototype__proto.monthsShortRegex = monthsShortRegex; - - // Week - prototype__proto.week = localeWeek; - prototype__proto._week = defaultLocaleWeek; - prototype__proto.firstDayOfYear = localeFirstDayOfYear; - prototype__proto.firstDayOfWeek = localeFirstDayOfWeek; - - // Day of Week - prototype__proto.weekdays = localeWeekdays; - prototype__proto._weekdays = defaultLocaleWeekdays; - prototype__proto.weekdaysMin = localeWeekdaysMin; - prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin; - prototype__proto.weekdaysShort = localeWeekdaysShort; - prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort; - prototype__proto.weekdaysParse = localeWeekdaysParse; - - prototype__proto._weekdaysRegex = defaultWeekdaysRegex; - prototype__proto.weekdaysRegex = weekdaysRegex; - prototype__proto._weekdaysShortRegex = defaultWeekdaysShortRegex; - prototype__proto.weekdaysShortRegex = weekdaysShortRegex; - prototype__proto._weekdaysMinRegex = defaultWeekdaysMinRegex; - prototype__proto.weekdaysMinRegex = weekdaysMinRegex; - - // Hours - prototype__proto.isPM = localeIsPM; - prototype__proto._meridiemParse = defaultLocaleMeridiemParse; - prototype__proto.meridiem = localeMeridiem; - - function lists__get (format, index, field, setter) { - var locale = locale_locales__getLocale(); - var utc = create_utc__createUTC().set(setter, index); - return locale[field](utc, format); - } - - function listMonthsImpl (format, index, field) { - if (typeof format === 'number') { - index = format; - format = undefined; - } - - format = format || ''; - - if (index != null) { - return lists__get(format, index, field, 'month'); - } - - var i; - var out = []; - for (i = 0; i < 12; i++) { - out[i] = lists__get(format, i, field, 'month'); - } - return out; - } - - // () - // (5) - // (fmt, 5) - // (fmt) - // (true) - // (true, 5) - // (true, fmt, 5) - // (true, fmt) - function listWeekdaysImpl (localeSorted, format, index, field) { - if (typeof localeSorted === 'boolean') { - if (typeof format === 'number') { - index = format; - format = undefined; - } - - format = format || ''; - } else { - format = localeSorted; - index = format; - localeSorted = false; - - if (typeof format === 'number') { - index = format; - format = undefined; - } - - format = format || ''; - } - - var locale = locale_locales__getLocale(), - shift = localeSorted ? locale._week.dow : 0; - - if (index != null) { - return lists__get(format, (index + shift) % 7, field, 'day'); - } - - var i; - var out = []; - for (i = 0; i < 7; i++) { - out[i] = lists__get(format, (i + shift) % 7, field, 'day'); - } - return out; - } - - function lists__listMonths (format, index) { - return listMonthsImpl(format, index, 'months'); - } - - function lists__listMonthsShort (format, index) { - return listMonthsImpl(format, index, 'monthsShort'); - } - - function lists__listWeekdays (localeSorted, format, index) { - return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); - } - - function lists__listWeekdaysShort (localeSorted, format, index) { - return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); - } - - function lists__listWeekdaysMin (localeSorted, format, index) { - return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); - } - - locale_locales__getSetGlobalLocale('en', { - ordinalParse: /\d{1,2}(th|st|nd|rd)/, - ordinal : function (number) { - var b = number % 10, - output = (toInt(number % 100 / 10) === 1) ? 'th' : - (b === 1) ? 'st' : - (b === 2) ? 'nd' : - (b === 3) ? 'rd' : 'th'; - return number + output; - } - }); - - // Side effect imports - utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale); - utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale); - - var mathAbs = Math.abs; - - function duration_abs__abs () { - var data = this._data; - - this._milliseconds = mathAbs(this._milliseconds); - this._days = mathAbs(this._days); - this._months = mathAbs(this._months); - - data.milliseconds = mathAbs(data.milliseconds); - data.seconds = mathAbs(data.seconds); - data.minutes = mathAbs(data.minutes); - data.hours = mathAbs(data.hours); - data.months = mathAbs(data.months); - data.years = mathAbs(data.years); - - return this; - } - - function duration_add_subtract__addSubtract (duration, input, value, direction) { - var other = create__createDuration(input, value); - - duration._milliseconds += direction * other._milliseconds; - duration._days += direction * other._days; - duration._months += direction * other._months; - - return duration._bubble(); - } - - // supports only 2.0-style add(1, 's') or add(duration) - function duration_add_subtract__add (input, value) { - return duration_add_subtract__addSubtract(this, input, value, 1); - } - - // supports only 2.0-style subtract(1, 's') or subtract(duration) - function duration_add_subtract__subtract (input, value) { - return duration_add_subtract__addSubtract(this, input, value, -1); - } - - function absCeil (number) { - if (number < 0) { - return Math.floor(number); - } else { - return Math.ceil(number); - } - } - - function bubble () { - var milliseconds = this._milliseconds; - var days = this._days; - var months = this._months; - var data = this._data; - var seconds, minutes, hours, years, monthsFromDays; - - // if we have a mix of positive and negative values, bubble down first - // check: https://github.com/moment/moment/issues/2166 - if (!((milliseconds >= 0 && days >= 0 && months >= 0) || - (milliseconds <= 0 && days <= 0 && months <= 0))) { - milliseconds += absCeil(monthsToDays(months) + days) * 864e5; - days = 0; - months = 0; - } - - // The following code bubbles up values, see the tests for - // examples of what that means. - data.milliseconds = milliseconds % 1000; - - seconds = absFloor(milliseconds / 1000); - data.seconds = seconds % 60; - - minutes = absFloor(seconds / 60); - data.minutes = minutes % 60; - - hours = absFloor(minutes / 60); - data.hours = hours % 24; - - days += absFloor(hours / 24); - - // convert days to months - monthsFromDays = absFloor(daysToMonths(days)); - months += monthsFromDays; - days -= absCeil(monthsToDays(monthsFromDays)); - - // 12 months -> 1 year - years = absFloor(months / 12); - months %= 12; - - data.days = days; - data.months = months; - data.years = years; - - return this; - } - - function daysToMonths (days) { - // 400 years have 146097 days (taking into account leap year rules) - // 400 years have 12 months === 4800 - return days * 4800 / 146097; - } - - function monthsToDays (months) { - // the reverse of daysToMonths - return months * 146097 / 4800; - } - - function as (units) { - var days; - var months; - var milliseconds = this._milliseconds; - - units = normalizeUnits(units); - - if (units === 'month' || units === 'year') { - days = this._days + milliseconds / 864e5; - months = this._months + daysToMonths(days); - return units === 'month' ? months : months / 12; - } else { - // handle milliseconds separately because of floating point math errors (issue #1867) - days = this._days + Math.round(monthsToDays(this._months)); - switch (units) { - case 'week' : return days / 7 + milliseconds / 6048e5; - case 'day' : return days + milliseconds / 864e5; - case 'hour' : return days * 24 + milliseconds / 36e5; - case 'minute' : return days * 1440 + milliseconds / 6e4; - case 'second' : return days * 86400 + milliseconds / 1000; - // Math.floor prevents floating point math errors here - case 'millisecond': return Math.floor(days * 864e5) + milliseconds; - default: throw new Error('Unknown unit ' + units); - } - } - } - - // TODO: Use this.as('ms')? - function duration_as__valueOf () { - return ( - this._milliseconds + - this._days * 864e5 + - (this._months % 12) * 2592e6 + - toInt(this._months / 12) * 31536e6 - ); - } - - function makeAs (alias) { - return function () { - return this.as(alias); - }; - } - - var asMilliseconds = makeAs('ms'); - var asSeconds = makeAs('s'); - var asMinutes = makeAs('m'); - var asHours = makeAs('h'); - var asDays = makeAs('d'); - var asWeeks = makeAs('w'); - var asMonths = makeAs('M'); - var asYears = makeAs('y'); - - function duration_get__get (units) { - units = normalizeUnits(units); - return this[units + 's'](); - } - - function makeGetter(name) { - return function () { - return this._data[name]; - }; - } - - var milliseconds = makeGetter('milliseconds'); - var seconds = makeGetter('seconds'); - var minutes = makeGetter('minutes'); - var hours = makeGetter('hours'); - var days = makeGetter('days'); - var months = makeGetter('months'); - var years = makeGetter('years'); - - function weeks () { - return absFloor(this.days() / 7); - } - - var round = Math.round; - var thresholds = { - s: 45, // seconds to minute - m: 45, // minutes to hour - h: 22, // hours to day - d: 26, // days to month - M: 11 // months to year - }; - - // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize - function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { - return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); - } - - function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) { - var duration = create__createDuration(posNegDuration).abs(); - var seconds = round(duration.as('s')); - var minutes = round(duration.as('m')); - var hours = round(duration.as('h')); - var days = round(duration.as('d')); - var months = round(duration.as('M')); - var years = round(duration.as('y')); - - var a = seconds < thresholds.s && ['s', seconds] || - minutes <= 1 && ['m'] || - minutes < thresholds.m && ['mm', minutes] || - hours <= 1 && ['h'] || - hours < thresholds.h && ['hh', hours] || - days <= 1 && ['d'] || - days < thresholds.d && ['dd', days] || - months <= 1 && ['M'] || - months < thresholds.M && ['MM', months] || - years <= 1 && ['y'] || ['yy', years]; - - a[2] = withoutSuffix; - a[3] = +posNegDuration > 0; - a[4] = locale; - return substituteTimeAgo.apply(null, a); - } - - // This function allows you to set a threshold for relative time strings - function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) { - if (thresholds[threshold] === undefined) { - return false; - } - if (limit === undefined) { - return thresholds[threshold]; - } - thresholds[threshold] = limit; - return true; - } - - function humanize (withSuffix) { - var locale = this.localeData(); - var output = duration_humanize__relativeTime(this, !withSuffix, locale); - - if (withSuffix) { - output = locale.pastFuture(+this, output); - } - - return locale.postformat(output); - } - - var iso_string__abs = Math.abs; - - function iso_string__toISOString() { - // for ISO strings we do not use the normal bubbling rules: - // * milliseconds bubble up until they become hours - // * days do not bubble at all - // * months bubble up until they become years - // This is because there is no context-free conversion between hours and days - // (think of clock changes) - // and also not between days and months (28-31 days per month) - var seconds = iso_string__abs(this._milliseconds) / 1000; - var days = iso_string__abs(this._days); - var months = iso_string__abs(this._months); - var minutes, hours, years; - - // 3600 seconds -> 60 minutes -> 1 hour - minutes = absFloor(seconds / 60); - hours = absFloor(minutes / 60); - seconds %= 60; - minutes %= 60; - - // 12 months -> 1 year - years = absFloor(months / 12); - months %= 12; - - - // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js - var Y = years; - var M = months; - var D = days; - var h = hours; - var m = minutes; - var s = seconds; - var total = this.asSeconds(); - - if (!total) { - // this is the same as C#'s (Noda) and python (isodate)... - // but not other JS (goog.date) - return 'P0D'; - } - - return (total < 0 ? '-' : '') + - 'P' + - (Y ? Y + 'Y' : '') + - (M ? M + 'M' : '') + - (D ? D + 'D' : '') + - ((h || m || s) ? 'T' : '') + - (h ? h + 'H' : '') + - (m ? m + 'M' : '') + - (s ? s + 'S' : ''); - } - - var duration_prototype__proto = Duration.prototype; - - duration_prototype__proto.abs = duration_abs__abs; - duration_prototype__proto.add = duration_add_subtract__add; - duration_prototype__proto.subtract = duration_add_subtract__subtract; - duration_prototype__proto.as = as; - duration_prototype__proto.asMilliseconds = asMilliseconds; - duration_prototype__proto.asSeconds = asSeconds; - duration_prototype__proto.asMinutes = asMinutes; - duration_prototype__proto.asHours = asHours; - duration_prototype__proto.asDays = asDays; - duration_prototype__proto.asWeeks = asWeeks; - duration_prototype__proto.asMonths = asMonths; - duration_prototype__proto.asYears = asYears; - duration_prototype__proto.valueOf = duration_as__valueOf; - duration_prototype__proto._bubble = bubble; - duration_prototype__proto.get = duration_get__get; - duration_prototype__proto.milliseconds = milliseconds; - duration_prototype__proto.seconds = seconds; - duration_prototype__proto.minutes = minutes; - duration_prototype__proto.hours = hours; - duration_prototype__proto.days = days; - duration_prototype__proto.weeks = weeks; - duration_prototype__proto.months = months; - duration_prototype__proto.years = years; - duration_prototype__proto.humanize = humanize; - duration_prototype__proto.toISOString = iso_string__toISOString; - duration_prototype__proto.toString = iso_string__toISOString; - duration_prototype__proto.toJSON = iso_string__toISOString; - duration_prototype__proto.locale = locale; - duration_prototype__proto.localeData = localeData; - - // Deprecations - duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString); - duration_prototype__proto.lang = lang; - - // Side effect imports - - // FORMATTING - - addFormatToken('X', 0, 0, 'unix'); - addFormatToken('x', 0, 0, 'valueOf'); - - // PARSING - - addRegexToken('x', matchSigned); - addRegexToken('X', matchTimestamp); - addParseToken('X', function (input, array, config) { - config._d = new Date(parseFloat(input, 10) * 1000); - }); - addParseToken('x', function (input, array, config) { - config._d = new Date(toInt(input)); - }); - - // Side effect imports - - - utils_hooks__hooks.version = '2.13.0'; - - setHookCallback(local__createLocal); - - utils_hooks__hooks.fn = momentPrototype; - utils_hooks__hooks.min = min; - utils_hooks__hooks.max = max; - utils_hooks__hooks.now = now; - utils_hooks__hooks.utc = create_utc__createUTC; - utils_hooks__hooks.unix = moment__createUnix; - utils_hooks__hooks.months = lists__listMonths; - utils_hooks__hooks.isDate = isDate; - utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale; - utils_hooks__hooks.invalid = valid__createInvalid; - utils_hooks__hooks.duration = create__createDuration; - utils_hooks__hooks.isMoment = isMoment; - utils_hooks__hooks.weekdays = lists__listWeekdays; - utils_hooks__hooks.parseZone = moment__createInZone; - utils_hooks__hooks.localeData = locale_locales__getLocale; - utils_hooks__hooks.isDuration = isDuration; - utils_hooks__hooks.monthsShort = lists__listMonthsShort; - utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin; - utils_hooks__hooks.defineLocale = defineLocale; - utils_hooks__hooks.updateLocale = updateLocale; - utils_hooks__hooks.locales = locale_locales__listLocales; - utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort; - utils_hooks__hooks.normalizeUnits = normalizeUnits; - utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold; - utils_hooks__hooks.prototype = momentPrototype; - - var _moment = utils_hooks__hooks; - - return _moment; - -})); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.hbs deleted file mode 100644 index d2cfa74b71..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.hbs +++ /dev/null @@ -1,114 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} - -{{#if control_operations}} -
    - - {{#each control_operations}} - - - {{name}} - - -
    -
    -
    -
    -

    - - - - - {{name}} -
    -

    -

    - {{description}} -
    -

    - -
    - -
    - - -
    - - - - -
    -
    -
    -
    -
    - {{/each}} -
    -{{else}} -
    -

    - Operations Loading Failed!

    -
    -{{/if}} - - - -{{#zone "bottomJs"}} - {{js "js/operation-bar.js"}} -{{/zone}} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.js deleted file mode 100644 index 1f9ef9fc07..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var log = new Log("operation.js"); - var deviceType = context.uriParams.deviceType; - var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"]; - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var restAPIEndpoint = devicemgtProps["backendRestEndpoints"]["deviceMgt"] - + "/devices/" + deviceType + "/operations"; - var device = context.unit.params.device; - var features = context.unit.params.features; - return {"control_operations": features, "device": device, "operationEndpoint": restAPIEndpoint}; -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.json deleted file mode 100644 index 688e939808..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/operation-bar.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/public/js/operation-bar.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/public/js/operation-bar.js deleted file mode 100644 index 4b12f40b4b..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.operation-bar/public/js/operation-bar.js +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * On operation click function. - * @param selection: Selected operation - */ -function operationSelect(selection) { - $(modalPopupContent).addClass("operation-data"); - $(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html()); - $(modalPopupContent).data("operation-code", selection); - showPopup(); -} - -function submitForm(formId) { - var form = $("#" + formId); - var operationDetails = $("#operation-details"); - var deviceId = operationDetails.data("deviceid"); - var operationEndpoint = operationDetails.data("endpoint"); - var contentType = "application/json"; - - var payload = {}; - var devices=[]; - devices.push(deviceId); - payload["deviceIdentifiers"] = devices; - var operation = {}; - operation["code"] = form.find("#operation-code").val(); - operation["type"]= form.find("#operation-type").val(); - operation["status"] = "PENDING"; - operation["control"] = "REPEAT"; - operation["payLoad"] = form.find("#operation-payload").val(); - operation["enabled"] = true; - payload["operation"] = operation; - - //setting responses callbacks - var defaultStatusClasses = "fw fw-stack-1x"; - var content = $("#operation-response-template").find(".content"); - var title = content.find("#title"); - title.attr("class","center-block text-center"); - var statusIcon = content.find("#status-icon"); - var description = content.find("#description"); - var successCallBack = function (response) { - var res = response; - try { - res = JSON.parse(response).messageFromServer; - } catch (err) { - //do nothing - } - title.html("Operation Triggered!"); - statusIcon.attr("class", defaultStatusClasses + " fw-check"); - description.html(res); - $(modalPopupContent).html(content.html()); - }; - var errorCallBack = function (response) { - console.log(response); - title.html("An Error Occurred!"); - statusIcon.attr("class", defaultStatusClasses + " fw-error"); - var reason = (response.responseText == "null")?response.statusText:response.responseText; - description.html(reason); - $(modalPopupContent).html(content.html()); - }; - invokerUtil.post(operationEndpoint, payload, successCallBack, errorCallBack, contentType); -} - -$(document).on('submit', 'form', function (e) { - e.preventDefault(); - var postOperationRequest = $.ajax({ - url: $(this).attr("action") + '&' + $(this).serialize(), - method: "post" - }); - - var btnSubmit = $('#btnSend', this); - btnSubmit.addClass('hidden'); - - var lblSending = $('#lblSending', this); - lblSending.removeClass('hidden'); - - var lblSent = $('#lblSent', this); - postOperationRequest.done(function (data) { - lblSending.addClass('hidden'); - lblSent.removeClass('hidden'); - setTimeout(function () { - hidePopup(); - }, 3000); - }); - - postOperationRequest.fail(function (jqXHR, textStatus) { - lblSending.addClass('hidden'); - lblSent.addClass('hidden'); - }); -}); - -function operationTypeChage(selectElement) { - if (selectElement.value == "COMMAND") { - $("#operation-payload").hide(); - } else { - $("#operation-payload").show(); - } -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.hbs deleted file mode 100644 index e122c8539f..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.hbs +++ /dev/null @@ -1,27 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} - - - {{#each device.initialDeviceInfo}} - - - - - {{/each}} - -
    {{@key}}{{this}}
    diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.js deleted file mode 100644 index 4638be4277..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest (context) { - var log = new Log("overview-section.js"); - var device = context.unit.params.device; - return {"device" : device}; -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.json deleted file mode 100644 index 688e939808..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.overview-section/overview-section.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.hbs deleted file mode 100644 index 456b895631..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.hbs +++ /dev/null @@ -1,47 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} - -{{unit "cdmf.unit.data-tables-extended"}} - - -
    -{{#if attributes}} - - - - - {{#each attributes}} - - {{/each}} - - - - -
    Timestamp{{this}}
    -{{else}} -

    Analytics Not Configured

    -{{/if}} -
    - -{{#zone "bottomJs"}} - {{js "js/device.js"}} -{{/zone}} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.js deleted file mode 100644 index 6a16f8eb5d..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - - var deviceType = context.uriParams.deviceType; - var deviceId = request.getParameter("deviceId"); - var keys = []; - var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - - if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var device = deviceModule.viewDevice(deviceType, deviceId); - - var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] - + "/events/" + deviceType; - serviceInvokers.XMLHttp.get( - restAPIEndpoint, - function (restAPIResponse) { - if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) { - var data = parse(restAPIResponse["responseText"]); - if (data.eventAttributes.attributes.length > 0) { - for (var i = 0; i < data.eventAttributes.attributes.length; i++) { - var attribute = data.eventAttributes.attributes[i]; - if (attribute['name'] == "deviceId") { - continue; - } - keys.push(attribute['name']); - } - } - - } - } - ); - - if (device && device.status != "error") { - if (keys.length === 0 || keys.length === undefined) { - return { - "device": device.content, - "backendApiUri": "/api/device-mgt/v1.0/events/" + deviceType - }; - } else { - - return { - "device": device.content, - "backendApiUri": "/api/device-mgt/v1.0/events/" + deviceType, - "attributes": keys - }; - } - } else { - response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); - exit(); - } - } -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.json deleted file mode 100644 index 688e939808..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/analytics-view.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/public/js/device.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/public/js/device.js deleted file mode 100644 index e7a216dd3e..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.analytics-view/public/js/device.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var InitiateViewOption = null; -var deviceId = null; -var deviceType = null; -var fromTime = null; -var toTime = null; -var keys = null; - -function drawTable(from, to) { - var device = $("#device-details"); - deviceId = device.data("deviceid"); - deviceType = device.data("devicetype"); - keys = device.data("attributes").split(","); - fromTime = from * 1000; - toTime = to * 1000; - if ( $.fn.dataTable.isDataTable( '#stats-table' ) ) { - var table = $('#stats-table').DataTable(); - table.clear().draw(); - table.ajax.reload(); - } - else { - $("#stats-table").datatables_extended({ - serverSide: true, - processing: false, - searching: false, - ordering: false, - pageLength: 100, - order: [], - ajax: { - url: "/devicemgt/api/stats/paginate", - data: buildAjaxData - } - }); - } -} - -function buildAjaxData (){ - var settings = $("#stats-table").dataTable().fnSettings(); - - var obj = { - //default params - "draw" : settings.iDraw, - "start" : settings._iDisplayStart, - "length" : settings._iDisplayLength, - "columns" : "", - "order": "", - "deviceType" : deviceType, - "deviceId" : deviceId, - "from": fromTime, - "to" : toTime, - "attributes" : JSON.stringify(keys) - }; - - return obj; - - -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.hbs deleted file mode 100644 index a3f87bfb29..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.hbs +++ /dev/null @@ -1,204 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} -{{#zone "topCss"}} - -{{/zone}} - -{{#zone "device-thumbnail"}} - -{{/zone}} - -{{#zone "device-details"}} - {{unit "cdmf.unit.default.device.overview-section" device=device}} -{{/zone}} - -{{#zone "device-opetations"}} - {{#if features}} -
    -
    -

    Device Operations

    -
    - {{unit "cdmf.unit.default.device.operation-bar" device=device features=features}} -
    - {{/if}} -{{/zone}} - -{{#zone "device-view-tabs"}} - {{#if attributes}} -
  • Device - Statistics -
  • - {{/if}} - {{#if features}} -
  • Operations Log
  • - {{/if}} -{{/zone}} - -{{#zone "device-view-tab-contents"}} - {{#if attributes}} -
    -
    Device Event
    - {{unit "cdmf.unit.default.device.type.realtime.analytics-view" device=device attributes=attributes}} -
    - {{/if}} - {{#if features}} -
    -
    Operations Log
    -
    - -
    -
    - - - - - - - - - - - - -
    NamePositionOffice
    -
    -
    -
    -
    -
    - {{/if}} -
    -

    Device Communication

    -
    - {{#if event}} -

    publish device events :

    - {{#if_eq event.transport "MQTT"}} -
    - MQTT Topic : - {{tenantDomain}}/{{device.type}}/<device_id>/events -
    - {{#if eventSample}} -
    - Device Event Payload : - {{eventSample}} -
    - {{/if}} - {{/if_eq}} - {{#if_eq event.transport "HTTP"}} -
    - curl -k -X POST {{httpsGateway}}/api/device-mgt/v1.0/device/agent/events/publish/{{device.type}}/{{device.deviceIdentifier}} - -H 'authorization: Bearer %accessToken%' - -H 'content-type: application/json' - -d '{{eventSample}}' - -
    - {{/if_eq}} - {{/if}} -
    -

    Retrieve operations

    - {{#if type.deviceTypeMetaDefinition.pushNotificationConfig}} - {{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}} -
    - MQTT Topic : - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/# -
    -
    - Topic Structure : -
      -
    • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/command/<feature_code>/<operation_id> -
    • -
    • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/config/<feature_code>/<operation_id> -
    • -
    • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/profile/<feature_code>/<operation_id> -
    • -
    • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_bundle -
    • -
    • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_revoke -
    • -
    -
    -
    -
    - Operation Response : - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/update/operation -
    -
    - Payload : - {"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"} -
    -
    - - {{/if_eq}} - {{else}} -
    - Retrieve pending operation : - curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/pending/operations/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -
    -
    - Retrieve next pending operation : - curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/next-pending/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -
    -
    - Update operation : - curl -k -X PUT {{httpsGateway}}/api/device-mgt/v1.0/device/agent/operations/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' -d '{"id": 1,"status": "COMPLETED", "payload": "this is my response"}' -
    - - {{/if}} - -
    -
    -
    -{{/zone}} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.js deleted file mode 100644 index 445106e6d0..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.js +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; -var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; -var process = require("process"); -var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; -function onRequest(context) { - var log = new Log("device-view.js"); - var deviceType = context.uriParams.deviceType; - var deviceId = request.getParameter("id"); - var attributes = []; - var featureList = []; - var user = userModule.getCarbonUser(); - var tenantDomain = user.domain; - - var autoCompleteParams = [ - {"name" : "deviceId", "value" : deviceId} - ]; - context.handlebars.registerHelper('if_eq', function(a, b, opts) { - if(a == b) // Or === depending on your needs - return opts.fn(this); - else - return opts.inverse(this); - }); - - var displayData = {}; - - var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] - + "/device-types/config/" + deviceType; - displayData.deviceType = deviceType; - displayData.tenantDomain = tenantDomain; - serviceInvokers.XMLHttp.get( - restAPIEndpoint, - function (restAPIResponse) { - if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) { - var typeData = parse(restAPIResponse["responseText"]); - displayData.type = typeData; - if (typeData.deviceTypeMetaDefinition) { - var features = typeData.deviceTypeMetaDefinition.features; - if (features) { - var feature; - for (var i = 0; i < features.length; i++) { - feature = {}; - feature["operation"] = features[i].code; - feature["name"] = features[i].name; - feature["description"] = features[i].description; - featureList.push(feature); - } - } - } - } - } - ); - - var eventRestAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] - + "/events/" + deviceType; - serviceInvokers.XMLHttp.get( - eventRestAPIEndpoint, - function (restAPIResponse) { - if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) { - var typeData = parse(restAPIResponse["responseText"]); - displayData.event = typeData; - var sampleValue = ""; - if (typeData.eventAttributes && typeData.eventAttributes.attributes) { - var eventExample = {}; - for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) { - var attribute = typeData.eventAttributes.attributes[i]; - if (attribute['name'] == "deviceId") { - continue; - } - attributes.push(attribute['name']); - - switch (attribute.type) { - case "STRING": - eventExample[attribute.name] = "string"; - sampleValue = sampleValue + "\"string\", "; - break; - case "LONG": - eventExample[attribute.name] = 0; - sampleValue = sampleValue + 0 +", "; - break; - case "INT": - eventExample[attribute.name] = 0; - sampleValue = sampleValue + 0 +", "; - break; - case "FLOAT": - eventExample[attribute.name] = 0.0; - sampleValue = sampleValue + 0.0 +", "; - break; - case "DOUBLE": - eventExample[attribute.name] = 0.0; - sampleValue = sampleValue + 0.0 +", "; - break; - case "BOOL": - eventExample[attribute.name] = false; - sampleValue = sampleValue + false + ", "; - break; - - } - - } - var sample = eventExample; - if (sampleValue && sampleValue.length > 2) { - displayData.sampleValue = sampleValue.substring(0, sampleValue.length - 2); - } - displayData.eventSample = JSON.stringify(sample); - displayData.mqttGateway = "tcp://" + process.getProperty("mqtt.broker.host") + ":" + process.getProperty("mqtt.broker.port"); - displayData.httpsGateway = "https://" + process.getProperty("iot.gateway.host") + ":" + process.getProperty("iot.gateway.https.port"); - - } - } - } - ); - - displayData.tenantDomain = tenantDomain; - - if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var device = deviceModule.viewDevice(deviceType, deviceId); - if (device && device.status != "error") { - displayData.device = device.content; - displayData.autoCompleteParams = autoCompleteParams; - displayData.encodedFeaturePayloads = ""; - displayData.features = featureList; - if (attributes.length === 0 || attributes.length === undefined) { - return displayData; - } else { - displayData.attributes = attributes; - return displayData; - } - } else { - response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!"); - exit(); - } - } -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.json deleted file mode 100644 index 9eecd8f5bf..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/device-view.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/public/images/deviceType.png b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/public/images/deviceType.png deleted file mode 100644 index 71e5c0c28b..0000000000 Binary files a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.device-view/public/images/deviceType.png and /dev/null differ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.hbs b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.hbs deleted file mode 100644 index 6911c698fc..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.hbs +++ /dev/null @@ -1,45 +0,0 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} -{{unit "cdmf.unit.lib.rickshaw-graph"}} - -
    - {{#if timestamp}}Last Known:{{timestamp}}{{/if}} - - - {{#each events}} - - - - - {{/each}} - -
    {{this.key}}{{this.value}}
    -
    - - - - - View Device Analytics - - -{{#zone "bottomJs"}} - {{js "js/moment.min.js"}} - {{js "js/socket.io.min.js"}} - {{js "js/device-stats.js"}} -{{/zone}} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.js deleted file mode 100644 index cfefa850e0..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; -var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - -function onRequest(context) { - var log = new Log("stats.js"); - var carbonServer = require("carbon").server; - var device = context.unit.params.device; - var attributes = context.unit.params.attributes; - var events = []; - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var constants = require("/app/modules/constants.js"); - var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss"); - var jwtService = carbonServer.osgiService( - 'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); - var jwtClient = jwtService.getJWTClient(); - var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]); - var token = ""; - var user = userModule.getCarbonUser(); - var tenantDomain = user.domain; - if (encodedClientKeys) { - var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"]; - var resp = tokenUtil.decode(encodedClientKeys).split(":"); - if (tenantDomain == "carbon.super") { - var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", {}); - if (tokenPair) { - token = tokenPair.accessToken; - } - websocketEndpoint = websocketEndpoint + "/secured-websocket/iot.per.device.stream." + tenantDomain + "." + device.type + "/1.0.0?" - + "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type + "&websocketToken=" + token; - } else { - var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username + "@" + tenantDomain,"default", {}); - if (tokenPair) { - token = tokenPair.accessToken; - } - websocketEndpoint = websocketEndpoint + "/secured-websocket" + "/t/" + tenantDomain + "/iot.per.device.stream." + tenantDomain - + "." + device.type + "/1.0.0?" + "deviceId=" + device.deviceIdentifier + "&deviceType=" - + device.type + "&websocketToken=" + token; - } - - } - var events = []; - var viewModel = {}; - viewModel.device = device; - viewModel.websocketEndpoint = websocketEndpoint; - - var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] - + "/events/last-known/" + device.type + "/" + device.deviceIdentifier; - serviceInvokers.XMLHttp.get( - restAPIEndpoint, - function (restAPIResponse) { - if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) { - var responsePayload = parse(restAPIResponse["responseText"]); - var records = responsePayload["records"]; - if (records && records[0] && records[0].values) { - var record = records[0].values; - viewModel.timestamp = new Date(records[0].timestamp); - for (var eventAttribute in attributes){ - var event = {}; - event.key = attributes[eventAttribute]; - event.value = record["" + attributes[eventAttribute]]; - events.push(event); - } - } else { - for (var eventAttribute in attributes){ - var event = {}; - event.key = attributes[eventAttribute]; - event.value = "-"; - events.push(event); - } - } - - } - } - ); - viewModel.attributes = attributes; - viewModel.events = events; - return viewModel; -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.json deleted file mode 100644 index 688e939808..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/analytics-view.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/device-stats.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/device-stats.js deleted file mode 100644 index 48bc419600..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/device-stats.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -var ws; -var attributes = null; -$(window).load(function () { - var div = $("#div-chart"); - var websocketUrl = div.data("websocketurl"); - attributes = div.data("attributes").split(","); - connect(websocketUrl) -}); - -$(window).unload(function () { - disconnect(); -}); - -//websocket connection -function connect(target) { - if ('WebSocket' in window) { - ws = new WebSocket(target); - } else if ('MozWebSocket' in window) { - ws = new MozWebSocket(target); - } else { - console.log('WebSocket is not supported by this browser.'); - } - if (ws) { - ws.onmessage = function (webSocketData) { - var data = JSON.parse(webSocketData.data); - console.log(data); - var payloadData = data["event"]["payloadData"]; - for (var i = 0; i < attributes.length; i++){ - $("#" + attributes[i] +"-value").text(payloadData[attributes[i]]); - } - $("#time-mode").text("Real Time Mode"); - }; - } -} - -function disconnect() { - if (ws != null) { - ws.close(); - ws = null; - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/moment.min.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/moment.min.js deleted file mode 100644 index d0b48f73e9..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/moment.min.js +++ /dev/null @@ -1,7 +0,0 @@ -//! moment.js -//! version : 2.10.2 -//! authors : Tim Wood, Iskren Chernev, Moment.js contributors -//! license : MIT -//! momentjs.com -!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function(){"use strict";function a(){return Ac.apply(null,arguments)}function b(a){Ac=a}function c(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function d(a){return"[object Array]"===Object.prototype.toString.call(a)}function e(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function f(a,b){var c,d=[];for(c=0;c0)for(c in Cc)d=Cc[c],e=b[d],"undefined"!=typeof e&&(a[d]=e);return a}function m(b){l(this,b),this._d=new Date(+b._d),Dc===!1&&(Dc=!0,a.updateOffset(this),Dc=!1)}function n(a){return a instanceof m||null!=a&&g(a,"_isAMomentObject")}function o(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function p(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&o(a[d])!==o(b[d]))&&g++;return g+f}function q(){}function r(a){return a?a.toLowerCase().replace("_","-"):a}function s(a){for(var b,c,d,e,f=0;f0;){if(d=t(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&p(e,c,!0)>=b-1)break;b--}f++}return null}function t(a){var b=null;if(!Ec[a]&&"undefined"!=typeof module&&module&&module.exports)try{b=Bc._abbr,require("./locale/"+a),u(b)}catch(c){}return Ec[a]}function u(a,b){var c;return a&&(c="undefined"==typeof b?w(a):v(a,b),c&&(Bc=c)),Bc._abbr}function v(a,b){return null!==b?(b.abbr=a,Ec[a]||(Ec[a]=new q),Ec[a].set(b),u(a),Ec[a]):(delete Ec[a],null)}function w(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return Bc;if(!d(a)){if(b=t(a))return b;a=[a]}return s(a)}function x(a,b){var c=a.toLowerCase();Fc[c]=Fc[c+"s"]=Fc[b]=a}function y(a){return"string"==typeof a?Fc[a]||Fc[a.toLowerCase()]:void 0}function z(a){var b,c,d={};for(c in a)g(a,c)&&(b=y(c),b&&(d[b]=a[c]));return d}function A(b,c){return function(d){return null!=d?(C(this,b,d),a.updateOffset(this,c),this):B(this,b)}}function B(a,b){return a._d["get"+(a._isUTC?"UTC":"")+b]()}function C(a,b,c){return a._d["set"+(a._isUTC?"UTC":"")+b](c)}function D(a,b){var c;if("object"==typeof a)for(c in a)this.set(c,a[c]);else if(a=y(a),"function"==typeof this[a])return this[a](b);return this}function E(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.lengthb;b++)d[b]=Jc[d[b]]?Jc[d[b]]:G(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function I(a,b){return a.isValid()?(b=J(b,a.localeData()),Ic[b]||(Ic[b]=H(b)),Ic[b](a)):a.localeData().invalidDate()}function J(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Hc.lastIndex=0;d>=0&&Hc.test(a);)a=a.replace(Hc,c),Hc.lastIndex=0,d-=1;return a}function K(a,b,c){Yc[a]="function"==typeof b?b:function(a){return a&&c?c:b}}function L(a,b){return g(Yc,a)?Yc[a](b._strict,b._locale):new RegExp(M(a))}function M(a){return a.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e}).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function N(a,b){var c,d=b;for("string"==typeof a&&(a=[a]),"number"==typeof b&&(d=function(a,c){c[b]=o(a)}),c=0;cd;d++){if(e=i([2e3,d]),c&&!this._longMonthsParse[d]&&(this._longMonthsParse[d]=new RegExp("^"+this.months(e,"").replace(".","")+"$","i"),this._shortMonthsParse[d]=new RegExp("^"+this.monthsShort(e,"").replace(".","")+"$","i")),c||this._monthsParse[d]||(f="^"+this.months(e,"")+"|^"+this.monthsShort(e,""),this._monthsParse[d]=new RegExp(f.replace(".",""),"i")),c&&"MMMM"===b&&this._longMonthsParse[d].test(a))return d;if(c&&"MMM"===b&&this._shortMonthsParse[d].test(a))return d;if(!c&&this._monthsParse[d].test(a))return d}}function U(a,b){var c;return"string"==typeof b&&(b=a.localeData().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),Q(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a)}function V(b){return null!=b?(U(this,b),a.updateOffset(this,!0),this):B(this,"Month")}function W(){return Q(this.year(),this.month())}function X(a){var b,c=a._a;return c&&-2===a._pf.overflow&&(b=c[_c]<0||c[_c]>11?_c:c[ad]<1||c[ad]>Q(c[$c],c[_c])?ad:c[bd]<0||c[bd]>24||24===c[bd]&&(0!==c[cd]||0!==c[dd]||0!==c[ed])?bd:c[cd]<0||c[cd]>59?cd:c[dd]<0||c[dd]>59?dd:c[ed]<0||c[ed]>999?ed:-1,a._pf._overflowDayOfYear&&($c>b||b>ad)&&(b=ad),a._pf.overflow=b),a}function Y(b){a.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+b)}function Z(a,b){var c=!0;return h(function(){return c&&(Y(a),c=!1),b.apply(this,arguments)},b)}function $(a,b){hd[a]||(Y(b),hd[a]=!0)}function _(a){var b,c,d=a._i,e=id.exec(d);if(e){for(a._pf.iso=!0,b=0,c=jd.length;c>b;b++)if(jd[b][1].exec(d)){a._f=jd[b][0]+(e[6]||" ");break}for(b=0,c=kd.length;c>b;b++)if(kd[b][1].exec(d)){a._f+=kd[b][0];break}d.match(Vc)&&(a._f+="Z"),sa(a)}else a._isValid=!1}function aa(b){var c=ld.exec(b._i);return null!==c?void(b._d=new Date(+c[1])):(_(b),void(b._isValid===!1&&(delete b._isValid,a.createFromInputFallback(b))))}function ba(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function ca(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function da(a){return ea(a)?366:365}function ea(a){return a%4===0&&a%100!==0||a%400===0}function fa(){return ea(this.year())}function ga(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=za(a).add(f,"d"),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function ha(a){return ga(a,this._week.dow,this._week.doy).week}function ia(){return this._week.dow}function ja(){return this._week.doy}function ka(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")}function la(a){var b=ga(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")}function ma(a,b,c,d,e){var f,g,h=ca(a,0,1).getUTCDay();return h=0===h?7:h,c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:da(a-1)+g}}function na(a){var b=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")}function oa(a,b,c){return null!=a?a:null!=b?b:c}function pa(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function qa(a){var b,c,d,e,f=[];if(!a._d){for(d=pa(a),a._w&&null==a._a[ad]&&null==a._a[_c]&&ra(a),a._dayOfYear&&(e=oa(a._a[$c],d[$c]),a._dayOfYear>da(e)&&(a._pf._overflowDayOfYear=!0),c=ca(e,0,a._dayOfYear),a._a[_c]=c.getUTCMonth(),a._a[ad]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=f[b]=d[b];for(;7>b;b++)a._a[b]=f[b]=null==a._a[b]?2===b?1:0:a._a[b];24===a._a[bd]&&0===a._a[cd]&&0===a._a[dd]&&0===a._a[ed]&&(a._nextDay=!0,a._a[bd]=0),a._d=(a._useUTC?ca:ba).apply(null,f),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()-a._tzm),a._nextDay&&(a._a[bd]=24)}}function ra(a){var b,c,d,e,f,g,h;b=a._w,null!=b.GG||null!=b.W||null!=b.E?(f=1,g=4,c=oa(b.GG,a._a[$c],ga(za(),1,4).year),d=oa(b.W,1),e=oa(b.E,1)):(f=a._locale._week.dow,g=a._locale._week.doy,c=oa(b.gg,a._a[$c],ga(za(),f,g).year),d=oa(b.w,1),null!=b.d?(e=b.d,f>e&&++d):e=null!=b.e?b.e+f:f),h=ma(c,d,e,g,f),a._a[$c]=h.year,a._dayOfYear=h.dayOfYear}function sa(b){if(b._f===a.ISO_8601)return void _(b);b._a=[],b._pf.empty=!0;var c,d,e,f,g,h=""+b._i,i=h.length,j=0;for(e=J(b._f,b._locale).match(Gc)||[],c=0;c0&&b._pf.unusedInput.push(g),h=h.slice(h.indexOf(d)+d.length),j+=d.length),Jc[f]?(d?b._pf.empty=!1:b._pf.unusedTokens.push(f),P(f,d,b)):b._strict&&!d&&b._pf.unusedTokens.push(f);b._pf.charsLeftOver=i-j,h.length>0&&b._pf.unusedInput.push(h),b._pf.bigHour===!0&&b._a[bd]<=12&&(b._pf.bigHour=void 0),b._a[bd]=ta(b._locale,b._a[bd],b._meridiem),qa(b),X(b)}function ta(a,b,c){var d;return null==c?b:null!=a.meridiemHour?a.meridiemHour(b,c):null!=a.isPM?(d=a.isPM(c),d&&12>b&&(b+=12),d||12!==b||(b=0),b):b}function ua(a){var b,d,e,f,g;if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(0/0));for(f=0;fg)&&(e=g,d=b));h(a,d||b)}function va(a){if(!a._d){var b=z(a._i);a._a=[b.year,b.month,b.day||b.date,b.hour,b.minute,b.second,b.millisecond],qa(a)}}function wa(a){var b,c=a._i,e=a._f;return a._locale=a._locale||w(a._l),null===c||void 0===e&&""===c?k({nullInput:!0}):("string"==typeof c&&(a._i=c=a._locale.preparse(c)),n(c)?new m(X(c)):(d(e)?ua(a):e?sa(a):xa(a),b=new m(X(a)),b._nextDay&&(b.add(1,"d"),b._nextDay=void 0),b))}function xa(b){var c=b._i;void 0===c?b._d=new Date:e(c)?b._d=new Date(+c):"string"==typeof c?aa(b):d(c)?(b._a=f(c.slice(0),function(a){return parseInt(a,10)}),qa(b)):"object"==typeof c?va(b):"number"==typeof c?b._d=new Date(c):a.createFromInputFallback(b)}function ya(a,b,d,e,f){var g={};return"boolean"==typeof d&&(e=d,d=void 0),g._isAMomentObject=!0,g._useUTC=g._isUTC=f,g._l=d,g._i=a,g._f=b,g._strict=e,g._pf=c(),wa(g)}function za(a,b,c,d){return ya(a,b,c,d,!1)}function Aa(a,b){var c,e;if(1===b.length&&d(b[0])&&(b=b[0]),!b.length)return za();for(c=b[0],e=1;ea&&(a=-a,c="-"),c+E(~~(a/60),2)+b+E(~~a%60,2)})}function Ga(a){var b=(a||"").match(Vc)||[],c=b[b.length-1]||[],d=(c+"").match(qd)||["-",0,0],e=+(60*d[1])+o(d[2]);return"+"===d[0]?e:-e}function Ha(b,c){var d,f;return c._isUTC?(d=c.clone(),f=(n(b)||e(b)?+b:+za(b))-+d,d._d.setTime(+d._d+f),a.updateOffset(d,!1),d):za(b).local();return c._isUTC?za(b).zone(c._offset||0):za(b).local()}function Ia(a){return 15*-Math.round(a._d.getTimezoneOffset()/15)}function Ja(b,c){var d,e=this._offset||0;return null!=b?("string"==typeof b&&(b=Ga(b)),Math.abs(b)<16&&(b=60*b),!this._isUTC&&c&&(d=Ia(this)),this._offset=b,this._isUTC=!0,null!=d&&this.add(d,"m"),e!==b&&(!c||this._changeInProgress?Za(this,Ua(b-e,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,a.updateOffset(this,!0),this._changeInProgress=null)),this):this._isUTC?e:Ia(this)}function Ka(a,b){return null!=a?("string"!=typeof a&&(a=-a),this.utcOffset(a,b),this):-this.utcOffset()}function La(a){return this.utcOffset(0,a)}function Ma(a){return this._isUTC&&(this.utcOffset(0,a),this._isUTC=!1,a&&this.subtract(Ia(this),"m")),this}function Na(){return this._tzm?this.utcOffset(this._tzm):"string"==typeof this._i&&this.utcOffset(Ga(this._i)),this}function Oa(a){return a=a?za(a).utcOffset():0,(this.utcOffset()-a)%60===0}function Pa(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Qa(){if(this._a){var a=this._isUTC?i(this._a):za(this._a);return this.isValid()&&p(this._a,a.toArray())>0}return!1}function Ra(){return!this._isUTC}function Sa(){return this._isUTC}function Ta(){return this._isUTC&&0===this._offset}function Ua(a,b){var c,d,e,f=a,h=null;return Ea(a)?f={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(f={},b?f[b]=a:f.milliseconds=a):(h=rd.exec(a))?(c="-"===h[1]?-1:1,f={y:0,d:o(h[ad])*c,h:o(h[bd])*c,m:o(h[cd])*c,s:o(h[dd])*c,ms:o(h[ed])*c}):(h=sd.exec(a))?(c="-"===h[1]?-1:1,f={y:Va(h[2],c),M:Va(h[3],c),d:Va(h[4],c),h:Va(h[5],c),m:Va(h[6],c),s:Va(h[7],c),w:Va(h[8],c)}):null==f?f={}:"object"==typeof f&&("from"in f||"to"in f)&&(e=Xa(za(f.from),za(f.to)),f={},f.ms=e.milliseconds,f.M=e.months),d=new Da(f),Ea(a)&&g(a,"_locale")&&(d._locale=a._locale),d}function Va(a,b){var c=a&&parseFloat(a.replace(",","."));return(isNaN(c)?0:c)*b}function Wa(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function Xa(a,b){var c;return b=Ha(b,a),a.isBefore(b)?c=Wa(a,b):(c=Wa(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c}function Ya(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||($(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period)."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=Ua(c,d),Za(this,e,a),this}}function Za(b,c,d,e){var f=c._milliseconds,g=c._days,h=c._months;e=null==e?!0:e,f&&b._d.setTime(+b._d+f*d),g&&C(b,"Date",B(b,"Date")+g*d),h&&U(b,B(b,"Month")+h*d),e&&a.updateOffset(b,g||h)}function $a(a){var b=a||za(),c=Ha(b,this).startOf("day"),d=this.diff(c,"days",!0),e=-6>d?"sameElse":-1>d?"lastWeek":0>d?"lastDay":1>d?"sameDay":2>d?"nextDay":7>d?"nextWeek":"sameElse";return this.format(this.localeData().calendar(e,this,za(b)))}function _a(){return new m(this)}function ab(a,b){var c;return b=y("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=n(a)?a:za(a),+this>+a):(c=n(a)?+a:+za(a),c<+this.clone().startOf(b))}function bb(a,b){var c;return b=y("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=n(a)?a:za(a),+a>+this):(c=n(a)?+a:+za(a),+this.clone().endOf(b)a?Math.ceil(a):Math.floor(a)}function fb(a,b,c){var d,e,f=Ha(a,this),g=6e4*(f.utcOffset()-this.utcOffset());return b=y(b),"year"===b||"month"===b||"quarter"===b?(e=gb(this,f),"quarter"===b?e/=3:"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:eb(e)}function gb(a,b){var c,d,e=12*(b.year()-a.year())+(b.month()-a.month()),f=a.clone().add(e,"months");return 0>b-f?(c=a.clone().add(e-1,"months"),d=(b-f)/(f-c)):(c=a.clone().add(e+1,"months"),d=(b-f)/(c-f)),-(e+d)}function hb(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function ib(){var a=this.clone().utc();return 0b;b++)if(this._weekdaysParse[b]||(c=za([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b}function Jb(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=Eb(a,this.localeData()),this.add(a-b,"d")):b}function Kb(a){var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")}function Lb(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)}function Mb(a,b){F(a,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),b)})}function Nb(a,b){return b._meridiemParse}function Ob(a){return"p"===(a+"").toLowerCase().charAt(0)}function Pb(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"}function Qb(a){F(0,[a,3],0,"millisecond")}function Rb(){return this._isUTC?"UTC":""}function Sb(){return this._isUTC?"Coordinated Universal Time":""}function Tb(a){return za(1e3*a)}function Ub(){return za.apply(null,arguments).parseZone()}function Vb(a,b,c){var d=this._calendar[a];return"function"==typeof d?d.call(b,c):d}function Wb(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b}function Xb(){return this._invalidDate}function Yb(a){return this._ordinal.replace("%d",a)}function Zb(a){return a}function $b(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)}function _b(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)}function ac(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b;this._ordinalParseLenient=new RegExp(this._ordinalParse.source+"|"+/\d{1,2}/.source)}function bc(a,b,c,d){var e=w(),f=i().set(d,b);return e[c](f,a)}function cc(a,b,c,d,e){if("number"==typeof a&&(b=a,a=void 0),a=a||"",null!=b)return bc(a,b,c,e);var f,g=[];for(f=0;d>f;f++)g[f]=bc(a,f,c,e);return g}function dc(a,b){return cc(a,b,"months",12,"month")}function ec(a,b){return cc(a,b,"monthsShort",12,"month")}function fc(a,b){return cc(a,b,"weekdays",7,"day")}function gc(a,b){return cc(a,b,"weekdaysShort",7,"day")}function hc(a,b){return cc(a,b,"weekdaysMin",7,"day")}function ic(){var a=this._data;return this._milliseconds=Od(this._milliseconds),this._days=Od(this._days),this._months=Od(this._months),a.milliseconds=Od(a.milliseconds),a.seconds=Od(a.seconds),a.minutes=Od(a.minutes),a.hours=Od(a.hours),a.months=Od(a.months),a.years=Od(a.years),this}function jc(a,b,c,d){var e=Ua(b,c);return a._milliseconds+=d*e._milliseconds,a._days+=d*e._days,a._months+=d*e._months,a._bubble()}function kc(a,b){return jc(this,a,b,1)}function lc(a,b){return jc(this,a,b,-1)}function mc(){var a,b,c,d=this._milliseconds,e=this._days,f=this._months,g=this._data,h=0;return g.milliseconds=d%1e3,a=eb(d/1e3),g.seconds=a%60,b=eb(a/60),g.minutes=b%60,c=eb(b/60),g.hours=c%24,e+=eb(c/24),h=eb(nc(e)),e-=eb(oc(h)),f+=eb(e/30),e%=30,h+=eb(f/12),f%=12,g.days=e,g.months=f,g.years=h,this}function nc(a){return 400*a/146097}function oc(a){return 146097*a/400}function pc(a){var b,c,d=this._milliseconds;if(a=y(a),"month"===a||"year"===a)return b=this._days+d/864e5,c=this._months+12*nc(b),"month"===a?c:c/12;switch(b=this._days+Math.round(oc(this._months/12)),a){case"week":return b/7+d/6048e5;case"day":return b+d/864e5;case"hour":return 24*b+d/36e5;case"minute":return 24*b*60+d/6e4;case"second":return 24*b*60*60+d/1e3;case"millisecond":return Math.floor(24*b*60*60*1e3)+d;default:throw new Error("Unknown unit "+a)}}function qc(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*o(this._months/12)}function rc(a){return function(){return this.as(a)}}function sc(a){return a=y(a),this[a+"s"]()}function tc(a){return function(){return this._data[a]}}function uc(){return eb(this.days()/7)}function vc(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function wc(a,b,c){var d=Ua(a).abs(),e=ce(d.as("s")),f=ce(d.as("m")),g=ce(d.as("h")),h=ce(d.as("d")),i=ce(d.as("M")),j=ce(d.as("y")),k=e0,k[4]=c,vc.apply(null,k)}function xc(a,b){return void 0===de[a]?!1:void 0===b?de[a]:(de[a]=b,!0)}function yc(a){var b=this.localeData(),c=wc(this,!a,b);return a&&(c=b.pastFuture(+this,c)),b.postformat(c)}function zc(){var a=ee(this.years()),b=ee(this.months()),c=ee(this.days()),d=ee(this.hours()),e=ee(this.minutes()),f=ee(this.seconds()+this.milliseconds()/1e3),g=this.asSeconds();return g?(0>g?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"}var Ac,Bc,Cc=a.momentProperties=[],Dc=!1,Ec={},Fc={},Gc=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g,Hc=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Ic={},Jc={},Kc=/\d/,Lc=/\d\d/,Mc=/\d{3}/,Nc=/\d{4}/,Oc=/[+-]?\d{6}/,Pc=/\d\d?/,Qc=/\d{1,3}/,Rc=/\d{1,4}/,Sc=/[+-]?\d{1,6}/,Tc=/\d+/,Uc=/[+-]?\d+/,Vc=/Z|[+-]\d\d:?\d\d/gi,Wc=/[+-]?\d+(\.\d{1,3})?/,Xc=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Yc={},Zc={},$c=0,_c=1,ad=2,bd=3,cd=4,dd=5,ed=6;F("M",["MM",2],"Mo",function(){return this.month()+1}),F("MMM",0,0,function(a){return this.localeData().monthsShort(this,a)}),F("MMMM",0,0,function(a){return this.localeData().months(this,a)}),x("month","M"),K("M",Pc),K("MM",Pc,Lc),K("MMM",Xc),K("MMMM",Xc),N(["M","MM"],function(a,b){b[_c]=o(a)-1}),N(["MMM","MMMM"],function(a,b,c,d){var e=c._locale.monthsParse(a,d,c._strict);null!=e?b[_c]=e:c._pf.invalidMonth=a});var fd="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),gd="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),hd={};a.suppressDeprecationWarnings=!1;var id=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,jd=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],kd=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],ld=/^\/?Date\((\-?\d+)/i;a.createFromInputFallback=Z("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i+(a._useUTC?" UTC":""))}),F(0,["YY",2],0,function(){return this.year()%100}),F(0,["YYYY",4],0,"year"),F(0,["YYYYY",5],0,"year"),F(0,["YYYYYY",6,!0],0,"year"),x("year","y"),K("Y",Uc),K("YY",Pc,Lc),K("YYYY",Rc,Nc),K("YYYYY",Sc,Oc),K("YYYYYY",Sc,Oc),N(["YYYY","YYYYY","YYYYYY"],$c),N("YY",function(b,c){c[$c]=a.parseTwoDigitYear(b)}),a.parseTwoDigitYear=function(a){return o(a)+(o(a)>68?1900:2e3)};var md=A("FullYear",!1);F("w",["ww",2],"wo","week"),F("W",["WW",2],"Wo","isoWeek"),x("week","w"),x("isoWeek","W"),K("w",Pc),K("ww",Pc,Lc),K("W",Pc),K("WW",Pc,Lc),O(["w","ww","W","WW"],function(a,b,c,d){b[d.substr(0,1)]=o(a)});var nd={dow:0,doy:6};F("DDD",["DDDD",3],"DDDo","dayOfYear"),x("dayOfYear","DDD"),K("DDD",Qc),K("DDDD",Mc),N(["DDD","DDDD"],function(a,b,c){c._dayOfYear=o(a)}),a.ISO_8601=function(){};var od=Z("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(){var a=za.apply(null,arguments);return this>a?this:a}),pd=Z("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(){var a=za.apply(null,arguments);return a>this?this:a});Fa("Z",":"),Fa("ZZ",""),K("Z",Vc),K("ZZ",Vc),N(["Z","ZZ"],function(a,b,c){c._useUTC=!0,c._tzm=Ga(a)});var qd=/([\+\-]|\d\d)/gi;a.updateOffset=function(){};var rd=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,sd=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;Ua.fn=Da.prototype;var td=Ya(1,"add"),ud=Ya(-1,"subtract");a.defaultFormat="YYYY-MM-DDTHH:mm:ssZ";var vd=Z("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(a){return void 0===a?this.localeData():this.locale(a)});F(0,["gg",2],0,function(){return this.weekYear()%100}),F(0,["GG",2],0,function(){return this.isoWeekYear()%100}),xb("gggg","weekYear"),xb("ggggg","weekYear"),xb("GGGG","isoWeekYear"),xb("GGGGG","isoWeekYear"),x("weekYear","gg"),x("isoWeekYear","GG"),K("G",Uc),K("g",Uc),K("GG",Pc,Lc),K("gg",Pc,Lc),K("GGGG",Rc,Nc),K("gggg",Rc,Nc),K("GGGGG",Sc,Oc),K("ggggg",Sc,Oc),O(["gggg","ggggg","GGGG","GGGGG"],function(a,b,c,d){b[d.substr(0,2)]=o(a)}),O(["gg","GG"],function(b,c,d,e){c[e]=a.parseTwoDigitYear(b)}),F("Q",0,0,"quarter"),x("quarter","Q"),K("Q",Kc),N("Q",function(a,b){b[_c]=3*(o(a)-1)}),F("D",["DD",2],"Do","date"),x("date","D"),K("D",Pc),K("DD",Pc,Lc),K("Do",function(a,b){return a?b._ordinalParse:b._ordinalParseLenient}),N(["D","DD"],ad),N("Do",function(a,b){b[ad]=o(a.match(Pc)[0],10)});var wd=A("Date",!0);F("d",0,"do","day"),F("dd",0,0,function(a){return this.localeData().weekdaysMin(this,a)}),F("ddd",0,0,function(a){return this.localeData().weekdaysShort(this,a)}),F("dddd",0,0,function(a){return this.localeData().weekdays(this,a)}),F("e",0,0,"weekday"),F("E",0,0,"isoWeekday"),x("day","d"),x("weekday","e"),x("isoWeekday","E"),K("d",Pc),K("e",Pc),K("E",Pc),K("dd",Xc),K("ddd",Xc),K("dddd",Xc),O(["dd","ddd","dddd"],function(a,b,c){var d=c._locale.weekdaysParse(a);null!=d?b.d=d:c._pf.invalidWeekday=a}),O(["d","e","E"],function(a,b,c,d){b[d]=o(a)});var xd="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),yd="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),zd="Su_Mo_Tu_We_Th_Fr_Sa".split("_");F("H",["HH",2],0,"hour"),F("h",["hh",2],0,function(){return this.hours()%12||12}),Mb("a",!0),Mb("A",!1),x("hour","h"),K("a",Nb),K("A",Nb),K("H",Pc),K("h",Pc),K("HH",Pc,Lc),K("hh",Pc,Lc),N(["H","HH"],bd),N(["a","A"],function(a,b,c){c._isPm=c._locale.isPM(a),c._meridiem=a}),N(["h","hh"],function(a,b,c){b[bd]=o(a),c._pf.bigHour=!0});var Ad=/[ap]\.?m?\.?/i,Bd=A("Hours",!0);F("m",["mm",2],0,"minute"),x("minute","m"),K("m",Pc),K("mm",Pc,Lc),N(["m","mm"],cd);var Cd=A("Minutes",!1);F("s",["ss",2],0,"second"),x("second","s"),K("s",Pc),K("ss",Pc,Lc),N(["s","ss"],dd);var Dd=A("Seconds",!1);F("S",0,0,function(){return~~(this.millisecond()/100)}),F(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Qb("SSS"),Qb("SSSS"),x("millisecond","ms"),K("S",Qc,Kc),K("SS",Qc,Lc),K("SSS",Qc,Mc),K("SSSS",Tc),N(["S","SS","SSS","SSSS"],function(a,b){b[ed]=o(1e3*("0."+a))});var Ed=A("Milliseconds",!1);F("z",0,0,"zoneAbbr"),F("zz",0,0,"zoneName");var Fd=m.prototype;Fd.add=td,Fd.calendar=$a,Fd.clone=_a,Fd.diff=fb,Fd.endOf=pb,Fd.format=jb,Fd.from=kb,Fd.fromNow=lb,Fd.get=D,Fd.invalidAt=wb,Fd.isAfter=ab,Fd.isBefore=bb,Fd.isBetween=cb,Fd.isSame=db,Fd.isValid=ub,Fd.lang=vd,Fd.locale=mb,Fd.localeData=nb,Fd.max=pd,Fd.min=od,Fd.parsingFlags=vb,Fd.set=D,Fd.startOf=ob,Fd.subtract=ud,Fd.toArray=tb,Fd.toDate=sb,Fd.toISOString=ib,Fd.toJSON=ib,Fd.toString=hb,Fd.unix=rb,Fd.valueOf=qb,Fd.year=md,Fd.isLeapYear=fa,Fd.weekYear=zb,Fd.isoWeekYear=Ab,Fd.quarter=Fd.quarters=Db,Fd.month=V,Fd.daysInMonth=W,Fd.week=Fd.weeks=ka,Fd.isoWeek=Fd.isoWeeks=la,Fd.weeksInYear=Cb,Fd.isoWeeksInYear=Bb,Fd.date=wd,Fd.day=Fd.days=Jb,Fd.weekday=Kb,Fd.isoWeekday=Lb,Fd.dayOfYear=na,Fd.hour=Fd.hours=Bd,Fd.minute=Fd.minutes=Cd,Fd.second=Fd.seconds=Dd,Fd.millisecond=Fd.milliseconds=Ed,Fd.utcOffset=Ja,Fd.utc=La,Fd.local=Ma,Fd.parseZone=Na,Fd.hasAlignedHourOffset=Oa,Fd.isDST=Pa,Fd.isDSTShifted=Qa,Fd.isLocal=Ra,Fd.isUtcOffset=Sa,Fd.isUtc=Ta,Fd.isUTC=Ta,Fd.zoneAbbr=Rb,Fd.zoneName=Sb,Fd.dates=Z("dates accessor is deprecated. Use date instead.",wd),Fd.months=Z("months accessor is deprecated. Use month instead",V),Fd.years=Z("years accessor is deprecated. Use year instead",md),Fd.zone=Z("moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779",Ka);var Gd=Fd,Hd={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},Id={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},Jd="Invalid date",Kd="%d",Ld=/\d{1,2}/,Md={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},Nd=q.prototype;Nd._calendar=Hd,Nd.calendar=Vb,Nd._longDateFormat=Id,Nd.longDateFormat=Wb,Nd._invalidDate=Jd,Nd.invalidDate=Xb,Nd._ordinal=Kd,Nd.ordinal=Yb,Nd._ordinalParse=Ld, -Nd.preparse=Zb,Nd.postformat=Zb,Nd._relativeTime=Md,Nd.relativeTime=$b,Nd.pastFuture=_b,Nd.set=ac,Nd.months=R,Nd._months=fd,Nd.monthsShort=S,Nd._monthsShort=gd,Nd.monthsParse=T,Nd.week=ha,Nd._week=nd,Nd.firstDayOfYear=ja,Nd.firstDayOfWeek=ia,Nd.weekdays=Fb,Nd._weekdays=xd,Nd.weekdaysMin=Hb,Nd._weekdaysMin=zd,Nd.weekdaysShort=Gb,Nd._weekdaysShort=yd,Nd.weekdaysParse=Ib,Nd.isPM=Ob,Nd._meridiemParse=Ad,Nd.meridiem=Pb,u("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(a){var b=a%10,c=1===o(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),a.lang=Z("moment.lang is deprecated. Use moment.locale instead.",u),a.langData=Z("moment.langData is deprecated. Use moment.localeData instead.",w);var Od=Math.abs,Pd=rc("ms"),Qd=rc("s"),Rd=rc("m"),Sd=rc("h"),Td=rc("d"),Ud=rc("w"),Vd=rc("M"),Wd=rc("y"),Xd=tc("milliseconds"),Yd=tc("seconds"),Zd=tc("minutes"),$d=tc("hours"),_d=tc("days"),ae=tc("months"),be=tc("years"),ce=Math.round,de={s:45,m:45,h:22,d:26,M:11},ee=Math.abs,fe=Da.prototype;fe.abs=ic,fe.add=kc,fe.subtract=lc,fe.as=pc,fe.asMilliseconds=Pd,fe.asSeconds=Qd,fe.asMinutes=Rd,fe.asHours=Sd,fe.asDays=Td,fe.asWeeks=Ud,fe.asMonths=Vd,fe.asYears=Wd,fe.valueOf=qc,fe._bubble=mc,fe.get=sc,fe.milliseconds=Xd,fe.seconds=Yd,fe.minutes=Zd,fe.hours=$d,fe.days=_d,fe.weeks=uc,fe.months=ae,fe.years=be,fe.humanize=yc,fe.toISOString=zc,fe.toString=zc,fe.toJSON=zc,fe.locale=mb,fe.localeData=nb,fe.toIsoString=Z("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",zc),fe.lang=vd,F("X",0,0,"unix"),F("x",0,0,"valueOf"),K("x",Uc),K("X",Wc),N("X",function(a,b,c){c._d=new Date(1e3*parseFloat(a,10))}),N("x",function(a,b,c){c._d=new Date(o(a))}),a.version="2.10.2",b(za),a.fn=Gd,a.min=Ba,a.max=Ca,a.utc=i,a.unix=Tb,a.months=dc,a.isDate=e,a.locale=u,a.invalid=k,a.duration=Ua,a.isMoment=n,a.weekdays=fc,a.parseZone=Ub,a.localeData=w,a.isDuration=Ea,a.monthsShort=ec,a.weekdaysMin=hc,a.defineLocale=v,a.weekdaysShort=gc,a.normalizeUnits=y,a.relativeTimeThreshold=xc;var ge=a;return ge}); \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/socket.io.min.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/socket.io.min.js deleted file mode 100644 index 7e870c9864..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/src/main/resources/jaggeryapps/store/app/units/cdmf.unit.default.device.type.realtime.analytics-view/public/js/socket.io.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! Socket.IO.min.js build:0.9.16, production. Copyright(c) 2011 LearnBoost MIT Licensed */ -var io="undefined"==typeof module?{}:module.exports;(function(){(function(a,b){var c=a;c.version="0.9.16",c.protocol=1,c.transports=[],c.j=[],c.sockets={},c.connect=function(a,d){var e=c.util.parseUri(a),f,g;b&&b.location&&(e.protocol=e.protocol||b.location.protocol.slice(0,-1),e.host=e.host||(b.document?b.document.domain:b.location.hostname),e.port=e.port||b.location.port),f=c.util.uniqueUri(e);var h={host:e.host,secure:"https"==e.protocol,port:e.port||("https"==e.protocol?443:80),query:e.query||""};c.util.merge(h,d);if(h["force new connection"]||!c.sockets[f])g=new c.Socket(h);return!h["force new connection"]&&g&&(c.sockets[f]=g),g=g||c.sockets[f],g.of(e.path.length>1?e.path:"")}})("object"==typeof module?module.exports:this.io={},this),function(a,b){var c=a.util={},d=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];c.parseUri=function(a){var b=d.exec(a||""),c={},f=14;while(f--)c[e[f]]=b[f]||"";return c},c.uniqueUri=function(a){var c=a.protocol,d=a.host,e=a.port;return"document"in b?(d=d||document.domain,e=e||(c=="https"&&document.location.protocol!=="https:"?443:document.location.port)):(d=d||"localhost",!e&&c=="https"&&(e=443)),(c||"http")+"://"+d+":"+(e||80)},c.query=function(a,b){var d=c.chunkQuery(a||""),e=[];c.merge(d,c.chunkQuery(b||""));for(var f in d)d.hasOwnProperty(f)&&e.push(f+"="+d[f]);return e.length?"?"+e.join("&"):""},c.chunkQuery=function(a){var b={},c=a.split("&"),d=0,e=c.length,f;for(;db.length?a:b,f=a.length>b.length?b:a;for(var g=0,h=f.length;g0&&a.splice(0,1)[0]!=c.transport.name);a.length?h(a):c.publish("connect_failed")}}},c.options["connect timeout"]))})}c.sessionid=d,c.closeTimeout=f*1e3,c.heartbeatTimeout=e*1e3,c.transports||(c.transports=c.origTransports=g?b.util.intersect(g.split(","),c.options.transports):c.options.transports),c.setHeartbeatTimeout(),h(c.transports),c.once("connect",function(){clearTimeout(c.connectTimeoutTimer),a&&typeof a=="function"&&a()})}),this},d.prototype.setHeartbeatTimeout=function(){clearTimeout(this.heartbeatTimeoutTimer);if(this.transport&&!this.transport.heartbeats())return;var a=this;this.heartbeatTimeoutTimer=setTimeout(function(){a.transport.onClose()},this.heartbeatTimeout)},d.prototype.packet=function(a){return this.connected&&!this.doBuffer?this.transport.packet(a):this.buffer.push(a),this},d.prototype.setBuffer=function(a){this.doBuffer=a,!a&&this.connected&&this.buffer.length&&(this.options.manualFlush||this.flushBuffer())},d.prototype.flushBuffer=function(){this.transport.payload(this.buffer),this.buffer=[]},d.prototype.disconnect=function(){if(this.connected||this.connecting)this.open&&this.of("").packet({type:"disconnect"}),this.onDisconnect("booted");return this},d.prototype.disconnectSync=function(){var a=b.util.request(),c=["http"+(this.options.secure?"s":"")+":/",this.options.host+":"+this.options.port,this.options.resource,b.protocol,"",this.sessionid].join("/")+"/?disconnect=1";a.open("GET",c,!1),a.send(null),this.onDisconnect("booted")},d.prototype.isXDomain=function(){var a=c.location.port||("https:"==c.location.protocol?443:80);return this.options.host!==c.location.hostname||this.options.port!=a},d.prototype.onConnect=function(){this.connected||(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit("connect"))},d.prototype.onOpen=function(){this.open=!0},d.prototype.onClose=function(){this.open=!1,clearTimeout(this.heartbeatTimeoutTimer)},d.prototype.onPacket=function(a){this.of(a.endpoint).onPacket(a)},d.prototype.onError=function(a){a&&a.advice&&a.advice==="reconnect"&&(this.connected||this.connecting)&&(this.disconnect(),this.options.reconnect&&this.reconnect()),this.publish("error",a&&a.reason?a.reason:a)},d.prototype.onDisconnect=function(a){var b=this.connected,c=this.connecting;this.connected=!1,this.connecting=!1,this.open=!1;if(b||c)this.transport.close(),this.transport.clearTimeouts(),b&&(this.publish("disconnect",a),"booted"!=a&&this.options.reconnect&&!this.reconnecting&&this.reconnect())},d.prototype.reconnect=function(){function e(){if(a.connected){for(var b in a.namespaces)a.namespaces.hasOwnProperty(b)&&""!==b&&a.namespaces[b].packet({type:"connect"});a.publish("reconnect",a.transport.name,a.reconnectionAttempts)}clearTimeout(a.reconnectionTimer),a.removeListener("connect_failed",f),a.removeListener("connect",f),a.reconnecting=!1,delete a.reconnectionAttempts,delete a.reconnectionDelay,delete a.reconnectionTimer,delete a.redoTransports,a.options["try multiple transports"]=c}function f(){if(!a.reconnecting)return;if(a.connected)return e();if(a.connecting&&a.reconnecting)return a.reconnectionTimer=setTimeout(f,1e3);a.reconnectionAttempts++>=b?a.redoTransports?(a.publish("reconnect_failed"),e()):(a.on("connect_failed",f),a.options["try multiple transports"]=!0,a.transports=a.origTransports,a.transport=a.getTransport(),a.redoTransports=!0,a.connect()):(a.reconnectionDelay=10:!1},c.xdomainCheck=function(){return!0},typeof window!="undefined"&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),b.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports);if("undefined"!=typeof window)var swfobject=function(){function A(){if(t)return;try{var a=i.getElementsByTagName("body")[0].appendChild(Q("span"));a.parentNode.removeChild(a)}catch(b){return}t=!0;var c=l.length;for(var d=0;d0)for(var c=0;c0){var g=P(d);if(g)if(S(m[c].swfVersion)&&!(y.wk&&y.wk<312))U(d,!0),e&&(f.success=!0,f.ref=G(d),e(f));else if(m[c].expressInstall&&H()){var h={};h.data=m[c].expressInstall,h.width=g.getAttribute("width")||"0",h.height=g.getAttribute("height")||"0",g.getAttribute("class")&&(h.styleclass=g.getAttribute("class")),g.getAttribute("align")&&(h.align=g.getAttribute("align"));var i={},j=g.getElementsByTagName("param"),k=j.length;for(var l=0;l');h.outerHTML='"+k+"",n[n.length]=c.id,g=P(c.id)}else{var m=Q(b);m.setAttribute("type",e);for(var o in c)c[o]!=Object.prototype[o]&&(o.toLowerCase()=="styleclass"?m.setAttribute("class",c[o]):o.toLowerCase()!="classid"&&m.setAttribute(o,c[o]));for(var p in d)d[p]!=Object.prototype[p]&&p.toLowerCase()!="movie"&&M(m,p,d[p]);h.parentNode.replaceChild(m,h),g=m}}return g}function M(a,b,c){var d=Q("param");d.setAttribute("name",b),d.setAttribute("value",c),a.appendChild(d)}function N(a){var b=P(a);b&&b.nodeName=="OBJECT"&&(y.ie&&y.win?(b.style.display="none",function(){b.readyState==4?O(a):setTimeout(arguments.callee,10)}()):b.parentNode.removeChild(b))}function O(a){var b=P(a);if(b){for(var c in b)typeof b[c]=="function"&&(b[c]=null);b.parentNode.removeChild(b)}}function P(a){var b=null;try{b=i.getElementById(a)}catch(c){}return b}function Q(a){return i.createElement(a)}function R(a,b,c){a.attachEvent(b,c),o[o.length]=[a,b,c]}function S(a){var b=y.pv,c=a.split(".");return c[0]=parseInt(c[0],10),c[1]=parseInt(c[1],10)||0,c[2]=parseInt(c[2],10)||0,b[0]>c[0]||b[0]==c[0]&&b[1]>c[1]||b[0]==c[0]&&b[1]==c[1]&&b[2]>=c[2]?!0:!1}function T(c,d,e,f){if(y.ie&&y.mac)return;var g=i.getElementsByTagName("head")[0];if(!g)return;var h=e&&typeof e=="string"?e:"screen";f&&(v=null,w=null);if(!v||w!=h){var j=Q("style");j.setAttribute("type","text/css"),j.setAttribute("media",h),v=g.appendChild(j),y.ie&&y.win&&typeof i.styleSheets!=a&&i.styleSheets.length>0&&(v=i.styleSheets[i.styleSheets.length-1]),w=h}y.ie&&y.win?v&&typeof v.addRule==b&&v.addRule(c,d):v&&typeof i.createTextNode!=a&&v.appendChild(i.createTextNode(c+" {"+d+"}"))}function U(a,b){if(!x)return;var c=b?"visible":"hidden";t&&P(a)?P(a).style.visibility=c:T("#"+a,"visibility:"+c)}function V(b){var c=/[\\\"<>\.;]/,d=c.exec(b)!=null;return d&&typeof encodeURIComponent!=a?encodeURIComponent(b):b}var a="undefined",b="object",c="Shockwave Flash",d="ShockwaveFlash.ShockwaveFlash",e="application/x-shockwave-flash",f="SWFObjectExprInst",g="onreadystatechange",h=window,i=document,j=navigator,k=!1,l=[D],m=[],n=[],o=[],p,q,r,s,t=!1,u=!1,v,w,x=!0,y=function(){var f=typeof i.getElementById!=a&&typeof i.getElementsByTagName!=a&&typeof i.createElement!=a,g=j.userAgent.toLowerCase(),l=j.platform.toLowerCase(),m=l?/win/.test(l):/win/.test(g),n=l?/mac/.test(l):/mac/.test(g),o=/webkit/.test(g)?parseFloat(g.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,p=!1,q=[0,0,0],r=null;if(typeof j.plugins!=a&&typeof j.plugins[c]==b)r=j.plugins[c].description,r&&(typeof j.mimeTypes==a||!j.mimeTypes[e]||!!j.mimeTypes[e].enabledPlugin)&&(k=!0,p=!1,r=r.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),q[0]=parseInt(r.replace(/^(.*)\..*$/,"$1"),10),q[1]=parseInt(r.replace(/^.*\.(.*)\s.*$/,"$1"),10),q[2]=/[a-zA-Z]/.test(r)?parseInt(r.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof h[["Active"].concat("Object").join("X")]!=a)try{var s=new(window[["Active"].concat("Object").join("X")])(d);s&&(r=s.GetVariable("$version"),r&&(p=!0,r=r.split(" ")[1].split(","),q=[parseInt(r[0],10),parseInt(r[1],10),parseInt(r[2],10)]))}catch(t){}return{w3:f,pv:q,wk:o,ie:p,win:m,mac:n}}(),z=function(){if(!y.w3)return;(typeof i.readyState!=a&&i.readyState=="complete"||typeof i.readyState==a&&(i.getElementsByTagName("body")[0]||i.body))&&A(),t||(typeof i.addEventListener!=a&&i.addEventListener("DOMContentLoaded",A,!1),y.ie&&y.win&&(i.attachEvent(g,function(){i.readyState=="complete"&&(i.detachEvent(g,arguments.callee),A())}),h==top&&function(){if(t)return;try{i.documentElement.doScroll("left")}catch(a){setTimeout(arguments.callee,0);return}A()}()),y.wk&&function(){if(t)return;if(!/loaded|complete/.test(i.readyState)){setTimeout(arguments.callee,0);return}A()}(),C(A))}(),W=function(){y.ie&&y.win&&window.attachEvent("onunload",function(){var a=o.length;for(var b=0;b= 10.0.0 is required.");return}location.protocol=="file:"&&a.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."),WebSocket=function(a,b,c,d,e){var f=this;f.__id=WebSocket.__nextId++,WebSocket.__instances[f.__id]=f,f.readyState=WebSocket.CONNECTING,f.bufferedAmount=0,f.__events={},b?typeof b=="string"&&(b=[b]):b=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(f.__id,a,b,c||null,d||0,e||null)})},0)},WebSocket.prototype.send=function(a){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var b=WebSocket.__flash.send(this.__id,encodeURIComponent(a));return b<0?!0:(this.bufferedAmount+=b,!1)},WebSocket.prototype.close=function(){if(this.readyState==WebSocket.CLOSED||this.readyState==WebSocket.CLOSING)return;this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id)},WebSocket.prototype.addEventListener=function(a,b,c){a in this.__events||(this.__events[a]=[]),this.__events[a].push(b)},WebSocket.prototype.removeEventListener=function(a,b,c){if(!(a in this.__events))return;var d=this.__events[a];for(var e=d.length-1;e>=0;--e)if(d[e]===b){d.splice(e,1);break}},WebSocket.prototype.dispatchEvent=function(a){var b=this.__events[a.type]||[];for(var c=0;c"),this.doc.close(),this.doc.parentWindow.s=this;var a=this.doc.createElement("div");a.className="socketio",this.doc.body.appendChild(a),this.iframe=this.doc.createElement("iframe"),a.appendChild(this.iframe);var c=this,d=b.util.query(this.socket.options.query,"t="+ +(new Date));this.iframe.src=this.prepareUrl()+d,b.util.on(window,"unload",function(){c.destroy()})},c.prototype._=function(a,b){a=a.replace(/\\\//g,"/"),this.onData(a);try{var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)}catch(d){}},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null,this.iframe.parentNode.removeChild(this.iframe),this.iframe=null,CollectGarbage()}},c.prototype.close=function(){return this.destroy(),b.Transport.XHR.prototype.close.call(this)},c.check=function(a){if(typeof window!="undefined"&&["Active"].concat("Object").join("X")in window)try{var c=new(window[["Active"].concat("Object").join("X")])("htmlfile");return c&&b.Transport.XHR.check(a)}catch(d){}return!1},c.xdomainCheck=function(){return!1},b.transports.push("htmlfile")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b,c){function d(){b.Transport.XHR.apply(this,arguments)}function e(){}a["xhr-polling"]=d,b.util.inherit(d,b.Transport.XHR),b.util.merge(d,b.Transport.XHR),d.prototype.name="xhr-polling",d.prototype.heartbeats=function(){return!1},d.prototype.open=function(){var a=this;return b.Transport.XHR.prototype.open.call(a),!1},d.prototype.get=function(){function b(){this.readyState==4&&(this.onreadystatechange=e,this.status==200?(a.onData(this.responseText),a.get()):a.onClose())}function d(){this.onload=e,this.onerror=e,a.retryCounter=1,a.onData(this.responseText),a.get()}function f(){a.retryCounter++,!a.retryCounter||a.retryCounter>3?a.onClose():a.get()}if(!this.isOpen)return;var a=this;this.xhr=this.request(),c.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=d,this.xhr.onerror=f):this.xhr.onreadystatechange=b,this.xhr.send(null)},d.prototype.onClose=function(){b.Transport.XHR.prototype.onClose.call(this);if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=this.xhr.onerror=e;try{this.xhr.abort()}catch(a){}this.xhr=null}},d.prototype.ready=function(a,c){var d=this;b.util.defer(function(){c.call(d)})},b.transports.push("xhr-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports,this),function(a,b,c){function e(a){b.Transport["xhr-polling"].apply(this,arguments),this.index=b.j.length;var c=this;b.j.push(function(a){c._(a)})}var d=c.document&&"MozAppearance"in c.document.documentElement.style;a["jsonp-polling"]=e,b.util.inherit(e,b.Transport["xhr-polling"]),e.prototype.name="jsonp-polling",e.prototype.post=function(a){function i(){j(),c.socket.setBuffer(!1)}function j(){c.iframe&&c.form.removeChild(c.iframe);try{h=document.createElement('