|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
872 bytes
|
| Line | |
|---|
| 1 | "use strict"
|
|---|
| 2 |
|
|---|
| 3 | const startsWithKeywordRegexp = /^(all|not|only|print|screen)/i
|
|---|
| 4 |
|
|---|
| 5 | module.exports = function (parentMedia, childMedia) {
|
|---|
| 6 | if (!parentMedia.length && childMedia.length) return childMedia
|
|---|
| 7 | if (parentMedia.length && !childMedia.length) return parentMedia
|
|---|
| 8 | if (!parentMedia.length && !childMedia.length) return []
|
|---|
| 9 |
|
|---|
| 10 | const media = []
|
|---|
| 11 |
|
|---|
| 12 | parentMedia.forEach(parentItem => {
|
|---|
| 13 | const parentItemStartsWithKeyword = startsWithKeywordRegexp.test(parentItem)
|
|---|
| 14 |
|
|---|
| 15 | childMedia.forEach(childItem => {
|
|---|
| 16 | const childItemStartsWithKeyword = startsWithKeywordRegexp.test(childItem)
|
|---|
| 17 | if (parentItem !== childItem) {
|
|---|
| 18 | if (childItemStartsWithKeyword && !parentItemStartsWithKeyword) {
|
|---|
| 19 | media.push(`${childItem} and ${parentItem}`)
|
|---|
| 20 | } else {
|
|---|
| 21 | media.push(`${parentItem} and ${childItem}`)
|
|---|
| 22 | }
|
|---|
| 23 | }
|
|---|
| 24 | })
|
|---|
| 25 | })
|
|---|
| 26 |
|
|---|
| 27 | return media
|
|---|
| 28 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.