mirror of
https://github.com/taroved/pol
synced 2025-05-17 23:00:10 -07:00
xpath autosave
This commit is contained in:
parent
7eb74a8f73
commit
a040bec004
@ -4,13 +4,38 @@
|
|||||||
if (!document.location.href.match('https?://[^/]+/[^/]+/setup\?.+'))
|
if (!document.location.href.match('https?://[^/]+/[^/]+/setup\?.+'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
function save(key, obj) {
|
||||||
|
if (typeof(localStorage) !== "undefined") {
|
||||||
|
var tm = new Date().getTime();
|
||||||
|
var v = {time: tm, value: obj}
|
||||||
|
localStorage.setItem(key, JSON.stringify(v));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function read(key) {
|
||||||
|
var day = 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
if (typeof(localStorage) !== "undefined") {
|
||||||
|
var v = localStorage.getItem(key);
|
||||||
|
if (v) {
|
||||||
|
var tm = new Date().getTime();
|
||||||
|
var v = JSON.parse(v);
|
||||||
|
if (tm - v.time < day) {
|
||||||
|
return v.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.save = save;
|
||||||
|
window.read = read;
|
||||||
|
|
||||||
function init_tool(pathes) {
|
function init_tool(pathes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_pathes(pathes) {
|
function check_pathes(pathes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var _config = null;
|
var _config = ['', {}];
|
||||||
var _active = false;
|
var _active = false;
|
||||||
|
|
||||||
function updateUI(config) {
|
function updateUI(config) {
|
||||||
@ -27,6 +52,17 @@ function showIcon(show) {
|
|||||||
$("#st-ext-trigger")[0].style.display = show ? "inline-block" : "none";
|
$("#st-ext-trigger")[0].style.display = show ? "inline-block" : "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUIConfig() {
|
||||||
|
var cfg = [
|
||||||
|
$('#ste-parent').val(),
|
||||||
|
{}
|
||||||
|
];
|
||||||
|
['title', 'description', 'link'].forEach(function(name){
|
||||||
|
cfg[1][name] = $('#ste-'+ name).val();
|
||||||
|
});
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
function changed() {
|
function changed() {
|
||||||
var ch = false;
|
var ch = false;
|
||||||
if (_config[0] != $('#ste-parent').val())
|
if (_config[0] != $('#ste-parent').val())
|
||||||
@ -57,24 +93,37 @@ window.ET = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function show_ext(show) {
|
function show_ext(show) {
|
||||||
if (show && changed() && !confirm($("#st-clicker-trigger").attr('confirm-text')))
|
$("#st-ext-trigger")[0].style.display = !show ? "inline-block" : "none";
|
||||||
return;
|
$("#st-clicker-trigger")[0].style.display = show ? "inline-block" : "none";
|
||||||
$("#st-ext-trigger")[0].style.display = show ? "inline-block" : "none";
|
$("#st-extended")[0].style.display = show ? "block" : "none";
|
||||||
$("#st-clicker-trigger")[0].style.display = !show ? "inline-block" : "none";
|
$("#st-clicker")[0].style.display = !show ? "block" : "none";
|
||||||
$("#st-extended")[0].style.display = !show ? "block" : "none";
|
|
||||||
$("#st-clicker")[0].style.display = show ? "block" : "none";
|
|
||||||
|
|
||||||
_active = show;
|
_active = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#st-ext-trigger").click(function(){
|
$("#st-ext-trigger").click(function(){
|
||||||
show_ext(false);
|
show_ext(true);
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
$("#st-clicker-trigger").click(function(){
|
$("#st-clicker-trigger").click(function(){
|
||||||
show_ext(true);
|
var ch = changed();
|
||||||
|
if (!ch || confirm($("#st-clicker-trigger").attr('confirm-text')))
|
||||||
|
show_ext(false);
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*var cfg = read('xpathes')
|
||||||
|
if (cfg) {
|
||||||
|
updateUI(cfg);
|
||||||
|
show_ext(true);
|
||||||
|
$("#restored-alert")[0].style.display = 'block';
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*$("#ste-parent, #ste-title, #ste-description, #ste-link").change(function(){
|
||||||
|
save('xpathes', getUIConfig());
|
||||||
|
return true;
|
||||||
|
});*/
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +44,10 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<div id="loader-bg"><div id="loader"></div></div>
|
<div id="loader-bg"><div id="loader"></div></div>
|
||||||
|
<div id="restored-alert" class="alert fade in" style="display: none">
|
||||||
|
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||||
|
<strong>Restored saved version.</strong> Autosaved selectors are restored
|
||||||
|
</div>
|
||||||
<div id="st-clicker" style="float: left; margin-bottom: 20px">
|
<div id="st-clicker" style="float: left; margin-bottom: 20px">
|
||||||
<h2 style="display: inline; line-height:inherit" id="setup-tool-string">
|
<h2 style="display: inline; line-height:inherit" id="setup-tool-string">
|
||||||
{% trans 'setup.you_are_creating_feed_with' %}
|
{% trans 'setup.you_are_creating_feed_with' %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user