Yurik has uploaded a new change for review.
https://gerrit.wikimedia.org/r/161902
Change subject: Even simpler error handling for auto-refresh
......................................................................
Even simpler error handling for auto-refresh
Change-Id: I7a646eb16926b4aad249854bd7770ec1cd2a8d6c
---
M js/graph.editor.js
1 file changed, 18 insertions(+), 26 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Graph
refs/changes/02/161902/1
diff --git a/js/graph.editor.js b/js/graph.editor.js
index 0d941b6..ce3fa7c 100644
--- a/js/graph.editor.js
+++ b/js/graph.editor.js
@@ -1,32 +1,24 @@
-( function( $ ) {
+(function( $ ) {
var oldContent = '';
(function() {
- $('.mw-wiki-graph').each(function () {
- // This should not be a loop - there must be only one
value with this class
- var el = this,
- textbox = $('#wpTextbox1'),
- context = textbox &&
textbox.data('wikiEditor-context');
+ try {
+ $('.mw-wiki-graph').each(function () {
+ // This should not be a loop - there must be
only one value with this class
+ var el = this,
+ textbox = $('#wpTextbox1'),
+ context = textbox &&
textbox.data('wikiEditor-context');
- if (!context || !context.fn || !context.fn.getContents)
{
- return;
- }
- var content = context.fn.getContents();
- if (oldContent === content) {
- return;
- }
- oldContent = content;
- var spec = null;
- try {
- spec = $.parseJSON(content);
- } catch(err) {
- }
- if (spec === null) {
- return;
- }
- if (this.hasAttribute('spec'))
- this.removeAttribute('spec');
- vg.parse.spec(spec, function(chart) {
chart({el:el}).update(); });
- });
+ var content = context.fn.getContents();
+ if (oldContent === content) return;
+ oldContent = content;
+ var spec = $.parseJSON(content);
+ if (spec === null) return;
+ if (this.hasAttribute('spec'))
this.removeAttribute('spec');
+ vg.parse.spec(spec, function(chart) {
chart({el:el}).update(); });
+ });
+ } catch(err) {
+ // Ignore all errors
+ }
// FIXME: This should be done on data modification, not on timer
setTimeout(arguments.callee, 300);
})();
--
To view, visit https://gerrit.wikimedia.org/r/161902
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a646eb16926b4aad249854bd7770ec1cd2a8d6c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Graph
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits