This file contains hidden or 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
Задача №1 | |
Ниже приведен пример создания dom-элемента div со вложенными ссылками: | |
const googleLink = document.createElement('a'); | |
firstLink.innerText = 'google'; | |
firstLink.href = 'http://www.google.com'; | |
const facebookLink = document.createElement('a'); |
This file contains hidden or 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
import { adapterFactory } from 'webrtc-adapter/src/js/adapter_factory'; | |
import JsSIP from '@krivega/jssip'; | |
adapterFactory({ window }); | |
const onUnloadPage = handler => { | |
window.addEventListener('unload', handler); | |
}; | |
const fetchSipIP = async serverUrl => { | |
const response = await fetch(serverUrl); |
This file contains hidden or 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
class Car { | |
start(typeEngine) { | |
const engine = this.createEngine(typeEngine); | |
engine.start(); | |
} | |
createEngine(typeEngine) { | |
throw new Error('You have to implement the method createEngine!'); | |
} |
This file contains hidden or 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
class Car { | |
start(typeEngine) { | |
const engine = this.createEngine(typeEngine); | |
engine.start(); | |
} | |
createEngine(typeEngine) { | |
throw new Error('You have to implement the method createEngine!'); | |
} |
This file contains hidden or 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
class Car { | |
start(typeEngine) { | |
let engine; | |
if (typeEngine === 'Jet') { | |
engine = new Jet(); | |
} else if (typeEngine === 'Gas') { | |
engine = new Gas(); | |
} else { | |
engine = new Brayton(); |
This file contains hidden or 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
const resolveEventHandler = parser => callback => event => { | |
const value = parser(event); | |
if (value !== undefined) { | |
callback(value); | |
} | |
}; | |
const isValid = value => !!value; | |
const validateEventHandler = resolveEventHandler(value => { |
This file contains hidden or 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
const resolveEventHandler = parser => (callback = noop) => event => { | |
if (parser && callback !== noop) { | |
const value = parser(event); | |
if (value !== undefined) { | |
callback(value); | |
} | |
} else { | |
callback(event); | |
} |
This file contains hidden or 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 withObserve(ClassRef) { | |
return class extends ClassRef { | |
#handlers = []; | |
observe(handler) { | |
this.#handlers.push(handler); | |
} | |
unobserve(handler) { | |
this.#handlers = this.#handlers.filter(item => item !== handler); |
This file contains hidden or 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
class ConnectInfo { | |
#handlers = []; | |
isConnected = false; | |
observe(handler) { | |
this.#handlers.push(handler); | |
} | |
unobserve(handler) { |
This file contains hidden or 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
class CallAction { | |
activate() { | |
console.log('CallAction is active!'); | |
} | |
deactivate() { | |
console.log('CallAction is inactive!'); | |
} | |
} |
NewerOlder