SuperScriptMaterializer/SuperScriptViewer/static/site.js

100 lines
3.0 KiB
JavaScript
Raw Normal View History

2020-04-17 23:31:27 +08:00
previousHighlight = "";
2020-04-13 09:46:01 +08:00
function highlightLink(target) {
realTarget = ".target" + target
if (previousHighlight != "") {
//need restore
$(previousHighlight).each(function() {
if ($(this).hasClass("link-blink")) {
$(this).attr("stroke", "black")
}
if ($(this).hasClass("link-blinkDelay")) {
$(this).attr("fill", "black")
}
if ($(this).hasClass("link-plink")) {
$(this).attr("stroke", "blue")
}
if ($(this).hasClass("link-elink")) {
$(this).attr("stroke", "cyan")
}
2020-04-13 09:46:01 +08:00
});
}
2020-04-13 15:36:37 +08:00
// double one-click, only cancel highlight and don't apply any hightlight
if (realTarget == previousHighlight) {
previousHighlight = "";
} else {
//apply new highlight
$(realTarget).each(function() {
if ($(this).hasClass("link-blink")) {
$(this).attr("stroke", "yellow")
}
if ($(this).hasClass("link-blinkDelay")) {
$(this).attr("fill", "yellow")
}
if ($(this).hasClass("link-plink")) {
$(this).attr("stroke", "orange")
}
if ($(this).hasClass("link-elink")) {
$(this).attr("stroke", "orange")
}
2020-04-13 15:36:37 +08:00
});
previousHighlight = realTarget
}
2020-04-13 09:46:01 +08:00
//cancel event seperate
event.stopPropagation();
}
2020-04-13 12:35:41 +08:00
function queryInfo(obj) {
$.post(window.location,
{
operation: "info",
target: obj
},
function(data, status) {
//set id
2020-04-17 23:31:27 +08:00
$("#sidepanel-properties-id").text(obj);
2020-04-13 12:35:41 +08:00
//set data
2020-04-17 23:31:27 +08:00
$("#sidepanel-properties-container").empty()
2020-04-13 12:35:41 +08:00
for (var key in data) {
2020-04-17 23:31:27 +08:00
$("#sidepanel-properties-container").append("<p><b>" + key + ":</b><br /><pre>" + data[key] +"</pre></p>")
2020-04-13 12:35:41 +08:00
}
});
}
2020-04-17 23:31:27 +08:00
function sidePanelSwitcher(target) {
// 0->property; 1->display; 2->tools
//disable all
$("#sidepanel-properties").hide();
$("#sidepanel-display").hide();
$("#sidepanel-tools").hide();
$(".tabitem").each(function() {
$(this).removeClass("tabitem-activated").addClass("tabitem-deactivated");
});
switch (target) {
case 0:
$("#sidepanel-properties").show();
$(".tabitem1").each(function() {
$(this).removeClass("tabitem-deactivated").addClass("tabitem-activated");
});
break;
case 1:
$("#sidepanel-display").show();
$(".tabitem2").each(function() {
$(this).removeClass("tabitem-deactivated").addClass("tabitem-activated");
});
break;
case 2:
$("#sidepanel-tools").show();
$(".tabitem3").each(function() {
$(this).removeClass("tabitem-deactivated").addClass("tabitem-activated");
});
break;
}
2020-04-13 12:35:41 +08:00
}