Subversion Repositories oidplus

Rev

Rev 1408 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1408 Rev 1447
Line 162... Line 162...
162
                                                if (errorThrown == "abort") return;
162
                                                if (errorThrown == "abort") return;
163
                                                console.error("Tree search failed");
163
                                                console.error("Tree search failed");
164
                                                console.error(_L("Error: %1",errorThrown));
164
                                                console.error(_L("Error: %1",errorThrown));
165
                                        },
165
                                        },
166
                                        success:function(data) {
166
                                        success:function(data) {
167
                                                if ("error" in data) {
167
                                                if (typeof data === "object" && "error" in data) {
168
                                                        console.error("Tree search failed");
168
                                                        console.error("Tree search failed");
169
                                                        console.error(data);
169
                                                        console.error(data);
170
                                                } else if ((data instanceof Array) && (data.length > 0)) {
170
                                                } else if ((data instanceof Array) && (data.length > 0)) {
171
                                                        x_rec(data, 0);
171
                                                        x_rec(data, 0);
172
                                                } else {
172
                                                } else {
Line 217... Line 217...
217
                        alertError(_L("Failed to load content: %1",errorThrown));
217
                        alertError(_L("Failed to load content: %1",errorThrown));
218
                        console.error(_L("Error: %1",errorThrown));
218
                        console.error(_L("Error: %1",errorThrown));
219
                },
219
                },
220
                success:function(data) {
220
                success:function(data) {
221
                        // TODO: Use oidplus_ajax_success(), since this checks the existance of "error" in data, and checks if status>=0
221
                        // TODO: Use oidplus_ajax_success(), since this checks the existance of "error" in data, and checks if status>=0
222
                        if ("error" in data) {
222
                        if (typeof data === "object" && "error" in data) {
223
                                alertError(_L("Failed to load content: %1",data.error));
-
 
224
                                console.error(data.error);
223
                                console.error(data.error);
-
 
224
                                alertError(_L("Failed to load content: %1",data.error));
225
                        } else if (data.status >= 0) {
225
                        } else if (typeof data === "object" && "status" in data && data.status >= 0) {
226
                                if (!("id" in data)) data.id = id;
226
                                if (!("id" in data)) data.id = id;
227
 
227
 
228
                                var state = {
228
                                var state = {
229
                                        "node_id":data.id,
229
                                        "node_id":data.id,
230
                                        "titleHTML":(data.icon ? '<img src="'+data.icon+'" width="48" height="48" alt="'+data.title.htmlentities()+'"> ' : '') + data.title.htmlentities(),
230
                                        "titleHTML":(data.icon ? '<img src="'+data.icon+'" width="48" height="48" alt="'+data.title.htmlentities()+'"> ' : '') + data.title.htmlentities(),
Line 252... Line 252...
252
                                executeAllCallbacks(pageLoadedCallbacks.ajaxPageLoad);
252
                                executeAllCallbacks(pageLoadedCallbacks.ajaxPageLoad);
253
 
253
 
254
                                if (anchor != '') {
254
                                if (anchor != '') {
255
                                        jumpToAnchor(anchor);
255
                                        jumpToAnchor(anchor);
256
                                }
256
                                }
-
 
257
                        } else if (typeof data === "object" && "status" in data && data.status < 0) {
257
                        } else {
258
                                console.error(data);
258
                                alertError(_L("Failed to load content: %1",data.status));
259
                                alertError(_L("Failed to load content: %1",data.status));
-
 
260
                        } else {
259
                                console.error(data);
261
                                console.error(data);
-
 
262
                                alertError(_L("Failed to load content: %1",data));
260
                        }
263
                        }
261
                }
264
                }
262
        });
265
        });
263
 
266
 
264
        return true;
267
        return true;
Line 578... Line 581...
578
        alertError(_L("Error: %1", errorThrown));
581
        alertError(_L("Error: %1", errorThrown));
579
}
582
}
580
 
583
 
581
function oidplus_ajax_success(data, cb) {
584
function oidplus_ajax_success(data, cb) {
582
        if (typeof data === "object" && "error" in data) {
585
        if (typeof data === "object" && "error" in data) {
-
 
586
                console.error(data);
583
                alertError(_L("Error: %1", data.error));
587
                alertError(_L("Error: %1", data.error));
584
        } else if (typeof data === "object" && data.status >= 0) {
588
        } else if (typeof data === "object" && "status" in data && data.status >= 0) {
585
                cb(data);
589
                cb(data);
-
 
590
        } else if (typeof data === "object" && "status" in data && data.status < 0) {
-
 
591
                console.error(data);
-
 
592
                alertError(_L("Error: %1", data.status));
586
        } else {
593
        } else {
-
 
594
                console.error(data);
587
                alertError(_L("Error: %1", data));
595
                alertError(_L("Error: %1", data));
588
        }
596
        }
589
}
597
}