-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathus.js
116 lines (106 loc) · 2.45 KB
/
us.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function hook_all_forms()
{
$("form").each(function () {
$(this).submit(function () {
// XXX this is getting one form data rev back
//XXX do the match on attachment so we can annotate the submit button
if (match_form($(this))) {
var o = {};
$.each( $(this).serializeArray(), function( i,e ) {
o[e.name] = e.value;
});
userdata_store(JSON.stringify(o));
}
return true;
});
});
$(":submit").after('++');
}
function configure_dialog()
{
inject_css(colorbox_css);
$.colorbox({title: "XXXXX", html: "<h2>XX Config</h2>\
\
<h3>User history</h3>" +
user_history() +
"<h3>Actions</h3>\
<a href='#'>[+] Set sharing preferences</a> | \
<a href='#'>[+] Backup personal data</a> | \
<a href='#'>[+] Configure sites</a> | \
<a href='#'>[+] </a> \
" });
}
function user_history()
{
var seq_start = save_data("seq-begin");
var seq_end = load_data("seq-end");
if (!seq_start) return "<i>No data stored</i>";
var data_html = "<ol>";
for (var i = seq_start; i <= seq_end; i++) {
data_html += "<li>" + print_r(JSON.parse(load_value("userdata-" + i))) + "</li>";
}
return data_html + "</ol>";
}
function print_r(obj){
var result = '<ul>';
for(var key in obj){
result += '<li>';
if (typeof obj[key] == 'object'){
result += print_r(obj[key]);
} else {
result += (key + '=' + obj[key]);
}
result += '</li>';
}
return result + '</ul>';
}
function userdata_store(data)
{
var seq_end = load_data("seq-end");
if (!seq_end) {
save_data("seq-begin", 1);
seq_end = 0;
}
seq_end++;
save_data("seq-end", seq_end);
save_data("userdata-" + seq_end, data);
//url: $(location).attr("href"),
//date:
}
//function remote_store
//function setup_match_rules
//{
// rules = get()
// cache_hash(rules)
matchRulez = [
//{ "group"
{
url_re: /post.*php/,
match: function() {
//return $("wpcontent") ? true : false;
},
form_id: "post",
reconstruct: function(obj) {
//return $.map(obj,
},
//form_sel: "#$ C2 A"
//form_action: "postit.php"
//
},
];
function match_form(form)
{
var current_url = $(location).attr("href");
//for (var rule in matchRulez)
for (var i = 0; i < matchRulez.length; i++)
{
rule = matchRulez[i];
if (!current_url.match(rule.url_re))
continue;
if (form.is("#" + rule.form_id))
return true;
//if ($(rule.form_sel) first == form)
}
}
hook_all_forms();
register_menus();