-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwidget_picture.tpl
35 lines (35 loc) · 1.42 KB
/
widget_picture.tpl
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
<!-- creates svg and png pictures (using create_png.php) and redirects to it when it is ready -->
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js"></script>
<script>
$(document).ready(function () {
postdata = {'url':CryptoJS.MD5(window.location.href).toString(), 'svg':$('#chart').html().replace(/<strong>/g,'').replace(/<\/strong>/g,'').replace(/<br>/g,''), 'nocache': getParameterByName('nocache')};
$.post('create_png.php',postdata);
nothing = 0;
get_picture();
});
var i = 0;
function get_picture() {
$.ajax('cache/{_FORMAT}/' + CryptoJS.MD5(window.location.href).toString() + '.{_FORMAT}', {
statusCode: {
200: function (response) {
location.href = 'cache/{_FORMAT}/' + CryptoJS.MD5(window.location.href).toString() + '.{_FORMAT}';
},
404: function(response) {
i++;
if (i < 60) {
setTimeout(get_picture, 1000)
} else {
alert('Something wrong, giving up...');
}
}
}
});
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
</script>