Best JavaScript code snippet using root
wdnative-1.0.js
Source:wdnative-1.0.js
1/**2 * wdnative.js3 * version -> 1.14 *5 * wdnative.callFun(funName, data) -> è°ç¨APPå½æ°6 * @ arguments --> funName {function} æ¹æ³å7 * @ arguments --> data {object} æ°æ®å¯¹è±¡8 * @ return --> null9 * @ creat in version 1.010 *11 * wdnative.openApp() -> å¤éAPP12 * @ return null13 * @ creat in version 1.014 */15//wdNative16window.wdNative = {};17//init18wdNative.init = function(){19 wdNative.onload();20};21//onload22wdNative.onload = function(){};23//对androidçå±æ§24wdNative.forandroid = {25 openAppUrl: 'weidai://openapp',26 appDownloadUrl: 'http://oss.weidai.com.cn/weidaiwang-release.apk'27};28//对iosçå±æ§29wdNative.forios = {30 // openAppUrl: 'WdaiIOSDev://cn.com.weidai.wd',31 openAppUrl: 'weidai://',32 appDownloadUrl: 'https://itunes.apple.com/us/app/wei-dai-wang-hu-lian-wang/id914404898?l=zh&ls=1&mt=8'33};34//è°ç¨nativeæ¹æ³35wdNative.callFun = function(funName, data) {36 if (window.android) {37 window.android.WDJSCallNative(funName, JSON.stringify(data));38 //window.androidLocalFunction(funName, data);39 return false;40 }41 if ('ios' in wdNative) {42 wdNative.ios.callFun(funName, data);43 return false;44 }45}46wdNative.downloadApp = function(){47 var u = navigator.userAgent;48 var isios = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //iosç»ç«¯49 var isandroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //androidç»ç«¯æè
ucæµè§å¨50 var downloadUrl = 'https://m.weidai.com.cn/weixin/registerDown4';51 if (isandroid) {52 //android53 downloadUrl = wdNative.forandroid.appDownloadUrl;54 }55 if (isios) {56 //ios57 downloadUrl = wdNative.forios.appDownloadUrl;58 }59 window.location = downloadUrl;60}61//appå¤é¨å¼å¯app62wdNative.openApp = function() {63 var u = navigator.userAgent;64 var isios = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //iosç»ç«¯65 var isandroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //androidç»ç«¯æè
ucæµè§å¨66 var openUrl = 'https://m.weidai.com.cn/weixin/registerDown4';67 function is_weixn() {68 var ua = navigator.userAgent.toLowerCase();69 if (ua.match(/MicroMessenger/i) == "micromessenger") {70 return true;71 } else {72 return false;73 }74 }75 if (is_weixn()) {76 window.location = openUrl;77 return false;78 }79 if (isandroid) {80 //android81 window.open(wdNative.forandroid.openAppUrl, '_blank');82 }83 if (isios) {84 //ios85 window.location = wdNative.forios.openAppUrl;86 }87}88function setupWebViewJavascriptBridge(callback) {89 if (window.WebViewJavascriptBridge) {90 return callback(WebViewJavascriptBridge);91 }92 if (window.WVJBCallbacks) {93 return window.WVJBCallbacks.push(callback);94 }95 window.WVJBCallbacks = [callback];96 var WVJBIframe = document.createElement('iframe');97 WVJBIframe.style.display = 'none';98 WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';99 document.documentElement.appendChild(WVJBIframe);100 setTimeout(function() {101 document.documentElement.removeChild(WVJBIframe)102 }, 0)103}104setupWebViewJavascriptBridge(function(bridge) {105 //alert(bridge);106 wdNative.ios = {107 jsonForIos: '',108 callFun: ''109 }110 wdNative.ios.jsonForIos = {111 methodName: '',112 params: {}113 }114 wdNative.ios.callFun = function(funName, data) {115 wdNative.ios.jsonForIos.methodName = funName;116 wdNative.ios.jsonForIos.params = data ? data : '';117 bridge.callHandler('WDJSCallNative', wdNative.ios.jsonForIos);118 }119 bridge.registerHandler('WDNativeCallJS', function(data) {120 console.info('ioså¼å«js: ' + data);121 });122 wdNative.init();123})124var wdNativeTimmer = setTimeout(function(){125 if(window.android){126 wdNative.init();127 }128 clearTimeout(wdNativeTimmer);...
View.js
Source:View.js
1import React from 'react';2import useSound from 'use-sound';3import ForIOS from './../../views/ForIOS/ForIOS';4import Question from './../../views/Question/Question';5import SetLanguage from './../../views/SetLanguage/SetLanguage';6import Intro from '../../views/Intro/Intro';7import Level from './../../views/Level/Level';8import Score from './../../views/Score/Score';9import QuestionSong from '../../views/QuestionSong/QuestionSong';10import introSound from '../../../assets/Sounds/Intro.mp3';11const View = ({lastESCYear, text, languageHandler, level, currentView, levelHandler, periodHandler, period, quizHandler, questionSongIsLoading, currentQuestion, questionNumber, viewHandler, animHandler, questionChangeHandler, scoreHandler, score}) => {12 const [playIntroSound, {stop}] = useSound(introSound);13 const ua = navigator.userAgent;14 const info = {15 browser: /Edge\/\d+/.test(ua) ? 'ed' : /MSIE 9/.test(ua) ? 'ie9' : /MSIE 10/.test(ua) ? 'ie10' : /MSIE 11/.test(ua) ? 'ie11' : /MSIE\s\d/.test(ua) ? 'ie?' : /rv:11/.test(ua) ? 'ie11' : /Firefox\W\d/.test(ua) ? 'ff' : /Chrom(e|ium)\W\d|CriOS\W\d/.test(ua) ? 'gc' : /\bSafari\W\d/.test(ua) ? 'sa' : /\bOpera\W\d/.test(ua) ? 'op' : /\bOPR\W\d/i.test(ua) ? 'op' : typeof MSPointerEvent !== 'undefined' ? 'ie?' : '',16 os: /Mac/.test(ua) ? "mac" : "",17 };18 const displayLoaderforQS = (songIsLoading) => {19 let questionSongDisplay = 'flex'20 if (songIsLoading === false ) questionSongDisplay = 'none'21 return questionSongDisplay;22 }23 if(info.os === "mac" && info.browser !== 'gc')24 return (25 <ForIOS/>26 );27 else if (currentView === 'start')28 return (29 <SetLanguage viewHandler={viewHandler} languageHandler={languageHandler}/>30 );31 else if (currentView === 'intro')32 return (33 <Intro text={text.intro} viewHandler={viewHandler} playBgMusic={playIntroSound}/>34 );35 else if (currentView === 'level')36 return (37 <Level text={text.level} lastESCYear={lastESCYear} viewHandler={viewHandler} levelHandler={levelHandler} periodHandler={periodHandler} quizHandler={quizHandler} stopBgMusic={stop}/>38 );39 else if (currentView === 'question song')40 return (41 <QuestionSong stopBgMusic={stop} displayLoader={displayLoaderforQS(questionSongIsLoading)} animHandler={animHandler} viewHandler={viewHandler} songId={currentQuestion.id} playerStart={currentQuestion.playerStart} playerEnd={currentQuestion.playerEnd}/>42 );43 else if (currentView === 'question')44 return (45 <Question text={text.question} level={level} period={period} question={currentQuestion} questionNumber={questionNumber} questionChangeHandler={questionChangeHandler} scoreHandler={scoreHandler}/>46 );47 else if (currentView === 'score')48 return (49 <Score text={text.score} score={score} viewHandler={viewHandler} scoreHandler={scoreHandler}/>50 );51}...
utils.ts
Source:utils.ts
1import { TextStyle } from 'react-native';2import { groupWith, pipe, map, type } from 'ramda';3import isIOS from 'shared/utils/isIOS';4import { ReactNode } from 'react';5export function checkInRange(source: number, from: number, to: number) {6 return source > from && source < to;7}8export function toAlphabetLowerCase(souce: string) {9 return souce10 .normalize('NFD')11 .replace(/[\u0300-\u036f]/g, '')12 .replace(/[ÄÄ]/g, m => (m === 'Ä' ? 'd' : 'D'))13 .toLowerCase();14}15export function getInputFakePaddingVerticalValue(value: string): TextStyle['paddingVertical'] {16 const checkTextMultipeLine = /\n/g.test(value);17 const forIos = 7;18 const forAndroid = checkTextMultipeLine ? 5 : 10;19 return isIOS ? forIos : forAndroid;20}21export function joinStringInArray(source: ReactNode[]) {22 return pipe(23 groupWith<ReactNode>((x, y) => type(x) === 'String' && type(y) === 'String'),24 map<ReactNode[], ReactNode>(item => (item.length === 1 ? item[0] : item.join(''))),25 )(source);...
Using AI Code Generation
1import React from 'react';2import {View, Text} from 'react-native';3import {createAppContainer} from 'react-navigation';4import {createStackNavigator} from 'react-navigation-stack';5import HomeScreen from './HomeScreen';6import DetailsScreen from './DetailsScreen';7const RootStack = createStackNavigator(8 {9 Home: {10 },11 Details: {12 },13 },14 {15 defaultNavigationOptions: {16 headerStyle: {17 },18 headerTitleStyle: {19 },20 },21 },22 {23 },24);25const AppContainer = createAppContainer(RootStack);26export default class App extends React.Component {27 render() {28 return <AppContainer />;29 }30}31import React from 'react';32import {View, Text, Button} from 'react-native';33export default class HomeScreen extends React.Component {34 render() {35 return (36 <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>37 onPress={() => this.props.navigation.navigate('Details')}38 );39 }40}41import React from 'react';42import {View, Text} from 'react-native';43export default class DetailsScreen extends React.Component {44 render() {45 return (46 <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>47 );48 }49}50import React from 'react';51import {View, Text} from 'react-native';52import {createAppContainer} from 'react-navigation';53import {createStackNavigator} from 'react-navigation-stack';54import HomeScreen from './HomeScreen';55import DetailsScreen from './DetailsScreen';56const RootStack = createStackNavigator(57 {58 Home: {59 },60 Details: {61 },62 },63 {
Using AI Code Generation
1import React, { Component } from 'react';2import { AppRegistry, View, Text } from 'react-native';3class App extends Component {4 render() {5 return (6 );7 }8}9AppRegistry.registerComponent('albums', () => App);10import React from 'react';11import { Text } from 'react-native';12const Header = () => {13 return <Text>Albums!</Text>;14};15export default Header;16import React, { Component } from 'react';17import { AppRegistry, View } from 'react-native';18import Header from './components/Header';19class App extends Component {20 render() {21 return (22 );23 }24}25AppRegistry.registerComponent('albums', () => App);26 - `shadowOffset`: `{ width: 0, height: 2 }`
Using AI Code Generation
1import React, { Component } from 'react';2import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';3import { createAppContainer } from 'react-navigation';4import { createStackNavigator } from 'react-navigation-stack';5import { createDrawerNavigator, DrawerItems } from 'react-navigation-drawer';6import { createBottomTabNavigator } from 'react-navigation-tabs';7import { createMaterialTopTabNavigator } from 'react-navigation-tabs';8import { createSwitchNavigator } from 'react-navigation';9import { Icon } from 'react-native-elements';10import { SafeAreaView } from 'react-navigation';11import { ScrollView } from 'react-native-gesture-handler';12import { connect } from 'react-redux';13import { fetchDishes, fetchComments, fetchPromos, fetchLeaders } from './redux/ActionCreators';14import { baseUrl } from './shared/baseUrl';15import Home from './components/HomeComponent';16import Menu from './components/MenuComponent';17import Contact from './components/ContactComponent';18import About from './components/AboutComponent';19import Dishdetail from './components/DishdetailComponent';20import Reservation from './components/ReservationComponent';21import Favorites from './components/FavoriteComponent';22import Login from './components/LoginComponent';23import NetInfo from '@react-native-community/netinfo';24import { Loading } from './components/LoadingComponent';25import * as Animatable from 'react-native-animatable';26import { Notifications } from 'expo';27import * as Permissions from 'expo-permissions';28const mapDispatchToProps = dispatch => ({29 fetchDishes: () => dispatch(fetchDishes()),30 fetchComments: () => dispatch(fetchComments()),31 fetchLeaders: () => dispatch(fetchLeaders()),32 fetchPromos: () => dispatch(fetchPromos())33});34const MenuNavigator = createStackNavigator({35 Menu: { screen: Menu,36 navigationOptions: ({ navigation }) => ({37 headerLeft: <Icon name='menu' size={24}38 onPress={() => navigation.toggleDrawer()} />39 }) },40 Dishdetail: { screen: Dish
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!!