bloggerize 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +19 -0
- package/blogger.format.gd3.js +952 -0
- package/blogger.pubvar.gd3.js +193 -0
- package/buasc.js +81 -0
- package/download.js +182 -0
- package/examples/apikey.json +1 -0
- package/examples/credentials.json +0 -0
- package/examples/delete.js +29 -0
- package/examples/download.js +63 -0
- package/examples/login.js +23 -0
- package/examples/token.json +0 -0
- package/examples/upload.js +72 -0
- package/htmls.js +110 -0
- package/index.js +1 -0
- package/loadlib.js +154 -0
- package/package.json +25 -0
- package/test/script.js +23 -0
- package/upload.js +226 -0
|
@@ -0,0 +1,952 @@
|
|
|
1
|
+
//////////////////////////////////////////////////
|
|
2
|
+
//
|
|
3
|
+
// Vars loaded from {blogger.pubvar.gd.js}
|
|
4
|
+
//
|
|
5
|
+
//////////////////////////////////////////////////
|
|
6
|
+
//
|
|
7
|
+
// Cookie-functions:
|
|
8
|
+
//
|
|
9
|
+
function setcookie(c_name,value,exdays){
|
|
10
|
+
var exdate = new Date();
|
|
11
|
+
exdate.setDate(exdate.getDate() + exdays);
|
|
12
|
+
var c_value = escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
|
|
13
|
+
document.cookie = c_name + "=" + c_value;
|
|
14
|
+
}
|
|
15
|
+
function getcookie(c_name){
|
|
16
|
+
var i, x, y, ARRcookies = document.cookie.split(";");
|
|
17
|
+
for(i=0; i<ARRcookies.length; i++){
|
|
18
|
+
x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
|
|
19
|
+
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
|
|
20
|
+
x = x.replace(/^\s+|\s+$/g,"");
|
|
21
|
+
if(x==c_name){
|
|
22
|
+
return(unescape(y));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//
|
|
27
|
+
//////////////////////////////////////////////////
|
|
28
|
+
//
|
|
29
|
+
// Format-functions:
|
|
30
|
+
//
|
|
31
|
+
// Global 25
|
|
32
|
+
//
|
|
33
|
+
String.prototype.ireg = function (scope='i') {
|
|
34
|
+
return new RegExp(this, scope);
|
|
35
|
+
}
|
|
36
|
+
Array.prototype.findObject = function (key, value) {
|
|
37
|
+
return this.find(obj => obj[key] === value);
|
|
38
|
+
}
|
|
39
|
+
globalThis.isObject = function (x) {
|
|
40
|
+
return (typeof x === 'object' && !Array.isArray(x) && x !== null);
|
|
41
|
+
}
|
|
42
|
+
globalThis.cloneObject = function (obj) {
|
|
43
|
+
return JSON.parse(JSON.stringify(obj));
|
|
44
|
+
}
|
|
45
|
+
function removeFontSizeStyle (htmlString) {
|
|
46
|
+
const regex = /font-size\s*:\s*[^;"]+;?/gi;
|
|
47
|
+
return htmlString.replace(regex, '').replace(/style\s*=\s*""/gi, '');
|
|
48
|
+
}
|
|
49
|
+
function removeFontSizeAttribute (htmlString) {
|
|
50
|
+
const regex = /\s*size\s*=\s*(["'])(?:(?!\1).)*\1|\s*size\s*=\s*\w+/gi;
|
|
51
|
+
return htmlString.replace(regex, '');
|
|
52
|
+
}
|
|
53
|
+
globalThis.removeFontSize = function (htmlString) {
|
|
54
|
+
return removeFontSizeStyle(removeFontSizeAttribute(htmlString));
|
|
55
|
+
}
|
|
56
|
+
String.prototype.domdoc = function () {
|
|
57
|
+
const parser = new DOMParser();
|
|
58
|
+
return parser.parseFromString(this, 'text/html');
|
|
59
|
+
}
|
|
60
|
+
globalThis.replaceSpanContentByClass = function (htmlString, className, newContent) {
|
|
61
|
+
const doc = htmlString.domdoc();
|
|
62
|
+
const spans = doc.querySelectorAll(`span.${className}`);
|
|
63
|
+
for (const span of spans) {
|
|
64
|
+
span.textContent = newContent;
|
|
65
|
+
}
|
|
66
|
+
return doc.documentElement.innerHTML;
|
|
67
|
+
}
|
|
68
|
+
globalThis.replaceSecondLastAppearance = function (originalString, search, replacement) {
|
|
69
|
+
const lastIndex = originalString.lastIndexOf(search);
|
|
70
|
+
if (lastIndex === -1) return originalString;
|
|
71
|
+
const secondLastIndex = originalString.lastIndexOf(search, lastIndex - 1);
|
|
72
|
+
if (secondLastIndex === -1) return originalString;
|
|
73
|
+
const partBefore = originalString.slice(0, secondLastIndex);
|
|
74
|
+
const partAfter = originalString.slice(secondLastIndex + search.length);
|
|
75
|
+
return partBefore + replacement + partAfter;
|
|
76
|
+
}
|
|
77
|
+
globalThis.replaceLastAppearance = function (originalString, search, replacement) {
|
|
78
|
+
const lastIndex = originalString.lastIndexOf(search);
|
|
79
|
+
if (lastIndex === -1) return originalString;
|
|
80
|
+
const partBefore = originalString.slice(0, lastIndex);
|
|
81
|
+
const partAfter = originalString.slice(lastIndex + search.length);
|
|
82
|
+
return partBefore + replacement + partAfter;
|
|
83
|
+
}
|
|
84
|
+
globalThis.updateCodeLine = function (codeline, toreplace='const', replacewith='var') {
|
|
85
|
+
if (RegExp(`^${toreplace}\\s+`).test(codeline)) {
|
|
86
|
+
codeline = codeline.replace(toreplace, replacewith);
|
|
87
|
+
}
|
|
88
|
+
return codeline;
|
|
89
|
+
}
|
|
90
|
+
globalThis.getProperties = function (domdoc, idname, property, selector='id') {
|
|
91
|
+
if (selector === 'class') { selector = `.${idname}`; }
|
|
92
|
+
else if (selector === 'id') { selector = `#${idname}`; }
|
|
93
|
+
else { selector = idname; }
|
|
94
|
+
try {
|
|
95
|
+
return [...domdoc.querySelectorAll(selector)].map(item => item[property]);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.log(err.message);
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
globalThis.getAttribute = function (domdoc, {sid, sel='class', attr='textContent'}) {
|
|
102
|
+
try {
|
|
103
|
+
const func = (() => {
|
|
104
|
+
if (sel == 'name') { return 'getElementsByName'; }
|
|
105
|
+
else if (sel == 'class') { return 'getElementsByClassName'; }
|
|
106
|
+
else if (sel == 'tag') { return 'getElementsByTagName'; }
|
|
107
|
+
else { return null; }
|
|
108
|
+
})();
|
|
109
|
+
const dom = func ? domdoc[func](sid)[0] : domdoc.getElementById(sid);
|
|
110
|
+
if (dom) {
|
|
111
|
+
if (dom[attr] !== undefined) return dom[attr];
|
|
112
|
+
return dom.getAttribute(attr);
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
} catch (err) {
|
|
116
|
+
return console.log(err.message);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
String.prototype.parse = function (values={}) {
|
|
120
|
+
return this.replace(/{{(.*?)}}/g, (match) => {
|
|
121
|
+
return values[match.split(/{{|}}/).filter(Boolean)[0].trim()];
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
String.prototype.html = function (checkonly=true) {
|
|
125
|
+
return this.createDiv(checkonly);
|
|
126
|
+
}
|
|
127
|
+
// Keeps slash in self-closing tag
|
|
128
|
+
String.prototype.htmlValue = function () {
|
|
129
|
+
const temp = document.createElement('textarea');
|
|
130
|
+
temp.innerHTML = this.toString();
|
|
131
|
+
return temp.value;
|
|
132
|
+
}
|
|
133
|
+
// Escape slash in self-closing tag
|
|
134
|
+
String.prototype.htmlEncode = function () {
|
|
135
|
+
return this.html(false).innerHTML;
|
|
136
|
+
}
|
|
137
|
+
String.prototype.htmlDecode = function () {
|
|
138
|
+
return this.replace(/[^\u0000-\u007F]/g, function(match) {
|
|
139
|
+
const codePoint = match.codePointAt(0);
|
|
140
|
+
return `&#${codePoint};`;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
String.prototype.perfect = function () {
|
|
144
|
+
const origin = this.toString();
|
|
145
|
+
const text = origin.htmlEncode().htmlDecode();
|
|
146
|
+
return [origin, origin.replace(/\/>/g, '>')].includes(text);
|
|
147
|
+
}
|
|
148
|
+
String.prototype.createDiv = function (checkonly=false) {
|
|
149
|
+
const tempDiv = document.createElement('div');
|
|
150
|
+
tempDiv.innerHTML = this;
|
|
151
|
+
if (checkonly) return tempDiv.outerHTML;
|
|
152
|
+
return tempDiv; // Just DIV element object
|
|
153
|
+
}
|
|
154
|
+
String.prototype.generateDiv = function (attributes={}, tag='div') {
|
|
155
|
+
const formatAttributes = (attrs) => {
|
|
156
|
+
return Object.entries(attrs)
|
|
157
|
+
.map(([key, value]) => `${key}="${value}"`)
|
|
158
|
+
.join(' ');
|
|
159
|
+
};
|
|
160
|
+
attributes = formatAttributes(attributes);
|
|
161
|
+
return `<${tag}${attributes ? ' ': ''}${attributes}>${this}</${tag}>`;
|
|
162
|
+
}
|
|
163
|
+
String.prototype.convertDate = function () {
|
|
164
|
+
try {
|
|
165
|
+
if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(this)) {
|
|
166
|
+
const parts = this.split('/');
|
|
167
|
+
const day = parts[0].padStart(2, '0');
|
|
168
|
+
const month = parts[1].padStart(2, '0');
|
|
169
|
+
const year = parts[2];
|
|
170
|
+
return `${year}-${month}-${day}`;
|
|
171
|
+
} else {
|
|
172
|
+
return new Date(this).toISOString().split('T')[0];
|
|
173
|
+
}
|
|
174
|
+
} catch {
|
|
175
|
+
return new Date(this).toString();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
String.prototype.convertTime = function () {
|
|
179
|
+
try {
|
|
180
|
+
const year = this.split('-')[0].split('/')[0];
|
|
181
|
+
if (year.length === 4) return new Date(this.toString()).toISOString();
|
|
182
|
+
const date = this.split('T')[0].split(' ')[0];
|
|
183
|
+
return new Date(this.replace(date, date.convertDate())).toISOString();
|
|
184
|
+
} catch {
|
|
185
|
+
return new Date(this).toString();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
String.prototype.forceHttps = function (force='https://') {
|
|
189
|
+
if (this.startsWith('//')) {
|
|
190
|
+
return 'https:' + this;
|
|
191
|
+
} else if (/^http:\/\//i.test(this)) {
|
|
192
|
+
return force + this.substring(7);
|
|
193
|
+
}
|
|
194
|
+
return this.toString();
|
|
195
|
+
}
|
|
196
|
+
String.prototype.convertAvatarUrl = function (force='https://') {
|
|
197
|
+
return `<img src="${this.forceHttps(force)}" class="comment-avatar" width="24" height="24" border="0"/>`;
|
|
198
|
+
}
|
|
199
|
+
String.prototype.replaceIframeDimensions = function (newWidth='100%', newHeight='auto') {
|
|
200
|
+
const [doc, allElements] = domParser(this.toString(), 'iframe');
|
|
201
|
+
allElements.forEach(iframe => {
|
|
202
|
+
iframe.setAttribute('width', newWidth);
|
|
203
|
+
iframe.setAttribute('height', newHeight);
|
|
204
|
+
let src;
|
|
205
|
+
if (src=iframe.getAttribute('src')) iframe.setAttribute('src', src.forceHttps());
|
|
206
|
+
});
|
|
207
|
+
return doc.body.innerHTML;
|
|
208
|
+
}
|
|
209
|
+
String.prototype.extractInput = function () {
|
|
210
|
+
const args = this.replace(/\s/g, '').toLowerCase().split(',').map(item => {
|
|
211
|
+
let elem = {};
|
|
212
|
+
const key = item.split(':')[0];
|
|
213
|
+
const val = item.substr(key.length + 1);
|
|
214
|
+
elem[key] = val;
|
|
215
|
+
return elem;
|
|
216
|
+
});
|
|
217
|
+
return Object.assign({}, ...args);
|
|
218
|
+
}
|
|
219
|
+
globalThis.nowDate = function () {
|
|
220
|
+
return (new Date()).toISOString().split('T')[0];
|
|
221
|
+
}
|
|
222
|
+
String.prototype.bloggerPostData = function (blog, title, {dated=nowDate(), tid='', page=0, labels=[]}={}) {
|
|
223
|
+
return {
|
|
224
|
+
kind: 'blogger#post',
|
|
225
|
+
blog: { id: blog },
|
|
226
|
+
title: title + (tid ? ` ${tid}${page}` : ''),
|
|
227
|
+
content: this.toString(),
|
|
228
|
+
labels: labels,
|
|
229
|
+
published: `${dated}T00:${String(page).padStart(2,'0')}:00Z`
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
String.prototype.correctContent = function (profunc, first='<comdiv', last='</comdiv>') {
|
|
233
|
+
const start = this.indexOf(first);
|
|
234
|
+
const end = this.lastIndexOf(last) + last.length;
|
|
235
|
+
const taken = String.prototype[profunc].call(this.substring(start, end));
|
|
236
|
+
return this.substr(0, start) + taken + this.substr(end);
|
|
237
|
+
}
|
|
238
|
+
String.prototype.pickContent = function (first='<comdiv', last='</comdiv>', outer=true) {
|
|
239
|
+
const start = this.indexOf(first);
|
|
240
|
+
const end = this.lastIndexOf(last);
|
|
241
|
+
if (outer) return this.substring(start, end + last.length);
|
|
242
|
+
return this.substring(start + first.length, end);
|
|
243
|
+
}
|
|
244
|
+
globalThis.loadJson = async function (url, format='json') {
|
|
245
|
+
try {
|
|
246
|
+
const response = await fetch(url);
|
|
247
|
+
if (!response.ok) {
|
|
248
|
+
return console.error(`Error: ${response.status}`);
|
|
249
|
+
}
|
|
250
|
+
const jsonData = await response[format]();
|
|
251
|
+
return jsonData;
|
|
252
|
+
} catch (err) {
|
|
253
|
+
console.error('Error:', err.message);
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
globalThis.blogId = async function (url) {
|
|
258
|
+
const feedUrl = `${url}/feeds/posts/summary?alt=json&max-results=1&start-index=1`;
|
|
259
|
+
const data = await loadJson(feedUrl);
|
|
260
|
+
return data?.feed?.id?.$t?.split('-').pop();
|
|
261
|
+
}
|
|
262
|
+
globalThis.loadVars = async function (url) {
|
|
263
|
+
const vars = await loadJson(url, 'text');
|
|
264
|
+
if (vars) {
|
|
265
|
+
eval(vars);
|
|
266
|
+
return true;
|
|
267
|
+
}
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
globalThis.removeImgWidth = function (tag='img', attr='width') {
|
|
271
|
+
const images = document.querySelectorAll(tag);
|
|
272
|
+
images.forEach(img => { img.removeAttribute(attr); });
|
|
273
|
+
}
|
|
274
|
+
globalThis.escapeBigDimension = function (maxval=36, tag='img') {
|
|
275
|
+
document.querySelectorAll(tag).forEach(img => {
|
|
276
|
+
if (img.getAttribute('width') > maxval || img.getAttribute('height') > maxval) {
|
|
277
|
+
img.removeAttribute('width');
|
|
278
|
+
img.removeAttribute('height');
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
//
|
|
283
|
+
// Classic
|
|
284
|
+
//
|
|
285
|
+
function sortObject(Objs, rev, back){
|
|
286
|
+
var sortable = [];
|
|
287
|
+
for(var key in Objs){sortable.push([key,Objs[key]]);}
|
|
288
|
+
sortable.sort(function(a,b){return(a[1]-b[1]);});
|
|
289
|
+
if(rev){sortable.reverse();}
|
|
290
|
+
if(back){
|
|
291
|
+
var cbObjs = {};
|
|
292
|
+
for(var key in sortable){cbObjs[sortable[key][0]]=sortable[key][1];}
|
|
293
|
+
return(cbObjs);
|
|
294
|
+
}
|
|
295
|
+
return(sortable);
|
|
296
|
+
}
|
|
297
|
+
String.prototype.include = function(pat){//25
|
|
298
|
+
return(this.toLowerCase().split(',').includes(pat.toLowerCase()));
|
|
299
|
+
}
|
|
300
|
+
String.prototype.in = function(pat){//25
|
|
301
|
+
return(pat.toLowerCase().split(',').includes(this.toLowerCase()));
|
|
302
|
+
}
|
|
303
|
+
String.prototype.extract = function(separator=','){//25
|
|
304
|
+
return this.split(separator).map(e=>e.trim().toLowerCase())
|
|
305
|
+
}
|
|
306
|
+
Date.prototype.addDays = function(days){
|
|
307
|
+
return(this.setDate(this.getDate()+days));
|
|
308
|
+
}
|
|
309
|
+
Date.prototype.toJDStr = function(){
|
|
310
|
+
return(this.toJSON().split('T')[0]);
|
|
311
|
+
}
|
|
312
|
+
function domParser(htmlString, selectors='*', mime='text/html'){//25
|
|
313
|
+
const parser = new DOMParser();
|
|
314
|
+
const doc = parser.parseFromString(htmlString, mime);
|
|
315
|
+
const allElements = doc.querySelectorAll(selectors);
|
|
316
|
+
return [doc, allElements];
|
|
317
|
+
}
|
|
318
|
+
function removeStyle(htmlString, properties=['width'], selectors='span'){//25
|
|
319
|
+
const tempDiv = document.createElement('div');
|
|
320
|
+
tempDiv.innerHTML = htmlString;
|
|
321
|
+
const spans = tempDiv.getElementsByTagName(selectors);
|
|
322
|
+
for(const span of spans){
|
|
323
|
+
for(const property of properties){
|
|
324
|
+
if(span.style[property]){
|
|
325
|
+
span.style.removeProperty(property);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return tempDiv.innerHTML;
|
|
330
|
+
}
|
|
331
|
+
function removeAttributes(htmlString, attributesToRemove=[]){//25
|
|
332
|
+
const [doc, allElements] = domParser(htmlString);
|
|
333
|
+
allElements.forEach(element=>{
|
|
334
|
+
attributesToRemove.forEach(attrName=>{
|
|
335
|
+
if(element.hasAttribute(attrName)){
|
|
336
|
+
element.removeAttribute(attrName);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
return doc.body.innerHTML;
|
|
341
|
+
}
|
|
342
|
+
function stripAttributes(htmlString, allowedAttributes=[], selectors='*'){//25
|
|
343
|
+
const [doc, allElements] = domParser(htmlString, selectors);
|
|
344
|
+
allElements.forEach(element=>{
|
|
345
|
+
const attributesToRemove = [];
|
|
346
|
+
for(const attr of element.attributes){
|
|
347
|
+
if(!allowedAttributes.map(e=>e.toLowerCase()).includes(attr.name)){
|
|
348
|
+
attributesToRemove.push(attr.name);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
attributesToRemove.forEach(attrName=>{
|
|
352
|
+
element.removeAttribute(attrName);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
return doc.body.innerHTML;
|
|
356
|
+
}
|
|
357
|
+
function stripTags(htmlString, allowedTags=[], osign='<', csign='>'){//25
|
|
358
|
+
const tempDiv = document.createElement('div');
|
|
359
|
+
tempDiv.innerHTML = htmlString;
|
|
360
|
+
const allElements = tempDiv.getElementsByTagName('*');
|
|
361
|
+
for(let i=allElements.length-1; i>=0; i--){
|
|
362
|
+
const element = allElements[i];
|
|
363
|
+
if(!allowedTags.includes(osign+element.tagName.toLowerCase()+csign)){
|
|
364
|
+
element.parentNode.removeChild(element);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return tempDiv.innerHTML;
|
|
368
|
+
}
|
|
369
|
+
String.prototype.stripTags = function(allowed=[]){return stripTags(this, allowed)}//25
|
|
370
|
+
String.prototype.cleanTags = function(allowed=sDefAllowedTagList+sMoreAllowedTagList, forbidden=tagForbiddenAttributes, accepted=tagAllowedAttributes, limited=tagStyleLimitedProperties){//25
|
|
371
|
+
text = stripTags(this, allowed.match(/<(.*?)>/g));
|
|
372
|
+
text = removeAttributes(text, forbidden.extract());
|
|
373
|
+
Object.entries(accepted).forEach(([key,val]) => {text = stripAttributes(text, val.extract(), key)});
|
|
374
|
+
Object.entries(limited).forEach(([key,val]) => {text = removeStyle(text, val.extract(), key)});
|
|
375
|
+
return text;
|
|
376
|
+
}
|
|
377
|
+
String.prototype.replaceText = function(replaceWhat, replaceTo, exp='gi'){//25
|
|
378
|
+
replaceWhat = replaceWhat.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
379
|
+
var reg = new RegExp(replaceWhat, exp);
|
|
380
|
+
return(this.replace(reg, replaceTo));
|
|
381
|
+
}
|
|
382
|
+
String.prototype.clearText = function(clearWhat, exp='gi'){//25
|
|
383
|
+
return(this.replaceText(clearWhat, '', exp));
|
|
384
|
+
}
|
|
385
|
+
String.prototype.adjustCmtStid = function(stid){//25
|
|
386
|
+
return this.replace(new RegExp(`\\[${stid}\\]([\\w\\W]+)\\[\/${stid}\\]`, 'gi'), `[${stid}=$1]`);
|
|
387
|
+
}
|
|
388
|
+
String.prototype.replaceCmtStid = function(stid, func){//25
|
|
389
|
+
return this.replace(new RegExp(`\\[${stid}=([^\\]]+)\\]`, 'gi'), String.prototype[func].call('$1'));
|
|
390
|
+
}
|
|
391
|
+
String.prototype.youtube = function(vid_stid='youtube'){//25
|
|
392
|
+
vid_stid = vid_stid.toLowerCase();
|
|
393
|
+
let vidfunc;
|
|
394
|
+
if(vid_stid.in('img,image')){
|
|
395
|
+
vidfunc = 'embedImg';
|
|
396
|
+
}else if(vid_stid=='facebook'){
|
|
397
|
+
vidfunc = 'embedFacebook';
|
|
398
|
+
}else if(vid_stid=='liveleak'){
|
|
399
|
+
vidfunc = 'embedLiveleak';
|
|
400
|
+
}else if(vid_stid=='tiktok'){
|
|
401
|
+
vidfunc = 'embedTiktok';
|
|
402
|
+
}else{
|
|
403
|
+
vid_stid = 'youtube';
|
|
404
|
+
vidfunc = 'embedYoutube';
|
|
405
|
+
}
|
|
406
|
+
let res = this;
|
|
407
|
+
res = res.adjustCmtStid(vid_stid);
|
|
408
|
+
res = res.replaceCmtStid(vid_stid, vidfunc);
|
|
409
|
+
return(res);
|
|
410
|
+
}
|
|
411
|
+
String.prototype.embedImg = function(){//25
|
|
412
|
+
return(`<img ${DEF_STYLE} src="${this}"></img>`);
|
|
413
|
+
}
|
|
414
|
+
String.prototype.embedFacebook = function(){//25
|
|
415
|
+
return(`<iframe ${DEF_STYLE} src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FPlayStation%2Fvideos%2F${this}%2F&show_text=0" frameborder="0" allowfullscreen></iframe>`);
|
|
416
|
+
}
|
|
417
|
+
String.prototype.embedLiveleak = function(){//25
|
|
418
|
+
return(`<iframe ${DEF_STYLE} src="https://www.itemfix.com/e/${this}" frameborder="0" allowfullscreen></iframe>`);
|
|
419
|
+
}
|
|
420
|
+
String.prototype.embedYoutube = function(){//25
|
|
421
|
+
return(`<iframe ${DEF_STYLE} src="https://www.youtube.com/embed/${this}" allow="accelerometer;encrypted-media;gyroscope;picture-in-picture;web-share" frameborder="0" allowfullscreen></iframe>`);
|
|
422
|
+
}
|
|
423
|
+
String.prototype.embedTiktok = function(){//25
|
|
424
|
+
return(`<iframe ${DEF_STYLE} src="https://www.tiktok.com/embed/v2/${this}?lang=en-US" frameborder="0" allowfullscreen></iframe>`);
|
|
425
|
+
}
|
|
426
|
+
String.prototype.json2date = function(){
|
|
427
|
+
var jts = this.split('T');
|
|
428
|
+
var jymd = jts[0].split('-');
|
|
429
|
+
var jhms = jts[1].split('+');
|
|
430
|
+
var monthes = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
|
431
|
+
return(monthes[jymd[1]-1]+' '+jymd[2]+' '+jhms[0].split('.')[0]+' UTC+'+jhms[1].replace(':','')+' '+jymd[0]);
|
|
432
|
+
}
|
|
433
|
+
function showListedDate(lDateTime){//25
|
|
434
|
+
var lDate = lDateTime.split('T')[0];
|
|
435
|
+
var lTime = lDateTime.split('T')[1].split('.')[0];
|
|
436
|
+
var lZone = 'GMT+' + lDateTime.split('+')[1];
|
|
437
|
+
return(`${lDate} ${lTime} ${lZone}`);
|
|
438
|
+
}
|
|
439
|
+
function showListedPostHref(lHref){
|
|
440
|
+
var title = lHref.split('.html')[0];
|
|
441
|
+
title = correctTitle(title,1); //VN
|
|
442
|
+
return(title);
|
|
443
|
+
}
|
|
444
|
+
function correctTitle(title,langID){
|
|
445
|
+
if(!langID){langID=1;}//[1:Viet;2:Eng]
|
|
446
|
+
for(var i=0; i<exPageNames.length; i++){
|
|
447
|
+
if(title==exPageNames[i][0] || title.match(RegExp('p/'+exPageNames[i][0],'i'))){
|
|
448
|
+
return(exPageNames[i][langID]);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
title = title.split('/')[5];
|
|
452
|
+
if(title){return(title.toUpperCase());}
|
|
453
|
+
else return('Unknown page');
|
|
454
|
+
}
|
|
455
|
+
function revertCommentCodeToHtml(text){//25:cmt2html
|
|
456
|
+
text = text.youtube();
|
|
457
|
+
text = text.youtube('facebook');
|
|
458
|
+
text = text.youtube('liveleak');
|
|
459
|
+
text = text.youtube('tiktok');
|
|
460
|
+
text = text.youtube('image');
|
|
461
|
+
text = text.youtube('img');
|
|
462
|
+
text = insertSmiley(text);
|
|
463
|
+
return revertTags(text).cleanTags().nicep().nicea().nicetag();
|
|
464
|
+
}
|
|
465
|
+
function convertCommentHtmlToCode(text){//25
|
|
466
|
+
return escapeTags(text.cleanTags().nicep().nicea().nicetag().escapebreaks()).trim();
|
|
467
|
+
}
|
|
468
|
+
String.prototype.cmt2html = function(){return(revertCommentCodeToHtml(this))}//25
|
|
469
|
+
String.prototype.html2cmt = function(){return(convertCommentHtmlToCode(this))}//25
|
|
470
|
+
function clearCustomTags(text){//25
|
|
471
|
+
return(text.clearcode()); //JQuery
|
|
472
|
+
}
|
|
473
|
+
function insertSmiley(htm){
|
|
474
|
+
for(var smiley in iCommentSmileys){
|
|
475
|
+
htm = htm.replaceText(smiley, iCommentSmileys[smiley]);
|
|
476
|
+
}
|
|
477
|
+
return(htm);
|
|
478
|
+
}
|
|
479
|
+
function updateDivContent(div_id, content){
|
|
480
|
+
var div = document.getElementById(div_id);
|
|
481
|
+
if(!content){div.innerHTML=revertCommentCodeToHtml(div.innerHTML);}
|
|
482
|
+
else{div.innerHTML=content;}
|
|
483
|
+
}
|
|
484
|
+
//
|
|
485
|
+
//////////////////////////////////////////////////
|
|
486
|
+
//
|
|
487
|
+
// Comment-format-customizing:
|
|
488
|
+
//
|
|
489
|
+
globalThis.getStyledComment = function(authorurl, author, published, content, fontface=true){//25
|
|
490
|
+
return((openAuthorStyle(authorurl, author, published, true, fontface) + closeAuthorStyle(revertCommentCodeToHtml(content.replace(/"/gi,'"').replace(/'/gi,"'")), true)).replaceIframeDimensions());
|
|
491
|
+
}
|
|
492
|
+
function getStyledTitle(ct, author, authorurl, authoravatar, hrefLink, published){
|
|
493
|
+
return('<a title="' + author + ' profile" href="' + authorurl + '"><img src="' + authoravatar + '" width="24" height="24" border="0"/></a> <b><a href="' + hrefLink + '" title="Posted at ' + showListedDate(published) + '">' + author + '</a></b> <span style="font-size: x-small; color: #9FC5E8;"><i>(' + ct + ')</i></span>');
|
|
494
|
+
}
|
|
495
|
+
function getCounterPat(count){
|
|
496
|
+
return('[CounterPat' + count + ']');
|
|
497
|
+
}
|
|
498
|
+
function openAuthorStyle(url, name, ctime, returnvalue, fontface=true){//25
|
|
499
|
+
// [ctime]: ISODateString
|
|
500
|
+
isVipAuthor = false;
|
|
501
|
+
isBLAuthor = false;
|
|
502
|
+
isStyleItalic = false;
|
|
503
|
+
isStyleBold = false;
|
|
504
|
+
isStyleBGC = false;
|
|
505
|
+
if(isBL(url,name,ctime)){
|
|
506
|
+
isBLAuthor = true;
|
|
507
|
+
if(returnvalue){return('');}
|
|
508
|
+
else{return;}
|
|
509
|
+
}
|
|
510
|
+
var strSetStyle = '';
|
|
511
|
+
var strTextStyle = '';
|
|
512
|
+
for(var i=0; i<UserVIPs.length; i++){
|
|
513
|
+
if(url.match(RegExp(UserVIPs[i][0], 'gi'))){
|
|
514
|
+
isVipAuthor = true;
|
|
515
|
+
var fSize = UserVIPs[i][2];
|
|
516
|
+
var color = UserVIPs[i][3];
|
|
517
|
+
var fFace = UserVIPs[i][4];
|
|
518
|
+
var sItal = UserVIPs[i][5];
|
|
519
|
+
var sBold = UserVIPs[i][6];
|
|
520
|
+
var sBCol = UserVIPs[i][7];
|
|
521
|
+
var avaID = UserVIPs[i][8]; //ShitAvatar
|
|
522
|
+
strSetStyle = `<font color="${color}" face="${fontface?fFace:''}">`;
|
|
523
|
+
if(returnvalue){strTextStyle+=strSetStyle;}
|
|
524
|
+
else{document.write(strSetStyle);}
|
|
525
|
+
if(sItal){
|
|
526
|
+
isStyleItalic = true;
|
|
527
|
+
strSetStyle = '<i>';
|
|
528
|
+
if(returnvalue){strTextStyle+=strSetStyle;}
|
|
529
|
+
else{document.write(strSetStyle);}
|
|
530
|
+
}
|
|
531
|
+
if(sBold){
|
|
532
|
+
isStyleBold = true;
|
|
533
|
+
strSetStyle = '<b>';
|
|
534
|
+
if(returnvalue){strTextStyle+=strSetStyle;}
|
|
535
|
+
else{document.write(strSetStyle);}
|
|
536
|
+
}
|
|
537
|
+
if(sBCol){
|
|
538
|
+
isStyleBGC = true;
|
|
539
|
+
strSetStyle = '<span style="background-color:'+sBCol+';">';
|
|
540
|
+
if(returnvalue){strTextStyle+=strSetStyle;}
|
|
541
|
+
else{document.write(strSetStyle);}
|
|
542
|
+
}
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
if(returnvalue){return(strTextStyle);}
|
|
547
|
+
}
|
|
548
|
+
function closeAuthorStyle(cbodyId, returnvalue){
|
|
549
|
+
var strSetStyle = '';
|
|
550
|
+
var strTextStyle = '';
|
|
551
|
+
if(isBLAuthor){
|
|
552
|
+
var strBL = 'Anh là ông bò đang bị khóa mõm đcmnc';
|
|
553
|
+
strSetStyle = rsBLAuthor ? rsBLAuthor : strBL;
|
|
554
|
+
if(returnvalue){return(strSetStyle);}
|
|
555
|
+
else{
|
|
556
|
+
updateDivContent(cbodyId, strSetStyle);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if(returnvalue){strTextStyle=cbodyId;}
|
|
561
|
+
else{updateDivContent(cbodyId);}
|
|
562
|
+
if(isStyleBGC){
|
|
563
|
+
strSetStyle = '</span>';
|
|
564
|
+
if(returnvalue){strTextStyle+=strSetStyle;}else{document.write(strSetStyle);}
|
|
565
|
+
}
|
|
566
|
+
if(isStyleBold){
|
|
567
|
+
strSetStyle = '</b>';
|
|
568
|
+
if(returnvalue){strTextStyle+=strSetStyle;}else{document.write(strSetStyle);}
|
|
569
|
+
}
|
|
570
|
+
if(isStyleItalic){
|
|
571
|
+
strSetStyle = '</i>';
|
|
572
|
+
if(returnvalue){strTextStyle+=strSetStyle;}else{document.write(strSetStyle);}
|
|
573
|
+
}
|
|
574
|
+
if(isVipAuthor){
|
|
575
|
+
strSetStyle = '</font>';
|
|
576
|
+
if(returnvalue){strTextStyle+=strSetStyle;}else{document.write(strSetStyle);}
|
|
577
|
+
}
|
|
578
|
+
if(returnvalue){return(strTextStyle);}
|
|
579
|
+
}
|
|
580
|
+
globalThis.isVIP = function(uid){
|
|
581
|
+
for(var i=0; i<UserVIPs.length; i++){
|
|
582
|
+
if(uid.match(RegExp(UserVIPs[i][0],'i'))){return(i);}
|
|
583
|
+
}
|
|
584
|
+
return(-1);
|
|
585
|
+
}
|
|
586
|
+
globalThis.isBL = function(url, name, ctime){
|
|
587
|
+
for(var i=0; i<UserBLs.length; i++){
|
|
588
|
+
if(url.match(RegExp(UserBLs[i][0], 'gi')) || name.match(RegExp(UserBLs[i][1], 'gi'))){
|
|
589
|
+
rsBLAuthor = UserBLs[i][4] ? UserBLs[i][4] : false;
|
|
590
|
+
if(UserBLs[i][2]){//UnlockDate
|
|
591
|
+
var prs = UserBLs[i][2].split("/");
|
|
592
|
+
var unlockDate = new Date(prs[0], prs[1]-1, prs[2]);
|
|
593
|
+
if(UserBLs[i][3]){//LockFromDate
|
|
594
|
+
prs = UserBLs[i][3].split("/");
|
|
595
|
+
var lockDate = new Date(prs[0], prs[1]-1, prs[2]);
|
|
596
|
+
}else{
|
|
597
|
+
var lockDate = new Date(0, 0, 0);
|
|
598
|
+
}
|
|
599
|
+
var cmttime = new Date(ctime);
|
|
600
|
+
if(isNaN(cmttime)){return(true);}
|
|
601
|
+
if(cmttime>lockDate && cmttime<unlockDate){return(true);}
|
|
602
|
+
}else{return(true);}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return(false);
|
|
606
|
+
}
|
|
607
|
+
globalThis.showVIP = function(uri, tag, width, nbsp, ava, ancNum, ancData, postUrl=strPostURL){
|
|
608
|
+
let ancRec = ancNum ? 'cmt.'+ancNum : '';
|
|
609
|
+
if(ancData){ancData='c'+ancData.split('-').slice(-1);}else{ancData='';}
|
|
610
|
+
var cmtUrl = postUrl+"?commentPage="+Math.ceil(ancNum/numCommentPerPage)+"&showComment="+ancData+"#"+ancData;
|
|
611
|
+
var icon = '';
|
|
612
|
+
var vipID = isVIP(uri);
|
|
613
|
+
if(vipID>=0){
|
|
614
|
+
if(vipID>0){//Admin:NotVIP
|
|
615
|
+
var iconURL = (vipID<=numIndexVip1) ? (urlVip1Avatar) : ((vipID<=numIndexVip2) ? (urlVip2Avatar) : (urlVip3Avatar));
|
|
616
|
+
if(!tag){icon = iconURL;}
|
|
617
|
+
else{icon = nbsp + '<img src="' + iconURL + '" border="0" width="' + (width*0.75) + '"/>';}
|
|
618
|
+
}
|
|
619
|
+
if(ava){
|
|
620
|
+
var cids = UserVIPs[vipID][8].split(','); //[th][vs][..]
|
|
621
|
+
var cid = cids[0];
|
|
622
|
+
if(cid){
|
|
623
|
+
if(!tag){
|
|
624
|
+
icon += ';' + urlIdAvatars[cid][0];
|
|
625
|
+
}else{
|
|
626
|
+
icon += nbsp + '<a title="'+urlIdAvatars[cid][1]+'" href="'+cmtUrl+'"><img src="' + urlIdAvatars[cid][0] + '" border="0" width="' + (width*1) + '"/></a>';
|
|
627
|
+
for(var i=1; i<cids.length; i++){
|
|
628
|
+
cid = cids[i];
|
|
629
|
+
icon += nbsp + '<img title="'+urlIdAvatars[cid][1]+'" src="' + urlIdAvatars[cid][0] + '" border="0" width="' + (width*1) + '"/>';
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
if(tag){
|
|
634
|
+
/// icon += nbsp + "<div class='fb-like' data-href='"+uri+"' data-send='false' data-layout='button_count' data-width='450' data-show-faces='false'></div>";
|
|
635
|
+
/// icon += nbsp + '<g:plusone zise="medium" href="'+uri+'"></g:plusone>';
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if(ancRec||ancData){
|
|
640
|
+
/// icon += nbsp + "<div class='fb-like' data-href='"+cmtUrl+"' data-send='false' data-layout='button_count' data-width='450' data-show-faces='false'></div>";
|
|
641
|
+
/// icon += nbsp + '<g:plusone zise="small" href="'+cmtUrl+'"></g:plusone>';
|
|
642
|
+
}
|
|
643
|
+
return(icon);
|
|
644
|
+
}
|
|
645
|
+
//
|
|
646
|
+
//////////////////////////////////////////////////
|
|
647
|
+
//
|
|
648
|
+
// Comments-paginating:
|
|
649
|
+
//
|
|
650
|
+
function recountTotalComments(){
|
|
651
|
+
numEntryCommentRecount = (numCommentPage-1)*numCommentPerPage+CommentsCounter;
|
|
652
|
+
return(numEntryCommentRecount);
|
|
653
|
+
}
|
|
654
|
+
function showPaginating(span_id, content){
|
|
655
|
+
if(content != '')
|
|
656
|
+
{content = 'Page: ' + content;}
|
|
657
|
+
updateDivContent(span_id, content);
|
|
658
|
+
}
|
|
659
|
+
function commentPagination(url, comment, printPaginating, pageNo, space){
|
|
660
|
+
return commentPaginate('commentpaging', url, comment, printPaginating, pageNo, space);
|
|
661
|
+
}
|
|
662
|
+
function getPostPaginating(json){
|
|
663
|
+
var numCmnts = json.feed.openSearch$totalResults.$t;
|
|
664
|
+
commentPagination(strPostURL, numCmnts, 1, false, ' ');
|
|
665
|
+
document.write(' ('+numCmnts+')');
|
|
666
|
+
}
|
|
667
|
+
function remakePaginating(){
|
|
668
|
+
var pageHref = document.location.href;
|
|
669
|
+
if(pageHref.split('/')[4]){ // Update pages but Main
|
|
670
|
+
strPagination = strPagination.replace(/\ /gi,'');
|
|
671
|
+
if(!pageHref.match('/p/')){ // For "Post", not "Page"
|
|
672
|
+
showPaginating("commentpaging-head", strPagination);
|
|
673
|
+
}else{
|
|
674
|
+
// Recount <numEntryCommentRecount>
|
|
675
|
+
recountTotalComments();
|
|
676
|
+
if(numEntryCommentRecount%numCommentPerPage>0){
|
|
677
|
+
// Update <strPagination>
|
|
678
|
+
commentPagination(pageHref.split('.html')[0]+'.html', numEntryCommentRecount, false, false, '');
|
|
679
|
+
showPaginating("commentpaging-head", strPagination);
|
|
680
|
+
showPaginating("commentpaging", strPagination);
|
|
681
|
+
}else{
|
|
682
|
+
showPaginating("commentpaging-head", strPagination);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
//
|
|
688
|
+
//////////////////////////////////////////////////
|
|
689
|
+
//
|
|
690
|
+
// Timer-functions:
|
|
691
|
+
//
|
|
692
|
+
function timedCount(showAlert, windowhost){
|
|
693
|
+
showAlert = showAlert || false;
|
|
694
|
+
windowhost = windowhost || window.location.hostname;
|
|
695
|
+
if(timer_is_on == 1){
|
|
696
|
+
$.getJSON(
|
|
697
|
+
"https://"+windowhost+"/feeds/comments/default?redirect=false&max-results=1&alt=json-in-script&callback=?",
|
|
698
|
+
{tags: "jquery,javascript", tagmode: "any", format: "json"},
|
|
699
|
+
function(data){
|
|
700
|
+
var counter = data.feed["openSearch$totalResults"].$t;
|
|
701
|
+
var newComments = counter - totalComments;
|
|
702
|
+
if(newComments>0){
|
|
703
|
+
totalComments = counter;
|
|
704
|
+
setcookie(cookieCount, totalComments, cookieDays);
|
|
705
|
+
getRecentComments01();//LocalFunc
|
|
706
|
+
if(showAlert){
|
|
707
|
+
alert(newComments + " new comment(s) comming");
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
timer = setTimeout(function(){ timedCount(showAlert, windowhost) }, timerInterval);
|
|
713
|
+
}
|
|
714
|
+
function doTimer(showAlert, windowhost){
|
|
715
|
+
if(timer_is_on != 1){
|
|
716
|
+
timer_is_on = 1;
|
|
717
|
+
setAutoAlertMsg(msgCAAOn);
|
|
718
|
+
setcookie(cookieName, 1, cookieDays);
|
|
719
|
+
timedCount(showAlert, windowhost);
|
|
720
|
+
}else{
|
|
721
|
+
timer_is_on = 0;
|
|
722
|
+
setAutoAlertMsg(msgCAAOff);
|
|
723
|
+
setcookie(cookieName, 0, cookieDays);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
function setAutoAlertMsg(msg){
|
|
727
|
+
document.getElementById("msgCommentAutoAlert").innerHTML = msg;
|
|
728
|
+
}
|
|
729
|
+
function doFloat(){
|
|
730
|
+
if(nav_is_on != 1){
|
|
731
|
+
nav_is_on = 1;
|
|
732
|
+
setcookie(cookieNav, 1, cookieDays);
|
|
733
|
+
}else{
|
|
734
|
+
nav_is_on = 0;
|
|
735
|
+
setcookie(cookieNav, 0, cookieDays);
|
|
736
|
+
}
|
|
737
|
+
setNavFloating(nav_is_on);
|
|
738
|
+
}
|
|
739
|
+
function setNavFloating(navOn){
|
|
740
|
+
if(navOn == 1){
|
|
741
|
+
setNavFloatingButton("spanNavFloatingButton", "blogPageTop", "comments", "blogPageBottom");
|
|
742
|
+
}else{
|
|
743
|
+
setNavFloatingButton("spanNavFloatingButton", 0);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function setNavFloatingButton(nfbDiv, top, mid, bot){
|
|
747
|
+
if(!mid){
|
|
748
|
+
document.getElementById(nfbDiv).innerHTML = "";
|
|
749
|
+
}else{
|
|
750
|
+
var msgTop = '<a href="#'+top+'"><img src="https://cdn.jsdelivr.net/gh/asinerum/project/team/gui/im_up.gif" border="0"/></a>';
|
|
751
|
+
var msgMid = '<a href="#'+mid+'"><img src="https://cdn.jsdelivr.net/gh/asinerum/project/team/gui/im_mid.gif" border="0"/></a>';
|
|
752
|
+
var msgBot = '<a href="#'+bot+'"><img src="https://cdn.jsdelivr.net/gh/asinerum/project/team/gui/im_down.gif" border="0"/></a>';
|
|
753
|
+
document.getElementById(nfbDiv).innerHTML = msgTop+msgMid+msgBot;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
//
|
|
757
|
+
//////////////////////////////////////////////////
|
|
758
|
+
//
|
|
759
|
+
// Misc-functions:
|
|
760
|
+
//
|
|
761
|
+
function showMainMenu(){
|
|
762
|
+
divmenu = document.getElementById("divMainMenu");
|
|
763
|
+
if(divmenu.innerHTML=="") divmenu.innerHTML=strMainMenu;
|
|
764
|
+
else hideMainMenu();
|
|
765
|
+
}
|
|
766
|
+
function hideMainMenu(){
|
|
767
|
+
divmenu = document.getElementById("divMainMenu");
|
|
768
|
+
strMainMenu = divmenu.innerHTML;
|
|
769
|
+
divmenu.innerHTML = "";
|
|
770
|
+
}
|
|
771
|
+
function getCommentQuote(author, cmtnum, cmtid){
|
|
772
|
+
var cmtnumRef = getGoToCommentLocation(cmtnum, cmtid);
|
|
773
|
+
return 'Ref: '+author+' <A HREF="'+cmtnumRef+'">('+cmtnum+')</A> \r\n\r\n';
|
|
774
|
+
}
|
|
775
|
+
function openCommentQuote(text,cmtInput='hiddenPostBody',cmtForm='hiddenCommentForm'){
|
|
776
|
+
//{xuteng}
|
|
777
|
+
db(cmtInput, text);
|
|
778
|
+
document[cmtForm].submit();
|
|
779
|
+
}
|
|
780
|
+
function setCommentQuote(text){
|
|
781
|
+
element = document.getElementById(idTextareaCommentPost);
|
|
782
|
+
element.value = text;
|
|
783
|
+
element.focus();
|
|
784
|
+
element.setSelectionRange(element.value.length,element.value.length);
|
|
785
|
+
}
|
|
786
|
+
function getGoToCommentValue(inputId){
|
|
787
|
+
if(!inputId){inputId='go-to-comment';}
|
|
788
|
+
var cmtnum = document.getElementById(inputId).value;
|
|
789
|
+
if(isNaN(cmtnum)||(!cmtnum)){cmtnum=1;}
|
|
790
|
+
return cmtnum;
|
|
791
|
+
}
|
|
792
|
+
function getGoToCommentLocation(cmtnum, cmtid){
|
|
793
|
+
if(!cmtid){cmthash='#cmt.'+cmtnum;}else{cmthash='#c'+cmtid;}
|
|
794
|
+
return location.href.split('?')[0].split('#')[0]+'?commentPage='+Math.ceil(cmtnum/numCommentPerPage)+cmthash;
|
|
795
|
+
}
|
|
796
|
+
function setGoToComment(inputId){
|
|
797
|
+
var cmtnum = getGoToCommentValue(inputId);
|
|
798
|
+
location.hash = '#cmt.'+cmtnum;
|
|
799
|
+
}
|
|
800
|
+
function setGoToCommentExt(inputId){
|
|
801
|
+
var cmtnum = getGoToCommentValue(inputId);
|
|
802
|
+
location.href = getGoToCommentLocation(cmtnum);
|
|
803
|
+
}
|
|
804
|
+
function pickButton(hide, sdiv, ocfShow, ocfHide,
|
|
805
|
+
titleShow, titleHide, imgShow, imgHide, idShow, idHide){
|
|
806
|
+
hide = hide || false;
|
|
807
|
+
sdiv = sdiv || "divRecentCommentsButton";
|
|
808
|
+
ocfShow = ocfShow || "getRecentComments01();";
|
|
809
|
+
ocfHide = ocfHide || "clearRecentComments01();";
|
|
810
|
+
titleShow = titleShow || "Show latest comments";
|
|
811
|
+
titleHide = titleHide || "Hide latest comments";
|
|
812
|
+
imgShow = imgShow || "https://cdn.jsdelivr.net/gh/asinerum/project/team/gui/icon_go_show.gif";
|
|
813
|
+
imgHide = imgHide || "https://cdn.jsdelivr.net/gh/asinerum/project/team/gui/icon_back_hide.gif";
|
|
814
|
+
idShow = idShow || "iRecentCommentShow";
|
|
815
|
+
idHide = idHide || "iRecentCommentHide";
|
|
816
|
+
title = hide ? titleHide : titleShow;
|
|
817
|
+
img = hide ? imgHide : imgShow;
|
|
818
|
+
id = hide ? idHide : idShow;
|
|
819
|
+
ocf = hide ? ocfHide : ocfShow;
|
|
820
|
+
shtm = "<a id='" + id + "' href='#' onclick='" + ocf + ";return(false);'><img border='0' title='" + title + "' src='" + img + "'/></a>";
|
|
821
|
+
document.getElementById(sdiv).innerHTML = shtm;
|
|
822
|
+
}
|
|
823
|
+
//
|
|
824
|
+
//////////////////////////////////////////////////
|
|
825
|
+
//
|
|
826
|
+
////
|
|
827
|
+
// V2014.008A:
|
|
828
|
+
////
|
|
829
|
+
function updateCommentContent(tagName, tagClass, tagIdBase, headIdBase, textIdBase, hideCounter){
|
|
830
|
+
var comments = [];
|
|
831
|
+
var divs = document.getElementsByTagName(tagName);
|
|
832
|
+
for(index=0; index<divs.length; index++){
|
|
833
|
+
if(divs[index].getAttribute('class')==tagClass){
|
|
834
|
+
var comment = {};
|
|
835
|
+
comment.id = divs[index].getAttribute('id');
|
|
836
|
+
comment.authorUrl = divs[index].getAttribute('authorUrl');
|
|
837
|
+
comment.timestamp = divs[index].getAttribute('timestamp');
|
|
838
|
+
comments.push(comment);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
for(var index=0; index<comments.length; index++){
|
|
842
|
+
var coreId = comments[index].id.split(tagIdBase)[1];
|
|
843
|
+
var headId = headIdBase + coreId;
|
|
844
|
+
var textId = textIdBase + coreId;
|
|
845
|
+
var comheadid = document.getElementById(headId);
|
|
846
|
+
var comtextid = document.getElementById(textId);
|
|
847
|
+
var cmtnum = ((numCommentPage-1)*numCommentPerPage + index + 1);
|
|
848
|
+
var mrHead = showVIP(comments[index].authorUrl, 1, 24, ' ', 1, cmtnum, coreId);
|
|
849
|
+
var mrText = getStyledComment(comments[index].authorUrl, '?', comments[index].timestamp, comtextid.innerHTML);
|
|
850
|
+
if(!hideCounter){mrHead = '<A NAME="cmt.'+cmtnum+'"></A><I><FONT COLOR="#FF9966">('+cmtnum+')</FONT></I>' + mrHead;}
|
|
851
|
+
comheadid.innerHTML = mrHead;
|
|
852
|
+
comtextid.innerHTML = mrText;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
////
|
|
856
|
+
// V2014.010A:
|
|
857
|
+
////
|
|
858
|
+
function copytext(text){//25
|
|
859
|
+
const temporaryTextArea = document.createElement('textarea');
|
|
860
|
+
temporaryTextArea.value = text;
|
|
861
|
+
temporaryTextArea.style.position = 'fixed';
|
|
862
|
+
temporaryTextArea.style.height = '0';
|
|
863
|
+
temporaryTextArea.style.opacity = '0';
|
|
864
|
+
document.body.appendChild(temporaryTextArea);
|
|
865
|
+
temporaryTextArea.select();
|
|
866
|
+
try{
|
|
867
|
+
document.execCommand('copy');
|
|
868
|
+
console.log('COPIED:', temporaryTextArea.value);
|
|
869
|
+
}catch(err){
|
|
870
|
+
console.error('COPY FAILED:', err);
|
|
871
|
+
}finally{
|
|
872
|
+
document.body.removeChild(temporaryTextArea);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
function updateOneCommentHeader(bcId, idPrefix, authorUrl, hideCounter, authorName, editor=false){
|
|
876
|
+
CommentsCounter++;
|
|
877
|
+
var cmtnum = ((numCommentPage-1)*numCommentPerPage + CommentsCounter);
|
|
878
|
+
var comheadid = document.getElementById(idPrefix+bcId);
|
|
879
|
+
var comgoid = document.getElementById('cgo-'+bcId);
|
|
880
|
+
var mrHead = showVIP(authorUrl, 1, 24, ' ', 1, cmtnum, bcId);
|
|
881
|
+
var cmtid = bcId.split('-')[1]; // bcId:[_cmt-xxxxxx]
|
|
882
|
+
if(!hideCounter){mrHead = '<A NAME="cmt.'+cmtnum+'"></A><I><FONT COLOR="#FF9966">('+cmtnum+')</FONT></I>' + mrHead;}
|
|
883
|
+
comheadid.innerHTML = mrHead;
|
|
884
|
+
var quote = `getCommentQuote(decodeURI('${authorName}'),${cmtnum},'${cmtid}')`;
|
|
885
|
+
var gocmt = `<IMG HEIGHT="12" SRC="https://cdn.jsdelivr.net/gh/asinerum/project/team/gui/button.gif" TITLE="Go comment"/>`
|
|
886
|
+
if(editor)
|
|
887
|
+
comgoid.innerHTML = `<A HREF="javascript:quot=${quote};editorAppendHtml(quot);editorSetFocus()">${gocmt}</A>`;
|
|
888
|
+
else{
|
|
889
|
+
comgoid.innerHTML = `<A HREF="javascript:quot=${quote};copytext(quot);openCommentQuote(quot)">${gocmt}</A>`;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
function updateOneCommentHeader2(bcId, idPrefix, authorUrl, hideCounter, authorName){
|
|
893
|
+
updateOneCommentHeader(bcId, idPrefix, authorUrl, hideCounter, authorName, true)
|
|
894
|
+
}
|
|
895
|
+
function updateOneCommentContent(bcId, idPrefix, authorUrl, timestamp){
|
|
896
|
+
var comtextid = document.getElementById(idPrefix+bcId); if(!comtextid)return;
|
|
897
|
+
var mrText = getStyledComment(authorUrl, '?', timestamp, comtextid.innerHTML);
|
|
898
|
+
comtextid.innerHTML = mrText;
|
|
899
|
+
}
|
|
900
|
+
function updateOneBloggerComment(bcId, idPrefix){
|
|
901
|
+
var comid = document.getElementById(idPrefix+bcId);
|
|
902
|
+
var authorUrl = comid.getAttribute('authorUrl');
|
|
903
|
+
var authorName = comid.getAttribute('authorName');
|
|
904
|
+
var timestamp = comid.getAttribute('timestamp');
|
|
905
|
+
if(!DEF_HIDE_STAMPS){
|
|
906
|
+
func = typeof(DEF_USE_BUILTIN_EDITOR)==='undefined' ? updateOneCommentHeader : updateOneCommentHeader2;
|
|
907
|
+
func(bcId, 'is-', authorUrl, DEF_HIDE_COUNTS, authorName);
|
|
908
|
+
}
|
|
909
|
+
updateOneCommentContent(bcId, 'ss-', authorUrl, timestamp);
|
|
910
|
+
}
|
|
911
|
+
//
|
|
912
|
+
//////////////////////////////////////////////////
|
|
913
|
+
//
|
|
914
|
+
//25
|
|
915
|
+
//
|
|
916
|
+
globalThis.revertEXTags = function(text){
|
|
917
|
+
text = text.exrevtagcolon('fo', '<font\n', '</font>');
|
|
918
|
+
text = text.exrevtagcolon('ss', '<span style=', '</span>');
|
|
919
|
+
text = text.exrevtagequal('al', '<div align=', '</div>');
|
|
920
|
+
text = text.exrevtagequal('bg', '<span style=background-color:', '</span>');
|
|
921
|
+
text = text.exrevtagequal('fa', '<font face=', '</font>');
|
|
922
|
+
text = text.exrevtagequal('si', '<font zise=', '</font>');
|
|
923
|
+
text = text.exrevtagequal('co', '<font color=', '</font>');
|
|
924
|
+
text = text.sxrevtagequal('xut', '<b class="xut-', '"></b>');
|
|
925
|
+
text = text.sxrevtagequal('xga', '<b class="xga-', '"></b>');
|
|
926
|
+
return text;
|
|
927
|
+
}
|
|
928
|
+
globalThis.revertXTags = function(text){
|
|
929
|
+
const style = 'style="max-width: 100%; height: auto;"'
|
|
930
|
+
text = text.xrevtag('im', `<img ${style} src="`, '"/>');
|
|
931
|
+
text = text.xrevtag('img', `<img ${style} src="`, '"/>');
|
|
932
|
+
text = text.xrevtag('fim', `<img ${style} src="`, '"/>');
|
|
933
|
+
text = text.xrevtag('image', `<img ${style} src="`, '"/>');
|
|
934
|
+
text = text.xrevtag('ifr', `<iframe ${style} src="`, '"></iframe>');
|
|
935
|
+
text = text.xrevtag('ac', '<div align=center>', '</div>');
|
|
936
|
+
text = text.xrevtag('ar', '<div align=right>', '</div>');
|
|
937
|
+
text = text.xrevtag('xut', '<b class="xut-', '"></b>');
|
|
938
|
+
text = text.xrevtag('xga', '<b class="xga-', '"></b>');
|
|
939
|
+
return text;
|
|
940
|
+
}
|
|
941
|
+
globalThis.revertTags = function(text, longs=standardLongTags, shorts=standardShortTags){
|
|
942
|
+
longs.split(',').forEach(tag=>{text=text.revtagex(tag, tag)});
|
|
943
|
+
shorts.split(',').forEach(tag=>{text=text.revtag(tag, tag)});
|
|
944
|
+
return removeFontSize(revertXTags(revertEXTags(text)));
|
|
945
|
+
}
|
|
946
|
+
globalThis.escapeTags = function(text, longs=standardLongTags, shorts=standardShortTags){
|
|
947
|
+
longs.split(',').forEach(tag=>{text=text.longreptag(tag, tag)});
|
|
948
|
+
shorts.split(',').forEach(tag=>{text=text.shortreptag(tag, tag)});
|
|
949
|
+
return text;
|
|
950
|
+
}
|
|
951
|
+
//
|
|
952
|
+
//////////////////////////////////////////////////
|