hi-ucs/front/public/leaflet/libs/iclient8c/examples/js/examples.js

139 lines
4.0 KiB
Vue
Raw Normal View History

2022-06-14 09:32:49 +08:00
var loadedScript, dataCount = 0;
var isFile = document.location.toString().match(/file:\/\//);
var editor;
$(document).ready(function () {
var url = location.href,isAutoClickTab = false,isAutoClickExample = false;
if (url.lastIndexOf("#") > -1) {
var exampleId = url.substring(url.lastIndexOf('#') + 1, url.length);
//<2F>ж<EFBFBD>url<72><6C><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ê<EFBFBD><C3AA>
if (exampleId) {
//<2F><>ê<EFBFBD><C3AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
var a = $("a[data-name='" + exampleId + "']");
var parentId = a.parents(".tab-pane").attr("id");
addFunc(a);
setTimeout(function(){
isAutoClickTab = true;
$("#myTab a[href='#" + parentId + "']").click();
isAutoClickExample = true;
a.click();
},0);
} else {
//<2F><>ê<EFBFBD><C3AA><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϴ򿪵<CFB4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
openDefalutExam();
}
} else {
openDefalutExam();
}
function openDefalutExam() {
setTimeout(function(){
isAutoClickExample = true;
$("#myTab li a").first().click();
},0);
}
//<2F><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>¼<EFBFBD>
$('#myTab').click(function (e) {
if(isAutoClickTab){
isAutoClickTab = false;
return;
}
e = e || window.event;
var target = e.target || e.srcElement;
var eid = target.hash;
isAutoClickExample = false;
$(eid + " .span10 li a").first().click();
});
//<2F><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>¼<EFBFBD>
$('#myTabContent').click(function (e) {
if(isAutoClickExample){
isAutoClickExample = false;
return;
}
e = e || window.event;
var target = e.target || e.srcElement;
addFunc(target);
//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD><C3B0>
if (typeof e.preventDefault === 'function') {
e.preventDefault();
e.stopPropagation();
} else {
e.returnValue = false;
e.cancleBubble = true;
}
});
//<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
if (!isFile) {
$(window).resize(function () {
var width = $('#container-main').width();
$("#mapContent").width(width * 0.62);
$("#code_area").width(width * 0.37);
});
$("#code_area").css("display", "block");
$("#drag").css("display", "block");
$("#mapContent").css("width", "62%");
$("#container-main").css("border", "1px solid #3473b7");
codeChange();
initCode();
dragCode();
}
});
//<2F><><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD><EFBFBD>İ<EFBFBD><C4B0><EFBFBD><EFBFBD><EFBFBD>
function addFunc(srcEle) {
activeExample(srcEle);
if (!isFile) {
setTimeout(function () {
initCode();
}, 200);
}
//<2F><>ѡ<EFBFBD>е<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>url<72><6C>
var urlName = $(srcEle).data("name");
if (location.href.lastIndexOf('#') > 0) {
location.href = location.href.substring(0, location.href.lastIndexOf('#')) + '#' + urlName;
}
else {
location.href = location.href + '#' + urlName;
}
}
function activeExample(srcEle) {
updateClassName(srcEle);
var $srcEle = $(srcEle);
$('#sourceCode').prop('url', './' + $srcEle.data("name") + '.html');
$('#skip').prop('href', './' + $srcEle.data("name") + '.html');
runExample($srcEle);
}
function updateClassName(ele) {
/*<2A><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ȷ<EFBFBD>Ķ<EFBFBD>λ*/
$('.tab-content').find('> .tab-pane ul > .active').removeClass('active');
$(ele).parent().addClass('active');
}
function attachScript(url, id) {
$("#examplesIframe").attr("src", url);
}
function attachDetails(name) {
var details = DemoDescription[name];
if (!details.title) {
details.title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
if (!details.desc) {
details.desc = "<22>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
}
if (!details.oper) {
details.oper = "<22><>ϸ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>˵<EFBFBD><CBB5>";
}
$('h3 #demo-title').text(details.title);
$('#desc').text(details.desc);
$('#oper').text(details.oper);
}
function runExample(srcEle) {
var url = './' + srcEle.data("name") + '.html';
attachScript(url, srcEle.data("name") + "_script");
attachDetails(srcEle.data("name"));
}