1 | {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} |
---|
2 | {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'} |
---|
3 | {combine_css path="admin/themes/default/uploadify.jGrowl.css"} |
---|
4 | |
---|
5 | {footer_script require='jquery.ajaxmanager,jquery.jgrowl'} |
---|
6 | var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; |
---|
7 | var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; |
---|
8 | var successHead = '{'Success'|@translate|@escape:'javascript'}'; |
---|
9 | |
---|
10 | {literal} |
---|
11 | var queue_lenght = 0; |
---|
12 | |
---|
13 | var queuedManager = jQuery.manageAjax.create('queued', { |
---|
14 | queue: true, |
---|
15 | maxRequests: 1 |
---|
16 | }); |
---|
17 | |
---|
18 | function add_cat_to_parse_queue(url, path) { |
---|
19 | queuedManager.add({ |
---|
20 | type: 'POST', |
---|
21 | dataType: 'json', |
---|
22 | url: 'ws.php?format=json', |
---|
23 | data: { method: 'pwg.pBase.parse', url: url, path: path }, |
---|
24 | success: function(data) { |
---|
25 | if (data['stat'] == 'ok') { |
---|
26 | cats = data['result']['categories']; |
---|
27 | for (i in cats) { |
---|
28 | queue_lenght++; |
---|
29 | add_cat_to_parse_queue(cats[i]['url'], cats[i]['path']); |
---|
30 | } |
---|
31 | $('#preview').html($('#preview').html()+data['result']['path']+"\n"); |
---|
32 | } else { |
---|
33 | jQuery.jGrowl(data['message'], { theme: 'error', header: errorHead, sticky: true }); |
---|
34 | jQuery('.loading').toggle(); |
---|
35 | } |
---|
36 | |
---|
37 | queue_lenght--; |
---|
38 | if (data['stat'] == 'ok' && queue_lenght == 0) { |
---|
39 | window.location.reload(); |
---|
40 | } |
---|
41 | }, |
---|
42 | error: function () { |
---|
43 | jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true }); |
---|
44 | jQuery('.loading').toggle(); |
---|
45 | } |
---|
46 | }); |
---|
47 | } |
---|
48 | {/literal} |
---|
49 | |
---|
50 | jQuery('#begin_analyse').click(function() {ldelim} |
---|
51 | login = $('#pbase_login').val(); |
---|
52 | |
---|
53 | if (login != '') {ldelim} |
---|
54 | queue_lenght++; |
---|
55 | add_cat_to_parse_queue('http://www.pbase.com/'+ login +'/root', '/root'); |
---|
56 | jQuery('.loading').toggle(); |
---|
57 | } |
---|
58 | return false; |
---|
59 | }); |
---|
60 | {/footer_script} |
---|
61 | |
---|
62 | |
---|
63 | <form action="{$PBASE_ADMIN}-import" method="post"> |
---|
64 | <p><label>{'PBase login'|@translate} <input type="text" id="pbase_login"></label></p> |
---|
65 | <p class="loading"><input type="submit" id="begin_analyse" value="{'Begin analyse'|@translate}"></p> |
---|
66 | <p class="loading" style="display:none;"><img src="{$PBASE_PATH}admin/template/loader-{$themeconf.name}.gif"></p> |
---|
67 | </form> |
---|
68 | |
---|
69 | <pre id="preview" style="margin-left:10px;"> |
---|
70 | </pre> |
---|