Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135046

Change subject: Attempt to detect slow machines and show an edit notice
......................................................................

Attempt to detect slow machines and show an edit notice

Using an entirely arbitrary, pretty bad guess.

Bug: 50518
Change-Id: Ia84cb3dada7fa1294f0e50330db43cabb39751d0
---
M VisualEditor.php
M modules/ve-mw/i18n/en.json
M modules/ve-mw/i18n/qqq.json
M modules/ve-mw/init/ve.init.mw.Target.js
4 files changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/46/135046/1

diff --git a/VisualEditor.php b/VisualEditor.php
index 8a5b01e..2a77137 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -664,6 +664,7 @@
                        'visualeditor-editconflict',
                        'visualeditor-editnotices-tool',
                        'visualeditor-editnotices-tooltip',
+                       'visualeditor-editnotice-slowmachine',
                        'visualeditor-editsummary',
                        'visualeditor-editsummary-bytes-remaining',
                        'visualeditor-feedback-tool',
diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json
index 7e13678..28d08f4 100644
--- a/modules/ve-mw/i18n/en.json
+++ b/modules/ve-mw/i18n/en.json
@@ -157,6 +157,7 @@
     "visualeditor-editconflict": "Your changes could not be saved because of 
an edit conflict. Would {{GENDER:|you}} like to resolve the conflict manually?",
     "visualeditor-editnotices-tool": "$1 {{PLURAL:$1|notice|notices}}",
     "visualeditor-editnotices-tooltip": "Edit notices",
+    "visualeditor-editnotice-slowmachine": "Your computer seems to be quite 
slow. If this editor is not working well for you, consider opening the dropdown 
menu next to \"{{int:visualeditor-toolbar-cancel}}\" and selecting 
\"{{int:visualeditor-mweditmodesource-title}}\".",
     "visualeditor-editsummary": "Describe what you changed",
     "visualeditor-editsummary-bytes-remaining": "The number of bytes 
remaining",
     "visualeditor-formatdropdown-format-mw-heading1": "Page title",
diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json
index 8cef1ca..8caa5c8 100644
--- a/modules/ve-mw/i18n/qqq.json
+++ b/modules/ve-mw/i18n/qqq.json
@@ -162,6 +162,7 @@
        "visualeditor-editconflict": "Alert message when saving a page causes 
an edit conflict",
        "visualeditor-editnotices-tool": "Text of tool in the toolbar that 
shows edit notices (such as [[MediaWiki:Editnotice-0]] and 
[[MediaWiki:Editnotice-8/en]]) as a pop-up.\n\nParameters:\n* $1 - the number 
of notices",
        "visualeditor-editnotices-tooltip": "Text of tooltip for the tool in 
the toolbar that shows edit notices (i.e. “messages about the editing”), e.g. 
the “you are not currently logged in” notice",
+       "visualeditor-editnotice-slowmachine": "Text of the edit notice shown 
if VE detects that the user's machine seems quite slow.",
        "visualeditor-editsummary": "Label for the edit summary box",
        "visualeditor-editsummary-bytes-remaining": "Tooltip for the number of 
bytes remaining in the edit summary",
        "visualeditor-formatdropdown-format-mw-heading1": "Item in the 
MediaWiki formatting dropdown for a level 1 heading (page 
title).\n{{Related|Visualeditor-formatdropdown}}\n{{Identical|Page title}}",
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js 
b/modules/ve-mw/init/ve.init.mw.Target.js
index 102860a..cfbeae4 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -377,7 +377,7 @@
  * @fires loadError
  */
 ve.init.mw.Target.onLoad = function ( response ) {
-       var data = response ? response.visualeditor : null;
+       var data = response ? response.visualeditor : null, startTime;
 
        if ( !data && !response.error ) {
                ve.init.mw.Target.onLoadError.call(
@@ -394,7 +394,14 @@
                );
        } else {
                this.originalHtml = data.content;
+
+               startTime = +new Date();
                this.doc = ve.createDocumentFromHtml( this.originalHtml );
+               // Anything worse than 0.01 seconds per byte triggers an edit 
notice
+               // This value is very arbitary and was based on some extremely 
basic testing
+               if ( ( new Date() - startTime ) / data.content.length > 0.01 ) {
+                       data.notices.push( ve.msg( 
'visualeditor-editnotice-slowmachine' ) );
+               }
 
                // Parsoid outputs a protocol-relative <base> tag, so 
absolutize it
                this.constructor.static.fixBase( this.doc, document );

-- 
To view, visit https://gerrit.wikimedia.org/r/135046
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia84cb3dada7fa1294f0e50330db43cabb39751d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <kren...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to