Migrate old externs 6/x

This commit is contained in:
2026-06-15 08:21:08 +08:00
parent a912d45b9a
commit 3bc6957677
13 changed files with 110 additions and 83 deletions
+1 -1
View File
@@ -19,7 +19,7 @@
var IDOMElement = __import( "Dandelion.IDOMElement" );
/** @type {Astro.Blog.Config} */
var Config = __import( "Astro.Blog.Config" );
/** @type {Astro.Blog.Components.Bubble} */
/** @type {typeof Astro.Blog.Components.Bubble} */
var Bubble = __import( "Astro.Blog.Components.Bubble" );
var opostData = __import( "System.Net.postData" );
+2 -2
View File
@@ -59,9 +59,9 @@
this.setColor = this.setColor.bind(this);
};
var wrapc = function( aClass, elem )
var wrapc = function( aClass )
{
return Dand.wrapc( "comp " + aClass, elem );
return Dand.wrapc( "comp " + aClass );
};
Bubble.prototype.init = function ()
+10 -9
View File
@@ -23,7 +23,7 @@
var Bootstrap = __import( "Astro.Bootstrap" );
/** @type {Astro.Blog.Config} */
var Conf = __import( "Astro.Blog.Config" );
/** @type {Astro.Blog.Components.Bubble} */
/** @type {typeof Astro.Blog.Components.Bubble} */
var Bubble = __import( "Astro.Blog.Components.Bubble" );
var postData = __import( "System.Net.postData" );
@@ -433,7 +433,8 @@
closeInputPanel( null );
// Remove false_fields
for(var i in fields) {
for(var i = 0, l = fields.length; i < l; i ++)
{
i = Dand.id("false_" + fields[i]);
i.parentNode.removeChild(i);
}
@@ -478,7 +479,7 @@
{
var name, field, falsefield, f;
for(var i in fields)
for(var i = 0, l = fields.length; i < l; i ++)
{
name = fields[i];
field = name + "_field";
@@ -577,19 +578,19 @@
IDOMElement( contentField ).addEventListener( "Input", commentInput );
var l = c_body.childNodes, c_id;
var cchildren = c_body.childNodes, c_id;
for( var i in l )
for( var i = 0, l = cchildren.length; i < l; i ++ )
{
if( l[i].nodeType == 1
&& ( c_id = IDOMElement( l[i] ).getDAttribute("value") )
if( cchildren[i].nodeType == 1
&& ( c_id = IDOMElement( cchildren[i] ).getDAttribute("value") )
)
{
var reply_button = Dand.id("c_reply_" + c_id);
reply_button.onclick = doReply.bind(reply_button);
l[i].onmouseover = showReplyButton.bind(reply_button);
l[i].onmouseout = hideReplyButton.bind(reply_button);
cchildren[i].onmouseover = showReplyButton.bind(reply_button);
cchildren[i].onmouseout = hideReplyButton.bind(reply_button);
}
}
@@ -20,7 +20,13 @@
/** @type {_AstConf_.SiteFile} */
var config;
var SiteFile = function ( id, hash, nObj )
/**
* @constructor
* @param {string} id
* @param {string} hash
* @param {_AstJson_.SiteFile=} nObj
*/
var SiteFile = function( id, hash, nObj )
{
if( !config ) throw new Error( "config is not defined" );
// TODO: Make a trigger for downloading from server
+18 -11
View File
@@ -21,11 +21,11 @@
var debug = __import( "System.Debug" );
/** @type {Astro.Bootstrap} */
var Bootstrap = __import( "Astro.Bootstrap" );
/** @type {Astro.Mechanism.CharacterCloud} */
/** @type {typeof Astro.Mechanism.CharacterCloud} */
var CharacterCloud = __import( "Astro.Mechanism.CharacterCloud" );
/** @type {Astro.Mechanism.Parallax} */
var Parallax = __import( "Astro.Mechanism.Parallax" );
/** @type {Astro.Blog.Components.Bubble} */
/** @type {typeof Astro.Blog.Components.Bubble} */
var Bubble = __import( "Astro.Blog.Components.Bubble" );
var postData = __import( "System.Net.postData" );
@@ -39,6 +39,11 @@
var getData = __import( "System.Net.getData" );
var mobile = __import( "System.Global.MOBILE" );
/** @const {number} */
var ELEMENT_NODE = Node.ELEMENT_NODE;
/** @const {number} */
var COMMENT_NODE = Node.COMMENT_NODE;
var header;
// menu and horizon
@@ -60,7 +65,7 @@
var displayProcessTime = function()
{
var ms = document.lastChild;
if( ms.nodeType == document.COMMENT_NODE && ms.textContent && ms.textContent.match( /^\d+$/ ) )
if( ms.nodeType == COMMENT_NODE && ms.textContent && ms.textContent.match( /^\d+$/ ) )
{
ms = ( Number( ms.textContent ) * 1e-6 ).toFixed( 2 ) + "ms";
var copysign = Dand.glass( "copysign" );
@@ -76,15 +81,15 @@
{
Dand.id( "archive-save" )
.setAttribute(
"href", "https://archive.today/?run=1&url=" + encodeURIComponent( document.location )
"href", "https://archive.today/?run=1&url=" + encodeURIComponent( window.location.href )
);
Dand.id( "archive-view" )
.setAttribute(
"href", "https://archive.today/" + document.location.href
"href", "https://archive.today/" + window.location.href
);
Dand.id( "archive-list" )
.setAttribute(
"href", "https://archive.today/" + encodeURIComponent( document.location.hostname )
"href", "https://archive.today/" + encodeURIComponent( window.location.hostname )
);
};
@@ -135,7 +140,7 @@
Cycle.next( function()
{
PrepareForm();
expandContact( e );
expandContact();
wrapper.style.marginTop = .5 * ( 400 - wrapper.clientHeight ) + "px";
} );
}
@@ -270,8 +275,8 @@
return true;
};
page_control.last( document.ELEMENT_NODE, appendp );
page_control.first( document.ELEMENT_NODE, appendp );
page_control.last( ELEMENT_NODE, appendp );
page_control.first( ELEMENT_NODE, appendp );
}
};
@@ -294,7 +299,9 @@
horizon.style.backgroundColor = "dimgray";
for( var i in topButtons ) topButtons[i].removeAttribute( "data-active" );
for( var i = 0, l= topButtons.length; i < l; i ++ )
topButtons[i].removeAttribute( "data-active" );
contact.setAttribute( new DataKey( "active" ) );
c_expand = true;
@@ -321,7 +328,7 @@
// Apply saved color to horizon
horizon.style.backgroundColor = collapse_panel.style.backgroundColor;
for( var i in topButtons )
for( var i = 0, l= topButtons.length; i < l; i ++ )
{
if( topButtons[i].getDAttribute( "master" ) )
{
+13 -11
View File
@@ -2,8 +2,8 @@
var ns = __namespace( "Astro.utils.Date" );
//// Static utilities
// Chinese char for 0-9
var cChar = [ "12295", "19968", "20108", "19977", "22235", "20116", "20845", "19971", "20843", "20061", "21313" ];
// han char for 0-9
var cChar = [ 12295, 19968, 20108, 19977, 22235, 20116, 20845, 19971, 20843, 20061, 21313 ];
// Capital month
var CAP_MONTHS = [ false, false, false, true, false, true, false, false, true, false, true, false ];
var MONTH_ABBR = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
@@ -24,28 +24,30 @@
var DAY_ABBR = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
var DAY = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
// get responding chinese char from number
// get corresponding han char from number
var cCountDay = function (num)
{
var str = num.toString();
var d0 = Number( str[0] );
var d1 = Number( str[1] );
if( num != 0 && num % 10 == 0 )
{
return ( num == 10 ? "" : String.fromCharCode( cChar[ str[0] ] ) )
return ( num == 10 ? "" : String.fromCharCode( cChar[d0] ) )
+ String.fromCharCode( cChar[10] );
}
else if( num < 10 )
{
return String.fromCharCode( cChar[ str[0] ] );
return String.fromCharCode( cChar[d0] );
}
else if( num < 20 )
{
return String.fromCharCode( cChar[10] )
+ String.fromCharCode( cChar[ str[1] ] );
+ String.fromCharCode( cChar[d1] );
}
return String.fromCharCode( cChar[ str[0] ] )
return String.fromCharCode( cChar[d0] )
+ String.fromCharCode( cChar[10] )
+ String.fromCharCode( cChar[ str[1] ] );
+ String.fromCharCode( cChar[d1] );
};
@@ -103,12 +105,12 @@
datestmp += String.fromCharCode( cChar[ str[i] ] );
}
datestmp += String.fromCharCode("24180");
datestmp += String.fromCharCode(24180); // 年
datestmp += cCountDay(date.getMonth() + 1)
+ String.fromCharCode("26376")
+ String.fromCharCode(26376) // 月
+ cCountDay(date.getDate())
+ String.fromCharCode("26085");
+ String.fromCharCode(26085); // 日
return datestmp;
};