EBernhardson has uploaded a new change for review.

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

Change subject: Explicitly handle title to preview content against
......................................................................

Explicitly handle title to preview content against

Bug: T75409
Change-Id: Ibc2fa5d0de892f9fcabfe8b38aac5edc64149d39
---
M Resources.php
M handlebars/compiled/flow_block_topic.handlebars.php
M handlebars/compiled/flow_block_topic_lock.handlebars.php
M handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
M handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
M handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
M handlebars/compiled/flow_post.handlebars.php
M handlebars/flow_block_topicsummary_edit.handlebars
M handlebars/flow_edit_post.handlebars
M handlebars/flow_newtopic_form.handlebars
M handlebars/flow_reply_form.handlebars
M handlebars/flow_topic_titlebar_lock.handlebars
M includes/Formatter/RevisionFormatter.php
M modules/engine/components/board/base/flow-board-api-events.js
A modules/engine/misc/flow-baseconvert.js
17 files changed, 127 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/74/191474/1

diff --git a/Resources.php b/Resources.php
index 5c7ca59..1ab96a6 100644
--- a/Resources.php
+++ b/Resources.php
@@ -321,6 +321,8 @@
                        'engine/misc/flow-api.js',
                        // FlowEventLog
                        'engine/misc/flow-eventlog.js',
+                       // wfBaseConvert ported to js
+                       'engine/misc/flow-baseconvert.js',
                        // Component registry
                        'engine/components/flow-registry.js',
                        // FlowComponent must come before actual components
@@ -350,7 +352,6 @@
 
                        // Component: FlowBoardHistoryComponent
                        'engine/components/board/flow-boardhistory.js',
-
                        // This must be the last file loaded
                        'flow-initialize.js',
                ),
diff --git a/handlebars/compiled/flow_block_topic.handlebars.php 
b/handlebars/compiled/flow_block_topic.handlebars.php
index 97204b2..ea232f9 100644
--- a/handlebars/compiled/flow_block_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic.handlebars.php
@@ -185,6 +185,7 @@
                                name="topic_content"
                                required
                                data-flow-preview-template="flow_post"
+                               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                                data-flow-expandable="true"
                                class="mw-ui-input flow-click-interactive"
                                type="text"
diff --git a/handlebars/compiled/flow_block_topic_lock.handlebars.php 
b/handlebars/compiled/flow_block_topic_lock.handlebars.php
index 3d6a7ec..7005f2b 100644
--- a/handlebars/compiled/flow_block_topic_lock.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_lock.handlebars.php
@@ -50,6 +50,7 @@
                                  required
                                  data-flow-preview-node="moderateReason"
                                  
data-flow-preview-template="flow_topic_titlebar"
+                                         
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                        >'.((LCRun3::ifvar($cx, 
((isset($cx['sp_vars']['root']['submitted']['reason']) && 
is_array($cx['sp_vars']['root']['submitted'])) ? 
$cx['sp_vars']['root']['submitted']['reason'] : null))) ? 
''.htmlentities((string)((isset($cx['sp_vars']['root']['submitted']['reason']) 
&& is_array($cx['sp_vars']['root']['submitted'])) ? 
$cx['sp_vars']['root']['submitted']['reason'] : null), ENT_QUOTES, 'UTF-8').'' 
: '').'</textarea>
                        <div class="flow-form-actions flow-form-collapsible">
                                <button data-role="submit"
diff --git a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php 
b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
index 96aef45..72ef0e7 100644
--- a/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_moderate_post.handlebars.php
@@ -229,6 +229,7 @@
 '.LCRun3::hbch($cx, 'ifAnonymous', array(array(),array()), $in, false, 
function($cx, $in) {return ''.LCRun3::p($cx, 'flow_anon_warning', 
array(array($in),array())).'';}).'
        <textarea name="topic_content" class="mw-ui-input flow-form-collapsible"
                data-flow-preview-template="flow_post"
+               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                data-role="content">'.((LCRun3::ifvar($cx, 
((isset($cx['sp_vars']['root']['rootBlock']['submitted']['content']) && 
is_array($cx['sp_vars']['root']['rootBlock']['submitted'])) ? 
$cx['sp_vars']['root']['rootBlock']['submitted']['content'] : null))) ? 
''.htmlentities((string)((isset($cx['sp_vars']['root']['rootBlock']['submitted']['content'])
 && is_array($cx['sp_vars']['root']['rootBlock']['submitted'])) ? 
$cx['sp_vars']['root']['rootBlock']['submitted']['content'] : null), 
ENT_QUOTES, 'UTF-8').'' : 
''.htmlentities((string)((isset($in['content']['content']) && 
is_array($in['content'])) ? $in['content']['content'] : null), ENT_QUOTES, 
'UTF-8').'').'</textarea>
 
        <div class="flow-form-actions flow-form-collapsible">
