微件:ScenarioSimulator:修订间差异
跳到导航
跳到搜索
小无编辑摘要 |
小无编辑摘要 |
||
第68行: | 第68行: | ||
//(window.RLQ = window.RLQ || []).push(function () { | //(window.RLQ = window.RLQ || []).push(function () { | ||
//$(document).ready(function() { | //$(document).ready(function() { | ||
var | var txt_max = 0,txt_num = 0,now_txt = "",now_txt_max = 0,now_txt_num = 0,now_txt_temp = ""; | ||
var timer_id,flag_timer = false; | var timer_id,flag_timer = false; | ||
var timer_id_auto,timer_id_wait,flag_auto = false; | var timer_id_auto,timer_id_wait,flag_auto = false; | ||
var reset_enabled = false,auto_enabled = true,click_enabled = true,system_enabled = true; | var reset_enabled = false,auto_enabled = true,click_enabled = true,system_enabled = true; | ||
var auto_num = 0; | var auto_num = 0; | ||
var data_temp = ""; | var data_temp = ""; | ||
var data_txt = new Array(); | var data_txt = new Array(); | ||
第95行: | 第93行: | ||
system_enabled = false; | system_enabled = false; | ||
} | } | ||
try | try | ||
{ | { | ||
第142行: | 第139行: | ||
// console.log("system didn't passed."); | // console.log("system didn't passed."); | ||
return; | return; | ||
} | |||
if (debug == true) | |||
{ | |||
num_max = data_txt_test.length; | |||
} | |||
else | |||
{ | |||
num_max = data_txt.length; | |||
} | } | ||
// console.log("system passed."); | // console.log("system passed."); | ||
第148行: | 第154行: | ||
function txt_click(enter_id) | function txt_click(enter_id) | ||
{ | { | ||
if(enter_id == undefined) | if(click_enabled == false && enter_id == undefined) | ||
{ | { | ||
console.log("Has disregard the default settings."); | |||
} | } | ||
else if(click_enabled == false) | else if(click_enabled == false) | ||
第162行: | 第168行: | ||
document.getElementById("button_reset").style.color = ""; | document.getElementById("button_reset").style.color = ""; | ||
} | } | ||
console.log(" | console.log("enter_id=" + enter_id); | ||
if(flag_auto == true) | if(flag_auto == true) | ||
{ | { | ||
第180行: | 第186行: | ||
var place = -1; | var place = -1; | ||
//before | //before | ||
if ( | if (txt_num == txt_max) | ||
{ | { | ||
if(flag_auto == true) | if(flag_auto == true) | ||
第194行: | 第200行: | ||
reset_enabled = false; | reset_enabled = false; | ||
document.getElementById("button_reset").style.color = "#808080"; | document.getElementById("button_reset").style.color = "#808080"; | ||
txt_num = 0; | |||
now_txt_max = 0; | |||
return; | return; | ||
} | } | ||
第202行: | 第208行: | ||
if (debug == true) | if (debug == true) | ||
{ | { | ||
if (data_txt_test[ | if (data_txt_test[txt_num] = "") | ||
{ | { | ||
ret = -3; | ret = -3; | ||
第208行: | 第214行: | ||
ret = txt_check_test(); | ret = txt_check_test(); | ||
} | } | ||
else | else | ||
{ | { | ||
if (data_txt[ | if (data_txt[txt_num] = "") | ||
{ | { | ||
ret = -3; | ret = -3; | ||
第218行: | 第224行: | ||
if(ret == -3) | if(ret == -3) | ||
{ | { | ||
console.log("Has skipped the space part.Data number:" + | console.log("Has skipped the space part.Data number:" + txt_num); | ||
txt_num++; | |||
txt_next(); | txt_next(); | ||
return; | return; | ||
第230行: | 第236行: | ||
else if(ret == -1) | else if(ret == -1) | ||
{ | { | ||
console.log("Has skipped the unused part.Data number:" + | console.log("Has skipped the unused part.Data number:" + txt_num); | ||
txt_num++; | |||
txt_next(); | txt_next(); | ||
return; | return; | ||
第237行: | 第243行: | ||
else if(ret == 1) | else if(ret == 1) | ||
{ | { | ||
console.log("Data analyze complete.Data number:" + | console.log("Data analyze complete.Data number:" + txt_num); | ||
txt_num++; | |||
txt_next(); | txt_next(); | ||
return; | return; | ||
} | } | ||
if( | if(txt_num < txt_max && txt_num >= 0) | ||
{ | { | ||
txt_dynamic(50); | txt_dynamic(50); | ||
第250行: | 第256行: | ||
{ | { | ||
var place = 0,temp = ""; | var place = 0,temp = ""; | ||
if(data_txt[ | if(data_txt[txt_num].indexOf(":") > 0) | ||
{ | { | ||
place = data_txt[ | place = data_txt[txt_num].indexOf(":"); | ||
document.getElementById("txt_name").innerHTML = data_txt[ | document.getElementById("txt_name").innerHTML = data_txt[txt_num].substr(0,place); | ||
now_txt = data_txt[ | now_txt = data_txt[txt_num].substr(place + 1); | ||
console.log("now_txt=" + now_txt); | |||
return 0; | return 0; | ||
} | } | ||
if(data_txt[ | if(data_txt[txt_num].startsWith("[clear]")) | ||
{ | { | ||
document.getElementById("pic_back").style.display = "none"; | document.getElementById("pic_back").style.display = "none"; | ||
第264行: | 第271行: | ||
return 1; | return 1; | ||
} | } | ||
else if(data_txt[ | else if(data_txt[txt_num].startsWith("[clear_back]")) | ||
{ | { | ||
document.getElementById("pic_back").style.display = "none"; | document.getElementById("pic_back").style.display = "none"; | ||
return 1; | return 1; | ||
} | } | ||
else if(data_txt[ | else if(data_txt[txt_num].startsWith("[clear_char]")) | ||
{ | { | ||
document.getElementById("pic_char_1").style.display = "none"; | document.getElementById("pic_char_1").style.display = "none"; | ||
第275行: | 第282行: | ||
return 1; | return 1; | ||
} | } | ||
else if(data_txt[ | else if(data_txt[txt_num].startsWith("[back]")) | ||
{ | { | ||
place = data_txt[ | place = data_txt[txt_num].indexOf("]") + 1; | ||
temp = data_txt[ | temp = data_txt[txt_num].substr(place); | ||
document.getElementById("pic_back").innerHTML = "<img alt=\"" + temp + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[temp] + "\">"; | document.getElementById("pic_back").innerHTML = "<img alt=\"" + temp + "\" width=\"800\" height=\"450\" src=\"" + data_pic_back[temp] + "\">"; | ||
document.getElementById("pic_back").style.display = "block"; | document.getElementById("pic_back").style.display = "block"; | ||
return 1; | return 1; | ||
} | } | ||
else if(data_txt[ | else if(data_txt[txt_num].startsWith("[char]")) | ||
{ | { | ||
place = data_txt[ | place = data_txt[txt_num].indexOf("]") + 1; | ||
temp = data_txt[ | temp = data_txt[txt_num].substr(place); | ||
document.getElementById("pic_char").innerHTML = "<img alt=\"" + temp + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[temp] + "\">"; | document.getElementById("pic_char").innerHTML = "<img alt=\"" + temp + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[temp] + "\">"; | ||
document.getElementById("pic_char_1").style.display = "block"; | document.getElementById("pic_char_1").style.display = "block"; | ||
第292行: | 第299行: | ||
return 1; | return 1; | ||
} | } | ||
else if(data_txt[ | else if(data_txt[txt_num].startsWith("[char_")) | ||
{ | { | ||
var pic_left = "",pic_right = ""; | var pic_left = "",pic_right = ""; | ||
var char_left = document.getElementById("pic_char_left"); | var char_left = document.getElementById("pic_char_left"); | ||
var char_right = document.getElementById("pic_char_right"); | var char_right = document.getElementById("pic_char_right"); | ||
place = data_txt[ | place = data_txt[txt_num].indexOf("]") + 1; | ||
temp = data_txt[ | temp = data_txt[txt_num].substr(place); | ||
temp = temp.split(","); | temp = temp.split(","); | ||
if(temp.length <= 1) | if(temp.length <= 1) | ||
第309行: | 第316行: | ||
char_left.innerHTML = "<img alt=\"" + pic_left + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_left] + "\">"; | char_left.innerHTML = "<img alt=\"" + pic_left + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_left] + "\">"; | ||
char_right.innerHTML = "<img alt=\"" + pic_right + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_right] + "\">"; | char_right.innerHTML = "<img alt=\"" + pic_right + "\" width=\"400\" height=\"400\" src=\"" + data_pic_char[pic_right] + "\">"; | ||
if (data_txt[ | if (data_txt[txt_num].startsWith("[char_left]")) | ||
{ | { | ||
char_left.style.display = "block"; | char_left.style.display = "block"; | ||
char_right.style.display = "none"; | char_right.style.display = "none"; | ||
} | } | ||
else if (data_txt[ | else if (data_txt[txt_num].startsWith("[char_right]")) | ||
{ | { | ||
char_right.style.display = "block"; | char_right.style.display = "block"; | ||
char_left.style.display = "none"; | char_left.style.display = "none"; | ||
} | } | ||
else if (data_txt[ | else if (data_txt[txt_num].startsWith("[char_both]")) | ||
{ | { | ||
char_left.style.display = "block"; | char_left.style.display = "block"; | ||
第328行: | 第335行: | ||
return 1; | return 1; | ||
} | } | ||
now_txt = data_txt[ | now_txt = data_txt[txt_num]; | ||
return 0; | return 0; | ||
} | } | ||
第348行: | 第355行: | ||
timer_id_auto = setInterval("auto_dynamic()",400); | timer_id_auto = setInterval("auto_dynamic()",400); | ||
flag_auto = true; | flag_auto = true; | ||
timer_id_wait = setTimeout("txt_next()", | timer_id_wait = setTimeout("txt_next()",now_txt_max*80+Math.min(now_txt_max,1)*1000); | ||
} | } | ||
else if(flag_auto == true) | else if(flag_auto == true) | ||
第379行: | 第386行: | ||
reset_enabled = false; | reset_enabled = false; | ||
document.getElementById("button_reset").style.color = "#808080" | document.getElementById("button_reset").style.color = "#808080" | ||
txt_num = 0; | |||
now_txt_max = 0; | |||
return; | return; | ||
} | } | ||
第397行: | 第404行: | ||
clearInterval(timer_id); | clearInterval(timer_id); | ||
flag_timer = false; | flag_timer = false; | ||
now_txt_num = 0; | |||
now_txt_temp = ""; | |||
txt_num++; | |||
} | } | ||
function auto_dynamic() | function auto_dynamic() | ||
第421行: | 第428行: | ||
function txt_dynamic(interval) | function txt_dynamic(interval) | ||
{ | { | ||
now_txt_max = now_txt.length; | |||
flag_timer = true; | flag_timer = true; | ||
timer_id = setInterval("timer1()",50); | timer_id = setInterval("timer1()",50); | ||
第427行: | 第434行: | ||
function timer1() | function timer1() | ||
{ | { | ||
if ( | if (now_txt_num < now_txt_max) | ||
{ | { | ||
now_txt_temp = now_txt_temp + now_txt.substr(now_txt_num,1); | |||
document.getElementById("txt_output").innerHTML = | document.getElementById("txt_output").innerHTML = now_txt_temp; | ||
now_txt_num++; | |||
return; | return; | ||
} | } | ||
第438行: | 第445行: | ||
if(flag_auto == true) | if(flag_auto == true) | ||
{ | { | ||
timer_id_wait = setTimeout("txt_next()", | timer_id_wait = setTimeout("txt_next()",now_txt_max*80+1000) | ||
} | } | ||
} | } | ||
function txt_check_test() | function txt_check_test() | ||
{ | { | ||
if(data_txt[ | if(data_txt[txt_num].match("^\\s+$")) //ONLY SPACE REGEX | ||
{ | { | ||
return -1; | return -1; | ||
} | } | ||
else if(data_txt[ | else if(data_txt[txt_num].match("^\\s*//.*$")) //COMMENT REGEX | ||
{ | { | ||
return -1; | return -1; | ||
} | } | ||
var data_command = data_txt[ | var data_command = data_txt[txt_num].match("^\\[\\s*(?:(.*)\\((.*)\\)|(?:([\\.|\\w]*)|(.*)))\\s*\\]\\s*(.*)"); //COMMAND REGEX | ||
if (data_command[1] != undefined) | if (data_command[1] != undefined) | ||
{ | { |