Best JavaScript code snippet using root
unlock.js
Source: unlock.js
1const inherits = require('util').inherits2const Component = require('react').Component3const h = require('react-hyperscript')4const connect = require('react-redux').connect5const actions = require('../../ui/app/actions')6const getCaretCoordinates = require('textarea-caret')7const EventEmitter = require('events').EventEmitter8const Mascot = require('./components/mascot')9module.exports = connect(mapStateToProps)(UnlockScreen)10inherits(UnlockScreen, Component)11function UnlockScreen () {12 Component.call(this)13 this.animationEventEmitter = new EventEmitter()14}15function mapStateToProps (state) {16 return {17 warning: state.appState.warning,18 }19}20UnlockScreen.prototype.render = function () {21 const state = this.props22 const warning = state.warning23 return (24 h('.flex-column', {25 style: {26 width: 'inherit',27 },28 }, [29 h('.unlock-screen.flex-column.flex-center.flex-grow', [30 h(Mascot, {31 animationEventEmitter: this.animationEventEmitter,32 }),33 h('h1', {34 style: {35 fontSize: '1.4em',36 textTransform: 'uppercase',37 color: '#7F8082',38 },39 }, 'MetaMask'),40 h('input.large-input', {41 type: 'password',42 id: 'password-box',43 placeholder: 'enter password',44 style: {45 },46 onKeyPress: this.onKeyPress.bind(this),47 onInput: this.inputChanged.bind(this),48 }),49 h('.error', {50 style: {51 display: warning ? 'block' : 'none',52 padding: '0 20px',53 textAlign: 'center',54 },55 }, warning),56 h('button.primary.cursor-pointer', {57 onClick: this.onSubmit.bind(this),58 style: {59 margin: 10,60 },61 }, 'Log In'),62 ]),63 h('.flex-row.flex-center.flex-grow', [64 h('p.pointer', {65 onClick: () => this.props.dispatch(actions.forgotPassword()),66 style: {67 fontSize: '0.8em',68 color: 'rgb(247, 134, 28)',69 textDecoration: 'underline',70 },71 }, 'Restore from seed phrase'),72 ]),73 ])74 )75}76UnlockScreen.prototype.componentDidMount = function () {77 document.getElementById('password-box').focus()78}79UnlockScreen.prototype.onSubmit = function (event) {80 const input = document.getElementById('password-box')81 const password = input.value82 this.props.dispatch(actions.tryUnlockMetamask(password))83}84UnlockScreen.prototype.onKeyPress = function (event) {85 if (event.key === 'Enter') {86 this.submitPassword(event)87 }88}89UnlockScreen.prototype.submitPassword = function (event) {90 var element = event.target91 var password = element.value92 // reset input93 element.value = ''94 this.props.dispatch(actions.tryUnlockMetamask(password))95}96UnlockScreen.prototype.inputChanged = function (event) {97 // tell mascot to look at page action98 var element = event.target99 var boundingRect = element.getBoundingClientRect()100 var coordinates = getCaretCoordinates(element, element.selectionEnd)101 this.animationEventEmitter.emit('point', {102 x: boundingRect.left + coordinates.left - element.scrollLeft,103 y: boundingRect.top + coordinates.top - element.scrollTop,104 })...
lockscreen_media_playback_test.js
...21 checks = (new LockScreenMediaPlaybackChecks()).start(client);22 });23 test('should show now playing info', function() {24 actions25 .unlockScreen()26 .openMusicApp()27 .playAlbumOne()28 .lockScreen();29 checks30 .containerShown(true)31 .nowPlayingText('Some Song', 'Some Artist');32 });33 test('should hide now playing info by stopping', function() {34 actions35 .unlockScreen()36 .openMusicApp()37 .playAlbumOne()38 .stopPlay()39 .lockScreen();40 checks41 .containerShown(false);42 });43 test('should hide now playing info by exiting', function() {44 actions45 .unlockScreen()46 .openMusicApp()47 .playAlbumOne()48 .lockScreen();49 checks50 .containerShown(true);51 actions52 .killMusicApp();53 checks54 .containerShown(false);55 });56 test('should update play/pause icon correctly', function() {57 actions58 .unlockScreen()59 .openMusicApp()60 .playAlbumOne()61 .lockScreen();62 checks63 .containerShown(true)64 .isPlaying(true);65 actions66 .unlockScreen()67 .switchToMusicApp()68 .togglePausePlay()69 .lockScreen();70 checks71 .isPlaying(false);72 actions73 .unlockScreen()74 .switchToMusicApp()75 .togglePausePlay()76 .lockScreen();77 checks78 .isPlaying(true);79 });80 test('should hide controls when interrupted', function() {81 actions82 .unlockScreen()83 .openMusicApp()84 .playAlbumOne()85 .lockScreen();86 checks87 .containerShown(true)88 .isPlaying(true);89 actions90 .unlockScreen()91 .switchToMusicApp()92 .interruptMusic()93 .lockScreen();94 checks95 .containerShown(false);96 actions97 .unlockScreen()98 .switchToMusicApp()99 .interruptMusic()100 .lockScreen();101 checks102 .containerShown(true);103 });...
Using AI Code Generation
1var activity = Ti.Android.currentActivity;2activity.unlockScreen();3### `lockScreen()`4var activity = Ti.Android.currentActivity;5activity.lockScreen();6### `getRequestedOrientation()`7var activity = Ti.Android.currentActivity;8var orientation = activity.getRequestedOrientation();9### `setRequestedOrientation()`10var activity = Ti.Android.currentActivity;11activity.setRequestedOrientation(Ti.Android.SCREEN_ORIENTATION_LANDSCAPE);12### `getRequestedOrientation()`13var activity = Ti.Android.currentActivity;14var orientation = activity.getRequestedOrientation();15### `getResources()`16var activity = Ti.Android.currentActivity;17var resources = activity.getResources();18### `getSystemService()`19var activity = Ti.Android.currentActivity;20var service = activity.getSystemService(Ti.Android.KEYGUARD_SERVICE);21### `getTaskId()`
Check out the latest blogs from LambdaTest on this topic:
This article is a part of our Content Hub. For more in-depth resources, check out our content hub on WebDriverIO Tutorial and Selenium Locators Tutorial.
Cypress is a new yet upcoming automation testing tool that is gaining prominence at a faster pace. Since it is based on the JavaScript framework, it is best suited for end-to-end testing of modern web applications. Apart from the QA community, Cypress can also be used effectively by the front-end engineers, a requirement that cannot be met with other test automation frameworks like Selenium.
Modernizr is an open-source and compact JavaScript library that allows developers to craft various levels of experiences for users depending with respect to cross browser compatibility. Modernizr helps developers to perform cross browser testing to check whether new generation HTML5 and CSS3 features are natively supported by their visitor’s browsers or not and to provide dedicated fallbacks for older browsers that are notorious for their poor feature support. Modernizr coupled with the principle of progressive enhancement helps to design cutting-edge websites layer after layer taking advantage of powerful modern web technologies without discarding users still using older browsers like IE.
Jenkins is an open-source and extensible continuous integration and continuous deployment server. It is used to automate the process of continuous integration and continuous deployment(CI/CD). The importance of monitoring remote jobs and interacting with team members for stable code is immense; Jenkins takes care of all these requirements and allows a smooth integration via plugins, pipelines, and Jenkins environment variables.
What is the key to achieving sustainable and dramatic speed gains for your business? Product velocity! It’s important to stay on top of changes in your quality metrics, and to modify your processes (if needed) so that they reflect current reality. The pace of delivery will increase when you foster simple, automated processes for building great software. The faster you push into production, the sooner you can learn and adapt. Monitoring your build and release pipeline is an important part of those efforts. It helps you design better software, which in turn leads to improved product velocity. Moving fast takes a lot of practice, a lot of hard work, and a toolkit that can help you achieve this!
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!