| 54 | } |
| 55 | |
| 56 | static getSolutionsHelper ({ targetLangs, allSolutions }) { |
| 57 | const solutions = [] |
| 58 | for (const lang of Array.from(targetLangs)) { |
| 59 | let s |
| 60 | if (lang === 'html') { |
| 61 | for (s of Array.from(allSolutions)) { |
| 62 | if (s.language === 'html') { |
| 63 | const strippedSource = utils.extractPlayerCodeTag(s.source || '') |
| 64 | if (strippedSource) { s.source = strippedSource } |
| 65 | solutions.push(s) |
| 66 | } |
| 67 | } |
| 68 | } else if ((lang !== 'javascript') && !_.find(allSolutions, { language: lang })) { |
| 69 | for (s of Array.from(allSolutions)) { |
| 70 | if (s.language === 'javascript') { |
| 71 | const translatedSolution = _.cloneDeep(s) |
| 72 | translatedSolution.language = lang |
| 73 | translatedSolution.source = translateUtils.translateJS(s.source, lang) |
| 74 | solutions.push(translatedSolution) |
| 75 | } |
| 76 | } |
| 77 | } else { |
| 78 | for (s of Array.from(allSolutions)) { |
| 79 | if (s.language === lang) { |
| 80 | solutions.push(s) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | return solutions |
| 86 | } |
| 87 | |
| 88 | fingerprint (code, language) { |
| 89 | // Add a zero-width-space at the end of every comment line |