forked from leftypol/leftypol
Post saving/cache and Google Analytics integration
This commit is contained in:
parent
10bd465ea3
commit
08bbd3f912
6 changed files with 131 additions and 8 deletions
|
@ -1,3 +1,12 @@
|
|||
function get_cookie(cookie_name)
|
||||
{
|
||||
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
|
||||
if(results)
|
||||
return (unescape(results[2]));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
function highlightReply(id)
|
||||
{
|
||||
var divs = document.getElementsByTagName('div');
|
||||
|
@ -20,7 +29,7 @@ function focusId(id)
|
|||
|
||||
function generatePassword() {
|
||||
pass = '';
|
||||
chars = '{config[genpassword_chars]}';
|
||||
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+';
|
||||
for(i=0;i<8;i++) {
|
||||
rnd = Math.floor(Math.random() * chars.length);
|
||||
pass += chars.substring(rnd,rnd + 1);
|
||||
|
@ -33,6 +42,9 @@ function dopost(form) {
|
|||
if(form.email.value != 'sage')
|
||||
localStorage.email = form.email.value;
|
||||
|
||||
saved[document.location] = form.body.value;
|
||||
sessionStorage.body = JSON.stringify(saved);
|
||||
|
||||
return form.body.value != "" || (typeof form.thread != "undefined" && form.file.value != "");
|
||||
}
|
||||
function citeReply(id) {
|
||||
|
@ -44,6 +56,7 @@ var styles = [
|
|||
{stylesheets:['{stylesheets[name]}', '{stylesheets[uri]}']{!%last?,
|
||||
}}
|
||||
];
|
||||
var saved = {};
|
||||
|
||||
function changeStyle(x) {
|
||||
localStorage.stylesheet = styles[x][1];
|
||||
|
@ -92,6 +105,28 @@ function init()
|
|||
if(localStorage.email)
|
||||
document.getElementsByTagName('form')[0].email.value = localStorage.email;
|
||||
|
||||
|
||||
if(sessionStorage.body) {
|
||||
saved = JSON.parse(sessionStorage.body);
|
||||
if(get_cookie('{config[cookies][js]}')) {
|
||||
// Remove successful posts
|
||||
successful = JSON.parse(get_cookie('{config[cookies][js]}'));
|
||||
for (var url in successful) {
|
||||
saved[url] = null;
|
||||
}
|
||||
sessionStorage.body = JSON.stringify(saved);
|
||||
|
||||
document.cookie = '{config[cookies][js]}={};expires=0;path=/;';
|
||||
}
|
||||
if(saved[document.location]) {
|
||||
document.getElementsByTagName('form')[0].body.value = saved[document.location];
|
||||
}
|
||||
}
|
||||
|
||||
if(localStorage.body) {
|
||||
document.getElementsByTagName('form')[0].body.value = localStorage.body;
|
||||
localStorage.body = '';
|
||||
}
|
||||
link = document.getElementsByTagName('a');
|
||||
for ( i in link ) {
|
||||
if(typeof link[i] == "object" && link[i].childNodes[0].src) {
|
||||
|
@ -120,4 +155,7 @@ function init()
|
|||
}
|
||||
}
|
||||
|
||||
window.onload = init;
|
||||
window.onload = init;
|
||||
{config[google_analytics]?
|
||||
|
||||
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{config[google_analytics]}']);_gaq.push(['_setDomainName', 'none']);_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();}
|
Loading…
Add table
Add a link
Reference in a new issue