2 * Push badges to backpack.
4 function addtobackpack(event, args) {
5 var badgetable = Y.one('#issued-badge-table');
6 var errordiv = Y.one('#addtobackpack-error');
7 var errortext = M.util.get_string('error:backpackproblem', 'badges');
8 var errorhtml = '<div id="addtobackpack-error" class="box boxaligncenter notifyproblem">' + errortext + '</div>';
10 if (typeof OpenBadges !== 'undefined') {
11 OpenBadges.issue([args.assertion], function(errors, successes) { });
13 // Add error div if it doesn't exist yet.
15 var badgerror = Y.Node.create(errorhtml);
16 badgetable.insert(badgerror, 'before');
22 * Check if website is externally accessible from the backpack.
24 function check_site_access() {
25 var add = Y.one('#check_connection');
30 success: function(id, o) {
31 var data = Y.JSON.parse(o.responseText);
32 if (data.code == 'http-unreachable') {
33 add.setHTML(data.response);
34 add.removeClass('hide');
36 M.util.js_complete('badge/backpack::check_site_access');
39 M.util.js_complete('badge/backpack::check_site_access');
44 Y.use('io-base', function(Y) {
45 M.util.js_pending('badge/backpack::check_site_access');
46 Y.io('ajax.php', callback);