How to use fire method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

zh.js

Source:zh.js Github

copy

Full Screen

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": "说明暂缺"...

Full Screen

Full Screen

fireformedit2.js

Source:fireformedit2.js Github

copy

Full Screen

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 = "&nbsp;";632 }else633 {634 var suffix = "<br>";635 var suffixWas = "&nbsp;";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">&nbsp;</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">&nbsp;</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 }...

Full Screen

Full Screen

fireformedit.js

Source:fireformedit.js Github

copy

Full Screen

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 = "&nbsp;";588 }else589 {590 var suffix = "<br>";591 var suffixWas = "&nbsp;";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">&nbsp;</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">&nbsp;</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 }...

Full Screen

Full Screen

fire_manager.js

Source:fire_manager.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful