redesign url and add settings storage
This commit is contained in:
@ -1,11 +1,59 @@
|
||||
previousHighlight = "";
|
||||
//=======================================settings
|
||||
currentSettings = {
|
||||
"plink": true,
|
||||
"properties": true,
|
||||
"highlight": true,
|
||||
"keyboard": true,
|
||||
"move": true
|
||||
};
|
||||
$(document).ready(function () {
|
||||
//read settings and apply it
|
||||
for (var key in currentSettings) {
|
||||
currentSettings[key] = localstorageAssist_Get("ssm-settings-" + key, "true") == "true";
|
||||
if (currentSettings[key]) $("#sidepanel-display-" + key).prop("checked", true);
|
||||
else $("#sidepanel-display-" + key).removeProp("checked");
|
||||
}
|
||||
//additional settings
|
||||
if (!currentSettings["plink"]) {
|
||||
$(".link-elink").hide();
|
||||
$(".link-plink").hide();
|
||||
}
|
||||
});
|
||||
function settingChange(target) {
|
||||
newValue = $("#sidepanel-display-" + target).prop("checked");
|
||||
currentSettings[target] = newValue;
|
||||
localstorageAssist_Set("ssm-settings-" + target, newValue);
|
||||
|
||||
if (target == "plink") {
|
||||
if (currentSettings["plink"]) {
|
||||
$(".link-elink").show();
|
||||
$(".link-plink").show();
|
||||
} else {
|
||||
$(".link-elink").hide();
|
||||
$(".link-plink").hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
function localstorageAssist_Get(index, defaultValue) {
|
||||
var cache = localStorage.getItem(index);
|
||||
if (cache == null) {
|
||||
localstorageAssist_Set(index, defaultValue);
|
||||
return defaultValue;
|
||||
} else return cache;
|
||||
}
|
||||
function localstorageAssist_Set(index, value) {
|
||||
localStorage.setItem(index, value);
|
||||
}
|
||||
|
||||
|
||||
//=======================================internal event
|
||||
previousHighlight = "";
|
||||
function highlightLink(target) {
|
||||
realTarget = ".target" + target
|
||||
|
||||
if (previousHighlight != "") {
|
||||
//need restore
|
||||
$(previousHighlight).each(function() {
|
||||
$(previousHighlight).each(function () {
|
||||
if ($(this).hasClass("link-blink")) {
|
||||
$(this).attr("stroke", "black")
|
||||
}
|
||||
@ -26,7 +74,7 @@ function highlightLink(target) {
|
||||
previousHighlight = "";
|
||||
} else {
|
||||
//apply new highlight
|
||||
$(realTarget).each(function() {
|
||||
$(realTarget).each(function () {
|
||||
if ($(this).hasClass("link-blink")) {
|
||||
$(this).attr("stroke", "yellow")
|
||||
}
|
||||
@ -54,14 +102,14 @@ function queryInfo(obj) {
|
||||
operation: "info",
|
||||
target: obj
|
||||
},
|
||||
function(data, status) {
|
||||
function (data, status) {
|
||||
//set id
|
||||
$("#sidepanel-properties-id").text(obj);
|
||||
|
||||
//set data
|
||||
$("#sidepanel-properties-container").empty()
|
||||
for (var key in data) {
|
||||
$("#sidepanel-properties-container").append("<p><b>" + key + ":</b><br /><pre>" + data[key] +"</pre></p>")
|
||||
$("#sidepanel-properties-container").append("<p><b>" + key + ":</b><br /><pre>" + data[key] + "</pre></p>")
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -72,26 +120,26 @@ function sidePanelSwitcher(target) {
|
||||
$("#sidepanel-properties").hide();
|
||||
$("#sidepanel-display").hide();
|
||||
$("#sidepanel-tools").hide();
|
||||
$(".tabitem").each(function() {
|
||||
$(".tabitem").each(function () {
|
||||
$(this).removeClass("tabitem-activated").addClass("tabitem-deactivated");
|
||||
});
|
||||
|
||||
switch (target) {
|
||||
case 0:
|
||||
$("#sidepanel-properties").show();
|
||||
$(".tabitem1").each(function() {
|
||||
$(".tabitem1").each(function () {
|
||||
$(this).removeClass("tabitem-deactivated").addClass("tabitem-activated");
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
$("#sidepanel-display").show();
|
||||
$(".tabitem2").each(function() {
|
||||
$(".tabitem2").each(function () {
|
||||
$(this).removeClass("tabitem-deactivated").addClass("tabitem-activated");
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
$("#sidepanel-tools").show();
|
||||
$(".tabitem3").each(function() {
|
||||
$(".tabitem3").each(function () {
|
||||
$(this).removeClass("tabitem-deactivated").addClass("tabitem-activated");
|
||||
});
|
||||
break;
|
||||
|
Reference in New Issue
Block a user