@@ -251,6 +252,7 @@
                                name="topic_content"
                                required
                                data-flow-preview-template="flow_post"
+                               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                                data-flow-expandable="true"
                                class="mw-ui-input flow-click-interactive"
                                type="text"
diff --git a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php 
b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
index 49fab3f..a77c764 100644
--- a/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_moderate_topic.handlebars.php
@@ -229,6 +229,7 @@
 '.LCRun3::hbch($cx, 'ifAnonymous', array(array(),array()), $in, false, 
function($cx, $in) {return ''.LCRun3::p($cx, 'flow_anon_warning', 
array(array($in),array())).'';}).'
        <textarea name="topic_content" class="mw-ui-input flow-form-collapsible"
                data-flow-preview-template="flow_post"
+               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                data-role="content">'.((LCRun3::ifvar($cx, 
((isset($cx['sp_vars']['root']['rootBlock']['submitted']['content']) && 
is_array($cx['sp_vars']['root']['rootBlock']['submitted'])) ? 
$cx['sp_vars']['root']['rootBlock']['submitted']['content'] : null))) ? 
''.htmlentities((string)((isset($cx['sp_vars']['root']['rootBlock']['submitted']['content'])
 && is_array($cx['sp_vars']['root']['rootBlock']['submitted'])) ? 
$cx['sp_vars']['root']['rootBlock']['submitted']['content'] : null), 
ENT_QUOTES, 'UTF-8').'' : 
''.htmlentities((string)((isset($in['content']['content']) && 
is_array($in['content'])) ? $in['content']['content'] : null), ENT_QUOTES, 
'UTF-8').'').'</textarea>
 
        <div class="flow-form-actions flow-form-collapsible">
@@ -251,6 +252,7 @@
                                name="topic_content"
                                required
                                data-flow-preview-template="flow_post"
+                               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                                data-flow-expandable="true"
                                class="mw-ui-input flow-click-interactive"
                                type="text"
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php 
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index a9f2acf..abd500e 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -127,6 +127,7 @@
                />
                <textarea name="topiclist_content"
                        data-flow-preview-template="flow_topic"
+                       data-flow-preview-title-generator="newTopic"
                        class="mw-ui-input flow-form-collapsible 
mw-ui-input-large"
                        '.((LCRun3::ifvar($cx, ((isset($in['isOnFlowBoard']) && 
is_array($in)) ? $in['isOnFlowBoard'] : null))) ? 'style="display:none;"' : 
'').'
                        placeholder="'.LCRun3::ch($cx, 'l10n', 
array(array('flow-newtopic-content-placeholder',((isset($cx['sp_vars']['root']['title'])
 && is_array($cx['sp_vars']['root'])) ? $cx['sp_vars']['root']['title'] : 
null)),array()), 'encq').'"
@@ -271,6 +272,7 @@
                                name="topic_content"
                                required
                                data-flow-preview-template="flow_post"
+                               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                                data-flow-expandable="true"
                                class="mw-ui-input flow-click-interactive"
                                type="text"
diff --git a/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php 
b/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
index 6c018cd..46b9acb 100644
--- a/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist_newtopic.handlebars.php
@@ -64,6 +64,7 @@
                />
                <textarea name="topiclist_content"
                        data-flow-preview-template="flow_topic"
+                       data-flow-preview-title-generator="newTopic"
                        class="mw-ui-input flow-form-collapsible 
mw-ui-input-large"
                        '.((LCRun3::ifvar($cx, ((isset($in['isOnFlowBoard']) && 
is_array($in)) ? $in['isOnFlowBoard'] : null))) ? 'style="display:none;"' : 
'').'
                        placeholder="'.LCRun3::ch($cx, 'l10n', 
array(array('flow-newtopic-content-placeholder',((isset($cx['sp_vars']['root']['title'])
 && is_array($cx['sp_vars']['root'])) ? $cx['sp_vars']['root']['title'] : 
null)),array()), 'encq').'"
diff --git a/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php 
b/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
index 872ec1d..56ee963 100644
--- a/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
+++ b/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
@@ -57,6 +57,7 @@
                                  
name="'.htmlentities((string)((isset($in['type']) && is_array($in)) ? 
$in['type'] : null), ENT_QUOTES, 'UTF-8').'_summary"
                                  data-flow-preview-node="summary"
                                  
