add_blocks_for_trigger_and_fix_bugs

This commit is contained in:
Eason010212
2025-08-27 19:02:23 +08:00
parent 880f786a52
commit 45384b0c57
5 changed files with 86 additions and 8 deletions

View File

@@ -80,13 +80,14 @@ var MixIO = {
DASHBOARD: 11,
DATA_MAP: 12,
WEATHER: 13,
TIMER: 14
TIMER: 14,
TRIGGER: 15
},
oldTags: ["input_button", "input_slider", "input_keyboard", "input_controller", "input_rgb", "output_bulb", "output_text",
"output_chart", "output_bar", "table", "output_dashboard", "output_map", "input_weather", "timer"
"output_chart", "output_bar", "table", "output_dashboard", "output_map", "input_weather", "timer", "trigger"
],
zhcnTags: ["按键/开关", "滑杆", "文本输入", "摇杆手柄", "RGB色盘", "指示灯", "文本显示屏", "折线图表", "柱状图表", "数据表格", "仪表盘", "数据地图", "实时气象仪", "定时触发器"],
zhcnTags: ["按键/开关", "滑杆", "文本输入", "摇杆手柄", "RGB色盘", "指示灯", "文本显示屏", "折线图表", "柱状图表", "数据表格", "仪表盘", "数据地图", "实时气象仪", "定时触发器", "条件触发器"],
/*合法的MixIO事件种类*/
eventTags: {
@@ -124,7 +125,9 @@ var MixIO = {
WEATHER_SYNCED: "1311", //气象仪更新数据
WEATHER_SENT: "1312", //气象仪发送数据
TIMER_TRIGGERED: "1411"
TIMER_TRIGGERED: "1411",
TRIGGER_TRIGGERED: "1511"
},
@@ -332,7 +335,7 @@ var MixIO = {
instance.getData = function(type) {
return sepMsgs[type]
}
} else if (type === MixIO.typeTags.TIMER){
} else if (type === MixIO.typeTags.TIMER || type === MixIO.typeTags.TRIGGER){
instance.getTriggerTimes = function(){
try{
return parseInt(instance.attr('user-times'))

View File

@@ -800,7 +800,7 @@ function view_project(projectName, projectType) {
}
var modald = showmodaltext("<div style='text-align:center'><i class='fa fa-spin fa-cog' style='font-size:2rem;color:#4e73df'></i><p style='margin-top:6px;margin-bottom:0;color:#4e73df;font-size:1rem;font-weight:bold'>" + JSLang[lang].downloading + "</p></div>")
$.post('getProject', { 'projectName': projectName }, function(res) {
$.post('getProject', { 'projectName': projectName }, async function(res) {
console.log(JSON.parse(res))
modald.close().remove()
if (res == 0) {
@@ -1162,7 +1162,7 @@ function view_project(projectName, projectType) {
'input_mic': add_mic,
'tinydb': add_tinydb,
}
toolkits[un.attr('user-type')](un.attr('user-title'), un.attr('user-topic'), un.attr('user-content'), un.attr('style'), titleHidden)
await toolkits[un.attr('user-type')](un.attr('user-title'), un.attr('user-topic'), un.attr('user-content'), un.attr('style'), titleHidden)
}
var topicOuterDiv = $("<div style='width:100%;display:flex;align-items:center;'></div>")
var topicDiv = $("<div style='z-index:1000;margin:0;display:flex;flex-direction:row;align-items:center;justify-content:center;margin-bottom:20px;width:320px;background-color:white;border-radius:0 0 40px 0;padding-left:10px;padding-right:10px;padding-top:5px;padding-bottom:10px;box-shadow:0 .15rem 1.75rem 0 rgba(58,59,69,.15)!important;flex-wrap:wrap'></div>")

View File

@@ -2675,6 +2675,9 @@ async function add_trigger(user_title, user_topic, user_content, user_style, tit
return true
}
MixIO.triggers[title.text()] = function() {
// Aug 2025
var localTime = 0
title.parent().parent().attr('user-times', localTime)
MixIO.onMessage(function(topic1, message) {
var message = String(message)
if (topic1 == topic.text()) {
@@ -2685,6 +2688,9 @@ async function add_trigger(user_title, user_topic, user_content, user_style, tit
itemdiv.removeClass("triggered")
}, 150)
MixIO.publish(dstTopic, dstMessage)
localTime = localTime + 1
title.parent().parent().attr('user-times', localTime)
itemdiv.trigger(MixIO.eventTags.TRIGGER_TRIGGERED, dstMessage)
} else {
itemdiv.addClass("imtriggered")
setTimeout(function() {
@@ -2698,6 +2704,9 @@ async function add_trigger(user_title, user_topic, user_content, user_style, tit
itemdiv.removeClass("triggered")
}, 150)
MixIO.publish(dstTopic, dstMessage)
localTime = localTime + 1
title.parent().parent().attr('user-times', localTime)
itemdiv.trigger(MixIO.eventTags.TRIGGER_TRIGGERED, dstMessage)
} else {
itemdiv.addClass("imtriggered")
setTimeout(function() {
@@ -2711,6 +2720,9 @@ async function add_trigger(user_title, user_topic, user_content, user_style, tit
itemdiv.removeClass("triggered")
}, 150)
MixIO.publish(dstTopic, dstMessage)
localTime = localTime + 1
title.parent().parent().attr('user-times', localTime)
itemdiv.trigger(MixIO.eventTags.TRIGGER_TRIGGERED, dstMessage)
} else {
itemdiv.addClass("imtriggered")
setTimeout(function() {