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,29 +4,65 @@
|
||||
if (!document.location.href.match('https?://[^/]+/[^/]+/setup\?.+'))
|
||||
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 check_pathes(pathes) {
|
||||
}
|
||||
|
||||
var _config = null;
|
||||
var _config = ['', {}];
|
||||
var _active = false;
|
||||
|
||||
function updateUI(config) {
|
||||
console.log(config);
|
||||
_config = config;
|
||||
console.log(config);
|
||||
_config = config;
|
||||
|
||||
$('#ste-parent').val(config[0]);
|
||||
['title', 'description', 'link'].forEach(function(name){
|
||||
$('#ste-'+ name).val(name in config[1] ? config[1][name] : '');
|
||||
});
|
||||
$('#ste-parent').val(config[0]);
|
||||
['title', 'description', 'link'].forEach(function(name){
|
||||
$('#ste-'+ name).val(name in config[1] ? config[1][name] : '');
|
||||
});
|
||||
}
|
||||
|
||||
function showIcon(show) {
|
||||
$("#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() {
|
||||
var ch = false;
|
||||
if (_config[0] != $('#ste-parent').val())
|
||||
@ -57,24 +93,37 @@ window.ET = {
|
||||
};
|
||||
|
||||
function show_ext(show) {
|
||||
if (show && changed() && !confirm($("#st-clicker-trigger").attr('confirm-text')))
|
||||
return;
|
||||
$("#st-ext-trigger")[0].style.display = show ? "inline-block" : "none";
|
||||
$("#st-clicker-trigger")[0].style.display = !show ? "inline-block" : "none";
|
||||
$("#st-extended")[0].style.display = !show ? "block" : "none";
|
||||
$("#st-clicker")[0].style.display = show ? "block" : "none";
|
||||
$("#st-ext-trigger")[0].style.display = !show ? "inline-block" : "none";
|
||||
$("#st-clicker-trigger")[0].style.display = show ? "inline-block" : "none";
|
||||
$("#st-extended")[0].style.display = show ? "block" : "none";
|
||||
$("#st-clicker")[0].style.display = !show ? "block" : "none";
|
||||
|
||||
_active = show;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#st-ext-trigger").click(function(){
|
||||
show_ext(false);
|
||||
show_ext(true);
|
||||
return true;
|
||||
});
|
||||
$("#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>
|
||||
<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">
|
||||
<h2 style="display: inline; line-height:inherit" id="setup-tool-string">
|
||||
{% trans 'setup.you_are_creating_feed_with' %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user