data-flow-preview-template="flow_topic_titlebar_summary"
+                                 
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                                  type="text"
                                          
data-role="content">'.((LCRun3::ifvar($cx, ((isset($in['submitted']['summary']) 
&& is_array($in['submitted'])) ? $in['submitted']['summary'] : null))) ? 
''.htmlentities((string)((isset($in['submitted']['summary']) && 
is_array($in['submitted'])) ? $in['submitted']['summary'] : null), ENT_QUOTES, 
'UTF-8').'' : ''.((LCRun3::ifvar($cx, ((isset($in['revision']['revisionId']) && 
is_array($in['revision'])) ? $in['revision']['revisionId'] : null))) ? 
''.htmlentities((string)((isset($in['revision']['content']['content']) && 
is_array($in['revision']['content'])) ? $in['revision']['content']['content'] : 
null), ENT_QUOTES, 'UTF-8').'' : '').'').'</textarea>
                        <div class="flow-form-actions flow-form-collapsible">
diff --git a/handlebars/compiled/flow_post.handlebars.php 
b/handlebars/compiled/flow_post.handlebars.php
index e31011a..db1940c 100644
--- a/handlebars/compiled/flow_post.handlebars.php
+++ b/handlebars/compiled/flow_post.handlebars.php
@@ -208,6 +208,7 @@
 '.LCRun3::hbch($cx, 'ifAnonymous', array(array(),array()), $in, false, 
function($cx, $in) {return ''.LCRun3::p($cx, 'flow_anon_warning', 
array(array($in),array())).'';}).'
        <textarea name="topic_content" class="mw-ui-input flow-form-collapsible"
                data-flow-preview-template="flow_post"
+               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                data-role="content">'.((LCRun3::ifvar($cx, 
((isset($cx['sp_vars']['root']['rootBlock']['submitted']['content']) && 
is_array($cx['sp_vars']['root']['rootBlock']['submitted'])) ? 
$cx['sp_vars']['root']['rootBlock']['submitted']['content'] : null))) ? 
''.htmlentities((string)((isset($cx['sp_vars']['root']['rootBlock']['submitted']['content'])
 && is_array($cx['sp_vars']['root']['rootBlock']['submitted'])) ? 
$cx['sp_vars']['root']['rootBlock']['submitted']['content'] : null), 
ENT_QUOTES, 'UTF-8').'' : 
''.htmlentities((string)((isset($in['content']['content']) && 
is_array($in['content'])) ? $in['content']['content'] : null), ENT_QUOTES, 
'UTF-8').'').'</textarea>
 
        <div class="flow-form-actions flow-form-collapsible">
@@ -230,6 +231,7 @@
                                name="topic_content"
                                required
                                data-flow-preview-template="flow_post"
+                               
data-flow-preview-title="'.htmlentities((string)((isset($in['articleTitle']) && 
is_array($in)) ? $in['articleTitle'] : null), ENT_QUOTES, 'UTF-8').'"
                                data-flow-expandable="true"
                                class="mw-ui-input flow-click-interactive"
                                type="text"
diff --git a/handlebars/flow_block_topicsummary_edit.handlebars 
b/handlebars/flow_block_topicsummary_edit.handlebars
index 4f9e38c..485ea7e 100644
--- a/handlebars/flow_block_topicsummary_edit.handlebars
+++ b/handlebars/flow_block_topicsummary_edit.handlebars
@@ -13,6 +13,7 @@
                                  name="{{type}}_summary"
                                  data-flow-preview-node="summary"
                                  
