(typed, namedByEvent)
| 101 | // names a keyboard too, but leaves every one of them on the same layout, so the |
| 102 | // label reads the same whichever of them the name settles on. |
| 103 | function selectKeyboard(typed, namedByEvent) { |
| 104 | var keyboards = typed || [] |
| 105 | |
| 106 | return keyboards.find(function (keyboard) { |
| 107 | return keyboard.name === namedByEvent |
| 108 | }) || keyboards.reduce(function (furthest, keyboard) { |
| 109 | return layoutIndex(keyboard) > layoutIndex(furthest) ? keyboard : furthest |
| 110 | }, keyboards[0]) |
| 111 | } |
| 112 | |
| 113 | function layoutIndex(keyboard) { |
| 114 | return (keyboard && keyboard.active_layout_index) || 0 |
nothing calls this directly
no test coverage detected