Best JavaScript code snippet using playwright-internal
zh.js
Source:zh.js
1module.exports = {2 "UI/DIE NUM": "æ»äº¡æ¬¡æ° : ",3 4 "TestList.fire.30": "è¿åå表",5 "TestList.fire.37": "æ¥ç说æ",6 "cases/01_graphics/01_sprite/AtlasSprite.fire.7": "è¿ä¸ªç²¾çµæ¥èªåå¼ å¾ç",7 "cases/01_graphics/01_sprite/AtlasSprite.fire.11": "è¿ä¸ªç²¾çµæ¥èªå¾é",8 "cases/01_graphics/01_sprite/FilledSprite.fire.9": "å¡«å
ç±»åï¼æ°´å¹³",9 "cases/01_graphics/01_sprite/FilledSprite.fire.15": "å¡«å
ç±»åï¼åç´",10 "cases/01_graphics/01_sprite/FilledSprite.fire.23": "å¡«å
ç±»åï¼åå½¢",11 "cases/01_graphics/01_sprite/SimpleSprite.fire.7": "è¿æ¯æ®éç²¾çµ",12 "cases/01_graphics/01_sprite/SlicedSprite.fire.7": "è¿æ¯ä¹å®«æ ¼ç²¾çµ",13 "cases/01_graphics/01_sprite/TiledSprite.fire.6": "è¿æ¯å¹³éºç²¾çµ",14 "cases/01_graphics/01_sprite/TrimmedSprite.fire.7": "èªå¨åªè£ ",15 "cases/01_graphics/01_sprite/TrimmedSprite.fire.12": "æªèªå¨åªè£",16 "cases/01_graphics/02_particle/AutoRemoveParticle.fire.9": "ç²å 1\n\"å®ææ¶èªå¨ç§»é¤\" ç¦æ¢",17 "cases/01_graphics/02_particle/AutoRemoveParticle.fire.13": "ç²å 2\n\"å®ææ¶èªå¨ç§»é¤\" å¼å¯",18 "cases/01_graphics/02_particle/ToggleParticle.fire.6": "æ \"æé®\" è¿è¡å¼å
³ç²åææ¾",19 "cases/02_ui/01_widget/AdvancedWidget.fire.7": "å·¦ä¸",20 "cases/02_ui/01_widget/AdvancedWidget.fire.9": "top: 10% left: 6%",21 "cases/02_ui/01_widget/AdvancedWidget.fire.14": "ä¸",22 "cases/02_ui/01_widget/AdvancedWidget.fire.16": "top: -34px",23 "cases/02_ui/01_widget/AdvancedWidget.fire.21": "å³ä¸",24 "cases/02_ui/01_widget/AdvancedWidget.fire.23": "top: 10% right: 6%",25 "cases/02_ui/01_widget/AdvancedWidget.fire.28": "å·¦",26 "cases/02_ui/01_widget/AdvancedWidget.fire.30": "left: -50px",27 "cases/02_ui/01_widget/AdvancedWidget.fire.35": "å³",28 "cases/02_ui/01_widget/AdvancedWidget.fire.37": "right: -50px",29 "cases/02_ui/01_widget/AdvancedWidget.fire.42": "å·¦ä¸",30 "cases/02_ui/01_widget/AdvancedWidget.fire.44": "bottom: 10% left: 6%",31 "cases/02_ui/01_widget/AdvancedWidget.fire.49": "ä¸",32 "cases/02_ui/01_widget/AdvancedWidget.fire.51": "bottom: -34px",33 "cases/02_ui/01_widget/AdvancedWidget.fire.56": "å³ä¸",34 "cases/02_ui/01_widget/AdvancedWidget.fire.58": "bottom:10% right:6%",35 "cases/02_ui/01_widget/AdvancedWidget.fire.63": "é«çº§æ件",36 "cases/02_ui/01_widget/AlignOnceWidget.fire.1": "AlignOne 为 false æ¶ï¼ä¼ä¸ç´ä¿æ对é½",37 "cases/02_ui/01_widget/AlignOnceWidget.fire.2": "AlignOne 为 true æ¶ï¼åªå¨ Widget çææ¶å¯¹é½ä¸æ¬¡",38 "cases/02_ui/01_widget/AnimatedWidget.fire.9": "å¨ç»æ件ã",39 "cases/02_ui/01_widget/WidgetAlign.fire.18": "æ件对é½æ¹å¼ã",40 "cases/02_ui/01_widget/AutoResize.fire.13": "æ件èªå¨è°æ´å¤§å°ã",41 "cases/02_ui/02_label/GoldBeatingAnime.js.1": "0",42 "cases/02_ui/02_label/AlignFontLabel.fire.6": "ææ¬å¯¹é½",43 "cases/02_ui/02_label/AlignFontLabel.fire.9": "水平对é½",44 "cases/02_ui/02_label/AlignFontLabel.fire.14": "åå°ï¼\n欢è¿ä½¿ç¨ \nCocos Creator",45 "cases/02_ui/02_label/AlignFontLabel.fire.16": "对é½: é å·¦",46 "cases/02_ui/02_label/AlignFontLabel.fire.21": "åå°ï¼\n欢è¿ä½¿ç¨ \nCocos Creator",47 "cases/02_ui/02_label/AlignFontLabel.fire.23": "对é½: å±
ä¸",48 "cases/02_ui/02_label/AlignFontLabel.fire.28": "åå°ï¼\n欢è¿ä½¿ç¨ \nCocos Creator",49 "cases/02_ui/02_label/AlignFontLabel.fire.30": "对é½: é å³",50 "cases/02_ui/02_label/AlignFontLabel.fire.33": "åç´å¯¹é½",51 "cases/02_ui/02_label/AlignFontLabel.fire.38": "欢è¿ä½¿ç¨ \nCocos Creator",52 "cases/02_ui/02_label/AlignFontLabel.fire.40": "对é½: 顶é¨",53 "cases/02_ui/02_label/AlignFontLabel.fire.45": "欢è¿ä½¿ç¨ \nCocos Creator",54 "cases/02_ui/02_label/AlignFontLabel.fire.47": "对é½: å±
ä¸",55 "cases/02_ui/02_label/AlignFontLabel.fire.52": "欢è¿ä½¿ç¨ \nCocos Creator",56 "cases/02_ui/02_label/AlignFontLabel.fire.54": "对é½: åºé¨",57 "cases/02_ui/02_label/SystemFontLabel.fire.6": "ç³»ç»åä½",58 "cases/02_ui/02_label/SystemFontLabel.fire.9": "æ¢è¡",59 "cases/02_ui/02_label/SystemFontLabel.fire.14": "è¿æ¯ç³»ç»é»è®¤åä½",60 "cases/02_ui/02_label/SystemFontLabel.fire.16": "Overflow: CLAMP",61 "cases/02_ui/02_label/SystemFontLabel.fire.21": "è¿æ¯ç³»ç»é»è®¤åä½",62 "cases/02_ui/02_label/SystemFontLabel.fire.23": "Overflow: SHRINK",63 "cases/02_ui/02_label/SystemFontLabel.fire.26": "ä¸æ¢è¡",64 "cases/02_ui/02_label/SystemFontLabel.fire.31": "è¿æ¯ç³»ç»é»è®¤åä½",65 "cases/02_ui/02_label/SystemFontLabel.fire.33": "Overflow: CLAMP",66 "cases/02_ui/02_label/SystemFontLabel.fire.38": "è¿æ¯ç³»ç»é»è®¤åä½",67 "cases/02_ui/02_label/SystemFontLabel.fire.40": "Overflow: SHRINK",68 "cases/02_ui/02_label/SystemFontLabel.fire.45": "åå½! 欢è¿ä½¿ç¨ Cocos Creator",69 "cases/02_ui/02_label/SystemFontLabel.fire.47": "Overflow: RESZIE_HEIGHT",70 "cases/02_ui/03_button/ButtonInScroll.js.1": "顶é¨æé®è¢«ç¹å»ï¼",71 "cases/02_ui/03_button/ButtonInScroll.js.2": "åºé¨æé®è¢«ç¹å»ï¼",72 "cases/02_ui/03_button/ButtonInScroll.fire.21": "åªä¸ªæé®è¢«ç¹å»ï¼",73 "cases/02_ui/03_button/ButtonInScroll.fire.27": "æå¨æ¾ç¤ºæ´å¤æé®\n\n",74 "cases/02_ui/03_button/SimpleButton.js.1": "左边çæé®è¢«ç¹å»ï¼",75 "cases/02_ui/03_button/SimpleButton.js.2": "å³è¾¹çæé®è¢«ç¹å»ï¼",76 "cases/02_ui/03_button/ButtonInteractable.fire.7": "ææ¾",77 "cases/02_ui/03_button/ButtonInteractable.fire.16": "åæ¢",78 "cases/02_ui/03_button/ButtonInteractable.fire.21": "交äº(interactable): true",79 "cases/02_ui/03_button/ButtonInteractable.fire.23": "交äº(interactable): false",80 "cases/02_ui/03_button/ButtonInteractable.js.1": "交äº(interactable): ",81 "cases/02_ui/03_button/ButtonInteractable.js.2": "交äº(interactable): ",82 "cases/02_ui/03_button/SimpleButton.fire.6": "åªä¸ªæé®è¢«ç¹å»ï¼",83 "cases/02_ui/05_scrollView/Item.js.1": "Tmpl#",84 "cases/02_ui/04_progressbar/progressbar.fire.7": "æ°´å¹³è¿åº¦æ¡ï¼è¿åº¦ 0.3",85 "cases/02_ui/04_progressbar/progressbar.fire.11": "ååæ°´å¹³è¿åº¦æ¡ï¼è¿åº¦ 1.0",86 "cases/02_ui/04_progressbar/progressbar.fire.15": "åç´è¿åº¦æ¡ \nä»ä¸åä¸",87 "cases/02_ui/04_progressbar/progressbar.fire.19": "åç´è¿åº¦æ¡ \nä»ä¸åä¸",88 "cases/02_ui/04_progressbar/progressbar.fire.23": "设置äºç²¾çµçè¿åº¦æ¡",89 "cases/02_ui/04_progressbar/progressbar.fire.28": "设置äºç²¾çµï¼åæ§ä»¶ï¼çè¿åº¦æ¡",90 "cases/02_ui/05_scrollView/ListView.fire.23": "Item #00",91 "cases/02_ui/05_scrollView/ScrollView.fire.7": "Scrollview å®æ´åè½",92 "cases/02_ui/05_scrollView/ScrollView.fire.30": "Scrollview 没ææ¯æ§",93 "cases/02_ui/05_scrollView/ScrollView.fire.53": "Scrollview 没æå¼¹æ§",94 "cases/02_ui/05_scrollView/ScrollView.fire.76": "Scrollview åªè½æ°´å¹³æ»å¨",95 "cases/02_ui/05_scrollView/ScrollView.fire.93": "Scrollview åªè½åç´æ»å¨",96 "cases/02_ui/05_scrollView/ScrollView.fire.110": "Scrollview 没ææ»å¨æ¡",97 "cases/02_ui/06_layout/LayoutInScrollView.fire.6": "ScrollView ååç´å¸å±å®¹å¨",98 "cases/02_ui/06_layout/LayoutInScrollView.fire.40": "ScrollView åæ°´å¹³å¸å±å®¹å¨",99 "cases/02_ui/06_layout/LayoutInScrollView.fire.74": "ScrollView å横åç½æ ¼å¸å±å®¹å¨ ",100 "cases/02_ui/06_layout/LayoutInScrollView.fire.144": "ScrollView å纵åç½æ ¼å¸å±å®¹å¨ ",101 "cases/02_ui/06_layout/LayoutResizeChildren.fire.6": "æ°´å¹³å¸å±å®¹å¨",102 "cases/02_ui/06_layout/LayoutResizeChildren.fire.31": "åç´å¸å±å®¹å¨",103 "cases/02_ui/06_layout/LayoutResizeChildren.fire.48": "横åç½æ ¼å¸å±å®¹å¨",104 "cases/02_ui/06_layout/LayoutResizeChildren.fire.85": "纵åç½æ ¼å¸å±å®¹å¨",105 "cases/02_ui/06_layout/LayoutResizeContainer.fire.6": "åºæ¬",106 "cases/02_ui/06_layout/LayoutResizeContainer.fire.31": "æ°´å¹³",107 "cases/02_ui/06_layout/LayoutResizeContainer.fire.36": "åç´",108 "cases/02_ui/06_layout/LayoutResizeContainer.fire.41": "横åç½æ ¼å¸å±å®¹å¨",109 "cases/02_ui/06_layout/LayoutResizeContainer.fire.46": "纵åç½æ ¼å¸å±å®¹å¨",110 "cases/02_ui/07_change_canvas_anchor/BottomLeftAnchor.fire.8": "x:0, y:0",111 "cases/02_ui/07_change_canvas_anchor/BottomLeftAnchor.fire.12": "x:480, y:320",112 "cases/02_ui/07_change_canvas_anchor/BottomLeftAnchor.fire.16": "x:960, y:640",113 "cases/02_ui/07_editBox/editbox.js.1": "è¾å
¥ææ¬: ",114 "cases/02_ui/06_layout/LayoutNone.fire.6": "åºæ¬å¸å±å®¹å¨, ç±»å: None\nèªå¨è°æ´å¤§å°",115 "cases/02_ui/06_layout/LayoutNone.fire.35": "æ°´å¹³å¸å±å®¹å¨ï¼ç±»å: None\nä¸èªå¨è°æ´å¤§å°",116 "cases/02_ui/06_layout/LayoutNone.fire.60": "åç´å¸å±å®¹å¨ï¼ç±»å: None\nä¸èªå¨è°æ´å¤§å°",117 "cases/02_ui/06_layout/LayoutNone.fire.77": "横åç½æ ¼å¸å±å®¹å¨ï¼ç±»å: None\nä¸èªå¨è°æ´å¤§å°",118 "cases/02_ui/06_layout/LayoutNone.fire.142": "纵åç½æ ¼å¸å±å®¹å¨ï¼ç±»å: None\nä¸èªå¨è°æ´å¤§å°",119 "cases/02_ui/07_editBox/EditBox.fire.25": "åè¡å¯ç æ¡:",120 "cases/02_ui/07_editBox/EditBox.fire.27": "åè¡ææ¬æ¡:",121 "cases/02_ui/07_editBox/EditBox.fire.29": "å¤è¡ææ¬æ¡:",122 "cases/02_ui/07_editBox/EditBox.fire.32": "ç¹å»",123 "cases/02_ui/07_editBox/EditBox.fire.38": "æé®å¿
é¡»å¨ EditBox çä¸é¢, \n并ä¸å®åºè¯¥å
许ç¹å».",124 "cases/03_gameplay/01_player_control/EventManager/KeyboardInput.fire.6": "æ 'A' æ 'D' é®æ§å¶å°ç»µç¾",125 "cases/03_gameplay/01_player_control/On/OnTouchCtrl.js.1": "touch (",126 "cases/03_gameplay/01_player_control/On/OnTouchInput.fire.10": "请触æ¸ä»»æä½ç½®è¯è¯",127 "cases/03_gameplay/01_player_control/On/OnMultiTouchInput.fire.20": "该ææåªè½å¨ç§»å¨å¹³å°ä¸ææï¼",128 "cases/03_gameplay/01_player_control/On/OnMultiTouchInput.fire.21": "ç¨ä½ çæææ¾ç¼©å¾çï¼",129 "cases/03_gameplay/02_actions/SimpleAction.fire.13": "ç®åçå¨ä½",130 "cases/03_gameplay/03_animation/AnimateCustomProperty.fire.14": "Label",131 "cases/03_gameplay/03_animation/AnimateCustomProperty.fire.18": "èªå®ä¹å¨ç»å±æ§",132 "cases/03_gameplay/03_animation/AnimationEvent.js.1": "å¼å§ç¬¬",133 "cases/03_gameplay/03_animation/AnimationEvent.fire.6": "å¼å§ç¬¬1个å¨ç»",134 "cases/03_gameplay/03_animation/AnimationEvent.fire.14": "å¨ç»äºä»¶",135 "cases/03_gameplay/03_animation/MoveAnimation.fire.11": "Linear",136 "cases/03_gameplay/03_animation/MoveAnimation.fire.17": "Case In Expo",137 "cases/03_gameplay/03_animation/MoveAnimation.fire.23": "Case Out Expo",138 "cases/03_gameplay/03_animation/MoveAnimation.fire.29": "Case Out In Expo",139 "cases/03_gameplay/03_animation/MoveAnimation.fire.35": "Back Forward",140 "cases/03_gameplay/03_animation/MoveAnimation.fire.41": "è¿æ¯ä¸ä¸ªç§»å¨å¨ç»ã",141 "cases/03_gameplay/03_animation/SpriteAnimation.fire.9": "è¿æ¯ç²¾çµå¸§å¨ç»",142 "cases/03_gameplay/03_animation/CreateClip.fire.1": "å¨æå建å¨ç»åªè¾",143 "cases/04_audio/SimpleAudio.fire.6": "享åé³ä¹!",144 "cases/05_scripting/01_properties/NodeArray.fire.14": "è¿æ¯èç¹æ°ç»",145 "cases/05_scripting/01_properties/NonSerialized.fire.6": "Label",146 "cases/05_scripting/01_properties/NonSerialized.fire.8": "Label",147 "cases/05_scripting/01_properties/NonSerialized.fire.10": "è¿æ¯éåºåå",148 "cases/05_scripting/01_properties/ReferenceType.fire.8": "Label",149 "cases/05_scripting/01_properties/ReferenceType.fire.11": "è¿ä¸ªä¾åä¸å
æ¬è¿è¡æ¶æ¼ç¤º",150 "cases/05_scripting/01_properties/ValueType.fire.6": "è¿ä¸ªä¾åä¸å
æ¬è¿è¡æ¶æ¼ç¤º",151 "cases/05_scripting/02_prefab/InstantiatePrefab.fire.7": "å®ä¾åé¢å¶èµæº",152 "cases/05_scripting/03_events/EventInMask.fire.23": "æ´æ¹èç¹æåº",153 "cases/05_scripting/03_events/SimpleEvent.fire.19": "触æ¸äºä»¶å¯ä»¥æ¯æç¹å»",154 "cases/05_scripting/03_events/SimpleEvent.fire.21": "é¼ æ äºä»¶å¯ä»¥æ¯æåå»ãæ¬åãæ»è½®",155 "cases/05_scripting/03_events/SimpleEvent.fire.23": "èªå®ä¹äºä»¶å¯ä»¥æå¨è§¦å\n(ç¹å»ä¸é¢çæé®)",156 "cases/05_scripting/03_events/SimpleEvent.fire.25": "åºæ¬äºä»¶",157 "cases/05_scripting/03_events/TouchPropagation.fire.15": "触æ¸äºä»¶å泡",158 "cases/05_scripting/04_scheduler/scheduleCallbacks.js.1": "5.00 s",159 "cases/05_scripting/04_scheduler/scheduler.fire.9": "5.00 s",160 "cases/05_scripting/04_scheduler/scheduler.fire.12": "éå¤å®æ¶å¨",161 "cases/05_scripting/04_scheduler/scheduler.fire.18": "åæ¶å®æ¶å¨",162 "cases/05_scripting/04_scheduler/scheduler.fire.24": "å®æ¶æ§è¡1次",163 "cases/05_scripting/04_scheduler/scheduler.fire.29": "ä½¿ç¨ update å½æ°æ¯å¸§æ´æ°è®¡æ°",164 "cases/05_scripting/04_scheduler/scheduler.fire.31": "å®æ¶å¨",165 "cases/05_scripting/05_cross_reference/CrossReference.fire.7": "Label",166 "cases/05_scripting/05_cross_reference/CrossReference.fire.12": "Label",167 "cases/05_scripting/05_cross_reference/CrossReference.fire.14": "交åå¼ç¨",168 "cases/05_scripting/06_life_cycle/life_cycle.fire.6": "çå½å¨æ",169 "cases/05_scripting/07_asset_loading/AssetLoading.fire.5": "èµæºå è½½",170 "cases/05_scripting/07_asset_loading/AssetLoading.fire.9": "å è½½ SpriteFrame",171 "cases/05_scripting/07_asset_loading/AssetLoading.fire.15": "å è½½ Texture",172 "cases/05_scripting/07_asset_loading/AssetLoading.fire.21": "å è½½ Audio",173 "cases/05_scripting/07_asset_loading/AssetLoading.fire.27": "å è½½ Txt",174 "cases/05_scripting/07_asset_loading/AssetLoading.fire.33": "å è½½ Font",175 "cases/05_scripting/07_asset_loading/AssetLoading.fire.39": "å è½½ Plist",176 "cases/05_scripting/07_asset_loading/AssetLoading.fire.45": "å è½½ Prefab",177 "cases/05_scripting/07_asset_loading/AssetLoading.fire.51": "å è½½ Scene",178 "cases/05_scripting/07_asset_loading/AssetLoading.fire.57": "å è½½ Animation",179 "cases/05_scripting/07_asset_loading/AssetLoading.fire.59": "å è½½ Spine",180 "cases/05_scripting/07_asset_loading/AssetLoading.fire.65": "å½åå°æ å è½½ã",181 "cases/05_scripting/07_asset_loading/AssetLoading.js.1": "å·²å è½½ ",182 "cases/05_scripting/07_asset_loading/AssetLoading.js.2": "ææ¾ ",183 "cases/05_scripting/07_asset_loading/AssetLoading.js.3": "å建 ",184 "cases/05_scripting/07_asset_loading/AssetLoading.js.4": "ææ¾é³ä¹ã",185 "cases/05_scripting/07_asset_loading/AssetLoading.js.5": "è¿æ¯åä½ï¼",186 "cases/05_scripting/07_asset_loading/LoadRes.fire.7": "æç±»å",187 "cases/05_scripting/07_asset_loading/LoadRes.fire.10": "å è½½ SpriteFrame",188 "cases/05_scripting/07_asset_loading/LoadRes.fire.17": "æ Url",189 "cases/05_scripting/07_asset_loading/LoadRes.fire.20": "å è½½é¢å¶èµæº",190 "cases/05_scripting/07_asset_loading/LoadResAll.fire.6": "è¿ä¸ªä¾åä¸å
æ¬è¿è¡æ¶æ¼ç¤º",191 "cases/05_scripting/07_asset_loading/LoadResAll.fire.24": "å
¨é¨å è½½",192 "cases/05_scripting/07_asset_loading/LoadResAll.fire.30": "å è½½å
¨é¨çSpriteFrame",193 "cases/05_scripting/07_asset_loading/LoadResAll.fire.36": "æ¸
空",194 "cases/05_scripting/08_module/load_module.fire.6": "å 载模å",195 "cases/05_scripting/08_module/load_module.fire.10": "å建æªç©",196 "cases/05_scripting/09_singleton/Singleton.fire.6": "è¿ä¾åä¸å
å«è¿è¡æ¶æ¼ç¤º",197 "cases/05_scripting/10_loadingBar/LoadingBarCtrl.js.1": "ä¸è½½å®æ!!",198 "cases/05_scripting/10_loadingBar/LoadingBarCtrl.js.2": "æ£å¨ä¸è½½: ",199 "cases/05_scripting/10_loadingBar/loadingBar.fire.7": "å è½½å®æ",200 "cases/05_scripting/10_loadingBar/loadingBar.fire.18": "æ£å¨ä¸è½½",201 "cases/05_scripting/11_network/NetworkCtrl.js.1": "请ç¨ç...",202 "cases/05_scripting/11_network/NetworkCtrl.js.2": "请ç¨ç...",203 "cases/05_scripting/11_network/NetworkCtrl.js.3": "请ç¨ç...",204 "cases/05_scripting/11_network/NetworkCtrl.js.4": "请ç¨ç...",205 "cases/05_scripting/11_network/NetworkCtrl.js.5": "WebSocket\nåéäºè¿å¶WSå·²æå¼.",206 "cases/05_scripting/11_network/NetworkCtrl.js.6": "WebSocket\næ¶å°ååº.",207 "cases/05_scripting/11_network/NetworkCtrl.js.7": "WebSocket\nåéäºè¿å¶éå°é误.",208 "cases/05_scripting/11_network/NetworkCtrl.js.8": "WebSocket\nwebsocket å®ä¾å·²å
³é.",209 "cases/05_scripting/11_network/NetworkCtrl.js.9": "WebSocket\nåéäºè¿å¶WSçå¾
ä¸...",210 "cases/05_scripting/11_network/NetworkCtrl.js.10": "WebSocket\n",211 "cases/05_scripting/11_network/NetworkCtrl.js.11": "SocketIO\n",212 "cases/05_scripting/11_network/NetworkCtrl.js.12": "SocketIO\n",213 "cases/05_scripting/11_network/NetworkCtrl.js.13": "SocketIO\n",214 "cases/05_scripting/11_network/NetworkCtrl.js.14": "SocketIO\n",215 "cases/05_scripting/11_network/network.fire.7": "Label",216 "cases/05_scripting/11_network/network.fire.6": "XMLHttpRequest",217 "cases/05_scripting/11_network/network.fire.11": "Label",218 "cases/05_scripting/11_network/network.fire.10": "XMLHttpRequest (ArrayBuffer)",219 "cases/05_scripting/11_network/network.fire.15": "Label",220 "cases/05_scripting/11_network/network.fire.14": "WebSocket",221 "cases/05_scripting/11_network/network.fire.19": "Label",222 "cases/05_scripting/11_network/network.fire.18": "SocketIO",223 "cases/native_call/native_call.fire.1": "JS to JAVA åå°åªå¨å®å移å¨å¹³å°ä¸æææï¼",224 "cases/native_call/native_call.fire.2": "ç¹å»æé®è°ç¨éææ¹æ³ï¼",225 "cases/native_call/native_call.fire.3": "ç¹å»",226 "cases/collider/Category.fire.3": "ç»: 碰æ",227 "cases/collider/Category.fire.5": "ç»: 碰æ",228 "cases/collider/Category.fire.7": "ç»: 碰æ",229 "cases/collider/Category.fire.9": "ç»: é»è®¤",230 "cases/collider/Shape.fire.20": "æ¾ç¤ºå¤è¾¹å½¢",231 "cases/collider/Shape.fire.27": "æ¾ç¤ºå",232 "cases/collider/Shape.fire.34": "æ¾ç¤ºçå",233 "cases/collider/Shape.fire.43": "æ¾ç¤ºå¤è¾¹å½¢",234 "cases/collider/Shape.fire.50": "æ¾ç¤ºå",235 "cases/collider/Shape.fire.57": "æ¾ç¤ºçå",236 "cases/motionStreak/MotionStreak.fire.1": "åªå¨ WebGL ç¯å¢ä¸çæï¼",237 "cases/motionStreak/MotionStreak.fire.2": "æ¹åæå°¾",238 "cases/spine/SpineBoy.fire.11": "è°è¯æ槽",239 "cases/spine/SpineBoy.fire.18": "è°è¯å
³è",240 "cases/spine/SpineBoy.fire.25": "æ¶é´ç¼©æ¾",241 "cases/spine/SpineBoy.fire.36": "åæ¢",242 "cases/spine/SpineBoy.fire.43": "èµ°",243 "cases/spine/SpineBoy.fire.50": "è·",244 "cases/spine/SpineBoy.fire.58": "è·³",245 "cases/spine/SpineBoy.fire.65": "å°å»",246 "cases/tiledmap/Puzzle.fire.18": "ä½ èµ¢äº",247 "cases/tiledmap/Puzzle.fire.21": "éæ°å¼å§",248 "res/prefabs/ListItem.prefab.2": "Label ssss",249 "res/prefabs/Monster.prefab.3": "åå:",250 "res/prefabs/Monster.prefab.11": "ç级 :",251 "res/prefabs/Monster.prefab.19": "è¡é :",252 "res/prefabs/Monster.prefab.27": "æ»å» :",253 "res/prefabs/Monster.prefab.35": "é²å¾¡ :",254 "res/prefabs/loadItem.prefab.1": "Label",255 "resources/test assets/prefab.prefab.2": "è¿æ¯ä¸ä¸ªé¢å¶",256 "resources/test assets/scene.fire.3": "è¿åèµæºå è½½åºæ¯",257 "resources/test assets/scene.fire.6": "è¿å",258 "scripts/Global/Menu.js.1": "说ææ缺"...
fireformedit2.js
Source:fireformedit2.js
1$(document).ready(2 function()3 {4 $('#fireFormMenu li').click(function(){$('#fireFormMenu li').removeClass('active'); $(this).addClass('active'); clickFireFormMenu(this.id);});5 $('#fireFormPanel').catfish({6 animation: 'fade',7 closeLink: '#fireFormClose',8 height: 1709 });10 $('#fireFormMin').click(11 function()12 {13 $('#fireFormMax').toggleClass('fireFormLink').show();14 //$(this).toggleClass('fireFormLink').hide();15 $('#fireFormPanel').height(18); 16 }17 );18 $('#fireFormMax').click(19 function()20 {21 $('#fireFormMin').toggleClass('fireFormLink').show();22 //$(this).toggleClass('fireFormLink').hide();23 $('#fireFormPanel').height(150); 24 }25 ); 26 refreshFireFormMode(); 27 refreshQuestionRows();28 $('#fireForm_title').dblclick(29 function()30 {31 clickFireFormMenu('fireFormSetting');32 }33 );34 }35);36function saveForm()37{38 var options = {39 dataType:'json',40 type:'POST',41 error: function (data, status, e) 42 {43 var err = config.error.unexpected;44 if(typeof(e) == 'string')45 {46 err += '\n' + e;47 }48 fireFormAjaxError(err);49 },50 51 beforeSubmit: function(){fireFormAjaxStart();}, // pre-submit callback 52 success: function(json)53 {54 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')55 {56 57 fireFormAjaxError(config.error.unexpected);58 }59 else if(!empty(json.error))60 {61 fireFormAjaxError(json.error);62 }else63 {64 if(formInfo.theme != json.formInfo.theme)65 {66 //reload the page if theme changed67 window.location.reload();68 }else69 {70 for(var j in json.formInfo)71 {72 formInfo[j] = json.formInfo[j];73 } 74 fireFormAjaxComplete(); 75 }76 77 } 78 79 }80 };81 $('#fireFormfireForm').ajaxSubmit(options); 82 return false;83}84function clickFireFormMenu(menuID)85{86 $('#fireFormPanelMC>div').hide();87 var panelId = menuID + 'Panel';88 $('#' + panelId).show();89 switch(menuID)90 {91 case 'fireFormSetting':92 $('#' + panelId + ' input[@name=title]').val(formInfo.title);93 $('#' + panelId + ' input[@name=submit_label]').val(formInfo.submit_label);94 $('#' + panelId + ' input[@name=url]').val(formInfo.url);95 $('#' + panelId + ' input[@name=email]').val(formInfo.email);96 $('#' + panelId + ' input[@name=subject]').val(formInfo.subject);97 var creatorId = $('#' + panelId + ' select[@name=creator_id]').get(0);98 if($(creatorId).length)99 {100 for(var i = 0 ; i < creatorId.options.length; i++)101 {102 if(creatorId.options[i].value == formInfo.creator_id)103 {104 creatorId.options[i].selected = true;105 }else106 {107 creatorId.options[i].selected = false;108 }109 }110 }111 var theme = $('#' + panelId + ' select[@name=theme]').get(0);112 if($(theme).length)113 {114 for(var i = 0 ; i < theme.options.length; i++)115 {116 if(theme.options[i].value == formInfo.theme)117 {118 theme.options[i].selected = true;119 }else120 {121 theme.options[i].selected = false;122 }123 }124 } 125 $('#' + panelId + ' input[@name=mode]').each(126 function()127 {128 if(this.value == formInfo.mode)129 {130 this.checked = true;131 }else132 {133 this.checked = false;134 }135 }136 ); 137 refreshFireFormMode(); 138 139 break;140 case 'fireFormQuestion':141 break;142 }143 144}145function fireFormQAdd(qType, relativeTo, position, relativeValue)146{147 var position = typeof(position)!= 'undefined'?position: 'after'; //either before or after148 var relativeTo = typeof(relativeTo)!= 'undefined'?relativeTo: 'form'; //form or question149 var relativeValue = typeof(relativeValue)!= 'undefined'?relativeValue: 0; //question id or empty150 var settings = {'question_type':qType, 'relative_to':relativeTo, 'position':position, 'post_action':'add_question', 'form_id':config.form_id, 'relative_value':relativeValue};151 $.ajax({152 dataType:'json',153 type:'POST',154 url:config.url.site + 'fireformmanager.php',155 data:settings,156 error: function (data, status, e) 157 {158 var err = config.error.unexpected;159 if(typeof(e) == 'string')160 {161 err += '\n' + e;162 }163 fireFormAjaxError(err);164 },165 success:function(json)166 {167 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')168 {169 170 fireFormAjaxError(config.error.unexpected);171 }172 else if(!empty(json.error))173 {174 175 fireFormAjaxError(json.error);176 }else177 {178 questions[json.question_id] = {};179 for(var i in json.question_info)180 {181 if(typeof(json.question_info[i]) != 'function')182 {183 questions[json.question_id][i] = json.question_info[i];184 }185 }186 switch(relativeTo)187 {188 case 'form':189 if(position == 'before')190 {191 $(json.html).prependTo('.tableFireFormBody');192 193 }else194 {195 $(json.html).appendTo('.tableFireFormBody');196 } 197 break;198 default:199 if(position == 'before')200 {201 $(json.html).insertBefore('#fireFormRow' + relativeTo);202 }else203 {204 $(json.html).insertAfter('#fireFormRow' + relativeTo);205 }206 //append to question207 }208 refreshQuestionRows();209 fireFormAjaxComplete();210 $('#fireFormPanelMC>div').hide();211 $('#fireFormQuestionPanel').show();212 fireFormEditQ(json.question_id); 213 }214 } 215 }216 ); 217 return false; 218}219function fireFormEditQ(qId)220{221 $('#fireFormPanelMC>div').hide();222 funcQEdit[questions[qId].question_type](qId);223 $('#fireFormSettingFor' + questions[qId].question_type + ' input[@name=id]').val(qId);224 $('#fireFormSettingFor' + questions[qId].question_type + ' input[@name=form_id]').val(formInfo.id);225 $('#fireFormSettingFor' + questions[qId].question_type).show(); 226}227/**228* 229*/230function fireFormRemoveQ(question_id)231{232 if(window.confirm(config.delete_question))233 {234 var settings = {'form_id':config.form_id, 'question_id':question_id, 'post_action':'delete_question'};235 $.ajax({236 dataType:'json',237 type:'POST',238 url:config.url.site + 'fireformmanager.php',239 data:settings,240 error: function (data, status, e) 241 {242 var err = config.error.unexpected;243 if(typeof(e) == 'string')244 {245 err += '\n' + e;246 }247 fireFormAjaxError(err);248 },249 success:function(json)250 {251 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')252 {253 254 fireFormAjaxError(config.error.unexpected);255 }256 else if(!empty(json.error))257 {258 259 fireFormAjaxError(json.error);260 }else261 {262 263 $('#fireFormRow' + question_id).remove();264 fireFormAjaxComplete();265 }266 } 267 }268 ); 269 }270 return false; 271}272function refreshQuestionRows()273{274 $('.fireFormRow').unbind().dblclick(275 function()276 {277 278 var qId = getNum(this.id);279 fireFormEditQ(qId);280 }281 ).mouseover(282 function()283 {284 $(this).addClass('fireFormMouseover');285 $(this).children('.fire_form_actions').children('.fireFormRowDelete').show();286 $(this).children('.fire_form_actions').children('.fireFormRowEdit').show();287 }288 ).mouseout(289 290 function()291 {292 $(this).removeClass('fireFormMouseover');293 $(this).children('.fire_form_actions').children('.fireFormRowDelete').hide();294 $(this).children('.fire_form_actions').children('.fireFormRowEdit').hide();295 }296 ).each(297 function()298 {299 //var qId = getNum(this.id);300 }301 );302 var currentRowPosition = 0;303 $(".tableFireFormBody").tableDnD(304 {onDragClass: "fireFormDrag",305 onDrop: function(tbody, row) 306 {307 var rowPosition = 0; 308 var settings = {'form_id':config.form_id, 'post_action':'reorder_question'};309 for(var i = 0; i < tbody.rows.length; i++)310 {311 if(row === tbody.rows[i])312 {313 rowPosition = i;314 }315 settings['questions[' + i + ']'] = getNum(tbody.rows[i].id);316 }317 if(rowPosition != currentRowPosition)318 {319 $.ajax({320 dataType:'json',321 type:'POST',322 url:config.url.site + 'fireformmanager.php',323 data:settings,324 error: function (data, status, e) 325 {326 var err = config.error.unexpected;327 if(typeof(e) == 'string')328 {329 err += '\n' + e;330 }331 fireFormAjaxError(err);332 },333 success:function(json)334 {335 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')336 {337 338 fireFormAjaxError(config.error.unexpected);339 }340 else if(!empty(json.error))341 {342 343 fireFormAjaxError(json.error);344 }else345 {346 347 fireFormAjaxComplete();348 }349 } 350 }351 ); 352 }353 return false; 354 },355 onDragStart:function(tbody, row)356 {357 for(var i = 0; i < tbody.rows.length; i++)358 {359 if(row === tbody.rows[i])360 {361 currentRowPosition = i;362 }363 } 364 }365 366 367 }368 );369}370/**371* save the setting for the specified question372*/373function fireFormPanelSaveQ(qType)374{375 var options = {376 dataType:'json', 377 type:'POST',378 url:config.url.site + 'fireformmanager.php',379 error: function (data, status, e) 380 {381 var err = config.error.unexpected;382 if(typeof(e) == 'string')383 {384 err += '\n' + e;385 }386 fireFormAjaxError(err);387 }, 388 beforeSubmit: function(){fireFormAjaxStart();}, // pre-submit callback 389 success: function(json)390 {391 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')392 {393 394 fireFormAjaxError(config.error.unexpected);395 }396 else if(!empty(json.error))397 {398 fireFormAjaxError(json.error);399 }else400 {401 for(var j in json.questionInfo)402 {403 questions[json.questionInfo.id][j] = json.questionInfo[j];404 }405 406 fireFormAjaxComplete();407 } 408 409 }410 };411 $('#fireFormFireForm' + qType).ajaxSubmit(options); 412 return false; 413}414/**415* set input value for one-line text type of question416*/417function setInput(qId, fieldName, onChangeCallback)418{419 var q = questions[qId];420 var value = q[fieldName] == null?'':q[fieldName];421 var type = q.question_type;422 var jquerySelector = '#fireFormSettingFor' + type + ' input[@name=' + fieldName + ']';423 $(jquerySelector).val(value).unbind().keyup(function(){424 425 if(typeof(onChangeCallback) == 'function')426 {427 onChangeCallback();428 429 }else430 {431 questionSync(qId, fieldName, this.value);432 }433 434 435 436 });437 438 439};440/**441* set input value for one-line text type of question442*/443function setTextarea(qId, fieldName, onChangeCallback)444{445 var q = questions[qId];446 var value = q[fieldName] == null?'':q[fieldName];447 var type = q.question_type;448 var jquerySelector = '#fireFormSettingFor' + type + ' textarea[@name=' + fieldName + ']';449 $(jquerySelector).val(value).unbind('keyup').keyup(function(){450 451 if(typeof(onChangeCallback) == 'function')452 {453 onChangeCallback();454 455 }else456 {457 questionSync(qId, fieldName,this.value); 458 }459 460 461 });462 463 464};465function setYesOrNo(qId, fieldName, onChangeCallback)466{467 var q = questions[qId];468 var value = q[fieldName] == null?'0':q[fieldName];469 var type = q.question_type;470 var jquerySelector = '#fireFormSettingFor' + type + ' input[@name=' + fieldName + ']';471 $(jquerySelector).each(472 function()473 {474 if(this.value == value)475 {476 this.checked = true;477 }else478 {479 this.checked = false;480 }481 }482 ).unbind().click(483 function()484 {485 if(typeof(onChangeCallback) == 'function')486 {487 onChangeCallback(); 488 }else489 {490 questionSync(qId, fieldName, this.value);491 }492 493 }494 );495 496 497};498function setRadio(qId, fieldName, onChangeCallback)499{500 var q = questions[qId];501 var value = q[fieldName] == 'vertical'?'vertical':'horizontal';502 var type = q.question_type;503 var jquerySelector = '#fireFormSettingFor' + type + ' input[@name=' + fieldName + ']';504 $(jquerySelector).each(505 function()506 {507 if(this.value == value)508 {509 this.checked = true;510 }else511 {512 this.checked = false;513 }514 }515 ).unbind().click(516 function()517 {518 if(typeof(onChangeCallback) == 'function')519 {520 onChangeCallback(); 521 }else522 {523 questionSync(qId, fieldName, this.value);524 }525 526 }527 ); 528}529function questionSync(qId, fieldName, value, jsonConfig)530{531 var q = questions[qId];532 var type = q.question_type; 533 switch(fieldName)534 {535 case 'question':536 $('#fireFormRow' + qId + ' th label').html(value);537 break;538 case 'default_value':539 switch(type)540 {541 case 'text':542 case 'password':543 $('#fireFormRow' + qId + ' input[@name=' + qId + ']').val(value);544 break;545 case 'textarea':546 $('#fireFormRow' + qId + ' textarea[@name=' + qId + ']').val(value);547 548 case 'select':549 var q = document.getElementById('fireFormField' + qId);550 for(var i = q.options.length - 1; i > 0; i--)551 {552 if(q.options[i].value == value)553 {554 q.options[i].selected = true;555 556 }else557 {558 q.options[i].selected = false;559 }560 } 561 break;562 case 'radio': 563 $('#fireFormRow' + qId + ' input[@name=' + qId +']').each(564 function()565 {566 if(this.value == value)567 {568 this.checked = true;569 }else570 {571 this.checked = false;572 }573 }574 );575 break;576 case 'checkbox':577 var values = value.split(","); 578 $('#fireFormRow' + qId + ' input[@name=' + qId +']').each(579 function()580 {581 if(values.inArray(this.value, false))582 {583 this.checked = true;584 }else585 {586 this.checked = false;587 }588 }589 ); 590 break;591 592 593 }594 break;595 case 'instruction':596 $('#fireFormRow' + qId + ' .fireFormInstruction').html(value);597 break;598 case 'width': 599 switch(type)600 {601 case 'text':602 case 'password':603 $('#fireFormRow' + qId + ' input[@name=' + qId + ']').width(value + 'px');604 break;605 case 'textarea':606 $('#fireFormRow' + qId + ' textarea[@name=' + qId + ']').width(value + 'px');607 break;608 }609 break;610 case 'max_length':611 $('#fireFormRow' + qId + ' input[@name=' + qId + ']').attr('max_length', value);612 break;613 case 'rows':614 $('#fireFormRow' + qId + ' textarea[@name=' + qId + ']').attr('rows', getNum(value));615 break;616 case 'options':617 var defaultValue = $('#fireFormSettingFor' + type + ' input[@name=default_value]').val();618 var display = 'vertical';619 $('#fireFormSettingFor' + type + ' input[@name=display]').each(620 function()621 {622 if(this.checked)623 {624 display = this.value;625 }626 }627 ); 628 if(display == "horizontal")629 {630 var suffixWas = '<br>';631 var suffix = " ";632 }else633 {634 var suffix = "<br>";635 var suffixWas = " ";636 } 637 var questionOptions = value.split("\n"); 638 $('#fireFormSelectOthers' + qId).remove(); 639 switch(type)640 {641 case 'select':642 var q = document.getElementById('fireFormField' + qId);643 for(var i = q.options.length - 1; i > 0; i--)644 {645 q.options[i] = null;646 } 647 for(var i in questionOptions)648 {649 if(typeof(questionOptions[i]) == "string" && questionOptions[i] != "")650 {651 q.options[q.options.length] = new Option(questionOptions[i], questionOptions[i], false, (questionOptions[i] == defaultValue?true:false));652 }653 } 654 655 break;656 case 'radio':657 $('#fireFormFieldContainer' + qId).empty();658 var html = '';659 var num = 1;660 for(var i in questionOptions)661 {662 if(typeof(questionOptions[i]) == "string" && questionOptions[i] != "")663 {664 if(num++ > 1)665 {666 html += suffix;667 }668 html += '<input type="radio" onclick="changeFireFormRadio(' + qId + ', this);" name="' + qId + '" value="' + questionOptions[i] + '" class="fireFormFieldRadio"> <label class="fireFormFieldLabel">' + questionOptions[i] + '</label>';669 }670 }671 $(html).appendTo('#fireFormFieldContainer' + qId); 672 break;673 case 'checkbox': 674 $('#fireFormFieldContainer' + qId).empty();675 var html = '';676 var num = 1;677 for(var i in questionOptions)678 {679 if(typeof(questionOptions[i]) == "string" && questionOptions[i] != "")680 {681 if(num++ > 1)682 {683 html += suffix;684 }685 html += '<input type="checkbox" onclick="changeFireFormCheckbox(' + qId + ', this);" name="' + qId + '" value="' + questionOptions[i] + '" class="fireFormFieldCheckbox"> <label class="fireFormFieldLabel">' + questionOptions[i] + '</label>';686 }687 }688 $(html).appendTo('#fireFormFieldContainer' + qId); 689 break;690 }691 questionSync(qId, 'default_value', $('#fireFormSettingFor' + type + ' input[@name=default_value]').val()); 692 questionSync(qId, 'specify_allowed', $('#fireFormSettingFor' + type + ' input:checked[@name=specify_allowed]').val()); 693 break;694 case 'specify_allowed': 695 switch(type)696 {697 case 'select':698 $('#fireFormSelectOthers' + qId).remove(); 699 var q = document.getElementById('fireFormField' + qId);700 for(var i = q.options.length - 1; i > 0; i--)701 {702 if(q.options[i].value == 'fireFormOthers')703 {704 q.options[i] = null;705 break;706 }707 } 708 if(value == '1')709 {710 q.options[q.options.length] = new Option($('#fireFormSettingFor' + type + ' input[@name=specify_label]').val(), "fireFormOthers", false, false);711 $('<span class="fireFormSelectOthers" style="display:none" id="fireFormSelectOthers' + qId + '"><br><input type="text" class="fireFormOthers" name="fireFormOthers[' + qId + ']" id="fireFormOthers' + qId + '"></span>').insertAfter(q); 712 } 713 break;714 case 'radio':715 $('#fireFormSelectOthers' + qId).remove(); 716 $('#fireFormRow' + qId + ' .fireFormOthers').remove();717 $('#fireFormRow' + qId + ' .fireFormOtherDelimiters').remove();718 var suffix = ($('#fireFormSettingFor' + type + ' input:checked[@name=display]').val() == 'vertical'?'<br class="fireFormOtherDelimiters">':'<span class="fireFormOtherDelimiters"> </span>');719 if(value == '1')720 { 721 722 $(suffix + '<input type="radio" onclick="changeFireFormRadio(' + qId + ', this);" class="fireFormFieldRadio fireFormOthers" name="' + qId + '" value="fireFormOthers"> <label class="fireFormOthers">' + $('#fireFormSettingFor' + type + ' input[@name=specify_label]').val() + '</label><span class="fireFormSelectOthers" style="display:none" id="fireFormSelectOthers' + qId + '">' + suffix + '<input type="text" class="fireFormOthers" name="fireFormOthers[' + qId + ']" id="fireFormOthers' + qId + '"></span>').appendTo('#fireFormFieldContainer' + qId); 723 } 724 break;725 case 'checkbox':726 $('#fireFormSelectOthers' + qId).remove(); 727 $('#fireFormRow' + qId + ' .fireFormOthers').remove();728 $('#fireFormRow' + qId + ' .fireFormOtherDelimiters').remove();729 var suffix = ($('#fireFormSettingFor' + type + ' input:checked[@name=display]').val() == 'vertical'?'<br class="fireFormOtherDelimiters">':'<span class="fireFormOtherDelimiters"> </span>');730 if(value == '1')731 { 732 733 $(suffix + '<input type="checkbox" onclick="changeFireFormCheckbox(' + qId + ', this);" class="fireFormFieldCheckbox fireFormOthers" name="' + qId + '[]" value="fireFormOthers"> <label class="fireFormOthers">' + $('#fireFormSettingFor' + type + ' input[@name=specify_label]').val() + '</label><span class="fireFormSelectOthers" style="display:none" id="fireFormSelectOthers' + qId + '">' + suffix + '<input type="text" class="fireFormOthers" name="fireFormOthers[' + qId + ']" id="fireFormOthers' + qId + '"></span>').appendTo('#fireFormFieldContainer' + qId); 734 } 735 break;736 } 737 738 break;739 case 'specify_label':740 switch(type)741 {742 case 'select':743 var q = document.getElementById('fireFormField' + qId);744 for(var i = q.options.length - 1; i > 0; i--)745 {746 if(q.options[i].value == 'fireFormOthers')747 {748 q.options[i].text = value;749 }750 } 751 752 break;753 case 'radio':754 case 'checkbox': 755 $('#fireFormRow' + qId + ' label.fireFormOthers').html(value);756 break;757 } 758 break;759 case 'display':760 switch(type)761 {762 case 'radio':763 case 'checkbox':764 questionSync(qId, 'options', $('#fireFormSettingFor' + type + ' textarea[@name=options]').val()); 765 break;766 }767 break;768 }...
fireformedit.js
Source:fireformedit.js
1$(document).ready(2 function()3 {4 $('#fireFormMenu li').click(function(){$('#fireFormMenu li').removeClass('active'); $(this).addClass('active'); clickFireFormMenu(this.id);});5 $('#fireFormPanel').catfish({6 animation: 'fade',7 closeLink: '#fireFormClose',8 height: 1709 });10 $('#fireFormMin').click(11 function()12 {13 $('#fireFormMax').toggleClass('fireFormLink').show();14 $(this).toggleClass('fireFormLink').hide();15 $('#fireFormPanel').height(18);16 }17 );18 $('#fireFormMax').click(19 function()20 {21 $('#fireFormMin').toggleClass('fireFormLink').show();22 $(this).toggleClass('fireFormLink').hide();23 $('#fireFormPanel').height(150);24 }25 );26 refreshFireFormMode();27 refreshQuestionRows();28 $('#fireForm_title').dblclick(29 function()30 {31 clickFireFormMenu('fireFormSetting');32 }33 );34 }35);36function saveForm()37{38 var options = {39 dataType:'json',40 type:'POST',41 error: function (data, status, e)42 {43 var err = config.error.unexpected;44 if(typeof(e) == 'string')45 {46 err += '\n' + e;47 }48 fireFormAjaxError(err);49 },50 beforeSubmit: function(){fireFormAjaxStart();}, // pre-submit callback51 success: function(json)52 {53 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')54 {55 fireFormAjaxError(config.error.unexpected);56 }57 else if(!empty(json.error))58 {59 fireFormAjaxError(json.error);60 }else61 {62 if(formInfo.theme != json.formInfo.theme)63 {64 //reload the page if theme changed65 window.location.reload();66 }else67 {68 for(var j in json.formInfo)69 {70 formInfo[j] = json.formInfo[j];71 }72 fireFormAjaxComplete();73 }74 }75 }76 };77 $('#fireFormfireForm').ajaxSubmit(options);78 return false;79}80function clickFireFormMenu(menuID)81{82 $('#fireFormPanelMC>div').hide();83 var panelId = menuID + 'Panel';84 $('#' + panelId).show();85 switch(menuID)86 {87 case 'fireFormSetting':88 $('#' + panelId + ' input[@name=title]').val(formInfo.title);89 $('#' + panelId + ' input[@name=submit_label]').val(formInfo.submit_label);90 $('#' + panelId + ' input[@name=url]').val(formInfo.url);91 $('#' + panelId + ' input[@name=email]').val(formInfo.email);92 $('#' + panelId + ' input[@name=subject]').val(formInfo.subject);93 var creatorId = $('#' + panelId + ' select[@name=creator_id]').get(0);94 if($(creatorId).length)95 {96 for(var i = 0 ; i < creatorId.options.length; i++)97 {98 if(creatorId.options[i].value == formInfo.creator_id)99 {100 creatorId.options[i].selected = true;101 }else102 {103 creatorId.options[i].selected = false;104 }105 }106 }107 var theme = $('#' + panelId + ' select[@name=theme]').get(0);108 if($(theme).length)109 {110 for(var i = 0 ; i < theme.options.length; i++)111 {112 if(theme.options[i].value == formInfo.theme)113 {114 theme.options[i].selected = true;115 }else116 {117 theme.options[i].selected = false;118 }119 }120 }121 $('#' + panelId + ' input[@name=mode]').each(122 function()123 {124 if(this.value == formInfo.mode)125 {126 this.checked = true;127 }else128 {129 this.checked = false;130 }131 }132 );133 refreshFireFormMode();134 break;135 case 'fireFormQuestion':136 break;137 }138}139function fireFormQAdd(qType, relativeTo, position, relativeValue)140{141 var position = typeof(position)!= 'undefined'?position: 'after'; //either before or after142 var relativeTo = typeof(relativeTo)!= 'undefined'?relativeTo: 'form'; //form or question143 var relativeValue = typeof(relativeValue)!= 'undefined'?relativeValue: 0; //question id or empty144 var settings = {'question_type':qType, 'relative_to':relativeTo, 'position':position, 'post_action':'add_question', 'form_id':config.form_id, 'relative_value':relativeValue};145 $.ajax({146 dataType:'json',147 type:'POST',148 url:config.url.site + 'fireformmanager.php',149 data:settings,150 error: function (data, status, e)151 {152 var err = config.error.unexpected;153 if(typeof(e) == 'string')154 {155 err += '\n' + e;156 }157 fireFormAjaxError(err);158 },159 success:function(json)160 {161 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')162 {163 fireFormAjaxError(config.error.unexpected);164 }165 else if(!empty(json.error))166 {167 fireFormAjaxError(json.error);168 }else169 {170 questions[json.question_id] = {};171 for(var i in json.question_info)172 {173 if(typeof(json.question_info[i]) != 'function')174 {175 questions[json.question_id][i] = json.question_info[i];176 }177 }178 switch(relativeTo)179 {180 case 'form':181 if(position == 'before')182 {183 $(json.html).prependTo('.tableFireFormBody');184 }else185 {186 $(json.html).appendTo('.tableFireFormBody');187 }188 break;189 default:190 if(position == 'before')191 {192 $(json.html).insertBefore('#fireFormRow' + relativeTo);193 }else194 {195 $(json.html).insertAfter('#fireFormRow' + relativeTo);196 }197 //append to question198 }199 refreshQuestionRows();200 fireFormAjaxComplete();201 $('#fireFormPanelMC>div').hide();202 fireFormEditQ(json.question_id);203 }204 }205 }206 );207 return false;208}209function fireFormEditQ(qId)210{211 $('#fireFormPanelMC>div').hide();212 funcQEdit[questions[qId].question_type](qId);213 $('#fireFormSettingFor' + questions[qId].question_type + ' input[@name=id]').val(qId);214 $('#fireFormSettingFor' + questions[qId].question_type + ' input[@name=form_id]').val(formInfo.id);215 $('#fireFormSettingFor' + questions[qId].question_type).show();216}217/**218*219*/220function fireFormRemoveQ(question_id)221{222 if(window.confirm(config.delete_question))223 {224 var settings = {'form_id':config.form_id, 'question_id':question_id, 'post_action':'delete_question'};225 $.ajax({226 dataType:'json',227 type:'POST',228 url:config.url.site + 'fireformmanager.php',229 data:settings,230 error: function (data, status, e)231 {232 var err = config.error.unexpected;233 if(typeof(e) == 'string')234 {235 err += '\n' + e;236 }237 fireFormAjaxError(err);238 },239 success:function(json)240 {241 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')242 {243 fireFormAjaxError(config.error.unexpected);244 }245 else if(!empty(json.error))246 {247 fireFormAjaxError(json.error);248 }else249 {250 $('#fireFormRow' + question_id).remove();251 fireFormAjaxComplete();252 }253 }254 }255 );256 }257 return false;258}259function refreshQuestionRows()260{261 $('.fireFormRow').unbind().dblclick(262 function()263 {264 var qId = getNum(this.id);265 fireFormEditQ(qId);266 }267 ).mouseover(268 function()269 {270 $(this).addClass('fireFormMouseover');271 $(this).children('.fire_form_actions').children('.fireFormRowDelete').show();272 $(this).children('.fire_form_actions').children('.fireFormRowEdit').show();273 }274 ).mouseout(275 function()276 {277 $(this).removeClass('fireFormMouseover');278 $(this).children('.fire_form_actions').children('.fireFormRowDelete').hide();279 $(this).children('.fire_form_actions').children('.fireFormRowEdit').hide();280 }281 ).each(282 function()283 {284 //var qId = getNum(this.id);285 }286 );287 var currentRowPosition = 0;288 $(".tableFireFormBody").tableDnD(289 {onDragClass: "fireFormDrag",290 onDrop: function(tbody, row)291 {292 var rowPosition = 0;293 var settings = {'form_id':config.form_id, 'post_action':'reorder_question'};294 for(var i = 0; i < tbody.rows.length; i++)295 {296 if(row === tbody.rows[i])297 {298 rowPosition = i;299 }300 settings['questions[' + i + ']'] = getNum(tbody.rows[i].id);301 }302 if(rowPosition != currentRowPosition)303 {304 $.ajax({305 dataType:'json',306 type:'POST',307 url:config.url.site + 'fireformmanager.php',308 data:settings,309 error: function (data, status, e)310 {311 var err = config.error.unexpected;312 if(typeof(e) == 'string')313 {314 err += '\n' + e;315 }316 fireFormAjaxError(err);317 },318 success:function(json)319 {320 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')321 {322 fireFormAjaxError(config.error.unexpected);323 }324 else if(!empty(json.error))325 {326 fireFormAjaxError(json.error);327 }else328 {329 fireFormAjaxComplete();330 }331 }332 }333 );334 }335 return false;336 },337 onDragStart:function(tbody, row)338 {339 for(var i = 0; i < tbody.rows.length; i++)340 {341 if(row === tbody.rows[i])342 {343 currentRowPosition = i;344 }345 }346 }347 }348 );349}350/**351* save the setting for the specified question352*/353function fireFormPanelSaveQ(qType)354{355 var options = {356 dataType:'json',357 type:'POST',358 url:config.url.site + 'fireformmanager.php',359 error: function (data, status, e)360 {361 var err = config.error.unexpected;362 if(typeof(e) == 'string')363 {364 err += '\n' + e;365 }366 fireFormAjaxError(err);367 },368 beforeSubmit: function(){fireFormAjaxStart();}, // pre-submit callback369 success: function(json)370 {371 if(typeof(json) != 'object' || typeof(json.error) == 'undefined')372 {373 fireFormAjaxError(config.error.unexpected);374 }375 else if(!empty(json.error))376 {377 fireFormAjaxError(json.error);378 }else379 {380 for(var j in json.questionInfo)381 {382 questions[json.questionInfo.id][j] = json.questionInfo[j];383 }384 fireFormAjaxComplete();385 }386 }387 };388 $('#fireFormFireForm' + qType).ajaxSubmit(options);389 return false;390}391/**392* set input value for one-line text type of question393*/394function setInput(qId, fieldName, onChangeCallback)395{396 var q = questions[qId];397 var value = q[fieldName] == null?'':q[fieldName];398 var type = q.question_type;399 var jquerySelector = '#fireFormSettingFor' + type + ' input[@name=' + fieldName + ']';400 $(jquerySelector).val(value).unbind().keyup(function(){401 if(typeof(onChangeCallback) == 'function')402 {403 onChangeCallback();404 }else405 {406 questionSync(qId, fieldName, this.value);407 }408 });409};410/**411* set input value for one-line text type of question412*/413function setTextarea(qId, fieldName, onChangeCallback)414{415 var q = questions[qId];416 var value = q[fieldName] == null?'':q[fieldName];417 var type = q.question_type;418 var jquerySelector = '#fireFormSettingFor' + type + ' textarea[@name=' + fieldName + ']';419 $(jquerySelector).val(value).unbind('keyup').keyup(function(){420 if(typeof(onChangeCallback) == 'function')421 {422 onChangeCallback();423 }else424 {425 questionSync(qId, fieldName,this.value);426 }427 });428};429function setYesOrNo(qId, fieldName, onChangeCallback)430{431 var q = questions[qId];432 var value = q[fieldName] == null?'0':q[fieldName];433 var type = q.question_type;434 var jquerySelector = '#fireFormSettingFor' + type + ' input[@name=' + fieldName + ']';435 $(jquerySelector).each(436 function()437 {438 if(this.value == value)439 {440 this.checked = true;441 }else442 {443 this.checked = false;444 }445 }446 ).unbind().click(447 function()448 {449 if(typeof(onChangeCallback) == 'function')450 {451 onChangeCallback();452 }else453 {454 questionSync(qId, fieldName, this.value);455 }456 }457 );458};459function setRadio(qId, fieldName, onChangeCallback)460{461 var q = questions[qId];462 var value = q[fieldName] == 'vertical'?'vertical':'horizontal';463 var type = q.question_type;464 var jquerySelector = '#fireFormSettingFor' + type + ' input[@name=' + fieldName + ']';465 $(jquerySelector).each(466 function()467 {468 if(this.value == value)469 {470 this.checked = true;471 }else472 {473 this.checked = false;474 }475 }476 ).unbind().click(477 function()478 {479 if(typeof(onChangeCallback) == 'function')480 {481 onChangeCallback();482 }else483 {484 questionSync(qId, fieldName, this.value);485 }486 }487 );488}489function questionSync(qId, fieldName, value, jsonConfig)490{491 var q = questions[qId];492 var type = q.question_type;493 switch(fieldName)494 {495 case 'question':496 $('#fireFormRow' + qId + ' th label').html(value);497 break;498 case 'default_value':499 switch(type)500 {501 case 'text':502 case 'password':503 $('#fireFormRow' + qId + ' input[@name=' + qId + ']').val(value);504 break;505 case 'textarea':506 $('#fireFormRow' + qId + ' textarea[@name=' + qId + ']').val(value);507 case 'select':508 var q = document.getElementById('fireFormField' + qId);509 for(var i = q.options.length - 1; i > 0; i--)510 {511 if(q.options[i].value == value)512 {513 q.options[i].selected = true;514 }else515 {516 q.options[i].selected = false;517 }518 }519 break;520 case 'radio':521 $('#fireFormRow' + qId + ' input[@name=' + qId +']').each(522 function()523 {524 if(this.value == value)525 {526 this.checked = true;527 }else528 {529 this.checked = false;530 }531 }532 );533 break;534 case 'checkbox':535 var values = value.split(",");536 $('#fireFormRow' + qId + ' input[@name=' + qId +']').each(537 function()538 {539 if(values.inArray(this.value, false))540 {541 this.checked = true;542 }else543 {544 this.checked = false;545 }546 }547 );548 break;549 }550 break;551 case 'instruction':552 $('#fireFormRow' + qId + ' .fireFormInstruction').html(value);553 break;554 case 'width':555 switch(type)556 {557 case 'text':558 case 'password':559 $('#fireFormRow' + qId + ' input[@name=' + qId + ']').width(value + 'px');560 break;561 case 'textarea':562 $('#fireFormRow' + qId + ' textarea[@name=' + qId + ']').width(value + 'px');563 break;564 }565 break;566 case 'max_length':567 $('#fireFormRow' + qId + ' input[@name=' + qId + ']').attr('max_length', value);568 break;569 case 'rows':570 $('#fireFormRow' + qId + ' textarea[@name=' + qId + ']').attr('rows', getNum(value));571 break;572 case 'options':573 var defaultValue = $('#fireFormSettingFor' + type + ' input[@name=default_value]').val();574 var display = 'vertical';575 $('#fireFormSettingFor' + type + ' input[@name=display]').each(576 function()577 {578 if(this.checked)579 {580 display = this.value;581 }582 }583 );584 if(display == "horizontal")585 {586 var suffixWas = '<br>';587 var suffix = " ";588 }else589 {590 var suffix = "<br>";591 var suffixWas = " ";592 }593 var questionOptions = value.split("\n");594 $('#fireFormSelectOthers' + qId).remove();595 switch(type)596 {597 case 'select':598 var q = document.getElementById('fireFormField' + qId);599 for(var i = q.options.length - 1; i > 0; i--)600 {601 q.options[i] = null;602 }603 for(var i in questionOptions)604 {605 if(typeof(questionOptions[i]) == "string" && questionOptions[i] != "")606 {607 q.options[q.options.length] = new Option(questionOptions[i], questionOptions[i], false, (questionOptions[i] == defaultValue?true:false));608 }609 }610 break;611 case 'radio':612 $('#fireFormFieldContainer' + qId).empty();613 var html = '';614 var num = 1;615 for(var i in questionOptions)616 {617 if(typeof(questionOptions[i]) == "string" && questionOptions[i] != "")618 {619 if(num++ > 1)620 {621 html += suffix;622 }623 html += '<input type="radio" onclick="changeFireFormRadio(' + qId + ', this);" name="' + qId + '" value="' + questionOptions[i] + '" class="fireFormFieldRadio"> <label class="fireFormFieldLabel">' + questionOptions[i] + '</label>';624 }625 }626 $(html).appendTo('#fireFormFieldContainer' + qId);627 break;628 case 'checkbox':629 $('#fireFormFieldContainer' + qId).empty();630 var html = '';631 var num = 1;632 for(var i in questionOptions)633 {634 if(typeof(questionOptions[i]) == "string" && questionOptions[i] != "")635 {636 if(num++ > 1)637 {638 html += suffix;639 }640 html += '<input type="checkbox" onclick="changeFireFormCheckbox(' + qId + ', this);" name="' + qId + '" value="' + questionOptions[i] + '" class="fireFormFieldCheckbox"> <label class="fireFormFieldLabel">' + questionOptions[i] + '</label>';641 }642 }643 $(html).appendTo('#fireFormFieldContainer' + qId);644 break;645 }646 questionSync(qId, 'default_value', $('#fireFormSettingFor' + type + ' input[@name=default_value]').val());647 questionSync(qId, 'specify_allowed', $('#fireFormSettingFor' + type + ' input:checked[@name=specify_allowed]').val());648 break;649 case 'specify_allowed':650 switch(type)651 {652 case 'select':653 $('#fireFormSelectOthers' + qId).remove();654 var q = document.getElementById('fireFormField' + qId);655 for(var i = q.options.length - 1; i > 0; i--)656 {657 if(q.options[i].value == 'fireFormOthers')658 {659 q.options[i] = null;660 break;661 }662 }663 if(value == '1')664 {665 q.options[q.options.length] = new Option($('#fireFormSettingFor' + type + ' input[@name=specify_label]').val(), "fireFormOthers", false, false);666 $('<span class="fireFormSelectOthers" style="display:none" id="fireFormSelectOthers' + qId + '"><br><input type="text" class="fireFormOthers" name="fireFormOthers[' + qId + ']" id="fireFormOthers' + qId + '"></span>').insertAfter(q);667 }668 break;669 case 'radio':670 $('#fireFormSelectOthers' + qId).remove();671 $('#fireFormRow' + qId + ' .fireFormOthers').remove();672 $('#fireFormRow' + qId + ' .fireFormOtherDelimiters').remove();673 var suffix = ($('#fireFormSettingFor' + type + ' input:checked[@name=display]').val() == 'vertical'?'<br class="fireFormOtherDelimiters">':'<span class="fireFormOtherDelimiters"> </span>');674 if(value == '1')675 {676 $(suffix + '<input type="radio" onclick="changeFireFormRadio(' + qId + ', this);" class="fireFormFieldRadio fireFormOthers" name="' + qId + '" value="fireFormOthers"> <label class="fireFormOthers">' + $('#fireFormSettingFor' + type + ' input[@name=specify_label]').val() + '</label><span class="fireFormSelectOthers" style="display:none" id="fireFormSelectOthers' + qId + '">' + suffix + '<input type="text" class="fireFormOthers" name="fireFormOthers[' + qId + ']" id="fireFormOthers' + qId + '"></span>').appendTo('#fireFormFieldContainer' + qId);677 }678 break;679 case 'checkbox':680 $('#fireFormSelectOthers' + qId).remove();681 $('#fireFormRow' + qId + ' .fireFormOthers').remove();682 $('#fireFormRow' + qId + ' .fireFormOtherDelimiters').remove();683 var suffix = ($('#fireFormSettingFor' + type + ' input:checked[@name=display]').val() == 'vertical'?'<br class="fireFormOtherDelimiters">':'<span class="fireFormOtherDelimiters"> </span>');684 if(value == '1')685 {686 $(suffix + '<input type="checkbox" onclick="changeFireFormCheckbox(' + qId + ', this);" class="fireFormFieldCheckbox fireFormOthers" name="' + qId + '[]" value="fireFormOthers"> <label class="fireFormOthers">' + $('#fireFormSettingFor' + type + ' input[@name=specify_label]').val() + '</label><span class="fireFormSelectOthers" style="display:none" id="fireFormSelectOthers' + qId + '">' + suffix + '<input type="text" class="fireFormOthers" name="fireFormOthers[' + qId + ']" id="fireFormOthers' + qId + '"></span>').appendTo('#fireFormFieldContainer' + qId);687 }688 break;689 }690 break;691 case 'specify_label':692 switch(type)693 {694 case 'select':695 var q = document.getElementById('fireFormField' + qId);696 for(var i = q.options.length - 1; i > 0; i--)697 {698 if(q.options[i].value == 'fireFormOthers')699 {700 q.options[i].text = value;701 }702 }703 break;704 case 'radio':705 case 'checkbox':706 $('#fireFormRow' + qId + ' label.fireFormOthers').html(value);707 break;708 }709 break;710 case 'display':711 switch(type)712 {713 case 'radio':714 case 'checkbox':715 questionSync(qId, 'options', $('#fireFormSettingFor' + type + ' textarea[@name=options]').val());716 break;717 }718 break;719 }...
fire_manager.js
Source:fire_manager.js
1// fire_manager.js2//3// Created by Alezia Kurdis on December 13, 2020.4// Copyright 2020 Alezia Kurdis.5//6// This script manage the fire element events7//8// Distributed under the Apache License, Version 2.0.9// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html10//11(function(){12 var ROOT = Script.resolvePath("").split("fire_manager.js")[0];13 var FIRE_SOUND_URL = ROOT + "SOUND_FIRE_MONO.mp3";14 var PARTICLE_FLAME_URL = ROOT + "PARTICLE_FIRE_FLAME.png";15 var PARTICLE_LOW_FLAME_URL = ROOT + "PARTICLE_FIRE_LOW_FLAME.png";16 var PARTICLE_SPARK_URL = ROOT + "PARTICLE_FIRE_SPARK.png";17 var LIGHT_FLICKER_SCRIPT_URL = ROOT + "flicker.js";18 19 var UPDATE_TIMER_INTERVAL = 20000; // 20 sec20 var processTimer = 0;21 var SOUND_UPDATE_TIMER_INTERVAL = 500; 22 var soundProcessTimer = 0;23 var fireSound;24 var fireSoundInjector;25 var volume;26 var masterVolume = 0.6;27 var currentKnownUserData;28 var thisEntityId;29 var fireScaleFactor = 1;30 var previousDimensions;31 32 var FIRE_MODEL_Y_SIZE = 0.3003;33 var FIRE_MODEL_Z_SIZE = 0.9676;34 35 var FIRE_CYCLE = 2100; //35 minutes36 var highFlamId;37 var lowFlamId;38 var sparksFlamId;39 var lightFireId;40 this.preload = function(entityID) { 41 thisEntityId = entityID;42 fireSound = SoundCache.getSound(FIRE_SOUND_URL);43 44 var properties = Entities.getEntityProperties(thisEntityId, ["dimensions", "userData"]);45 currentKnownUserData = properties.userData;46 var setupData = JSON.parse(currentKnownUserData);47 if (setupData.volume === undefined) {48 masterVolume = 0.6;49 } else {50 masterVolume = setupData.volume;51 if (masterVolume < 0 || masterVolume > 1) {52 masterVolume = 0.6;53 }54 }55 56 fireScaleFactor = properties.dimensions.x;57 previousDimensions = properties.dimensions;58 addLowFire(thisEntityId);59 addSparks(thisEntityId); 60 addLight(thisEntityId);61 addHighFire(thisEntityId);62 if (fireSound.downloaded) {63 playFireSound();64 } else {65 fireSound.ready.connect(onFireSoundReady);66 }67 Script.update.connect(myTimer);68 }; 69 this.unload = function(entityID) {70 71 if (fireSoundInjector !== undefined){72 fireSoundInjector.stop();73 }74 75 Entities.deleteEntity(lowFlamId);76 Entities.deleteEntity(sparksFlamId);77 Entities.deleteEntity(lightFireId); 78 Entities.deleteEntity(highFlamId);79 Script.update.disconnect(myTimer);80 }; 81 function onFireSoundReady() {82 fireSound.ready.disconnect(onFireSoundReady);83 playFireSound();84 }85 86 function myTimer(deltaTime) {87 var today = new Date();88 89 if ((today.getTime() - soundProcessTimer) > SOUND_UPDATE_TIMER_INTERVAL ) {90 if (fireSoundInjector !== undefined){91 var prop = Entities.getEntityProperties(thisEntityId, ["position"]); 92 fireSoundInjector.setOptions({93 "position": prop.position,94 "volume": volume * masterVolume95 });96 } 97 soundProcessTimer = today.getTime();98 }99 100 if ((today.getTime() - processTimer) > UPDATE_TIMER_INTERVAL ) {101 var state = GetCurrentCycleValue(100, FIRE_CYCLE);102 if (state > 49){103 Entities.editEntity(lightFireId, {104 "color": {105 "blue": 0,106 "green": 68,107 "red": 255108 },109 "falloffRadius": 1.6110 });111 Entities.editEntity(highFlamId, {112 "isEmitting": false113 });114 115 volume = 0.4;116 } else {117 Entities.editEntity(lightFireId, {118 "color": {119 "blue": 0,120 "green": 128,121 "red": 255122 },123 "falloffRadius": 3.0124 });125 Entities.editEntity(highFlamId, {126 "isEmitting": true127 }); 128 volume = 0.8; 129 }130 131 //Check for resize132 var properties = Entities.getEntityProperties(thisEntityId, ["dimensions", "userData"]);133 if ((properties.dimensions.x - previousDimensions.x) > 0.001){134 //Resize135 fireScaleFactor = properties.dimensions.x;136 var newDimensions = {137 "x": fireScaleFactor, 138 "y": fireScaleFactor * FIRE_MODEL_Y_SIZE, 139 "z": fireScaleFactor * FIRE_MODEL_Z_SIZE140 };141 Entities.editEntity(thisEntityId, {142 "dimensions": newDimensions143 });144 145 Entities.deleteEntity(lowFlamId);146 addLowFire(thisEntityId); 147 Entities.deleteEntity(sparksFlamId);148 addSparks(thisEntityId);149 Entities.deleteEntity(lightFireId);150 addLight(thisEntityId);151 Entities.deleteEntity(highFlamId);152 addHighFire(thisEntityId);153 previousDimensions = newDimensions;154 }155 if (properties.userData !== currentKnownUserData) {156 157 currentKnownUserData = properties.userData;158 var setupData = JSON.parse(currentKnownUserData);159 if (setupData.volume === undefined) {160 masterVolume = 0.6;161 } else {162 masterVolume = setupData.volume;163 if (masterVolume < 0 || masterVolume > 1) {164 masterVolume = 0.6;165 }166 } 167 }168 today = new Date();169 processTimer = today.getTime();170 } 171 }172 173 function addHighFire(entityID) {174 var state = GetCurrentCycleValue(100, FIRE_CYCLE);175 var isEmitting = true;176 if (state > 49){177 isEmitting = false;178 }179 var properties = Entities.getEntityProperties(entityID, ["position", "rotation", "renderWithZones"]); 180 181 highFlamId = Entities.addEntity({182 "accelerationSpread": {183 "x": 0,184 "y": 0,185 "z": 0186 }, 187 "alpha": 0.20000000298023224,188 "alphaFinish": 0,189 "alphaSpread": 0,190 "alphaStart": 0.5,191 "azimuthStart": -3.14159,192 "azimuthFinish": 3.14159,193 "color": {194 "blue": 18,195 "green": 113,196 "red": 255197 },198 "colorFinish": {199 "blue": 0,200 "green": 0,201 "red": 255202 },203 "colorSpread": {204 "blue": 0,205 "green": 15,206 "red": 0207 },208 "colorStart": {209 "blue": 66,210 "green": 208,211 "red": 255212 },213 "dimensions": {214 "x": 2.5576000213623047 * fireScaleFactor,215 "y": 2.5576000213623047 * fireScaleFactor,216 "z": 2.5576000213623047 * fireScaleFactor217 },218 "emitAcceleration": {219 "x": 0,220 "y": 3 * fireScaleFactor,221 "z": 0222 },223 "emitDimensions": {224 "x": fireScaleFactor,225 "y": fireScaleFactor,226 "z": fireScaleFactor227 },228 "emitOrientation": {229 "w": 0.7071068,230 "x": 0.7071068,231 "y": 0,232 "z": 0233 },234 "emitRate": 30,235 "emitterShouldTrail": 0, 236 "emitSpeed": 0.59 * fireScaleFactor,237 "ignoreForCollisions": 1,238 "isEmitting": isEmitting, 239 "lifespan": 1.0,240 "maxParticles": 300,241 "name": "HIGH-FLAME",242 "particleRadius": 0.3 * fireScaleFactor,243 "polarStart": 0,244 "polarFinish": 0.20944,245 "position":{246 "x": properties.position.x,247 "y": properties.position.y + (0.53 * fireScaleFactor),248 "z": properties.position.z249 },250 "parentID": entityID,251 "renderWithZones": properties.renderWithZones,252 "radiusFinish": 0,253 "radiusSpread": 0,254 "radiusStart": 0,255 "rotation": properties.rotation,256 "speedSpread": 0.08 * fireScaleFactor,257 "textures": PARTICLE_FLAME_URL,258 "type": "ParticleEffect",259 "grab": {260 "grabbable": false261 }262 }, "local");263 264 265 }266 function addLowFire(entityID) {267 var properties = Entities.getEntityProperties(entityID, ["position", "rotation", "renderWithZones"]); 268 269 lowFlamId = Entities.addEntity({ 270 "alpha": 0.2,271 "alphaFinish": 0,272 "alphaSpread": 0,273 "alphaStart": 0.5,274 "azimuthStart": 0,275 "azimuthFinish": 3.14159,276 "collisionless": 1,277 "color": {278 "blue": 18,279 "green": 93,280 "red": 255281 },282 "colorFinish": {283 "blue": 0,284 "green": 0,285 "red": 255286 },287 "colorSpread": {288 "blue": 0,289 "green": 35,290 "red": 0291 },292 "colorStart": {293 "blue": 0,294 "green": 0,295 "red": 255296 },297 "dimensions": {298 "x": 2.5576000213623047 * fireScaleFactor,299 "y": 2.5576000213623047 * fireScaleFactor,300 "z": 2.5576000213623047 * fireScaleFactor301 },302 "emitAcceleration": {303 "x": 0,304 "y": 0.2 * fireScaleFactor,305 "z": 0306 },307 "accelerationSpread": {308 "x": 0,309 "y": 0.05 * fireScaleFactor,310 "z": 0311 }, 312 "emitDimensions": {313 "x": 0.4 * fireScaleFactor,314 "y": 0.01 * fireScaleFactor,315 "z": 0.4 * fireScaleFactor316 },317 "emitOrientation": {318 "w": 1,319 "x": 0,320 "y": 0,321 "z": 0322 },323 "emitRate": 30,324 "emitterShouldTrail": 0, 325 "emitSpeed": 0.06 * fireScaleFactor,326 "speedSpread": 0.03 * fireScaleFactor,327 "ignoreForCollisions": 1,328 "isEmitting": 1, 329 "lifespan": 1.1,330 "maxParticles": 60,331 "name": "Low Flames Particles",332 "particleRadius": 0.3 * fireScaleFactor,333 "polarStart": 0,334 "polarFinish": Math.PI,335 "position":{336 "x": properties.position.x,337 "y": properties.position.y - (0.05 * fireScaleFactor),338 "z": properties.position.z339 },340 "parentID": entityID,341 "renderWithZones": properties.renderWithZones,342 "radiusFinish": 0.2 * fireScaleFactor,343 "radiusSpread": 0.1 * fireScaleFactor,344 "radiusStart": 0.1 * fireScaleFactor,345 "rotation": properties.rotation,346 "textures": PARTICLE_LOW_FLAME_URL,347 "type": "ParticleEffect",348 "grab": {349 "grabbable": false350 }351 }, "local"); 352 } 353 354 function addSparks(entityID) {355 356 var properties = Entities.getEntityProperties(entityID,["position", "rotation", "renderWithZones"]); 357 358 sparksFlamId = Entities.addEntity({359 "accelerationSpread": { 360 "x": 0,361 "y": 0,362 "z": 0363 }, 364 "alpha": 0.5,365 "alphaFinish": 0,366 "alphaSpread": 0,367 "alphaStart": 1,368 "azimuthStart": -3.14159,369 "azimuthFinish": 3.14159, 370 "collisionless": 1,371 "color": {372 "blue": 0,373 "green": 77,374 "red": 255375 },376 "colorFinish": {377 "blue": 0,378 "green": 0,379 "red": 255380 },381 "colorSpread": {382 "blue": 0,383 "green": 15,384 "red": 0385 },386 "colorStart": {387 "blue": 0,388 "green": 183,389 "red": 255390 },391 "dimensions": {392 "x": 2.5576000213623047 * fireScaleFactor,393 "y": 2.5576000213623047 * fireScaleFactor,394 "z": 2.5576000213623047 * fireScaleFactor395 },396 "emitAcceleration": {397 "x": 0,398 "y": 2 * fireScaleFactor,399 "z": 0400 },401 "emitDimensions": {402 "x": 0.4 * fireScaleFactor,403 "y": 0.2 * fireScaleFactor,404 "z": 0.4 * fireScaleFactor405 },406 "emitOrientation": {407 "w": 1,408 "x": 0,409 "y": 0,410 "z": 0411 },412 "emitRate": 3 * fireScaleFactor,413 "emitterShouldTrail": 0, 414 "emitSpeed": 0,415 "speedSpread": 0.1 * fireScaleFactor,416 "ignoreForCollisions": 1,417 "isEmitting": 1, 418 "lifespan": 1.6 * fireScaleFactor,419 "maxParticles": 20 * fireScaleFactor,420 "name": "Sparks Particles",421 "particleRadius": 0.2,422 "polarStart": Math.PI/2,423 "polarFinish": Math.PI,424 "position":{425 "x": properties.position.x,426 "y": properties.position.y,427 "z": properties.position.z428 },429 "parentID": entityID,430 "radiusFinish": 0.2,431 "radiusSpread": 0,432 "radiusStart": 0.2,433 "rotation": properties.rotation,434 "renderWithZones": properties.renderWithZones,435 "textures": PARTICLE_SPARK_URL,436 "type": "ParticleEffect",437 "grab": {438 "grabbable": false439 }440 }, "local");441 } 442 function addLight(entityID){443 var state = GetCurrentCycleValue(100, FIRE_CYCLE);444 var falloffRadius = 3;445 var color = {446 "blue": 0,447 "green": 128,448 "red": 255449 };450 if (state > 49){451 color = {452 "blue": 0,453 "green": 68,454 "red": 255455 };456 falloffRadius = 1.6;457 }458 var properties = Entities.getEntityProperties(entityID,["position", "rotation", "renderWithZones"]); 459 lightFireId = Entities.addEntity({460 "color": color,461 "cutoff": 90,462 "dimensions": {463 "x": 6 * fireScaleFactor,464 "y": 6 * fireScaleFactor,465 "z": 6 * fireScaleFactor466 },467 "exponent": 0.20,468 "falloffRadius": falloffRadius,469 "isSpotlight": true,470 "intensity": 1.0,471 "name": "FIRE-LIGHT",472 "rotation": {473 "w": 0.7071067690849304,474 "x": 0.7071067690849304,475 "y": 0,476 "z": 0477 },478 "position": {479 "x": properties.position.x,480 "y": properties.position.y - (0.11 * fireScaleFactor), 481 "z": properties.position.z 482 },483 "renderWithZones": properties.renderWithZones, 484 "parentID": entityID, 485 "script": LIGHT_FLICKER_SCRIPT_URL,486 "type": "Light",487 "grab": {488 "grabbable": false489 }490 }, "local"); 491 } 492 493 function playFireSound(){494 var state = GetCurrentCycleValue(100, FIRE_CYCLE);495 volume = 0.8;496 if (state > 49){497 volume = 0.4;498 }499 var prop = Entities.getEntityProperties(thisEntityId, ["position"]); 500 fireSoundInjector = Audio.playSound(fireSound, {501 "position": prop.position,502 "loop": true,503 "volume": volume * masterVolume504 });505 }506 /*507 * Return the current position in a cycle 508 * for specific time length509 *510 * @param {number integer} cyclelength a cycle goes from 0 to cyclelength511 * @param {number integer} cycleduration duration of a cycle in seconds.512 * @return {number double} current position in the cycle (double)513 */514 function GetCurrentCycleValue(cyclelength, cycleduration){515 var today = new Date();516 var TodaySec = today.getTime()/1000;517 var CurrentSec = TodaySec%cycleduration;518 519 return (CurrentSec/cycleduration)*cyclelength;520 521 }...
App.test.js
Source:App.test.js
1import React from 'react';2import ReactDOM from 'react-dom';3import { act } from 'react-dom/test-utils';4import { render, fireEvent, getByTestId, getByText } from '@testing-library/react';5import Calculator from "./components/Calculator";6describe('ê³ì°ê¸° í
ì¤í¸', () => {7 it('(â ë²í¼ì ì¶ê°íë ì§)', () => {8 const utils = render(<Calculator/>);9 utils.getByText('â');10 });11 it('(history ì¶ê°íë ì§)', () => {12 const utils = render(<Calculator/>);13 utils.getByText('â');14 });15 it('40 - 31 == 9', () => {16 const utils = render(<Calculator/>);17 let btn_4 = utils.getByText('4');18 let btn_0 = utils.getByText('0');19 let btn_3 = utils.getByText('3');20 let btn_1 = utils.getByText('1');21 let minus = utils.getByText('-');22 expect(utils.getByTestId('display').textContent).toBe('');23 act(() => {fireEvent.click(btn_4);});24 act(() => {fireEvent.click(btn_0);});25 act(() => {fireEvent.click(minus);});26 act(() => {fireEvent.click(btn_3);});27 act(() => {fireEvent.click(btn_1);});28 expect(utils.getByTestId('display').textContent).toBe('40-31');29 act(() => {fireEvent.click(utils.getByText('='));})30 expect(utils.getByTestId('display').textContent).toBe('9');31 })32 it('3.14 == 3.14', () => {33 const utils = render(<Calculator/>);34 let btn_4 = utils.getByText('4');35 let btn_3 = utils.getByText('3');36 let btn_1 = utils.getByText('1');37 let point = utils.getByText('.');38 expect(utils.getByTestId('display').textContent).toBe('');39 act(() => {fireEvent.click(btn_3);});40 act(() => {fireEvent.click(point);});41 act(() => {fireEvent.click(btn_1);});42 act(() => {fireEvent.click(btn_4);});43 expect(utils.getByTestId('display').textContent).toBe('3.14');44 act(() => {fireEvent.click(utils.getByText('='));})45 expect(utils.getByTestId('display').textContent).toBe('3.14');46 })47 it('3..14 == 3.14', () => {48 const utils = render(<Calculator/>);49 let btn_4 = utils.getByText('4');50 let btn_3 = utils.getByText('3');51 let btn_1 = utils.getByText('1');52 let point = utils.getByText('.');53 expect(utils.getByTestId('display').textContent).toBe('');54 act(() => {fireEvent.click(btn_3);});55 act(() => {fireEvent.click(point);});56 act(() => {fireEvent.click(point);}); // 무ìëì´ì¼ í¨57 act(() => {fireEvent.click(btn_1);});58 act(() => {fireEvent.click(btn_4);});59 expect(utils.getByTestId('display').textContent).toBe('3.14');60 act(() => {fireEvent.click(utils.getByText('='));})61 expect(utils.getByTestId('display').textContent).toBe('3.14');62 })63 it('3.1.4 == 3.14', () => {64 const utils = render(<Calculator/>);65 let btn_4 = utils.getByText('4');66 let btn_3 = utils.getByText('3');67 let btn_1 = utils.getByText('1');68 let point = utils.getByText('.');69 expect(utils.getByTestId('display').textContent).toBe('');70 act(() => {fireEvent.click(btn_3);});71 act(() => {fireEvent.click(point);});72 act(() => {fireEvent.click(btn_1);});73 act(() => {fireEvent.click(point);}); // 무ìëì´ì¼ í¨74 act(() => {fireEvent.click(btn_4);});75 expect(utils.getByTestId('display').textContent).toBe('3.14');76 act(() => {fireEvent.click(utils.getByText('='));})77 expect(utils.getByTestId('display').textContent).toBe('3.14');78 })79 it('97 à 107 == 10379', () => {80 const utils = render(<Calculator/>);81 expect(utils.getByTestId('display').textContent).toBe('');82 let btn_9 = utils.getByText('9');83 let btn_7 = utils.getByText('7');84 let btn_1 = utils.getByText('1');85 let btn_0 = utils.getByText('0');86 let mult = utils.getByText('Ã');87 act(() => {fireEvent.click(btn_9);});88 act(() => {fireEvent.click(btn_7);});89 act(() => {fireEvent.click(mult);});90 act(() => {fireEvent.click(btn_1);});91 act(() => {fireEvent.click(btn_0);});92 act(() => {fireEvent.click(btn_7);});93 expect(utils.getByTestId('display').textContent).toBe('97Ã107');94 act(() => {fireEvent.click(utils.getByText('='));});95 expect(utils.getByTestId('display').textContent).toBe('10379');96 })97 it('2 à 2 à 2 == 8', () => {98 const utils = render(<Calculator/>);99 expect(utils.getByTestId('display').textContent).toBe('');100 let btn_2 = utils.getByText('2');101 let mult = utils.getByText('Ã');102 act(() => {fireEvent.click(btn_2);});103 act(() => {fireEvent.click(mult);});104 act(() => {fireEvent.click(btn_2);});105 act(() => {fireEvent.click(mult);});106 act(() => {fireEvent.click(btn_2);});107 expect(utils.getByTestId('display').textContent).toBe('2Ã2Ã2');108 act(() => {fireEvent.click(utils.getByText('='));});109 expect(utils.getByTestId('display').textContent).toBe('8');110 })111 it('16 ÷ 4 == 4', () => {112 const utils = render(<Calculator/>);113 expect(utils.getByTestId('display').textContent).toBe('');114 let btn_1 = utils.getByText('1');115 let btn_6 = utils.getByText('6');116 let btn_4 = utils.getByText('4');117 let div = utils.getByText('÷');118 act(() => {fireEvent.click(btn_1);});119 act(() => {fireEvent.click(btn_6);});120 act(() => {fireEvent.click(div);});121 act(() => {fireEvent.click(btn_4);});122 expect(utils.getByTestId('display').textContent).toBe('16÷4');123 act(() => {fireEvent.click(utils.getByText('='));});124 expect(utils.getByTestId('display').textContent).toBe('4');125 })126 it('16 ÷ 2 ÷ 4 == 2', () => {127 const utils = render(<Calculator/>);128 expect(utils.getByTestId('display').textContent).toBe('');129 let btn_1 = utils.getByText('1');130 let btn_6 = utils.getByText('6');131 let btn_2 = utils.getByText('2');132 let btn_4 = utils.getByText('4');133 let div = utils.getByText('÷');134 act(() => {fireEvent.click(btn_1);});135 act(() => {fireEvent.click(btn_6);});136 act(() => {fireEvent.click(div);});137 act(() => {fireEvent.click(btn_2);});138 act(() => {fireEvent.click(div);});139 act(() => {fireEvent.click(btn_4);});140 expect(utils.getByTestId('display').textContent).toBe('16÷2÷4');141 act(() => {fireEvent.click(utils.getByText('='));})142 expect(utils.getByTestId('display').textContent).toBe('2');143 })144 it('â16 == 4', () => {145 const utils = render(<Calculator/>);146 expect(utils.getByTestId('display').textContent).toBe('');147 let btn_1 = utils.getByText('1');148 let btn_6 = utils.getByText('6');149 let root = utils.getByText('â');150 act(() => {fireEvent.click(btn_1);});151 act(() => {fireEvent.click(btn_6);});152 expect(utils.getByTestId('display').textContent).toBe('16');153 act(() => {fireEvent.click(root);});154 expect(utils.getByTestId('display').textContent).toBe('4');155 })156 it('â(77 + 4) == 9', () => {157 const utils = render(<Calculator/>);158 expect(utils.getByTestId('display').textContent).toBe('');159 let btn_7 = utils.getByText('7');160 let btn_4 = utils.getByText('4');161 let root = utils.getByText('â');162 let plus = utils.getByText('+');163 act(() => {fireEvent.click(btn_7);});164 act(() => {fireEvent.click(btn_7);});165 act(() => {fireEvent.click(plus);});166 act(() => {fireEvent.click(btn_4);});167 expect(utils.getByTestId('display').textContent).toBe('77+4');168 act(() => {fireEvent.click(root);});169 expect(utils.getByTestId('display').textContent).toBe('9');170 })171 it('â(77 + 4) == 9', () => {172 const utils = render(<Calculator/>);173 expect(utils.getByTestId('display').textContent).toBe('');174 let btn_7 = utils.getByText('7');175 let btn_4 = utils.getByText('4');176 let root = utils.getByText('â');177 let plus = utils.getByText('+');178 act(() => {fireEvent.click(btn_7);});179 act(() => {fireEvent.click(btn_7);});180 act(() => {fireEvent.click(plus);});181 act(() => {fireEvent.click(btn_4);});182 expect(utils.getByTestId('display').textContent).toBe('77+4');183 act(() => {fireEvent.click(root);});184 expect(utils.getByTestId('display').textContent).toBe('9');185 })186 it('â(77 + 4) == 9', () => {187 const utils = render(<Calculator/>);188 expect(utils.getByTestId('display').textContent).toBe('');189 let btn_7 = utils.getByText('7');190 let btn_4 = utils.getByText('4');191 let root = utils.getByText('â');192 let plus = utils.getByText('+');193 act(() => {fireEvent.click(btn_7);});194 act(() => {fireEvent.click(btn_7);});195 act(() => {fireEvent.click(plus);});196 act(() => {fireEvent.click(btn_4);});197 expect(utils.getByTestId('display').textContent).toBe('77+4');198 act(() => {fireEvent.click(root);});199 expect(utils.getByTestId('display').textContent).toBe('9');200 })201 it('â("") 무ì', () => {202 const utils = render(<Calculator/>);203 expect(utils.getByTestId('display').textContent).toBe('');204 let root = utils.getByText('â');205 act(() => {fireEvent.click(root);});206 expect(utils.getByTestId('display').textContent).toBe('');207 })208 it('history ìì±', () => {209 const utils = render(<Calculator/>);210 expect(utils.getByTestId('display').textContent).toBe('');211 let btn_7 = utils.getByText('7');212 let btn_4 = utils.getByText('4');213 let plus = utils.getByText('+');214 act(() => {fireEvent.click(btn_7);});215 act(() => {fireEvent.click(plus);});216 act(() => {fireEvent.click(btn_4);});217 expect(utils.getByTestId('display').textContent).toBe('7+4');218 act(() => {fireEvent.click(utils.getByText('='));})219 expect(utils.getByTestId('display').textContent).toBe('11');220 expect(utils.getByTestId('history').childNodes[0].childNodes[0].textContent).toBe('7+4');221 expect(utils.getByTestId('history').childNodes[0].childNodes[1].textContent).toBe('= 11');222 })223 it('history í´ë¦', () => {224 const utils = render(<Calculator/>);225 expect(utils.getByTestId('display').textContent).toBe('');226 let btn_7 = utils.getByText('7');227 let btn_4 = utils.getByText('4');228 let plus = utils.getByText('+');229 act(() => {fireEvent.click(btn_7);});230 act(() => {fireEvent.click(plus);});231 act(() => {fireEvent.click(btn_4);});232 expect(utils.getByTestId('display').textContent).toBe('7+4');233 act(() => {fireEvent.click(utils.getByText('='));});234 expect(utils.getByTestId('display').textContent).toBe('11');235 act(() => {fireEvent.click(utils.getByTestId('history').childNodes[0]);});236 expect(utils.getByTestId('display').textContent).toBe('7+4');237 })238 it('â history í´ë¦', () => {239 const utils = render(<Calculator/>);240 expect(utils.getByTestId('display').textContent).toBe('');241 let btn_9 = utils.getByText('9');242 let root = utils.getByText('â');243 act(() => {fireEvent.click(btn_9);});244 act(() => {fireEvent.click(root);});245 expect(utils.getByTestId('display').textContent).toBe('3');246 act(() => {fireEvent.click(utils.getByTestId('history').childNodes[0]);});247 expect(utils.getByTestId('display').textContent).toBe('â(9)');248 })249 it('â history í´ë¦ ì´í = ì¬ì¤í', () => {250 const utils = render(<Calculator/>);251 expect(utils.getByTestId('display').textContent).toBe('');252 let btn_9 = utils.getByText('9');253 let root = utils.getByText('â');254 act(() => {fireEvent.click(btn_9);});255 act(() => {fireEvent.click(root);});256 expect(utils.getByTestId('display').textContent).toBe('3');257 act(() => {fireEvent.click(utils.getByTestId('history').childNodes[0]);});258 expect(utils.getByTestId('display').textContent).toBe('â(9)');259 act(() => {fireEvent.click(utils.getByText('='));});260 expect(utils.getByTestId('display').textContent).toBe('3');261 })262 it('â history í´ë¦ ì´í â ì¬ì¤í', () => {263 const utils = render(<Calculator/>);264 expect(utils.getByTestId('display').textContent).toBe('');265 let btn_1 = utils.getByText('1');266 let btn_6 = utils.getByText('6');267 let root = utils.getByText('â');268 act(() => {fireEvent.click(btn_1);});269 act(() => {fireEvent.click(btn_6);});270 act(() => {fireEvent.click(root);});271 expect(utils.getByTestId('display').textContent).toBe('4');272 act(() => {fireEvent.click(utils.getByTestId('history').childNodes[0]);});273 expect(utils.getByTestId('display').textContent).toBe('â(16)');274 act(() => {fireEvent.click(root);});275 expect(utils.getByTestId('display').textContent).toBe('2');276 expect(utils.getByTestId('history').childNodes[0].childNodes[0].textContent).toBe('â(â(16))');277 expect(utils.getByTestId('history').childNodes[0].childNodes[1].textContent).toBe('= 2');278 expect(utils.getByTestId('history').childNodes[1].childNodes[0].textContent).toBe('â(16)');279 expect(utils.getByTestId('history').childNodes[1].childNodes[1].textContent).toBe('= 4');280 })...
Tap.js
Source:Tap.js
...14 }); 15 16 it("should fire", function() {17 runs(function() {18 eventSimulator.fire('mousedown', document.body, {19 pageX: 10,20 pageY: 1021 }); 22 });23 waits(5);24 runs(function() {25 expect(spy).wasCalled();26 });27 });28 });29 30 describe("tap", function() {31 beforeEach(function() {32 spy = spyOn(listener, 'fire');33 manager.addEventListener(document.body, 'tap', listener.fire, {34 cancelThreshold: 535 });36 37 eventSimulator.fire('mousedown', document.body, {38 pageX: 10,39 pageY: 1040 });41 });42 afterEach(function() {43 manager.removeEventListener(document.body, 'tap', listener.fire);44 }); 45 46 it("should fire", function() {47 runs(function() {48 eventSimulator.fire('mouseup', document.body, {}); 49 });50 waits(5);51 runs(function() {52 expect(spy).wasCalled();53 });54 });55 56 it("should not fire when moved 5px", function() {57 runs(function() {58 eventSimulator.fire('mousemove', document.body, {59 pageX: 15,60 pageY: 1561 });62 eventSimulator.fire('mouseup', document.body, {});63 });64 waits(5);65 runs(function() {66 expect(spy).wasNotCalled();67 });68 });69 });70 71 describe("tapcancel", function() {72 beforeEach(function() {73 spy = spyOn(listener, 'fire');74 manager.addEventListener(document.body, 'tapcancel', listener.fire, {75 cancelThreshold: 576 });77 78 eventSimulator.fire('mousedown', document.body, {79 pageX: 10,80 pageY: 1081 });82 });83 afterEach(function() {84 manager.removeEventListener(document.body, 'tapcancel', listener.fire);85 eventSimulator.fire('mouseup', document.body, {});86 }); 87 88 it("should fire when moved 5px", function() {89 runs(function() {90 eventSimulator.fire('mousemove', document.body, {91 pageX: 15,92 pageY: 1593 }); 94 });95 waits(5);96 runs(function() {97 expect(spy).wasCalled();98 });99 });100 101 it("should not fire when not moved 5px", function() {102 runs(function() {103 eventSimulator.fire('mousemove', document.body, {104 pageX: 13,105 pageY: 13106 });107 });108 waits(5);109 runs(function() {110 expect(spy).wasNotCalled();111 });112 });113 });114 115 describe("doubletap", function() {116 beforeEach(function() {117 spy = spyOn(listener, 'fire');118 manager.addEventListener(document.body, 'doubletap', listener.fire, {119 doubleTapThreshold: 500120 });121 122 eventSimulator.fire('mousedown', document.body, {123 pageX: 10,124 pageY: 10125 });126 });127 afterEach(function() {128 manager.removeEventListener(document.body, 'doubletap', listener.fire);129 }); 130 131 it("should fire", function() {132 runs(function() {133 eventSimulator.fire('mouseup', document.body, {});134 eventSimulator.fire('mousedown', document.body, {135 pageX: 10,136 pageY: 10137 });138 eventSimulator.fire('mouseup', document.body, {});139 });140 waits(5);141 runs(function() {142 expect(spy).wasCalled();143 });144 });145 146 it("should not fire when more then doubleTapThreshold", function() {147 runs(function() {148 eventSimulator.fire('mouseup', document.body, {});149 });150 waits(800);151 152 runs(function() {153 eventSimulator.fire('mousedown', document.body, {154 pageX: 10,155 pageY: 10156 });157 eventSimulator.fire('mouseup', document.body, {});158 })159 waits(5);160 161 runs(function() {162 expect(spy).wasNotCalled();163 });164 });165 });166 167 describe("singletap", function() {168 beforeEach(function() {169 spy = spyOn(listener, 'fire');170 manager.addEventListener(document.body, 'singletap', listener.fire, {171 singleTapThreshold: 500172 });173 174 eventSimulator.fire('mousedown', document.body, {175 pageX: 10,176 pageY: 10177 });178 });179 afterEach(function() {180 manager.removeEventListener(document.body, 'singletap', listener.fire);181 }); 182 183 it("should fire", function() {184 runs(function() {185 eventSimulator.fire('mouseup', document.body, {});186 });187 waits(5);188 runs(function() {189 expect(spy).wasCalled();190 });191 });192 193 it("should not fire within 500ms of the last one", function() {194 runs(function() {195 eventSimulator.fire('mouseup', document.body, {});196 });197 waits(5);198 runs(function() {199 expect(spy).wasCalled();200 });201 202 waits(100);203 204 runs(function() {205 eventSimulator.fire('mousedown', document.body, {206 pageX: 10,207 pageY: 10208 });209 eventSimulator.fire('mouseup', document.body, {});210 });211 212 waits(5);213 214 runs(function() {215 expect(spy.callCount).toEqual(1);216 });217 });218 219 it("should fire again after more then 500ms", function() {220 runs(function() {221 eventSimulator.fire('mouseup', document.body, {});222 });223 waits(5);224 runs(function() {225 expect(spy).wasCalled();226 });227 228 waits(600);229 230 runs(function() {231 eventSimulator.fire('mousedown', document.body, {232 pageX: 10,233 pageY: 10234 });235 eventSimulator.fire('mouseup', document.body, {});236 });237 238 waits(5);239 240 runs(function() {241 expect(spy.callCount).toEqual(2);242 });243 });244 });245 246 describe("taphold", function() {247 beforeEach(function() {248 spy = spyOn(listener, 'fire');249 manager.addEventListener(document.body, 'taphold', listener.fire, {250 holdThreshold: 100251 });252 253 eventSimulator.fire('mousedown', document.body, {254 pageX: 10,255 pageY: 10256 });257 });258 afterEach(function() {259 manager.removeEventListener(document.body, 'taphold', listener.fire);260 }); 261 262 it("should fire", function() {263 waits(200);264 265 runs(function() {266 eventSimulator.fire('mouseup', document.body, {}); 267 });268 waits(5);269 runs(function() {270 expect(spy).wasCalled();271 });272 });273 274 it("should not fire when released before 100ms", function() {275 runs(function() {276 eventSimulator.fire('mouseup', document.body, {}); 277 });278 waits(5);279 runs(function() {280 expect(spy).wasNotCalled();281 });282 });283 });284 });...
fire.js
Source:fire.js
1const firePixelArray = []2const fireWidth = 503const fireHeight = 504const fireColorsPalette = [{ "r": 7, "g": 7, "b": 7 }, { "r": 31, "g": 7, "b": 7 }, { "r": 47, "g": 15, "b": 7 }, { "r": 71, "g": 15, "b": 7 }, { "r": 87, "g": 23, "b": 7 }, { "r": 103, "g": 31, "b": 7 }, { "r": 119, "g": 31, "b": 7 }, { "r": 143, "g": 39, "b": 7 }, { "r": 159, "g": 47, "b": 7 }, { "r": 175, "g": 63, "b": 7 }, { "r": 191, "g": 71, "b": 7 }, { "r": 199, "g": 71, "b": 7 }, { "r": 223, "g": 79, "b": 7 }, { "r": 223, "g": 87, "b": 7 }, { "r": 223, "g": 87, "b": 7 }, { "r": 215, "g": 95, "b": 7 }, { "r": 215, "g": 95, "b": 7 }, { "r": 215, "g": 103, "b": 15 }, { "r": 207, "g": 111, "b": 15 }, { "r": 207, "g": 119, "b": 15 }, { "r": 207, "g": 127, "b": 15 }, { "r": 207, "g": 135, "b": 23 }, { "r": 199, "g": 135, "b": 23 }, { "r": 199, "g": 143, "b": 23 }, { "r": 199, "g": 151, "b": 31 }, { "r": 191, "g": 159, "b": 31 }, { "r": 191, "g": 159, "b": 31 }, { "r": 191, "g": 167, "b": 39 }, { "r": 191, "g": 167, "b": 39 }, { "r": 191, "g": 175, "b": 47 }, { "r": 183, "g": 175, "b": 47 }, { "r": 183, "g": 183, "b": 47 }, { "r": 183, "g": 183, "b": 55 }, { "r": 207, "g": 207, "b": 111 }, { "r": 223, "g": 223, "b": 159 }, { "r": 239, "g": 239, "b": 199 }, { "r": 255, "g": 255, "b": 255 }]5let fireIntensityChanger = 366let isDebugActive = false7function debugMode() {8 if (isDebugActive == true) {9 return isDebugActive = false10 }11 return isDebugActive = true;12}13// initial function14function start() {15 createFireDataStructure()16 createFireSource()17 renderFire()18 setInterval(calculateFirePropagation, 50)19}20function createFireDataStructure() {21 // create a 2D array22 // each array position is a fire's pixel with an intensity23 const numberOfPixels = fireWidth * fireHeight24 for (let i = 0; i < numberOfPixels; i++) {25 firePixelArray[i] = 026 }27}28function calculateFirePropagation() {29 // run over the columns first and after render fire30 for (let column = 0; column < fireWidth; column++) {31 for (let row = 0; row < fireHeight; row++) {32 const pixelIndex = column + (fireWidth * row)33 updateFireIntensityPerPixel(pixelIndex)34 }35 }36 renderFire()37}38function updateFireIntensityPerPixel(currentPixelIndex) {39 belowPixelIndex = currentPixelIndex + fireWidth40 if (belowPixelIndex > fireWidth * fireHeight) {41 return42 }43 const decay = Math.floor(Math.random() * 3)44 const belowPixelFireIntensity = firePixelArray[belowPixelIndex]45 const newFireIntensity = belowPixelFireIntensity - decay >= 0 ? belowPixelFireIntensity - decay : 046 firePixelArray[currentPixelIndex - decay] = newFireIntensity47}48function createFireSource() {49 for (let column = 0; column <= fireWidth; column++) {50 const overflowPixelIndex = fireWidth * fireHeight51 const pixelIndex = (overflowPixelIndex - fireWidth) + column52 firePixelArray[pixelIndex] = fireIntensityChanger53 }54}55function renderFire() {56 const debug = isDebugActive57 // table58 let html = '<table cellpadding=0 cellspacing=0>'59 // rows60 for (let row = 0; row < fireHeight; row++) {61 html += '<tr>'62 // columns63 for (let column = 0; column < fireWidth; column++) {64 // discover the position vertical and horizontal 65 const pixelIndex = column + (fireWidth * row)66 // get the fireIntensity on the structure67 const fireIntensity = firePixelArray[pixelIndex]68 if (debug === true) {69 const color = fireColorsPalette[fireIntensity]70 const colorString = `${color.r},${color.g},${color.b}`71 html += '<td>'72 html += `<div class="pixel-index">${pixelIndex}</div>`73 html += `<div style="color: rgb(${colorString})">`74 html += fireIntensity75 html += `</div>`76 html += '</td>'77 } else {78 const color = fireColorsPalette[fireIntensity]79 const colorString = `${color.r},${color.g},${color.b}`80 html += `<td class="pixel" style="background-color: rgb(${colorString})">`81 html += `</td>`82 }83 }84 html += '</tr>'85 }86 html += '</table>'87 document.querySelector('#fireCanvas').innerHTML = html88}89function destroyFire() {90 for (let column = 0; column <= fireHeight; column++) {91 const overflowPixelIndex = fireWidth * fireHeight92 const pixelIndex = (overflowPixelIndex - fireWidth) + column93 firePixelArray[pixelIndex] = 094 if (firePixelArray[pixelIndex] > 0) {95 firePixelArray[pixelIndex] = 096 }97 }98}99function decreaseFire() {100 for (let column = 0; column <= fireHeight; column++) {101 const overflowPixelIndex = fireHeight * fireWidth102 const pixelIndex = (overflowPixelIndex - fireWidth) + column103 const currentFireIntensity = firePixelArray[pixelIndex]104 if (currentFireIntensity > 0) {105 const decrease = Math.floor(Math.random() * 14)106 const newFireIntensity = currentFireIntensity - decrease < 0 ? 0 : currentFireIntensity - decrease107 firePixelArray[pixelIndex] = newFireIntensity108 }109 }110}111function maxFire() {112 for (let column = 0; column <= fireHeight; column++) {113 const overflowPixelIndex = fireWidth * fireHeight114 const pixelIndex = (overflowPixelIndex - fireWidth) + column115 firePixelArray[pixelIndex] = 36116 }117}118function growFire() {119 for (let column = 0; column < fireHeight; column++) {120 const overflowPixelIndex = fireHeight * fireWidth121 const pixelIndex = (overflowPixelIndex - fireWidth) + column122 const currentFireIntensity = firePixelArray[pixelIndex]123 if (currentFireIntensity < 36) {124 const increase = Math.floor(Math.random() * 14)125 const newFireIntensity = currentFireIntensity + increase > 36 ? 36 : currentFireIntensity + increase126 firePixelArray[pixelIndex] = newFireIntensity127 }128 }129}...
serviceDetails.js
Source:serviceDetails.js
1import React, { Component } from 'react';2import PubSub from 'pubsub-js';3const attributeList = {4 "fireExtinguishers": [{"image": "./fireExtinguishers/automaticFireExtinguishers.png", "title": "Automatic Fire Extinguishers"},5 {"image": "./fireExtinguishers/backupTrolleyFireExtinguishers.png", "title": "Backup Trolley Mount Fire Extinguishers"},6 {"image": "./fireExtinguishers/carbonDioxideFireExtinguishers.png", "title": "Carbon dioxide Fire Extinguishers"},7 {"image": "./fireExtinguishers/cleanAgentFireExtinguishers.png", "title": "Clean Agent Fire Extinguishers"},8 {"image": "./fireExtinguishers/foamFireExtinguishers.png", "title": "Foam Fire Extinguishers"},9 {"image": "./fireExtinguishers/mriSafeFireExtinguishers.png", "title": "MRI Safe Fire Extinguishers"},10 {"image": "./fireExtinguishers/powderFireExtinguishers.png", "title": "Powder Fire Extinguishers"},11 {"image": "./fireExtinguishers/waterFireExtinguishers.png", "title": "Water Fire Extinguishers"},12 {"image": "./fireExtinguishers/waterMistFireExtinguishers.png", "title": "Water Mist Fire Extinguishers"}],13 "safetySuits": [{"image": "./safetySuits/boilerSuits.png", "title": "Boiler Suits"},14 {"image": "./safetySuits/fireSuits.png", "title": "Fire Suits"},15 {"image": "./safetySuits/industrialSuits.png", "title": "Industrial Suits"}]16 };17const style = {18 background: '#222d32',19 display: 'inline-block',20 width: 'calc(100% - 330px)',21 minWidth: '670px',22 margin: '0 0 0 10px',23 minHeight: '60vh',24 borderRadius: '10px',25 position: 'relative',26 verticalAlign: 'top',27 overflow: 'auto',28 backgroundRepeat: 'no-repeat',29 backgroundPosition: 'center center',30 marginTop: '10px'31};32class serviceDetails extends Component {33 constructor(props) {34 super(props);35// this.state = {itemList: attributeList["fireExtinguishers"]};36 }37 sideMenuSelectionUpdate = (msg, data) => {38 if(attributeList[data.selection])39 this.setState({itemList: attributeList[data.selection]});40 }41 componentDidMount() {42// this.setState({itemList: attributeList["fireExtinguishers"]});43 this.token = PubSub.subscribe('sideMenu', this.sideMenuSelectionUpdate);44 }45 render(){46 return (47 <div style = {style}>48 </div>49 );50 }51}...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.fire('input', 'input[name="q"]', { type: 'keydown', key: 'Enter' });7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();
Using AI Code Generation
1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch({headless: false});4 const page = await browser.newPage();5 await page.fire('input[name="q"]', 'Playwright');6 await browser.close();7})();8const {chromium} = require('playwright');9(async () => {10 const browser = await chromium.launch({headless: false});11 const page = await browser.newPage();12 await page.fire('input[name="q"]', 'Playwright');13 await browser.close();14})();15const {chromium} = require('playwright');16(async () => {17 const browser = await chromium.launch({headless: false});18 const page = await browser.newPage();19 await page.fire('input[name="q"]', 'Playwright');20 await browser.close();21})();22const {chromium} = require('playwright');23(async () => {24 const browser = await chromium.launch({headless: false});25 const page = await browser.newPage();26 await page.fire('input[name="q"]', 'Playwright');27 await browser.close();28})();29const {chromium} = require('playwright');30(async () => {31 const browser = await chromium.launch({headless: false});32 const page = await browser.newPage();33 await page.fire('input[name="q"]', 'Playwright');34 await browser.close();35})();36const {chromium} = require('playwright');37(async () => {38 const browser = await chromium.launch({headless: false});39 const page = await browser.newPage();40 await page.fire('input[name="q"]', 'Playwright
Using AI Code Generation
1const { chromium, firefox, webkit } = require('playwright');2const browser = await chromium.launch();3const page = await browser.newPage();4await page.fire('keydown', { keyCode: 13 });5await page.close();6await browser.close();7const playwright = require('playwright');8playwright.fire('keydown', { keyCode: 13 });9"compilerOptions": {10}11const playwright = require('playwright');12playwright.fire('keydown', { keyCode: 13 });13"compilerOptions": {14}
Using AI Code Generation
1const { fire } = require('playwright/lib/internal/inspectorInstrumentation');2const { chromium } = require('playwright');3const { test } = require('@playwright/test');4test('test', async ({ page }) => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.click('text=Get started');9});
Using AI Code Generation
1await page.fire('input[type="text"]', 'input', { value: 'foo' });2await page.fire('input[type="text"]', 'input', { value: 'foo' });3await page.fire('input[type="text"]', 'input', { value: 'foo' });4await page.fire('input[type="text"]', 'input', { value: 'foo' });5await page.fire('input[type="text"]', 'input', { value: 'foo' });6await page.fire('input[type="text"]', 'input', { value: 'foo' });7await page.fire('input[type="text"]', 'input', { value: 'foo' });8await page.fire('input[type="text"]', 'input', { value: 'foo' });9await page.fire('input[type="text"]', 'input', { value: 'foo' });10await page.fire('input[type="text"]', 'input', { value: 'foo' });11await page.fire('input[type="text"]', 'input', { value: 'foo' });12await page.fire('input[type="text"]', 'input', { value: 'foo' });13await page.fire('input[type="text"]', 'input', { value: 'foo' });
Using AI Code Generation
1const {fire} = require('playwright/lib/internal/keyboard');2fire(document.activeElement, 'keydown', {key: 'Escape'});3fire(document.activeElement, 'keyup', {key: 'Escape'});4const {fire} = require('playwright/lib/internal/keyboard');5fire(document.activeElement, 'keydown', {key: 'Escape'});6fire(document.activeElement, 'keyup', {key: 'Escape'});7const {fire} = require('playwright/lib/internal/keyboard');8fire(document.activeElement, 'keydown', {key: 'Escape'});9fire(document.activeElement, 'keyup', {key: 'Escape'});10const {fire} = require('playwright/lib/internal/keyboard');11fire(document.activeElement, 'keydown', {key: 'Escape'});12fire(document.activeElement, 'keyup', {key: 'Escape'});13const {fire} = require('playwright/lib/internal/keyboard');14fire(document.activeElement, 'keydown', {key: 'Escape'});15fire(document.activeElement, 'keyup', {key: 'Escape'});16const {fire} = require('playwright/lib/internal/keyboard');17fire(document.activeElement, 'keydown', {key: 'Escape'});18fire(document.activeElement, 'keyup', {key: 'Escape'});19const {fire} = require('playwright/lib/internal/keyboard');20fire(document.activeElement, 'keydown', {key: 'Escape'});21fire(document.activeElement, 'keyup', {key: 'Escape'});22const {fire} = require('playwright/lib/internal/keyboard');23fire(document.activeElement, 'keydown', {key: 'Escape'});24fire(document.activeElement, 'keyup', {key: 'Escape'});25const {fire} = require('playwright/lib/internal/keyboard');26fire(document.activeElement, 'keydown', {key: 'Escape'});27fire(document.activeElement, 'keyup', {key: 'Escape'});28const {
Using AI Code Generation
1const { _fire } = require('playwright');2const { _fire } = require('playwright');3const { chromium } = require('playwright');4const { firefox } = require('playwright');5const { webkit } = require('playwright');6(async () => {7 const browser = await chromium.launch();8 const context = await browser.newContext();9 const page = await context.newPage();10 await _fire(page, 'keydown', { key: 'a' });11 await _fire(page, 'keydown', { keyCode: 65 });12 await _fire(page, 'keydown', { code: 'KeyA' });13 await _fire(page, 'keydown', { text: 'a' });14 await _fire(page, 'keydown', { shiftKey: true });15 await _fire(page, 'keydown', { ctrlKey: true });16 await _fire(page, 'keydown', { altKey: true });17 await _fire(page, 'keydown', { metaKey: true });18 await _fire(page, 'keydown', { repeat: true });19 await _fire(page, 'keydown', { isComposing: true });20 await _fire(page, 'keydown', { location: 1 });21 await _fire(page, 'keydown', { detail: 1 });22 await _fire(page, 'keydown', { view: window });23 await _fire(page, 'keydown', { bubbles: true });24 await _fire(page, 'keydown', { cancelable: true });25 await _fire(page, 'keydown', { composed: true });26 await _fire(page, 'keydown', { defaultPrevented: true });27 await _fire(page, 'keydown', { eventPhase: 1 });28 await _fire(page, 'keydown', { isTrusted: true });29 await _fire(page, 'keydown', { returnValue: true });30 await _fire(page, 'keydown', { timeStamp: 1 });31 await _fire(page, 'keydown', { cancelBubble: true });32 await _fire(page, 'keydown', { srcElement: page });33 await _fire(page, 'keydown', { currentTarget: page });34 await _fire(page, 'keydown', { path: [page] });35 await _fire(page, 'keydown', { composedPath
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!