data-flow-preview-template="flow_topic_titlebar_summary"
+                                 data-flow-preview-title="{{articleTitle}}"
                                  type="text"
                                          data-role="content">
                                {{~#if submitted.summary~}}
diff --git a/handlebars/flow_edit_post.handlebars 
b/handlebars/flow_edit_post.handlebars
index ce597ad..dc15fdb 100644
--- a/handlebars/flow_edit_post.handlebars
+++ b/handlebars/flow_edit_post.handlebars
@@ -11,6 +11,7 @@
 
        <textarea name="topic_content" class="mw-ui-input flow-form-collapsible"
                data-flow-preview-template="flow_post"
+               data-flow-preview-title="{{articleTitle}}"
                data-role="content">
                {{~#if @root.rootBlock.submitted.content~}}
                        {{[email protected]~}}
diff --git a/handlebars/flow_newtopic_form.handlebars 
b/handlebars/flow_newtopic_form.handlebars
index e43c731..dd9b491 100644
--- a/handlebars/flow_newtopic_form.handlebars
+++ b/handlebars/flow_newtopic_form.handlebars
@@ -24,6 +24,7 @@
                />
                <textarea name="topiclist_content"
                        data-flow-preview-template="flow_topic"
+                       data-flow-preview-title-generator="newTopic"
                        class="mw-ui-input flow-form-collapsible 
mw-ui-input-large"
                        {{#if isOnFlowBoard}}style="display:none;"{{/if}}
                        placeholder="{{l10n "flow-newtopic-content-placeholder" 
@root.title}}"
diff --git a/handlebars/flow_reply_form.handlebars 
b/handlebars/flow_reply_form.handlebars
index ce58032..dcbd191 100644
--- a/handlebars/flow_reply_form.handlebars
+++ b/handlebars/flow_reply_form.handlebars
@@ -17,6 +17,7 @@
                                name="topic_content"
                                required
                                data-flow-preview-template="flow_post"
+                               data-flow-preview-title="{{articleTitle}}"
                                data-flow-expandable="true"
                                class="mw-ui-input flow-click-interactive"
                                type="text"
diff --git a/handlebars/flow_topic_titlebar_lock.handlebars 
b/handlebars/flow_topic_titlebar_lock.handlebars
index c62a7e1..09c77df 100644
--- a/handlebars/flow_topic_titlebar_lock.handlebars
+++ b/handlebars/flow_topic_titlebar_lock.handlebars
@@ -15,6 +15,7 @@
                                  required
                                  data-flow-preview-node="moderateReason"
                                  
data-flow-preview-template="flow_topic_titlebar"
+                                         
data-flow-preview-title="{{articleTitle}}"
                        >
                                {{~#if @root.submitted.reason~}}
                                        {{[email protected]~}}
diff --git a/includes/Formatter/RevisionFormatter.php 
b/includes/Formatter/RevisionFormatter.php
index 8ca5be1..5d41757 100644
--- a/includes/Formatter/RevisionFormatter.php
+++ b/includes/Formatter/RevisionFormatter.php
@@ -183,6 +183,7 @@
                $ts = $row->revision->getRevisionId()->getTimestampObj();
                $res = array(
                        'workflowId' => 
$row->workflow->getId()->getAlphadecimal(),
+                       'articleTitle' => 
$row->workflow->getArticleTitle()->getPrefixedText(),
                        'revisionId' => 
$row->revision->getRevisionId()->getAlphadecimal(),
                        'timestamp' => $ts->getTimestamp( TS_MW ),
                        'changeType' => $row->revision->getChangeType(),
diff --git a/modules/engine/components/board/base/flow-board-api-events.js 
b/modules/engine/components/board/base/flow-board-api-events.js
index 6e94be2..39e69e3 100644
--- a/modules/engine/components/board/base/flow-board-api-events.js
+++ b/modules/engine/components/board/base/flow-board-api-events.js
@@ -164,10 +164,31 @@
        FlowBoardComponentApiEventsMixin.UI.events.apiPreHandlers.preview = 
function ( event ) {
                var callback,
                        $this = $( this ),
+                       $target = $this.findWithParent( $this.data( 
'flow-api-target' ) ),
+                       previewTitleGenerator = $target.data( 
'flow-preview-title-generator' ),
+                       previewTitle = $target.data( 'flow-preview-title' ),
                        flowBoard = mw.flow.getPrototypeMethod( 'board', 
'getInstanceByElement' )( $this ),
-                       schemaName = $( this ).data( 'flow-eventlog-schema' ),
-                       funnelId = $( this ).data( 'flow-eventlog-funnel-id' ),
-                       logAction = $( this ).data( 'flow-return-to-edit' ) ? 
'keep-editing' : 'preview';
+                       schemaName = $this.data( 'flow-eventlog-schema' ),
+                       funnelId = $this.data( 'flow-eventlog-funnel-id' ),
+                       logAction = $this.data( 'flow-return-to-edit' ) ? 
'keep-editing' : 'preview',
+                       generators = {
+                               newTopic: function() {
+                                       // Convert current timestamp to base-2
+                                       var namespace = mw.config.get( 
'wgFormattedNamespaces' )[2600],
+                                               timestamp = 
mw.flow.baseConvert( Date.now(), 10, 2 );
+                                       // Pad base-2 out to 88 bits (@todo why 
84?)
+                                       timestamp += Array( 84 - 
timestamp.length ).join( '0' );
+                                       // convert base-2 to base-36
+                                       return namespace + ':' + 
mw.flow.baseConvert( timestamp, 2, 36 );
+                               },
+                               wgPageName: function() {
+                                       return mw.config.get( 'wgPageName' );
+                               }
+                       };
+
+               if ( !previewTitleGenerator || !generators.hasOwnProperty( 
previewTitleGenerator ) ) {
+                       previewTitleGenerator = 'wgPageName';
+               }
 
                flowBoard.logEvent( schemaName, { action: logAction, funnelId: 
funnelId } );
 
@@ -192,10 +213,15 @@
                                'action':  'flow-parsoid-utils',
                                'from':    'wikitext',
                                'to':      'html',
-                               'content': content,
-                               'title':   mw.config.get( 'wgPageName' )
+                               'content': content
                        };
 
+                       if ( previewTitle ) {
+                               queryMap.title = previewTitle;
+                       } else {
+                               queryMap.title = 
generators[previewTitleGenerator]();
+                       }
+
                        return queryMap;
                };
 
diff --git a/modules/engine/misc/flow-baseconvert.js 
b/modules/engine/misc/flow-baseconvert.js
new file mode 100644
index 0000000..055f8a0
--- /dev/null
+++ b/modules/engine/misc/flow-baseconvert.js
@@ -0,0 +1,76 @@
+/*!
+ *
+ */
+
+window.mw = window.mw || {}; // mw-less testing
+
+( function ( mw, $ ) {
+       mw.flow = mw.flow || {}; // create mw.flow globally
+
+       // Direct translation of wfBaseConvert.  Can't be done with parseInt and
+       // Integer.toString because javascript uses doubles for math, giving 
only
+       // 53 bits of precision.
+       mw.flow.baseConvert = function ( input, sourceBase, destBase ) {
+               var regex = new RegExp( "^[" + 
'0123456789abcdefghijklmnopqrstuvwxyz'.substr( 0, sourceBase ) + "]+$" ),
+                       baseChars = {
+                               '10': 'a', '11': 'b', '12': 'c', '13': 'd', 
'14': 'e', '15': 'f',
+                               '16': 'g', '17': 'h', '18': 'i', '19': 'j', 
'20': 'k', '21': 'l',
+                               '22': 'm', '23': 'n', '24': 'o', '25': 'p', 
'26': 'q', '27': 'r',
+                               '28': 's', '29': 't', '30': 'u', '31': 'v', 
'32': 'w', '33': 'x',
+                               '34': 'y', '35': 'z',
+
+                               '0':  0, '1':  1, '2':  2, '3':  3, '4':  4, 
'5': 5,
+                               '6':  6, '7':  7, '8':  8, '9':  9, 'a': 10, 
'b': 11,
+                               'c': 12, 'd': 13, 'e': 14, 'f': 15, 'g': 16, 
'h': 17,
+                               'i': 18, 'j': 19, 'k': 20, 'l': 21, 'm': 22, 
'n': 23,
+                               'o': 24, 'p': 25, 'q': 26, 'r': 27, 's': 28, 
't': 29,
+                               'u': 30, 'v': 31, 'w': 32, 'x': 33, 'y': 34, 
'z': 35
+                       },
+                       inDigits = [],
+                       result = [],
+                       i, work, workDigits;
+
+               input = String( input );
+               if ( sourceBase < 2 ||
+                       sourceBase > 36 ||
+                       destBase < 2 ||
+                       destBase > 36 ||
+                       sourceBase !== parseInt( sourceBase, 10 ) ||
+                       destBase !== parseInt( destBase, 10 ) ||
+                       !regex.test( input )
+               ) {
+                       return false;
+               }
+
+               for ( i in input ) {
+                       inDigits.push( baseChars[input[i]] );
+               }
+
+               // Iterate over the input, modulo-ing out an output digit
+               // at a time until input is gone.
+               while( inDigits.length ) {
+                       work = 0;
+                       workDigits = [];
+
+                       // Long division...
+                       for ( i in inDigits ) {
+                               work *= sourceBase;
+                               work += inDigits[i];
+
+                               if ( workDigits.length || work >= destBase ) {
+                                       workDigits.push( parseInt( work / 
destBase, 10 ) );
+                               }
+                               work %= destBase;
+                       }
+
+                       // All that division leaves us with a remainder,
+                       // which is conveniently our next output digit
+                       result.push( baseChars[work] );
+
+                       // And we continue
+                       inDigits = workDigits;
+               }
+
+               return result.reverse().join("");
+       };
+}( mw, jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc2fa5d0de892f9fcabfe8b38aac5edc64149d39
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to