-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpct_script.js
More file actions
executable file
·142 lines (120 loc) · 5.34 KB
/
wpct_script.js
File metadata and controls
executable file
·142 lines (120 loc) · 5.34 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
function wpct_bookmarklet() {
console.log('Testing whether jQuery is loaded (' + !!(typeof jQuery == 'function') + ')');
if (waitingForScript('http://code.jquery.com/jquery-latest.pack.js', 'jQuery')) return;
console.log('Do some action with jQuery');
if (waitingForScript('http://trentrichardson.com/Impromptu/scripts/jquery-impromptu.1.4.js', 'Impromptu')) return;
console.log('Do some action with jQuery Impromptu');
}
/**
* Only returns true when the external script has been loaded
* in to the DOM. It uses arguments.callee.caller to work out
* which function is the callback.
*
* @param url {String} URL of external script
* @param obj {String} The name of a function or variable within
* the external script to test for.
* @license: Creative Commons License -
* ShareAlike http://creativecommons.org/licenses/by-sa/3.0/
* @author Remy Sharp / leftlogic.com
*/
function waitingForScript(url, obj) {
function lateLoader(u,id,test,fn){
var d = document;
if (!d.getElementById(id)) {
var s = d.createElement('script');
s.src = u;
s.id = id;
d.body.appendChild(s);
}
var timer = setInterval(function (){
var ok = false;
try {
ok = test.call();
} catch(e) {}
if (ok) {
clearInterval(timer);
fn.call();
}
}, 10);
}
var callback = arguments.callee.caller;
if ((typeof window[obj] == 'undefined') && !window['loading' + obj]) {
window['loading' + obj] = true;
lateLoader(url, '_' + obj, function () {
return (typeof window[obj] != 'undefined');
}, callback);
return true;
} else if (typeof window[obj] == 'undefined') {
return true;
} else {
return false;
}
}
// http://noteslog.com/post/how-to-download-scripts-and-stylesheets/
function load_stylesheet(uri) {
if (document.createElement) {
var e = document.createElement("link");
e.rel = "stylesheet";
e.type = "text/css";
e.href = uri;
document.getElementsByTagName("head")[0].appendChild(e);
}
};
wpct_bookmarklet();
load_stylesheet('http://junyent.org/blog/wp-content/plugins/wp-commentracker/wpct_styles.css');
console.log('CSS loaded');
var wpct_title = document.title;
var wpct_textarea = "";
var wpct_obj = null;
var wpct_url = location.href;
var wpct_blog = document.title;
var wpct_blogurl = wpct_url;
var wpct_rss = wpct_url + '/feed/';
var wpct_tags = "";
var wpct_user = "";
var wpct_pass = "";
wpct_obj = document.getElementsByTagName('textarea')[0];
if (wpct_obj.value.length > 0) {
wpct_textarea = wpct_obj.value;
}
if (wpct_textarea.length > 0) {
var form = 'Is this?'+
'<div class="field"><label for="edittitle">Title</label><input type="text" id="edittitle" name="edittitle" value="'+ wpct_title +'" /></div>'+
'<div class="field"><label for="editurl">URL</label><input type="text" id="editurl" name="editurl" value="'+ wpct_url +'" /></div>'+
'<div class="field"><label for="editblog">Blog</label><input type="text" id="editblog" name="editblog" value="'+ wpct_blog +'" /></div>'+
'<div class="field"><label for="editblogurl">Blog URL</label><input type="text" id="editblogurl" name="editblogurl" value="'+ wpct_blogurl +'" /></div>'+
'<div class="field"><label for="editrss">RSS URL</label><input type="text" id="editrss" name="editrss" value="'+ wpct_rss +'" /></div>'+
'<div class="field"><label for="editcomment">Text</label><textarea id="edittext" name="edittext" cols="40" rows="4">'+ wpct_textarea +'</textarea></div>'+
'<div class="field"><label for="edittags">Tags</label><input type="text" id="edittags" name="edittags" value="'+ wpct_tags +'" /></div>'+
'<div class="field"><label for="edituser">User</label><input type="text" id="edituser" name="edituser" value="'+ wpct_user +'" /></div>'+
'<div class="field"><label for="editpass">Password</label><input type="text" id="editpass" name="editpass" value="'+ wpct_pass +'" /></div>';
$.prompt(form,
{
buttons:{OK:true, Cancel:false},
callback: function(v,m){
var title = m.find('#edittitle').val();
var url = m.find('#editurl').val();
var blog = m.find('#editblog').val();
var blogurl = m.find('#editblogurl').val();
var rss = m.find('#editrss').val();
var text = m.find('#edittext').val();
var tags = m.find('#edittags').val();
var user = m.find('#edituser').val();
var pass = m.find('#editpass').val();
if(v){
wpct_title = title;
wpct_url = url;
wpct_blog = blog;
wpct_blogurl = blogurl;
wpct_rss = rss;
wpct_textarea = text;
wpct_tags = tags;
wpct_user = user;
wpct_pass = pass;
data='user='+ encodeURIComponent(user) +'&pass='+ encodeURIComponent(pass) +'&title='+ encodeURIComponent(title) +'&url='+ encodeURIComponent(url) +'&blog='+ encodeURIComponent(blog) +'&blogurl='+ encodeURIComponent(blogurl) +'&rss='+ encodeURIComponent(rss) +'&text='+ encodeURIComponent(text) +'&tags='+ encodeURIComponent(tags);
wpct_trackerurl = wpct_baseurl + '/wp-content/plugins/wp-commentracker/wpct_tracker.php';
$.get(wpct_trackerurl, data, function(data) {$.prompt('yuhoo!');});
}else{ $.prompt('An Error Occured'); }
}
});
}