Migrate old externs 3/x

This commit is contained in:
2026-06-14 07:28:00 +08:00
parent 77a1e5c22e
commit 7cdcd3b681
23 changed files with 251 additions and 187 deletions
+1 -1
View File
@@ -82,6 +82,7 @@
var _content = "";
//// Classes & obj
var __statePusher;
var _visualizer = null;
var timestamp = new Date();
@@ -441,7 +442,6 @@
this.invoke = function (_class)
{
if ( _class instanceof Draft ) _ae_draft = _class;
if ( _class instanceof Visualizer )
{
_visualizer = _class;
@@ -131,7 +131,7 @@
};
// }}}
/** @param {Astro.Blog.AstroEdit.Visualizer} */
/** @param {Astro.Blog.AstroEdit.Visualizer} visualizer */
var SmartInput = function( visualizer )
{
this.Present = false;
@@ -9,6 +9,8 @@
var EventKey = __import( "System.utils.EventKey" );
/** @type {Components.Mouse.ContextMenu} */
var ContextMenu = __import( "Components.Mouse.ContextMenu" );
/** @type {typeof Components.MessageBox} */
var MessageBox = __import( "Components.MessageBox" );
/** @type {typeof Dandelion} */
var Dand = __import( "Dandelion" );
/** @type {Dandelion.IDOMObject} */
@@ -145,10 +145,10 @@
);
// ad handlers to handles size change event
IDOMElement(s).addEventListener("Change", selectionChanged.bind({size: "small"}));
IDOMElement(m).addEventListener("Change", selectionChanged.bind({size: "medium"}));
IDOMElement(l).addEventListener("Change", selectionChanged.bind({size: "large"}));
IDOMElement(o).addEventListener("Change", selectionChanged.bind({size: "original"}));
IDOMElement(s).element.addEventListener("Change", selectionChanged.bind({size: "small"}));
IDOMElement(m).element.addEventListener("Change", selectionChanged.bind({size: "medium"}));
IDOMElement(l).element.addEventListener("Change", selectionChanged.bind({size: "large"}));
IDOMElement(o).element.addEventListener("Change", selectionChanged.bind({size: "original"}));
var hasValue = _stage.getDAttribute( "size" );
if( hasValue )
@@ -50,7 +50,7 @@
, "OK", "Cancel", visualizer.bind({url:input_url, albumArt:input_albumArt, lrc:input_lrc, stage: this._stage})).show();
}
, visualizer = function (submitted)
, visualizer = function (submitted, override)
{
var src, albumArt , lrc, stage = this && this.stage;
@@ -64,11 +64,10 @@
article = e_document;
// Allow Html snippet
}
else if ( e_document instanceof CeDocument )
else
{
article = e_document;
return;
}
else return;
////// Variables
var contentDiv = Dand.wrap()
@@ -388,7 +387,7 @@
}
// Append module"s control
temp = Dand.wrapne( "span", mod_name, new IKey( "data-name", mod_name ) );
var temp = Dand.wrapne( "span", mod_name, new IKey( "data-name", mod_name ) );
snippetControls.appendChild( temp );
snippetControls.appendChild( Dand.textNode( "\t" ) );
@@ -431,7 +430,7 @@
return true;
};
temp = IDOMElement( contentDiv );
var temp = IDOMElement( contentDiv );
temp.addEventListener( "Input", ensureGoodness );
temp.addEventListener( "KeyUp", ensureGoodness );
temp.addEventListener( "Click", ensureGoodness );
@@ -463,7 +462,7 @@
if ( lastOffset != raw.length )
{
// innerText does not work in firefox:(
temp = Dand.wrape( raw.substr( lastOffset, raw.length - lastOffset ) );
var temp = Dand.wrape( raw.substr( lastOffset, raw.length - lastOffset ) );
// innerHTML will escape html entities, now replace linebreaks to br
temp.innerHTML = temp.innerHTML.replace( /[\r\n]/g, "<br>" );
IDOMElement( contentDiv ).loot( temp );
+2 -2
View File
@@ -27,7 +27,7 @@
// get responding chinese char from number
var cCountDay = function (num)
{
str = num.toString();
var str = num.toString();
if( num != 0 && num % 10 == 0 )
{
return ( num == 10 ? "" : String.fromCharCode( cChar[ str[0] ] ) )
@@ -98,7 +98,7 @@
var str = date.getFullYear().toString();
var datestmp = "";
for(i in str)
for(var i = 0, l = str.length; i < l; i ++)
{
datestmp += String.fromCharCode( cChar[ str[i] ] );
}
+7 -6
View File
@@ -61,15 +61,16 @@
{
cCallback = callback;
document.onmousemove = function (e)
document.onmousemove = function(e)
{
if( trigger() )
e = e || window.event;
if (trigger())
{
Global.IE && (event || (event = e));
stage.style.left = ( e.pageX - 10 ) + "px";
stage.style.top = ( e.pageY - 10 ) + "px";
stage.style.left = (e.pageX - 10) + "px";
stage.style.top = (e.pageY - 10) + "px";
}
}
};
};
var setTextToCopy = function( _text )
+5 -5
View File
@@ -419,8 +419,8 @@
var bodyOnContext = function (event)
{
var i, j;
for (i in bodyClickPairs)
var j;
for (var i = 0, l = bodyClickPairs.length; i < l; i ++)
{
if ( Dand.id( ( j = bodyClickPairs[i] )._id ) )
{
@@ -444,8 +444,8 @@
var cleanUpActionList = function ()
{
var i, j;
for ( i in bodyClickPairs )
var j;
for (var i = 0, l = bodyClickPairs.length; i < l; i ++)
{
if ( !Dand.id( ( j = bodyClickPairs[i] )._id ) )
{
@@ -479,7 +479,7 @@
var tryGetAction = function (id)
{
for (i in bodyClickPairs)
for (var i = 0, l = bodyClickPairs.length; i < l; i ++)
{
if (bodyClickPairs[i]._id == id)
{
+1 -1
View File
@@ -215,7 +215,7 @@
debug.Info( "Realize Indentation: " + ind );
l = ind[ IN_END ];
var l = ind[ IN_END ];
for( var i = ind[ IN_START ]; i < l; i ++ )
{
this.__rec( this.__cursor.feeder.content[ i ] );
@@ -56,7 +56,7 @@
}
else
{
throw new Error( "Missing token impl: \"" + tok + "\"" );
throw new Error( "Missing token impl: \"" + j + "\"" );
}
break;
@@ -151,7 +151,7 @@
feeder.content = content;
this.__msg = Mesg( "REPLACE", numSubs, "<TODO>" );
this.__msg = Mesg( "REPLACED", numSubs, "<TODO>" );
// Record this step for UNDO / REDO
this.__rec();
+1 -1
View File
@@ -29,7 +29,7 @@
var n = cur.getLine().lineNum;
var p = 0;
for( i = 0; p != -1 && i < n; i ++ )
for( var i = 0; p != -1 && i < n; i ++ )
{
p = f.content.indexOf( "\n", p + 1 );
}
+1 -1
View File
@@ -709,7 +709,7 @@
if( 0 < n )
{
p = f.content.indexOf( "\n" );
for( i = 1; p != -1 && i < n; i ++ )
for( var i = 1; p != -1 && i < n; i ++ )
{
p = f.content.indexOf( "\n", p + 1 );
}
@@ -147,6 +147,7 @@
var RelativeTime = function( given )
{
var result;
var diffSecs = Math.round( 0.001 * ( new Date().getTime() - given.getTime() ) );
if( Year < diffSecs )
-2
View File
@@ -62,14 +62,12 @@
var comm = _self.__command;
var pos = _self.__curPos;
var cLen = comm.length;
var faced = true;
for( var i = 0; i < cLen; i ++ )
{
var v = comm[i];
if( __blink && i == pos )
{
face = true;
v = Cursor.face + v.substr( 1 );
}
+1 -2
View File
@@ -11,7 +11,6 @@ var VIMRE_VERSION = "1.0.2";
, "REGISTERS": "--- Registers ---"
, "WRITE": "\"%1\" %2L, %3C written"
, "WAIT_FOR_INPUT": "Press ENTER or type command to continue"
, "SEARCH_HIT_BOTTOM": "Seach hit BOTTOM, contining at TOP"
, "TOP": "Top"
, "BOTTOM": "Bot"
, "ALL": "All"
@@ -30,7 +29,7 @@ var VIMRE_VERSION = "1.0.2";
, "SEARCH_HIT_BOTTOM": "search hit BOTTOM, continuing at TOP"
, "SEARCH_HIT_TOP": "search hit TOP, continuing at BOTTOM"
, "REPLACE": "%1 substitution(s) on %2 line(s)"
, "REPLACED": "%1 substitution(s) on %2 line(s)"
, "VA_REC_START": "Recording Session ..."
, "VA_REC_REPLAY": "Replaying Session ..."
+144 -88
View File
@@ -26,9 +26,11 @@ var __const = __static_method;
/* End Shorthand Functions }}}*/
/*{{{ BotanEvent & EventDispatcher */
/** @constructor */
/** @this {BotanEvent} */
var BotanEvent = function( name, data )
/** @type {typeof BotanEvent} */
var BotanEvent;
BotanEvent = function( name, data )
{
var __propagating = false;
var __propagated = false;
@@ -66,69 +68,155 @@ var BotanEvent = function( name, data )
}.bind( this );
};
/** type {typeof EventDispatcher} */
var EventDispatcher;
EventDispatcher = function() {
/**
* @constructor
* @implements {EventTarget}
*/
var EventDispatcher = function() {
var events = {};
var _self = this;
var getStack = function( name )
var getStack = function(name)
{
if( !events[ name ] ) events[ name ] = [];
return events[ name ];
if (!events[name]) events[name] = [];
return events[name];
};
var _dispatch = function()
{
this.evt.propagate();
for( var i in this.stack )
for (var i in this.stack)
{
if( this.evt.propagating )
if (this.evt.propagating)
{
this.stack[ i ]( this.evt );
this.stack[i](this.evt);
}
}
this.evt.stopPropagating();
};
this.addEventListener = function( type, handler )
{
var stack = getStack( type );
stack[ stack.length ] = handler;
};
this.removeEventListener = function( type, handler )
{
var stack = getStack( type );
var i = stack.indexOf( handler );
if( i < 0 ) return;
delete stack[ i ];
};
/** @type {Function}
* @param {BotanEvent} evt
/**
* @param {string} type
* @param {function(!BotanEvent): void} handler
* @return {void}
*/
this.dispatchEvent = function( _evt )
this.addEventListener = function(type, handler)
{
var _stack = getStack( _evt.type );
if( _evt.setTarget ) _evt.setTarget( _self );
// Dispatch the event asynchronously
setTimeout( _dispatch.bind({ evt: _evt, stack: _stack }), 0 );
var stack = getStack(type);
stack[stack.length] = handler;
};
/**
* @param {string} type
* @param {function(!BotanEvent): void} handler
* @return {void}
*/
this.removeEventListener = function(type, handler)
{
var stack = getStack(type);
var i = stack.indexOf(handler);
if (i < 0) return;
delete stack[i];
};
/**
* @param {!BotanEvent} _evt
* @return {boolean}
*/
this.dispatchEvent = function(_evt)
{
var _stack = getStack(_evt.type);
if (_evt.setTarget) _evt.setTarget(_self);
setTimeout(_dispatch.bind({ evt: _evt, stack: _stack }), 0);
return true;
};
};
/* End BotanEvent & EventDispatcher }}}*/
/** @type {Array}
* @extends {EventDispatcher}
/**
* @constructor
* @extends {EventDispatcher}
* @param {!Object<string, *>} target
* @param {string} name
*/
var NamespaceObj = function() {
EventDispatcher.call( this );
var NamespaceObj = function(target, name)
{
EventDispatcher.call(this);
/** @private {!Object<string, *>} */
this.t_ = target;
/** @private {string} */
this.n_ = name;
};
NamespaceObj.prototype = new Array();
NamespaceObj.prototype = Object.create(EventDispatcher.prototype);
NamespaceObj.prototype.constructor = NamespaceObj;
/**
* @param {string} type
* @param {string} name
* @param {*} obj
* @return {void}
*/
NamespaceObj.prototype.exportSymbol = function(type, name, obj)
{
if (this.t_[name]) return;
this.t_[name] = [type, obj];
var evt = new BotanEvent("NS_EXPORT", {
"name": this.n_ + "." + name,
"type": type
});
BotanJS.dispatchEvent(evt);
};
/**
* @param {string} target
* @return {*}
*/
NamespaceObj.prototype.invoke = function(target)
{
if (!this.t_[target])
{
throw new Error(
"[" + this.n_ + "] "
+ "Invoke failed: " + target + " does not exists"
);
}
return this.t_[target][1];
};
/**
* @param {string} code
* @param {function(...?): *} func
* @return {void}
*/
NamespaceObj.prototype.trigger = function(code, func)
{
this.t_.__TRIGGERS[code] = func;
};
/**
* @param {string} message
* @param {string=} subclass
* @return {void}
*/
NamespaceObj.prototype.throwError = function(message, subclass)
{
subclass = subclass ? ("." + subclass) : "";
throw new Error(
"[" + this.n_ + subclass + "] " + message
);
};
var packages = {};
var _global = {};
@@ -193,65 +281,33 @@ BotanJS = BotanJS || (function()
/* End Root level bug-free handlers }}}*/
/*{{{ Namespace declarator */
__namespace = __namespace || function( ns )
__namespace = __namespace || function(ns)
{
if( _NSs[ ns ] ) return _NSs[ ns ];
if (_NSs[ns]) return _NSs[ns];
var p = ns.split(".");
var l = p.length;
var target = packages;
for( var i = 0; i < l; i ++ ) {
target[ p[i] ] = target[ p[i] ] || {};
target = target[ p[i] ];
for (var i = 0; i < l; i++)
{
target[p[i]] = target[p[i]] || {};
target = target[p[i]];
}
target.__TRIGGERS = [];
/** @type {!Object<string, function(...?): *>} */
target.__TRIGGERS = {};
var nsObj = new NamespaceObj;
nsObj[ NS_EXPORT ] = function( type, name, obj )
{
if( this.t[ name ] ) return;
this.t[ name ] = [ type, obj ];
var nsObj = new NamespaceObj(target, ns);
/** @type {BotanEvent} */
var evt = new BotanEvent( "NS_EXPORT", {
"name": this.n + "." + name
, "type": type
});
BotanJS.dispatchEvent(new BotanEvent("NS_INIT", ns));
BotanJS.dispatchEvent( evt );
nsObj[NS_EXPORT] = nsObj.exportSymbol.bind(nsObj);
nsObj[NS_INVOKE] = nsObj.invoke.bind(nsObj);
nsObj[NS_TRIGGER] = nsObj.trigger.bind(nsObj);
nsObj[NS_THROW] = nsObj.throwError.bind(nsObj);
}.bind({ t: target, n: ns });
nsObj[ NS_INVOKE ] = function( target )
{
if( !this.t[ target ] )
{
throw new Error(
"[" + this.n + "] "
+ "Invoke failed: " + target + " does not exists"
);
}
return this.t[ target ][1];
}.bind({ t: target, n: ns });
nsObj[ NS_TRIGGER ] = function( code, func )
{
this.__TRIGGERS[ code ] = func;
}.bind( target );
nsObj[ NS_THROW ] = function( message, subclass )
{
subclass = subclass ? ( "." + subclass ) : "";
throw new Error(
"[" + this.n + subclass + "] " + message
);
}.bind({ n: ns });
BotanJS.dispatchEvent( new BotanEvent( "NS_INIT", ns ) );
return ( _NSs[ ns ] = nsObj );
return (_NSs[ns] = nsObj);
};
/* End Namespace declarator }}}*/
@@ -261,7 +317,7 @@ __import = __import || function( ns, noCache )
var nss = ns.replace( ".*", "" );
if( _NSs[ nss ] )
{
_NSs[ nss ].dispatchEvent( new BotanEvent( "NS_IMPORT", target ) );
_NSs[ nss ].dispatchEvent( new BotanEvent( "NS_IMPORT", nss ) );
}
// Read The Cache First
+7 -4
View File
@@ -1,13 +1,16 @@
/** @constructor */
var BotanEvent = function (){};
/** @constructor
* @param {string} name
* @param {*} data
**/
var BotanEvent = function (name, data){};
/** @type {*} */
BotanEvent.data;
/** @type {Function} */
BotanEvent.propagate;
BotanEvent.propagate = function() {};
/** @type {Function} */
BotanEvent.stopPropagating;
BotanEvent.stopPropagating = function() {};
/** @type {Boolean} */
BotanEvent.propagating;
+4 -3
View File
@@ -1,4 +1,5 @@
/** @constructor
* @implements {EventTarget}
**/
/**
* @constructor
* @implements {EventTarget}
*/
var EventDispatcher = function() {};
+2 -2
View File
@@ -2,7 +2,7 @@
System.Debug = function (){}
/** @type {Function} */
System.Debug.Info;
System.Debug.prototype.Info = function(){};
/** @type {Function} */
System.Debug.Error;
System.Debug.prototype.Error = function(){};
+26 -22
View File
@@ -1,23 +1,27 @@
/** @type {Object} */
_AstConf_.SiteFile = {};
/** @type {string} */
_AstConf_.SiteFile.f_host;
/**
* @typedef {{
* f_host: string,
* path: !_AstConf_.SiteFile.Path,
* files: !Array<*>
* }}
*/
_AstConf_.SiteFile;
/** @type {Object} */
_AstConf_.SiteFile.path;
/** @type {string} */
_AstConf_.SiteFile.path.download;
/** @type {string} */
_AstConf_.SiteFile.path.info;
/** @type {Object} */
_AstConf_.SiteFile.path.image;
/** @type {string} */
_AstConf_.SiteFile.path.image.small;
/** @type {string} */
_AstConf_.SiteFile.path.image.medium;
/** @type {string} */
_AstConf_.SiteFile.path.image.large;
/** @type {string} */
_AstConf_.SiteFile.path.image.original;
/** @type {Array} */
_AstConf_.SiteFile.files;
/**
* @typedef {{
* download: string,
* info: string,
* image: !_AstConf_.SiteFile.Path.Image
* }}
*/
_AstConf_.SiteFile.Path;
/**
* @typedef {{
* small: string,
* medium: string,
* large: string,
* original: string
* }}
*/
_AstConf_.SiteFile.Path.Image;