Created
December 4, 2019 18:52
-
-
Save ilyahoilik/7d94fa3c044b41afdc40715d940792e9 to your computer and use it in GitHub Desktop.
Добавляет новый интервал и рейс при нажатии Enter на Народной Яндекс.Карте
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function (undefined) { | |
"use strict"; | |
let CreateNewDepatureOnEnter = { | |
initialize: function () { | |
document.addEventListener('keypress', this.onKeyPress.bind(this)); | |
}, | |
onKeyPress: function (e) { | |
if (e.code === 'Enter' || e.code === 'NumpadEnter' || e.code === 'Comma') { | |
try { | |
var focused = document.activeElement; | |
if ( | |
focused.tagName.toLowerCase() == 'input' && | |
focused.className == 'nk-text-input__control' | |
) { | |
var parent = focused.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; | |
if ( | |
focused.parentNode.parentNode.parentNode.parentNode.parentNode.className === 'nk-transport-thread-schedule-row-item-edit-layout__row nk-grid' || | |
focused.parentNode.parentNode.parentNode.parentNode.className === 'nk-transport-thread-schedule-row-item-edit-layout__row' | |
) { | |
this.addIntervalOrDeparture(parent, true); | |
} else if ( | |
focused.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.className=== 'nk-list-edit-control nk-transport-thread-schedule-row-items-edit-control' | |
) { | |
this.addIntervalOrDeparture(parent, false); | |
} | |
} | |
} catch (error) {} | |
} | |
}, | |
addIntervalOrDeparture: function (node, isInterval) { | |
var controls = node.getElementsByClassName('nk-transport-thread-schedule-row-items-edit-control__add-control'); | |
var button = controls[isInterval ? 0 : 1].getElementsByTagName('a')[0]; | |
button.click(); | |
}, | |
}; | |
CreateNewDepatureOnEnter.initialize(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment