MDL-69773 block_section_links: Add an option to display section name
[moodle.git] / badges / backpack.js
CommitLineData
27806552
YB
1/**
2 * Push badges to backpack.
7444ba74 3 * @deprecated since 3.7
27806552
YB
4 */
5function addtobackpack(event, args) {
2c910861
YB
6 var badgetable = Y.one('#issued-badge-table');
7 var errordiv = Y.one('#addtobackpack-error');
8 var errortext = M.util.get_string('error:backpackproblem', 'badges');
9 var errorhtml = '<div id="addtobackpack-error" class="box boxaligncenter notifyproblem">' + errortext + '</div>';
10
11 if (typeof OpenBadges !== 'undefined') {
12 OpenBadges.issue([args.assertion], function(errors, successes) { });
13 } else {
14 // Add error div if it doesn't exist yet.
15 if (!errordiv) {
16 var badgerror = Y.Node.create(errorhtml);
17 badgetable.insert(badgerror, 'before');
18 }
19 }
27806552
YB
20}
21
22/**
23 * Check if website is externally accessible from the backpack.
7444ba74 24 * @deprecated since 3.7
27806552
YB
25 */
26function check_site_access() {
27 var add = Y.one('#check_connection');
85d7399e 28
27806552 29 var callback = {
85d7399e
YB
30 method: "GET",
31 on: {
57e226b9
AN
32 success: function(id, o) {
33 var data = Y.JSON.parse(o.responseText);
34 if (data.code == 'http-unreachable') {
35 add.setHTML(data.response);
36 add.removeClass('hide');
37 }
38 M.util.js_complete('badge/backpack::check_site_access');
39 },
40 failure: function() {
41 M.util.js_complete('badge/backpack::check_site_access');
42 }
27806552 43 }
85d7399e 44 };
27806552 45
85d7399e 46 Y.use('io-base', function(Y) {
57e226b9 47 M.util.js_pending('badge/backpack::check_site_access');
85d7399e 48 Y.io('ajax.php', callback);
27806552
YB
49 });
50
51 return false;
f6ebcd34 52}