- if (error.length > 0 && options.error) {
- options.error(error.text());
- } else {
- $('.theme-text-list', doc.firstChild).each(function(){
- var themes = $(this).html().split(',');
- for (i in themes) {
- themes[i] = $.trim(themes[i]);
- if (!(themes[i] in canonThemes))
- themes[i] = '<span x-pass-thru="true" class="noncanon">' + themes[i] + "</span>"
- }
- $(this).html(themes.join(', '));
- });
- options.success(doc.firstChild);
- }
- }, function() { options.error && options.error('Nie udało się załadować motywów'); });
+ error = $('parsererror', doc);
+ }
+
+ if (error.length > 0 && options.error) {
+ source = $('sourcetext', doc);
+ source_text = source.text();
+ source.text('');
+ options.error(error.text(), source_text);
+ } else {
+ options.success(doc.firstChild);
+
+ withThemes(function(canonThemes) {
+ if (canonThemes != null) {
+ $('.theme-text-list').addClass('canon').each(function(){
+ var themes = $(this).html().split(',');
+ for (i in themes) {
+ themes[i] = $.trim(themes[i]);
+ if (canonThemes.indexOf(themes[i]) == -1)
+ themes[i] = '<span x-pass-thru="true" class="noncanon">' + themes[i] + "</span>"
+ }
+ $(this).html(themes.join(', '));
+ });
+ }
+ });
+ }