12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568 |
- function initLanguage(langKey) {
- let defaultLang = 'en';
- let lang = langKey || defaultLang;
- if (defaultLang !== lang) {
- injectLanguageJsSources(lang);
- //updateLanguageText();
- }
- }
- // logout
- $("#modal_logout_btn").on("click", function () {
- // logout();
- });
- function logout() {
- $.ajax(`${CCB.base_url}api/logout`, {
- type: "GET",
- xhrFields: {
- withCredentials: true
- },
- success: () => {
- // $('#login_iframe').attr('src', '//staging.cocorobo.cn/login/');
- appendIframe("TM_login");
- $('#TM_login').children().css("height", "820px");
- appendIframe("before_login");
- appendIframe("cloud_askLogin");
- Materialize.toast(CCB.str_group.success_userLogout, 4000);
- CCB.userState = false;
- $("#cloud_fileListArea").html("");
- loginModalStatus();
- $("#modal_logout_btn").addClass('blue')
- $(".svgImg").css('display', 'none');
- $(".translate-signout").css('opacity', '1')
- }
- });
- }
- // 点击语言下拉隐藏
- // document.onclick = function () {
- // $('#languages').removeClass('active');
- // $('#languages').css({ display: 'none' })
- // }
- // 点击切换语言
- // $('#nav_language').click(function (e) {
- // $('#languages').addClass('active');
- // $('#languages').css({ display: 'block', opacity: 1, position: 'absolute',top:'64px' })
- // var ev = e || window.event;
- // if (ev.stopPropagation) { //阻止冒泡,否则会触发点击空白区域的事件
- // ev.stopPropagation();
- // } else if (window.event) {
- // window.event.cancelBubble = true; //兼容IE
- // }
- // })
- function getUrlLanguage() {
- const val = location.search.match(new RegExp('[?&]lang=([^&]+)'));
- let language = val ? decodeURIComponent(val[1].replace(/\+/g, '%20')) : '';
- if (['en', 'zh-hant', 'zh-hans'].indexOf(language) < 0) return 'zh-hant';
- return language;
- };
- function injectLanguageJsSources(langKey) {
- const head = document.getElementsByTagName('head')[0];
- // Retrieve and inject Ardublockly translations synchronously
- const appLangJsLoad = document.createElement('script');
- const request = createAjaxRequest();
- const appLangJdPath = `msg/${langKey}.js`;
- try {
- request.open('GET', appLangJdPath, false);
- request.send('');
- appLangJsLoad.text = request.responseText;
- } catch (e) {
- // But still asynchronous lazy load so at least some text gets translated
- appLangJsLoad.src = appLangJdPath;
- }
- head.appendChild(appLangJsLoad);
- // Retrieve and inject Blockly translations asynchronously
- const blocklyLangJsLoad = document.createElement('script');
- blocklyLangJsLoad.src = `blockly/msg/js/${langKey}.js`;
- head.appendChild(blocklyLangJsLoad);
- };
- function createAjaxRequest() {
- let request = false;
- try {
- // Firefox, Chrome, IE7+, Opera, Safari
- request = new XMLHttpRequest();
- } catch (e) {
- // IE6 and earlier
- try {
- request = new ActiveXObject('Msxml2.XMLHTTP');
- } catch (e) {
- try {
- request = new ActiveXObject('Microsoft.XMLHTTP');
- } catch (e) {
- throw 'Your browser does not support AJAX. You will not be able to' +
- 'use all of Ardublockly features.';
- request = null;
- }
- }
- }
- return request;
- };
- function updateLanguageText() {
- for (let textId in LOCALISED_TEXT) {
- const textStrings = document.getElementsByClassName(`translate-${textId}`);
- for (let i = 0; i < textStrings.length; i++) {
- textStrings[i].innerHTML = LOCALISED_TEXT[textId];
- }
- }
- };
- function clearBlocks(cb = () => { }) {
- const length = Blockly.mainWorkspace.getAllBlocks(true).length;
- if (length < 2) {
- Blockly.mainWorkspace.clear();
- cb();
- } else {
- Blockly.confirm(
- Blockly.Msg.DELETE_ALL_BLOCKS.replace("%1", length),
- ok => {
- if (!ok) return;
- Blockly.mainWorkspace.clear();
- cb();
- }
- );
- }
- }
- function addLibButton(lang) {
- // const addLib = document.createElement("button");
- // addLib.className = "waves-effect waves-light btn blue";
- // let content = lang === 'zh-hans' ? "添加库" : lang === 'zh-hant' ? "添加庫" : "Add Library";
- // addLib.textContent = content;
- // addLib.style = `
- // position: absolute;
- // width: 88%;
- // bottom: 10px;
- // left: 50%;
- // transform: translateX(-50%);
- // `;
- // $(addLib).click(e =>
- // blockpy.components.dialog.show("Add Library", document.createElement("div")));
- // $(".blocklyToolboxDiv").append(addLib);
- }
- // /**
- // * Save blocks into local storage. Note that MSIE 11 does not support
- // * LocalStorage on file:// URLs.
- // */
- // function saveLocalStorageBlocks() {
- // if (window.sessionStorage) {
- // var xml = blockpy.components.editor.getBlocksFromXml();
- // var text = Blockly.Xml.domToText(xml);
- // localStorage.setItem("blocks", text);
- // }
- // // blockpy.components.editor.getBlocksFromXml()
- // };
- // /** Load blocks saved on loacl storage and deletes them from storage. */
- // function loadLocalStorageBlocks() {
- // // try {
- // // var loadOnce = window.localStorage.loadOnceBlocks;
- // // } catch (e) {
- // // // Firefox sometimes throws a SecurityError when accessing sessionStorage.
- // // // Restarting Firefox fixes this, so it looks like a bug.
- // // var loadOnce = null;
- // // }
- // var loadBlocks = localStorage.getItem("blocks");
- // if (loadBlocks) {
- // var xml = Blockly.Xml.textToDom(loadBlocks);
- // blockpy.components.editor.setBlocksFromXml(xml);
- // localStorage.removeItem('blocks')
- // }
- // };
- var copyCodeClipboard;
- $(window).one("load", () => {
- // 判断从python blcokly 跳转过来是ai或者iot
- if (window.location.search.indexOf('name') > -1 || getLocalStorage("type") == 1) {
- $("#mode")[0].selectedIndex = 0;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
- selectmode($("#mode")[0], true);
- appearExample(1);
- } else {
- $("#mode")[0].selectedIndex = 1;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.ai_module;
- selectmode($("#mode")[0], true);
- appearExample(0);
- }
- $('#white-box').css('display', 'none');
- const _lang = getUrlLanguage();
- const copyCodeClipboard = new ClipboardJS(".copy_code", {
- text: function () {
- return blockpy.components.editor.codeMirror.getValue();
- // const codes = $(".CodeMirror-code pre");
- // let target = "";
- // for (let i = 0; i < codes.length; i++) {
- // let line = codes[i].textContent;
- // !(line.length === 1 && line.charCodeAt(0) === 8203) ? target += line : "";
- // i !== codes.length - 1 ? target += "\n" : "";
- // }
- // return target;
- }
- });
- copyCodeClipboard.on("success", () => copyCodeToast(2000));
- const copyCodeToast = (function (lang) {
- let toast = null,
- timeout = null;
- const content = lang === 'zh-hans' ? "复制成功" :
- lang === 'zh-hant' ? "複製成功" : "Copy Successfully";
- return function (ms) {
- if (toast) {
- toast.dismiss();
- clearTimeout(timeout);
- }
- toast = Materialize.toast(content, ms,'shareUrl');
- timeout = setTimeout(() => toast = timeout = null, ms);
- };
- })(_lang);
- $("#delete-all").click(() => clearBlocks());
- $("#screenshot").click(() => Blockly.captureDialog_());
- $("#clearOutput").click(() => $(".blockpy-printer").html(""));
- $("#resetAll").click(() => clearBlocks(() => $(".blockpy-printer").html("")));
- $("#lang-tool").click(() => $("#side-lang-trigger > a").dropdown('open'));
- $("#file-tool").click(() => $("#side-file-trigger > a").dropdown('open'));
- $("#blockpy-content > .blockpy-editor img.fullscreenIcon").click(e => {
- $(e.currentTarget.parentNode).toggleClass("fullscreen");
- $("#blockpy-content > .blockpy-editor img.fullscreenIcon").toggleClass("hidden");
- $("html").toggleClass("fullscreenMode");
- setTimeout(function () {
- Blockly.svgResize(blockpy.components.editor.blockly);
- Blockly.svgResize(Blockly.mainWorkspace);
- }, 100)
- });
- $("#blockpy-content .card-header > img.fullscreenIcon").click(e => {
- $(e.currentTarget.parentNode.parentNode).toggleClass("fullscreen");
- $("#blockpy-content .card-header > img.fullscreenIcon").toggleClass("hidden");
- $("html").toggleClass("fullscreenMode");
- setTimeout(() => $(".blockpy-toolbar > .blockpy-text")
- .css("height", "90%")
- .css("height", "100%"), 0);
- });
- // 提示全屏
- setTimeout(() => {
- if (document.body.clientWidth < 1265) {
- alert(CCB.str_group.alert)
- }
- myChart = echarts.init(document.getElementById('echartsMain'));
- window.onresize = function () {
- myChart.resize();
- }
- }, 1000)
- // 加载echarts
- myChart = myChart = echarts.init(document.getElementById('echartsMain'));
- window.onresize = function () {
- myChart.resize();
- }
- // 点击复制分享链接
- copyShare()
- $("#local_connect_select li").bind({
- mouseover: function () {
- $(this).children("ul").toggle();
- $("#plugin_mac_or_windows").css("opacity", "1");
- $("#connect_method").css("opacity", "1");
- },
- mouseout: function () {
- $(this).children("ul").toggle();
- $("#plugin_mac_or_windows").css("opacity", "0");
- $("#connect_method").css("opacity", "0");
- }
- });
- $("#local_help li").bind({
- mouseover: function () {
- $(this).children("ul").toggle();
- $("#local_help_ai_kit").css("opacity", "1");
- $("#help_extends").css("opacity", "1");
- },
- mouseout: function () {
- $(this).children("ul").toggle();
- $("#local_help_ai_kit").css("opacity", "0");
- $("#help_extends").css("opacity", "0");
- }
- });
- });
- window.onbeforeunload = window.onunload = function () {
- if ($("#mode")[0].selectedIndex == 1) {
- saveLocalStorage("type", 0);
- saveLocalStorageBlocks("pythonai-mode-blocks-xml");
- } else {
- saveLocalStorage("type", 1);
- saveLocalStorageBlocks("pythonmc-mode-blocks-xml");
- }
- }
- window.onload = function () {
- var url = window.location.hash.substring(1);
- // if (url) {
- // document.getElementById('ipAddress').value = 'ws://' + url;
- // }
- if (window.location.search.indexOf("en") > -1) {
- $("#cloud_input").attr("placeholder", "name");
- }
- else if (window.location.search.indexOf("zh-hans") > -1) {
- $("#cloud_input").attr("placeholder", "名称");
- }
- else {
- $("#cloud_input").attr("placeholder", "名稱");
- }
- $('.dropdown-trigger').dropdown();
- setTimeout(() => $('.modal').modal(), 0);
- blockpy = new BlockPy({
- blocklyPath: "blockly/",
- attachmentPoint: document.getElementById("blockpy-div"),
- instructor:
- !getQueryParams()["instructor"] ||
- getQueryParams()["instructor"] == "true",
- developer: true,
- editor: getQueryParams()["mode"] || "Split",
- urls: {
- }
- });
- // ready();
- var size = calculate_size($("#term")[0]);
- term = new Terminal({
- cols: size[0],
- rows: size[1],
- useStyle: true,
- screenKeys: true,
- cursorBlink: false
- });
- term.open(document.getElementById("term"));
- //show_https_warning();
- $(".filled-in")[0].onclick = function () {
- var _chi = $(".filled-in")[0];
- var _par = $(".filled-in")[0].parentNode;
- if (!_chi.checked) {
- _par.children[1].className = 'filled-in_nocheked translatable_Adapter_fill_connected';
- _par.children[1].innerHTML = CCB.str_group.Adapter_fill_connected;
- } else {
- _par.children[1].className = 'translatable_Adapter_connected';
- _par.children[1].innerHTML = CCB.str_group.Adapter_connected;
- };
- }
- setTimeout(() => {
- cocoblockly();
- }, 0);
- $('.blockpy-toolbar-download').on(
- "click", () => export_data(
- pythonnewcode || Blockly.Python.workspaceToCode(blockpy.components.editor.blockly) || blockpy.components.editor.codeMirror.getValue(), '.py', 0
- )
- );
- $('.blockpy-toolbar-edit').click(e => $('#toggle-button').click());
- const uploadXmlButton = $('#pyFileImport > input');
- uploadXmlButton.change(function () {
- var fr = new FileReader();
- var files = uploadXmlButton[0].files;
- const file = files[0];
- Ardublockly.alertExampleMessage(
- '', Ardublockly.getLocalStr('loadBlockBody'),
- true, {});
- fr.onload = function (e) {
- var pyInnerHTML = e.target.result;
- blockpy.components.editor.codeMirror.setValue(pyInnerHTML);
- };
- fr.readAsText(file);
- setTimeout(() => {
- $('#loading').css({ 'display': 'none' });
- $('#example_alert').modal('close');
- }, 300)
- uploadXmlButton.val("");
- });
- // $('.blockpy-toolbar-upload').click(e => $('#pyFileImport > input').click());
- fanyi();
- selectOnload();
- styled()
- let iframe = document.createElement("iframe")
- iframe.src = window.location.host.indexOf("beta") > -1 ? "//beta.project-x.cocorobo.cn/" : '//project-x.cocorobo.cn/';
- iframe.style.width = "100%";
- iframe.style.height = "50vh";
- document.getElementById('iframe').appendChild(iframe)
- // $('#select_mode')[0].onchange = function(e){
- // var e = e.target;
- // selectmode(e.selectedIndex);
- // var _index = e.selectedIndex;
- // localStorage.setItem("ModeIndex",_index);
- //
- // }
- // var _index = localStorage.getItem("ModeIndex") != "undefined" ? localStorage.getItem("ModeIndex") : 0;
- // selectmode(parseInt(_index));
- // $('#select_mode')[0].selectedIndex = parseInt(_index);
- $('#toggle-button').click(() => {
- if ($('#toggle-button')[0].checked) {
- $('#edit')[0].style.display = 'none';
- // $('.translatable_editing')[0].style.display = "none";
- // $('.translatable_close_editing')[0].style.display = "inline-block"
- $("#edit-on").css({
- "display": "block"
- });
- $("#edit-off").css({
- "display": "none"
- });
- } else {
- $('#edit')[0].style.display = 'block';
- // $('.translatable_editing')[0].style.display = "inline-block";
- // $('.translatable_close_editing')[0].style.display = "none"
- $("#edit-on").css({
- "display": "none"
- });
- $("#edit-off").css({
- "display": "block"
- });
- }
- })
- $('#sketch_name').focus(function () {
- if (window.location.search.indexOf("en") > -1) {
- this.setAttribute("placeholder", "Please enter the name of the work");
- $('#sketch_name').css("width", "330px");
- }
- else if (window.location.search.indexOf("zh-hans") > -1) {
- this.setAttribute("placeholder", "请输入作品名称");
- $('#sketch_name').css("width", "200px");
- }
- else {
- this.setAttribute("placeholder", "請輸入作品名稱");
- $('#sketch_name').css("width", "200px");
- }
- }).blur(function () {
- if (window.location.search.indexOf("en") > -1) {
- this.setAttribute("placeholder", "Please enter the name of the work");
- $('#sketch_name').css("width", "330px");
- }
- else if (window.location.search.indexOf("zh-hans") > -1) {
- this.setAttribute("placeholder", "请输入作品名称");
- $('#sketch_name').css("width", "200px");
- }
- else {
- this.setAttribute("placeholder", "請輸入作品名稱");
- $('#sketch_name').css("width", "200px");
- }
- });
- $("#python_full_screen").click(() => {
- window.location.href = "./python/?" + window.location.href.split("?")[1];
- });
- $("#confirm_btn").click(() => {
- var code = Ardublockly.generateXml();
- var title = $("#cloud_input").val() != '' ? $("#cloud_input").val() : '未命名';
- savelxfile(title, code, showSaveToast);
- });
- $("#cancel_btn").click(() => {
- $("#cloud_storage_name_modal").modal("close");
- });
- }
- function styled() {
- if (window.location.search.indexOf("en") > -1) {
- $(".downbox-style").css({ width: '280px', marginLeft: '-100px' })
- $("#downboxModule").addClass("english");
- $("#local_saveOrOpen").addClass("fileEnglish");
- $("#local_connect_select").addClass("fileEnglish");
- // $("#Serial_Interaction").css("marginLeft", "15px");
- // $("#Serial_Display").css("marginLeft", "35px");
- $("#iot_modules").css("width", "170px");
- $("#plugin_mac_or_windows").css("left", "208px");
- $("#connect_method").css("left", "208px");
- $("#connect_method").css("minWidth","155px");
- $("#local_help").addClass("helpEnglish");
- $("#local_help_ai_kit").css("left", "242px");
- $("#help_extends").css("left", "242px");
- // $("#Serial_Interaction").css("left","120px");
- // $("#Serial_Display").css("left","260px");
- $("body").css("font-family", "Arial");
- $("input").css("font-family", "Arial");
- $("#workspace_screenshot").css("right", "470px");
- $("#downloadbutton-li").css("right", "62px");
- $("#uploadpy").css("width","120px");
- }
- }
- function selectConnectMethods(type) {
- if ($('#runCode')[0].innerHTML == CCB.str_group.uploading) {
- if (type == 0) {
- $('.select-connected')[0].selectedIndex = 1;
- return null;
- }
- else {
- $('.select-connected')[0].selectedIndex = 0;
- return null;
- }
- }
- if (type == 0) {
- $('.select-connected')[0].selectedIndex = 0;
- $('.btn-network')[0].className = 'col cs6 btn-network';
- $('.btn-network')[1].className = 'col cs6 btn-network hidden';
- } else {
- $('#runCode')[0].innerHTML = Ardublockly.LOCALISED_TEXT.runCode;
- $('#uploadFiles')[0].innerHTML = Ardublockly.LOCALISED_TEXT.uploadFiles;
- $('.select-connected')[0].selectedIndex = 1;
- $('.btn-network')[1].className = 'col cs6 btn-network';
- $('.btn-network')[0].className = 'col cs6 btn-network hidden';
- }
- }
- function fanyi() {
- $('.ModeSelect')[0].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_Example;
- $('.ModeBox')[0].children[0].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.artificial_intelligence_textbook_program;
- $('.Hardware9 div')[0].innerHTML = Ardublockly.LOCALISED_TEXT.third_grade;
- $('.ModeBox ul')[0].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.recorded_voice_command;
- $('.ModeBox ul')[0].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.voice_recognition_lamp_stand;
- $('.Hardware5 div')[0].innerHTML = Ardublockly.LOCALISED_TEXT.fifth_grade;
- $('.ModeBox ul')[1].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.recorded_voice_command;
- $('.ModeBox ul')[1].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.intelligent_curtain;
- $('.ModeBox ul')[1].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.fruit_picking_robot;
- $('.Hardware6 div')[0].innerHTML = Ardublockly.LOCALISED_TEXT.sixth_grade;
- $('.ModeBox ul')[2].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.intelligent_traffic_lights;
- $('.ModeBox ul')[2].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.seeing_eye_necklace;
- $('.Hardware7 div')[0].innerHTML = Ardublockly.LOCALISED_TEXT.seventh_grade;
- $('.ModeBox ul')[3].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.face_recognition_electronic_police;
- $('.Hardware8 div')[0].innerHTML = Ardublockly.LOCALISED_TEXT.eighth_grade;
- $('.ModeBox ul')[4].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.payment_platform;
- $('.ModeBox')[0].children[1].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_Basics;
- $('.ModeBox ul')[5].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_sbcb;
- $('.ModeBox ul')[5].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_sbcsl;
- $('.ModeBox ul')[5].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_tacl
- $('.ModeBox ul')[5].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_ba
- $('.ModeBox ul')[5].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_desl
- $('.ModeBox ul')[5].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_tdsl;
- $('.ModeBox ul')[5].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.select_ha;
- $('.ModeBox ul')[5].children[7].innerHTML = Ardublockly.LOCALISED_TEXT.select_ssl;
- $('.ModeBox ul')[5].children[8].innerHTML = Ardublockly.LOCALISED_TEXT.select_ldliv;
- $('.ModeBox')[0].children[2].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_imefc;
- $('.ModeBox ul')[6].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_uls;
- $('.ModeBox ul')[6].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_umdm;
- $('.ModeBox ul')[6].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_uoglls;
- $('.ModeBox ul')[6].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_auogsm;
- $('.ModeBox ul')[6].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_ctsotem;
- $('.ModeBox ul')[6].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_thwos;
- $('.ModeBox ul')[6].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.select_sdla;
- $('.ModeBox ul')[6].children[7].innerHTML = Ardublockly.LOCALISED_TEXT.select_line;
- $('.ModeBox ul')[6].children[8].innerHTML = Ardublockly.LOCALISED_TEXT.select_bccs;
- $('.ModeBox ul')[6].children[9].innerHTML = Ardublockly.LOCALISED_TEXT.select_stepCounter;
- $('.ModeBox')[0].children[3].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_ionc;
- $('.ModeBox ul')[7].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_btsldtc;
- $('.ModeBox ul')[7].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_ktsedti;
- $('.ModeBox ul')[7].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_btoldalua;
- $('.ModeBox ul')[7].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_tsedtc;
- $('.ModeBox ul')[7].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_toedaluatc;
- $('.ModeBox ul')[7].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_ewhadtnocd;
- $('.ModeBox ul')[7].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.select_ledss;
- $('.ModeBox ul')[7].children[7].innerHTML = Ardublockly.LOCALISED_TEXT.select_ledac;
- $('.ModeBox ul')[7].children[8].innerHTML = Ardublockly.LOCALISED_TEXT.select_ctwn;
- $('.ModeBox ul')[7].children[9].innerHTML = Ardublockly.LOCALISED_TEXT.select_bssbms;
- $('.ModeBox ul')[7].children[10].innerHTML = Ardublockly.LOCALISED_TEXT.select_bsrbmc;
- $('.ModeBox ul')[7].children[11].innerHTML = Ardublockly.LOCALISED_TEXT.select_wrcbms;
- $('.ModeBox ul')[7].children[12].innerHTML = Ardublockly.LOCALISED_TEXT.select_wrcbmr;
- $('.ModeBox ul')[7].children[13].innerHTML = Ardublockly.LOCALISED_TEXT.select_snt;
- $('.ModeBox ul')[7].children[14].innerHTML = Ardublockly.LOCALISED_TEXT.select_dwsdat;
- $('.ModeBox')[0].children[4].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_work_u;
- $('.ModeBox ul')[8].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_middle_led;
- $('.ModeBox ul')[8].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_all_led;
- $('.ModeBox ul')[8].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_liu_led;
- $('.ModeBox ul')[8].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_warning;
- $('.ModeBox ul')[8].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_music;
- $('.ModeBox ul')[8].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_button_open;
- $('.ModeBox ul')[8].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.select_touch_open;
- $('.ModeBox ul')[8].children[7].innerHTML = Ardublockly.LOCALISED_TEXT.select_button_close;
- $('.ModeBox ul')[8].children[8].innerHTML = Ardublockly.LOCALISED_TEXT.select_control_LED;
- $('.ModeBox ul')[8].children[9].innerHTML = Ardublockly.LOCALISED_TEXT.select_sensor_LED;
- $('.ModeBox ul')[8].children[10].innerHTML = Ardublockly.LOCALISED_TEXT.select_humidity_alarm;
- $('.ModeBox')[0].children[5].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_work_d;
- $('.ModeBox ul')[9].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_shaking_LED;
- // $('.ModeBox ul')[4].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_connect_wifi;
- $('.ModeBox ul')[9].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_show_statement;
- $('.ModeBox ul')[9].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_establish_WiFi;
- $('.ModeBox ul')[9].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_download_lighting;
- $('.ModeBox ul')[9].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_controlling_servo;
- $('.ModeBox ul')[9].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_move_servo;
- $('.ModeBox ul')[9].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.select_button_controlling_servo;
- $('.ModeBox ul')[9].children[7].innerHTML = Ardublockly.LOCALISED_TEXT.select_face_recognition_door;
- $('.ModeBox ul')[9].children[8].innerHTML = Ardublockly.LOCALISED_TEXT.select_speech_recognition_car;
- $('.ModeBox ul')[9].children[9].innerHTML = Ardublockly.LOCALISED_TEXT.select_gyro_control_robot;
- $('.ModeBox ul')[9].children[10].innerHTML = Ardublockly.LOCALISED_TEXT.select_gesture_recognition_robot;
- $('.ModeBox ul')[9].children[11].innerHTML = Ardublockly.LOCALISED_TEXT.select_speech_recogniton_lamp;
- $('.ModeBox')[0].children[6].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_smmlc;
- $('.ModeBox ul')[10].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_gcaerhk;
- $('.ModeBox ul')[10].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_frs;
- $('.ModeBox ul')[10].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_ors;
- $('.ModeBox ul')[10].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_fr;
- $('.ModeBox ul')[10].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_or;
- $('.ModeBox ul')[10].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_srd;
- $('.ModeBox ul')[10].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.select_srt;
- $('.ModeBox ul')[10].children[7].innerHTML = Ardublockly.LOCALISED_TEXT.select_mhdr;
- $('.ModeBox')[0].children[7].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_ambc;
- $('.ModeBox ul')[11].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_bcsc;
- $('.ModeBox ul')[11].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_kcpccs;
- $('.ModeBox ul')[11].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_kcpficc;
- $('.ModeBox ul')[11].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_bccs;
- $('.ModeBox ul')[11].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_mc;
- $('.ModeBox ul')[11].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_sor;
- $('.ModeBox ul')[11].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.select_sdla;
- $('.ModeBox')[0].children[8].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_amefc;
- $('.ModeBox ul')[12].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_auls;
- $('.ModeBox ul')[12].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_aumdm;
- $('.ModeBox ul')[12].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_auogsm;
- $('.ModeBox ul')[12].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_actsotem;
- $('.ModeBox ul')[12].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_greedy_snake;
- $('.ModeBox')[0].children[9].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_amvc;
- $('.ModeBox ul')[13].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_bctbotci;
- $('.ModeBox ul')[13].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_aca;
- $('.ModeBox ul')[13].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_rqc;
- $('.ModeBox ul')[13].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_lhbl;
- $('.ModeBox ul')[13].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_fgr;
- $('.ModeBox ul')[13].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_fgaat;
- $('.ModeBox')[0].children[10].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_av;
- $('.ModeBox ul')[14].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.paly_video;
- $('.ModeBox ul')[14].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.paly_music;
- $('.ModeBox ul')[14].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.recording_camera;
- $('.ModeBox ul')[14].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.microphone_sound_analysis;
- $('.ModeBox')[0].children[11].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_teacher;
- $('.ModeBox ul')[15].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_thw;
- $('.ModeBox ul')[15].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_thwos;
- $('.ModeBox ul')[15].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_uoc;
- $('.ModeBox ul')[15].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_mc;
- $('.ModeBox ul')[15].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_sor;
- $('.ModeBox')[0].children[12].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_teacher2;
- $('.ModeBox ul')[16].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.select_aiaor;
- $('.ModeBox ul')[16].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.select_aifr;
- $('.ModeBox ul')[16].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.select_aica;
- $('.ModeBox ul')[16].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.select_aisrc;
- $('.ModeBox ul')[16].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_aisrr;
- $('.ModeBox ul')[16].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.select_aiaa;
- $('.ModeBox')[0].children[13].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_teachingcases;
- $('.ModeBox ul')[17].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ex1_servo;
- $('.ModeBox ul')[17].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.ex2_Ultrasound;
- // $('.ModeBox ul')[12].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.ex3_RangeFinder;
- // $('.ModeBox ul')[12].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.ex4_LightStrip;
- // $('.ModeBox ul')[12].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.ex5_Microbit;
- // $('.ModeBox ul')[12].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.ex6_MicrobitFace;
- // $('.ModeBox ul')[12].children[6].innerHTML = Ardublockly.LOCALISED_TEXT.ex7_Door;
- $('.ModeBox ul')[17].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.ex4_LightStrip
- $('.ModeBox ul')[17].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.ex5_Microbit;
- $('.ModeBox ul')[17].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.ex6_MicrobitFace;
- $('.ModeBox ul')[17].children[5].innerHTML = Ardublockly.LOCALISED_TEXT.ex7_Door;
- $('.ModeBox')[0].children[14].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_wc;
- $('.ModeBox ul')[18].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_smaa;
- $('.ModeBox ul')[18].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.ai_gc;
- $('.ModeBox ul')[18].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.ai_wsb;
- $('.ModeBox')[0].children[15].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_ad;
- $('.ModeBox ul')[19].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_trsr;
- $('.ModeBox ul')[19].children[1].innerHTML = Ardublockly.LOCALISED_TEXT.ai_tpl2;
- $('.ModeBox ul')[19].children[2].innerHTML = Ardublockly.LOCALISED_TEXT.ai_tpll;
- $('.ModeBox ul')[19].children[3].innerHTML = Ardublockly.LOCALISED_TEXT.ai_tph;
- // $('.ModeBox ul')[3].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_Mandarin;
- // $('.ModeBox ul')[3].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_English;
- // $('.ModeBox ul')[3].children[4].innerHTML = Ardublockly.LOCALISED_TEXT.select_Cantonese;
- // $('#uploadFiles')[0].innerHTML = Ardublockly.LOCALISED_TEXT.uploadFiles;
- // $("#sketch_name").val(Ardublockly.LOCALISED_TEXT.sketch_name);
- $('#runCode')[0].innerHTML = Ardublockly.LOCALISED_TEXT.runCode;
- $('#uploadFiles')[0].innerHTML = Ardublockly.LOCALISED_TEXT.uploadFiles;
- // $('#resetDevice')[0].innerHTML = Ardublockly.LOCALISED_TEXT.resetDevice;
- $('#select_dropdown')[0].value = Ardublockly.LOCALISED_TEXT.select_dropdown;
- $('#iot_modules')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
- $(".qiehuanbtn")[0].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.a_csm;
- $("#localsssssaveOrOpen")[0].children[0].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.a_butvmi;
- $("#localsssssaveOrOpen")[0].children[1].children[0].innerHTML = Ardublockly.LOCALISED_TEXT.a_buartlp;
- // $("#Serial_Interaction")[0].innerHTML = Ardublockly.LOCALISED_TEXT.Serial_Interaction;
- $('#ai_tt div')[0].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_thw;
- $('#ai_tt div')[1].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_thwos;
- $('#ai_tt div')[2].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_uoc;
- $('#ai_tt div')[3].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_mc;
- $('#ai_tt div')[4].innerHTML = Ardublockly.LOCALISED_TEXT.ai_modules_sor;
- }
- function selectOnload() {
- $('.select-connected')[0].onchange = function () {
- var a = $('.select-connected')[0].selectedIndex;
- if ($('#runCode')[0].innerHTML == CCB.str_group.uploading) {
- if (a == 0) {
- $('.select-connected')[0].selectedIndex = 1;
- return null;
- } else {
- $('.select-connected')[0].selectedIndex = 0;
- return null;
- }
- }
- if (a == 0) {
- $('.btn-network')[0].className = 'col s6 btn-network';
- $('.btn-network')[1].className = 'col s6 btn-network hidden';
- } else {
- $('.btn-network')[1].className = 'col s6 btn-network';
- $('.btn-network')[0].className = 'col s6 btn-network hidden';
- }
- }
- $('.selectMode_input')[0].onclick = function (e) {
- $('.MouduleBox')[0].style.cssText = 'display:block';
- }
- $('.ModeSelectBox')[0].onclick = function (e) {
- U.UF.EV.stopBubble();
- $('.ModeSelect')[0].className = 'ModeSelect active';
- $('#downboxModule').css("display", "none");
- }
- likeclose($('.selectMode_input')[0], $('.MouduleBox')[0], '', '');
- likeclose($('.ModeSelect')[0].children[0], $('.ModeSelect')[0], 1, 'ModeSelect');
- likeclose($('#bar_ai img')[0], $('.MouduleBox')[1], '', '');
- likeclose($('#bar_t img')[0], $('#ai_tt')[0], '', '');
- var MChild = $('.MouduleBox')[0].children;
- var tchild = $('.MouduleBox')[1].children;
- for (var i = 0; i < MChild.length; i++) {
- tchild[i].onclick = MChild[i].onclick = function (e) {
- window.event ? window.event.cancelBubble = true : e.stopPropagation()
- var e = e.target;
- if (e.parentElement.children[2] && e.parentElement.children[2].children.length > 0) { } else {
- if (e.innerHTML == Ardublockly.LOCALISED_TEXT.iot_module) {
- $("#mode")[0].selectedIndex = 0;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
- appearExample(1);
- }
- else if (e.innerHTML == Ardublockly.LOCALISED_TEXT.ai_module) {
- $("#mode")[0].selectedIndex = 1;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.ai_module;
- appearExample(0);
- }
- $('.MouduleBox')[0].style.display = 'none';
- $('.MouduleBox')[1].style.display = 'none';
- $('#ai_tt')[0].style.display = 'none';
- }
- }
- }
- for (var i = 0; i < $('.ModeBox')[0].children.length; i++) {
- $('.ModeBox')[0].children[i].onclick = function (e) {
- window.event ? window.event.cancelBubble = true : e.stopPropagation()
- }
- }
- // "AI/云端语音识别 (普通话).txt", "AI/云端语音识别 (英文).txt", "AI/云端语音识别 (粤语).txt"
- var _arr = [
- ["AI/AI 广州/录制语音指令.xml",
- "AI/AI 广州/语音识别台灯.xml",
- ],
- [
- "AI/AI 广州/录制语音指令.xml",
- "AI/AI 广州/智能窗帘.xml",
- "AI/AI 广州/水果采摘机器人.xml",
- ],
- [
- "AI/AI 广州/智能交通信号灯.xml",
- "AI/AI 广州/导盲项链.xml",
- ],
- [
- // "AI/AI 广州/二维码包裹分拣机器人.xml",
- "AI/AI 广州/人脸辨识电子警察.xml",
- ],
- [
- "AI/AI 广州/支付台.xml"
- ],
- [
- "Main/IoT 模块基础案例/侧边按键控制蜂鸣器.xml",
- "Main/IoT 模块基础案例/侧边按键控制开关 LED.xml",
- "Main/IoT 模块基础案例/触摸区域控制 LED.xml",
- "Main/IoT 模块基础案例/蜂鸣器警报.xml",
- "Main/IoT 模块基础案例/黑暗环境感应光照灯.xml",
- "Main/IoT 模块基础案例/倾斜方向感应 LED.xml",
- "Main/IoT 模块基础案例/湿度报警器.xml",
- "Main/IoT 模块基础案例/摇晃感应 LED.xml",
- "Main/IoT 模块基础案例/LED 显示光线强度值.xml"
- ],
- [
- "Main/IoT 模块扩展功能案例/使用 LED 灯屏.xml",
- "Main/IoT 模块扩展功能案例/使用电机驱动模块.xml",
- "Main/IoT 模块扩展功能案例/使用游戏手柄LED 灯屏.xml",
- "Main/IoT 模块扩展功能案例/使用游戏手柄屏幕.xml",
- "Main/IoT 模块扩展功能案例/在扩展模块上控制舵机.xml",
- "Main/IoT 模块扩展功能案例/屏幕显示Hello_World.xml",
- "Main/IoT 模块扩展功能案例/屏幕绘制线条动画.xml",
- "Main/IoT 模块基础案例/按键控制屏幕直线转动.xml",
- "Main/IoT 模块基础案例/按键控制颜色切换.xml",
- "Main/IoT 模块扩展功能案例/计步器.xml"
- ],
- [
- "Main/IoT 模块联网案例/按键发送光照数据至 CocoCloud.xml",
- "Main/IoT 模块联网案例/按键发送环境数据至 IFTTT.xml",
- "Main/IoT 模块联网案例/按键获取光照数据并根据条件亮灯.xml",
- "Main/IoT 模块联网案例/定时发送环境数据至 CocoCloud.xml",
- "Main/IoT 模块联网案例/定时接收环境数据并根据条件亮灯.xml",
- "Main/IoT 模块联网案例/建立 WiFi 热点并显示连接设备数量.xml",
- "Main/IoT 模块联网案例/局域网环境数据存储 - 服务器端.xml",
- "Main/IoT 模块联网案例/局域网环境数据获取 - 客户端.xml",
- "Main/IoT 模块联网案例/连接 WiFi 网络.xml",
- "Main/IoT 模块联网案例/模块间按钮状态存储 - 服务端.xml",
- "Main/IoT 模块联网案例/模块间按钮状态接收 - 客户端.xml",
- "Main/IoT 模块联网案例/模块间进行 WebSocket 实时通信 - 发送端.xml",
- "Main/IoT 模块联网案例/模块间进行 WebSocket 实时通信 - 接收端.xml",
- "Main/IoT 模块联网案例/同步网络时间.xml",
- "Main/IoT 模块联网案例/数字手表显示实时时间.xml"
- ],
- [
- "Main/IoT工作坊/00 程序/01 點亮正中間的LED燈.xml",
- "Main/IoT工作坊/00 程序/02 點亮所有LED燈.xml",
- "Main/IoT工作坊/00 程序/03 流水燈.xml",
- "Main/IoT工作坊/00 程序/04 蜂鳴器警報.xml",
- "Main/IoT工作坊/00 程序/05 8-bit音樂.xml",
- "Main/IoT工作坊/00 程序/06 序列埠通訊:按鈕開關.xml",
- "Main/IoT工作坊/00 程序/07 序列埠通訊:觸摸開關.xml",
- "Main/IoT工作坊/00 程序/08 按鈕開關蜂鳴器.xml",
- "Main/IoT工作坊/00 程序/09 觸摸開關燈.xml",
- "Main/IoT工作坊/00 程序/10 補光裝置.xml",
- "Main/IoT工作坊/00 程序/11 濕度報警器.xml"
- ],
- [
- "Main/IoT工作坊/00 程序/12 晃晃燈.xml",
- // "Main/IoT工作坊/00 程序/13 連接Wi-Fi.xml",
- "Main/IoT工作坊/00 程序/14 連接Wi-Fi並顯示連接狀態.xml",
- "Main/IoT工作坊/00 程序/15 建立熱點並顯示已連接的設備數.xml",
- "Main/IoT工作坊/00 程序/16 亮度數據上傳與下載.xml",
- "Main/IoT工作坊/00 程序/17 伺服馬達來回擺動.xml",
- "Main/IoT工作坊/00 程序/19 伺服馬達定時擺動.xml",
- "Main/IoT工作坊/00 程序/20 按鍵控制伺服馬達.xml",
- "Main/IoT工作坊/00 程序/18 閘門(人臉識別).xml",
- "Main/IoT工作坊/00 程序/體驗 iot-機械車(語音控制).xml",
- "Main/IoT工作坊/00 程序/體驗 iot-機械人(陀螺儀).xml",
- "Main/IoT工作坊/00 程序/體驗 iot-機械人(姿態識別).xml",
- "Main/IoT工作坊/00 程序/體驗 iot-檯燈(語音控制).xml"
- ],
- [
- "AI/AI 模块机器学习案例/垃圾分类识别(香港版).xml",
- "AI/AI 模块机器学习案例/人脸识别.xml",
- "AI/AI 模块机器学习案例/物体识别.xml",
- "AI/AI 模块机器学习案例/face.xml",
- "AI/AI 模块机器学习案例/object.xml",
- "AI/AI 模块机器学习案例/語音錄製.xml",
- "AI/AI 模块机器学习案例/語音識別.xml",
- "AI/AI 模块机器学习案例/MNIST 手写数字识别.xml"
- ],
- ["AI/AI 模块基础案例/按键控制屏幕时针转动.xml",
- "AI/AI 模块基础案例/按键控制图片改变颜色制式.xml",
- "AI/AI 模块基础案例/按键控制图片进行反色变化.xml",
- "AI/AI 模块基础案例/按键控制颜色切换.xml",
- "AI/AI 模块基础案例/迷你相机.xml",
- "AI/AI 模块基础案例/屏幕方向旋转.xml",
- "AI/AI 模块基础案例/屏幕绘制线条动画.xml"],
- ["AI/AI 模块扩展功能案例/使用 LED 灯屏.xml",
- "AI/AI 模块扩展功能案例/使用电机驱动模块.xml",
- "AI/AI 模块扩展功能案例/使用游戏手柄 + 屏幕模块.xml",
- "AI/AI 模块扩展功能案例/在扩展模块上控制舵机.xml",
- "AI/AI 模块扩展功能案例/贪吃蛇.xml"],
- ["AI/AI 模块视觉案例/按键改变相机图像的亮度.xml",
- "AI/AI 模块视觉案例/区域颜色分析.xml",
- "AI/AI 模块视觉案例/识别 QR 二维码.xml",
- "AI/AI 模块视觉案例/寻线(黑线).xml",
- "AI/AI 模块视觉案例/寻找绿色的圆形.xml",
- "AI/AI 模块视觉案例/寻找绿色区域并进行追踪.xml"],
- ["AI/AI 模块影音案例/播放录制的视频档案.xml",
- "AI/AI 模块影音案例/播放音乐.xml",
- "AI/AI 模块影音案例/录制摄像头画面并保存.xml",
- "AI/AI 模块影音案例/麦克风声音频谱分析.xml"],
- ["AI/AI 教学/AI_Workshop_ex1.xml",
- "AI/AI 教学/AI_Workshop_ex2.xml",
- "AI/AI 教学/AI_Workshop_ex3.xml",
- "AI/AI 教学/AI_Workshop_ex4.xml",
- "AI/AI 教学/AI_Workshop_ex5.xml"
- ],
- ["AI/AI 教学/AI_Workshop_II_ex1.xml",
- "AI/AI 教学/AI_Workshop_II_ex2.xml",
- "AI/AI 教学/AI_Workshop_II_ex3.xml",
- "AI/AI 教学/AI_Workshop_II_ex4a.xml",
- "AI/AI 教学/AI_Workshop_II_ex4b.xml",
- "AI/AI 教学/AI_Workshop_II_ex5.xml"],
- ["AI/AI 扩展使用案例/AI_Workshop_III_ex1_Servo.xml",
- "AI/AI 扩展使用案例/AI_Workshop_III_ex2_Ultrasound.xml",
- "AI/AI 扩展使用案例/AI_Workshop_III_ex4_LightStrip.xml",
- "AI/AI 扩展使用案例/AI_Workshop_III_ex5_Microbit.xml",
- "AI/AI 扩展使用案例/AI_Workshop_III_ex6_MicrobitFace.xml",
- "AI/AI 扩展使用案例/AI_Workshop_III_ex7_Door.xml"],
- ["AI/AI 垃圾分类/AI_Workshop_IV_1.xml",
- "AI/AI 垃圾分类/AI_Workshop_IV_2.xml",
- "AI/AI 垃圾分类/AI_Workshop_IV_3.xml",
- ],
- ["AI/AI 教学/第一場-路標識別(香港標識).xml",
- "AI/AI 教学/第二場-巡線(單線-靠左行駛).xml",
- "AI/AI 教学/第二場-巡線(雙線).xml",
- "AI/AI 教学/第三場-自動駕駛-香港標識.xml"
- ]
- ];
- // var _arr = [
- // ["Main/LED 灯闪烁.xml", "Main/按钮控制LED灯.xml", "Main/拨盘控制LED灯开关.xml", "Main/触摸控制LED灯开关.xml", "Main/LCD图形绘制动画.xml", "Main/LCD显示环境数据.xml", "Main/触摸控制小方块.xml", "Main/运动传感器数值显示.xml", "Main/简易计步器.xml", "Main/平衡球程序.xml", "Main/LCD 显示倾斜方向.xml", "Main/按钮计时器.xml"],
- // ["Main/连接周边WiFi网络.xml", "Main/建立WiFi热点.xml", "Main/IFTTT发送环境数据.xml", "Main/IFTTT触发事件.xml", "Main/ThingSpeak发送数据及获取最新数据.xml", "Main/CocoCloud发送数据及获取数据.xml", "Main/onenet_nbiot_send.xml", "Main/onenet_nbiot_read.xml", "Main/cococloud_nbiot_send.xml"],
- // ["AI/迷你照相機.xml", "AI/LCD 按鈕控制時針轉動.xml", "AI/LCD 按鈕控制顏色切換.xml", "AI/LCD 繪製圖形動畫.xml", "AI/屏幕圖片裁剪.xml", "AI/屏幕圖案旋轉.xml", "AI/按鍵改變圖片至反色.xml", "AI/按鍵改變圖片顏色模式.xml", "AI/按鍵改變圖片尺寸.xml"],
- // ["AI/二维码识别.xml", "AI/视觉循迹(黑线).xml", "AI/寻找绿色区域并追踪.xml", "AI/区域颜色分析.xml", "AI/寻找绿色的圆形.xml", "AI/按鍵改變相機顏色模式.xml", "AI/按鍵改變相機圖像的亮度.xml"],
- // ["AI/手写数字识别.xml", "AI/人脸检测.xml", "AI/物体识别.xml", "AI/hktrashclassification_9classes.xml"],
- // ["AI/麦克风分析声音频谱.xml", "AI/播放音频文件.xml", "AI/播放影片档案.xml", "AI/录制摄像头画面.xml"]
- // ];
- for (var i = 0; i < $('ul.HarxA').length; i++) {
- for (var j = 0; j < $('ul.HarxA')[i].children.length; j++) {
- if (i == 15) {
- $('#ai_tt div')[j].onclick = (function (i, j) {
- return function () {
- if (_arr[i][j].split("/")[0] == "Main") {
- $("#mode")[0].selectedIndex = 0;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
- appearExample(1);
- } else {
- $("#mode")[0].selectedIndex = 1;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.ai_module;
- appearExample(0);
- }
- $('.ModeSelect')[0].className = 'ModeSelect';
- Ardublockly.alertExampleMessage(
- '',
- Ardublockly.getLocalStr('loadBlockBody'),
- true, {});
- readTxt("src/python/" + _arr[i][j], function (txt) {
- if (_arr[i][j].split(".")[1] == "xml") {
- var xmlfile = Blockly.Xml.textToDom(txt);
- blockpy.components.editor.setBlocksFromXml(xmlfile);
- } else {
- blockpy.components.editor.codeMirror.setValue(txt);
- }
- setTimeout(() => {
- $('#loading').css({ 'display': 'none' });
- $('#example_alert').modal('close');
- }, 300)
- });
- }
- })(15, j)
- }
- if ($('ul.HarxA').length == i) {
- // ai_tt.children[j].innerHTML = (_arr[i][j].split(".")[1] == "xml" ? ("<span style='color:#00FF7F'>[" + "xml" + "]  </span>") : ("<span style='color:#FF7F00'>[" + "py" + "]  </span>")) + $('ul.HarxA')[i].children[j].innerHTML;
- ai_tt.children[j].onclick = (function (i, j) {
- return function () {
- if (_arr[i][j].split("/")[0] == "Main") {
- $("#mode")[0].selectedIndex = 0;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
- appearExample(1);
- } else {
- $("#mode")[0].selectedIndex = 1;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.ai_module;
- appearExample(0);
- }
- $('.ModeSelect')[0].className = 'ModeSelect';
- readTxt("src/python/" + _arr[i][j], function (txt) {
- if (_arr[i][j].split(".")[1] == "xml") {
- var xmlfile = Blockly.Xml.textToDom(txt);
- blockpy.components.editor.setBlocksFromXml(xmlfile);
- } else {
- blockpy.components.editor.codeMirror.setValue(txt);
- }
- });
- }
- })(i, j)
- }
- if (i === 10 && (j !== 0 && j !== 1 && j !== 2)) {
- $('ul.HarxA')[i].children[j].innerHTML = (_arr[i][j].split(".")[1] == "xml" ? ("<span style='color:orange'>[" + "beta" + "]  </span>") : ("<span style='color:#FF7F00'>[" + "py" + "]  </span>")) + $('ul.HarxA')[i].children[j].innerHTML
- }
- $('ul.HarxA')[i].children[j].onclick = (function (i, j) {
- return function () {
- if (_arr[i][j].split("/")[0] == "Main") {
- $("#mode")[0].selectedIndex = 0;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.iot_module;
- appearExample(1);
- } else {
- $("#mode")[0].selectedIndex = 1;
- $("#mode")[0].onchange();
- $('.selectMode_input')[0].value = Ardublockly.LOCALISED_TEXT.ai_module;
- appearExample(0);
- }
- $('.ModeSelect')[0].className = 'ModeSelect';
- Ardublockly.alertExampleMessage(
- '',
- Ardublockly.getLocalStr('loadBlockBody'),
- true, {});
- readTxt("src/python/" + _arr[i][j], function (txt) {
- if (_arr[i][j].split(".")[1] == "xml") {
- var xmlfile = Blockly.Xml.textToDom(txt);
- blockpy.components.editor.setBlocksFromXml(xmlfile);
- } else {
- blockpy.components.editor.codeMirror.setValue(txt);
- }
- if ($('ul.HarxA')[i].children[j].id) {
- fileDownload(`src/python/AI/AI 扩展使用案例/${$('ul.HarxA')[i].children[j].id}.hex`, $('ul.HarxA')[i].children[j].id + '.hex')
- }
- setTimeout(() => {
- $('#loading').css({ 'display': 'none' });
- $('#example_alert').modal('close');
- }, 300)
- });
- }
- })(i, j)
- }
- }
- $('.qiehuanbtn')[0].onclick = function (e) {
- if (!(CCB.socket && CCB.socket.id)) {
- return;
- }
- U.UF.EV.stopBubble();
- if (Ardublockly.LANG == "en") {
- $('#localsssssaveOrOpen')[0].className = 'dropdown-content qiehuan qiehuanposi';
- } else {
- $('#localsssssaveOrOpen')[0].className = 'dropdown-content qiehuan';
- }
- }
- var _aqieM = $("#localsssssaveOrOpen")[0].children;
- for (var i = 0; i < _aqieM.length; i++) {
- $("#localsssssaveOrOpen")[0].children[i].addEventListener('click', function () {
- window.event ? window.event.cancelBubble = false : e.stopPropagation()
- var e = this;
- $('#runCuploadFilesode')[0].innerHTML = e.children[0].innerHTML;
- })
- // $("#localsssssaveOrOpen")[0].children[i].children[0].onclick = function (e) {
- // window.event ? window.event.cancelBubble = true : e.stopPropagation()
- // }
- }
- qiehuanjjj($('.qiehuanbtn')[0], $('#localsssssaveOrOpen')[0]);
- $(".switch_box1")[0].onclick = switchCC;
- $(".switch_box")[0].onclick = switchCC;
- $(".switch_box2")[0].onclick = switchCC;
- $("#repl_delete")[0].onclick = function () {
- $("#repl_box_content")[0].innerHTML = "";
- }
- }
- function switchCC(e) {
- var e = e.target || e;
- var flag = true;
- var pythonbox = $("#python_box")[0];
- var replbox = $("#repl_box")[0];
- var repl_delete = $("#repl_delete")[0]
- if (e.className.indexOf("switch_select") != -1) {
- return;
- } else {
- var switch_select = $(".switch_select")[0]
- switch_select.className = switch_select.className.replace(" switch_select", "");
- e.className += " switch_select";
- if (e.className.indexOf("switch_box1") != -1) {
- pythonbox.className = "card-content hidden"
- replbox.className = "card-content"
- repl_delete.style.display = "none";
- $('#switchSerial1').click();
- $("#Serial_Display").addClass("display_switch_box2");
- $(".blockpy-toolbar-edit").css({
- "display": "none"
- });
- $(".copy_code").css({
- "display": "none"
- });
- $(".blockpy-toolbar-download").css({
- "display": "none"
- });
- $(".blockpy-toolbar-upload").css({
- "display": "none"
- });
- $("#repl_delete").css("display", "block");
- }
- else if (e.className.indexOf("switch_box2") != -1) {
- pythonbox.className = "card-content hidden"
- replbox.className = "card-content"
- repl_delete.style.display = "none";
- $('#switchSerial2').click();
- $(".blockpy-toolbar-edit").css({
- "display": "none"
- });
- $(".copy_code").css({
- "display": "none"
- });
- $(".blockpy-toolbar-download").css({
- "display": "none"
- });
- $(".blockpy-toolbar-upload").css({
- "display": "none"
- });
- $("#repl_delete").css("display", "none");
- }
- else {
- pythonbox.className = "card-content"
- replbox.className = "card-content hidden"
- repl_delete.style.display = "none";
- $("#Serial_Display").removeClass("display_switch_box2");
- $(".blockpy-toolbar-edit").css({
- "display": "block"
- });
- $(".copy_code").css({
- "display": "block"
- });
- $(".blockpy-toolbar-download").css({
- "display": "block"
- });
- $(".blockpy-toolbar-upload").css({
- "display": "none"
- });
- $("#repl_delete").css("display", "none");
- }
- }
- }
- function readTxt(url, fun) {
- var xhr = new XMLHttpRequest();
- xhr.open('get', url, true);
- xhr.send();
- xhr.onreadystatechange = function () {
- if (xhr.readyState == 4 && xhr.status == 200) {
- fun(xhr.responseText)
- }
- };
- }
- function qiehuanjjj(ele, _container) {
- $("body")[0].addEventListener('click', function (e) {
- if (ele != e.target) {
- _container.className = 'dropdown-content';
- }
- })
- }
- function likeclose(ele, _container, type, _className) {
- $("body")[0].addEventListener('click', function (e) {
- if (ele != e.target) {
- if (type == 1) {
- _container.className = _className;
- } else {
- _container.style.display = 'none'
- }
- }
- })
- }
- function export_data(data, postfix, is_firefox) {
- let url = new Blob([data], { type: 'text/plain' });
- let download_link = URL.createObjectURL(url);
- let a = document.createElement('a');
- a.style = "display:none";
- a.href = download_link;
- a.download = ($("#sketch_name").val() != '' ? $("#sketch_name").val() : "cocorobo") + postfix;
- if (is_firefox) {
- document.body.appendChild(a);
- a.click();
- setTimeout(() => document.body.removeChild(a), 100);
- } else
- a.click();
- // URL.revokeObjectURL(download_link);
- // IE edge need a short delay before revoke virtual download link
- setTimeout(() => URL.revokeObjectURL(download_link), 100);
- }
- // 积木生成
- function selectmode(sel, isload) {
- var _type = getLocalStorage("type");
- if (sel.selectedIndex == 0 && (_type != 1 || isload === true)) {
- saveLocalStorageBlocks("pythonai-mode-blocks-xml");
- saveLocalStorage("type", 1);
- blockpy.setAssignment(
- // settings
- {},
- // assignment
- {
- modules: {
- added: ["Decisions", "Iteration", "Calculation", "Variables", "Values", "Lists", "Functions", "Logic", "Loops", "Math", "Text", "Dictionary", "Tuples", "Set", "Functionsa", "Output", "Files", "Time", "Serial Comm.", "MainBoard", "ExtendedFunction", "Third_party_Sensor"],
- removed: ['A.I.Board']
- }
- },
- // programs
- {
- __main__: ""
- }
- );
- loadLocalStorageBlocks("pythonmc-mode-blocks-xml")
- }
- else if (sel.selectedIndex == 1 && (_type != 0 || isload === true)) {
- saveLocalStorageBlocks("pythonmc-mode-blocks-xml");
- saveLocalStorage("type", 0);
- blockpy.setAssignment(
- // settings
- {},
- // assignment
- {
- modules: {
- added: ["Decisions", "Iteration", "Calculation", "Variables", "Values", "Lists", "Functions", "Logic", "Loops", "Math", "Text", "Dictionary", "Tuples", "Set", "Functionsa", "Output", "Files", "Time", "Serial Comm.", "A.I.Board", "ExtendedFunctions", "Third_party_Sensor"],
- removed: ['MainBoard']
- }
- },
- // programs
- {
- __main__: ""
- }
- );
- loadLocalStorageBlocks("pythonai-mode-blocks-xml")
- }
- }
- function getQueryParams() {
- try {
- url = window.location.href;
- query_str = url.substr(url.indexOf("?") + 1, url.length - 1);
- r_params = query_str.split("&");
- params = {};
- for (i in r_params) {
- param = r_params[i].split("=");
- params[param[0]] = param[1];
- }
- return params;
- } catch (e) {
- return {};
- }
- }
- // onresize 多次执行解决办法
- var debounce = function (func, threshold, execAsap) {
- var timeout;
- return function debounced() {
- var obj = this, args = arguments;
- function delayed() {
- if (!execAsap)
- func.apply(obj, args);
- timeout = null;
- };
- if (timeout)
- clearTimeout(timeout);
- else if (execAsap)
- func.apply(obj, args);
- timeout = setTimeout(delayed, threshold || 100);
- };
- }
- window.onresize = debounce(function () {
- if (document.body.clientWidth < 1265) {
- alert(CCB.str_group.alert)
- }
- }, 100, true);
- // 切换数据显示方式
- var myChart = "";
- function switchSerial(type) {
- if (type == 2) {
- document.getElementById('repl_box_content').style.display = 'none';
- document.getElementById('echartsShow').style.display = 'block';
- document.getElementById('repl_box_content').innerHTML = ""
- // document.getElementsByClassName('translatable_serial_plotter')[0].classList.remove("serial-active")
- // document.getElementsByClassName('translatable_serial_visualization')[0].classList.add("serial-active")
- // document.getElementById('echartsShow').innerHTML = `<div id="echartsMain" class="echartsMain"></div>`
- myChart.resize();
- var options = {
- title: {
- // text: 'ECharts 入门示例'
- },
- tooltip: {},
- legend: {
- // data: ['销量']
- },
- xAxis: {
- data: []
- },
- yAxis: {},
- series: []
- };
- myChart.clear();
- myChart.setOption(options);
- document.getElementById('echartsMain').lastChild.innerHTML = CCB.str_group.echart_text;
- document.getElementById('echartsMain').lastChild.classList.add("echart-text");
- } else {
- document.getElementById('repl_box_content').style.display = 'block';
- document.getElementById('echartsShow').style.display = 'none';
- // document.getElementsByClassName('translatable_serial_plotter')[0].classList.add("serial-active")
- // document.getElementsByClassName('translatable_serial_visualization')[0].classList.remove("serial-active")
- document.getElementById('repl_box_content').innerHTML = ""
- }
- }
- // 点击下载文件
- function fileDownload(url, name) {
- var nowA = document.createElement('a');
- nowA.setAttribute('href', url);
- nowA.setAttribute('download', name);
- nowA.style.display = 'none';
- document.body.appendChild(nowA);
- nowA.click();
- document.body.removeChild(nowA);
- }
- // 点击复制分享链接
- function copyShare() {
- $('#cloudBtn-shares').click(() => {
- if (CCB.userState) {
- let time = 10000
- var $toastContent = $(`<span id="abc">${CCB.str_group.share_loading}</span>`)
- Materialize.toast($toastContent, time, "shareUrl")
- let fileNmae = new Date().getTime()
- $.ajax(`${CCB.base_url}blockx/`, {
- type: "POST",
- xhrFields: {
- withCredentials: true
- },
- data: {
- filename: fileNmae,
- xml: Ardublockly.generateXml()
- },
- success: (res) => {
- let fileobject = {
- filenameId: res.filename,
- filename: fileNmae,
- time: getCurrentDate(),
- timestamp: (new Date()).valueOf()
- };
- CCB.cloudFileList.push(fileobject);
- CCB.selectCloudFile = filename;
- let url = window.location.href + '&Qd=' + res.filename;
- let flag = copyText(url);
- // time = 3000;
- // document.getElementById('abc').innerHTML = flag ? CCB.str_group.share_success : CCB.str_group.share_fail
- setTimeout(function () {
- Materialize.toast(flag ? CCB.str_group.share_success : CCB.str_group.share_fail, 3000, "shareUrl")
- }, time)
- },
- error: () => {
- $("#cloud_modal_preload").css("display", "none");
- // time = 4000;
- // Materialize.toast(CCB.str_group.error_uploadFile, 4000);
- // document.getElementById('abc').style.display = CCB.str_group.error_uploadFile
- setTimeout(function () {
- Materialize.toast(CCB.str_group.error_uploadFile, 4000, 'shareUrl')
- }, time)
- }
- });
- } else {
- Materialize.toast(CCB.str_group.requestLogin, 3000, 'shareUrl');
- $("#login_modal").modal("open")
- }
- })
- }
- function openUrl(url) {
- window.open(url, "_blank")
- }
- function appearExample(type) {
- if (type == 0) {
- $('.ModeBox')[0].children[0].style.display = "block";
- $('.ModeBox')[0].children[1].style.display = "none";
- $('.ModeBox')[0].children[2].style.display = "none";
- $('.ModeBox')[0].children[3].style.display = "none";
- $('.ModeBox')[0].children[4].style.display = "none";
- $('.ModeBox')[0].children[5].style.display = "none";
- $('.ModeBox')[0].children[6].style.display = "block";
- $('.ModeBox')[0].children[7].style.display = "block";
- $('.ModeBox')[0].children[8].style.display = "block";
- $('.ModeBox')[0].children[9].style.display = "block";
- $('.ModeBox')[0].children[10].style.display = "block";
- $('.ModeBox')[0].children[11].style.display = "block";
- $('.ModeBox')[0].children[12].style.display = "block";
- $('.ModeBox')[0].children[13].style.display = "block";
- $('.ModeBox')[0].children[14].style.display = "block";
- $('.ModeBox')[0].children[15].style.display = "block";
- } else {
- $('.ModeBox')[0].children[0].style.display = "none";
- $('.ModeBox')[0].children[0].style.display = "none";
- $('.ModeBox')[0].children[1].style.display = "block";
- $('.ModeBox')[0].children[2].style.display = "block";
- $('.ModeBox')[0].children[3].style.display = "block";
- $('.ModeBox')[0].children[4].style.display = "block";
- $('.ModeBox')[0].children[5].style.display = "block";
- $('.ModeBox')[0].children[6].style.display = "none";
- $('.ModeBox')[0].children[7].style.display = "none";
- $('.ModeBox')[0].children[8].style.display = "none";
- $('.ModeBox')[0].children[9].style.display = "none";
- $('.ModeBox')[0].children[10].style.display = "none";
- $('.ModeBox')[0].children[11].style.display = "none";
- $('.ModeBox')[0].children[12].style.display = "none";
- $('.ModeBox')[0].children[13].style.display = "none";
- $('.ModeBox')[0].children[14].style.display = "none";
- $('.ModeBox')[0].children[15].style.display = "none";
- }
- }
- function savelxfile(title, code, cb) {
- var _token = window.localStorage.Token;
- if (_token) {
- $.ajax(`/api/web/v1/blockpy/project/add`, {
- type: "POST",
- headers: { 'Authorization': "Bearer " + _token },
- data: { code: code, title: title },
- success: (data) => {
- cb(data)
- }
- });
- }
- }
- function getlxfiles(page, cb) {
- var _token = window.localStorage.Token;
- if (_token) {
- $.ajax(`/api/web/v1/blockpy/project/list`, {
- type: "GET",
- headers: { 'Authorization': "Bearer " + _token },
- data: "pageNumber=" + "&" + page + "pageSize=500",
- success: (data) => {
- cb(data)
- }
- });
- }
- }
- function getFileList(data) {
- var fileList = [];
- data.data.records.filter(val => {
- var filename = val.title;
- var date = val.updateTime;
- var Timestamp = new Date(date).getTime();
- fileList.push({
- filename: filename,
- date: date,
- timestamp: Timestamp,
- filenameId: val.id
- });
- });
- console.log(fileList, 'getCloudFileList')
- updateCloudFileList(fileList);
- updateCloudFilePanel();
- // openCloudFile(CCB.cloudFileList[i].filename); 打开文件
- let arr = window.location.search.split('&')[1]
- if (arr) {
- fileList.map(x => {
- if (x.filenameid == arr.split('=')[1]) {
- openCloudFile(x.filename)
- }
- return x;
- })
- }
- }
- function dellxfilebyid(id, cb) {
- var _token = window.localStorage.Token;
- if (_token) {
- $.ajax(`/api/web/v1/blockpy/project/del/` + id, {
- type: "GET",
- headers: { 'Authorization': "Bearer " + _token },
- success: (data) => {
- cb(data)
- }
- });
- }
- }
- function upadtelxfilenamebyid(id, title, cb) {
- var _token = window.localStorage.Token;
- if (_token) {
- $.ajax(`/api/web/v1/blockpy/project/title/update`, {
- type: "POST",
- headers: { 'Authorization': "Bearer " + _token },
- data: { id: id, title: title },
- success: (data) => {
- cb(data)
- }
- });
- }
- }
- function uploadlxfilecontentbyid(id, code, cb) {
- var _token = window.localStorage.Token;
- if (_token) {
- $.ajax(`/api/web/v1/blockpy/project/code/update`, {
- type: "POST",
- headers: { 'Authorization': "Bearer " + _token },
- data: { id: id, code: code },
- success: (data) => {
- cb(data)
- }
- });
- }
- }
- function showSaveToast(data) {
- $("#cloud_storage_name_modal").modal("close");
- setTimeout(function () {
- Materialize.toast(data.success ? '保存成功' : '保存失败', 3000, "shareUrl")
- }, getCurrentDate())
- $("#cloud_input").val('');
- }
|