Skip to content
Browse files

Various cleanup [1/n]

- Move script loading functionality out of mscorlib into loader.js/script.web assembly
- Move alert and related methods to Window class in Script.Web
- Move setTimeout and related methods to Script class in mscorlib
- Remove IE-specific XMLHttpRequest/XML parsing wrappers from mscorlib.js
  • Loading branch information...
1 parent 5769f30 commit 54bae4a42b4d67a6fadb46665c6a1b761d712a83 @nikhilk committed Aug 26, 2012
View
13 docs/History.txt
@@ -1,7 +1,18 @@
Changelog
===============================================================================
-v0.7.5.0 [in progress]
+v0.7.6
+ - Removed script loading APIs from Script class in mscorlib
+ (moved them to Loader class in Script.Web)
+ - Removed script startup functionality from mscorlib.js ... all script
+ loading is now in ssloader.js (and included into the Runtime nuget
+ package)
+ - Removed Script.Alert/Confirm/Prompt from mscorlib and moved them to
+ Window in Script.Web
+ - Moved SetTimeout, SetInterval and ClearTimeout, ClearInterval from
+ Window object to Script object in mscorlib.
+
+v0.7.5.0
- DOM metadata update (readyState property on Document,
plugins on Navigator)
- jQuery API update (on/off methods)
View
1 src/Core/CoreLib/CoreLib.csproj
@@ -91,7 +91,6 @@
<Compile Include="Globalization\CultureInfo.cs" />
<Compile Include="Globalization\DateFormatInfo.cs" />
<Compile Include="Globalization\NumberFormatInfo.cs" />
- <Compile Include="ScriptInfo.cs" />
<Compile Include="Serialization\JsonStringifyCallback.cs" />
<Compile Include="Serialization\JsonParseCallback.cs" />
<Compile Include="Serialization\Json.cs" />
View
122 src/Core/CoreLib/Script.cs
@@ -17,37 +17,6 @@ namespace System {
public static class Script {
/// <summary>
- /// Displays a message box containing the specified message text.
- /// </summary>
- /// <param name="message">The text of the message.</param>
- public static void Alert(string message) {
- }
-
- /// <summary>
- /// Displays a message box containing the specified value converted
- /// into a string.
- /// </summary>
- /// <param name="b">The boolean to display.</param>
- public static void Alert(bool b) {
- }
-
- /// <summary>
- /// Displays a message box containing the specified value converted
- /// into a string.
- /// </summary>
- /// <param name="d">The date to display.</param>
- public static void Alert(Date d) {
- }
-
- /// <summary>
- /// Displays a message box containing the specified value converted
- /// into a string.
- /// </summary>
- /// <param name="n">The number to display.</param>
- public static void Alert(Number n) {
- }
-
- /// <summary>
/// Converts an object into a boolean.
/// </summary>
/// <param name="o">The object to convert.</param>
@@ -56,11 +25,18 @@ public static class Script {
return false;
}
+ public static void ClearInterval(int intervalID) {
+ }
+
+ public static void ClearTimeout(int timeoutID) {
+ }
+
/// <summary>
/// Prompts the user with a yes/no question.
/// </summary>
/// <param name="message">The text of the question.</param>
/// <returns>true if the user chooses yes; false otherwise.</returns>
+ [Obsolete("Use Window.Confirm instead.", true)]
public static bool Confirm(string message) {
return false;
}
@@ -133,80 +109,44 @@ public static class Script {
return null;
}
- /// <summary>
- /// Loads the specified scripts.
- /// </summary>
- /// <param name="scriptNames">The names of scripts that are required and must be loaded.</param>
- [ScriptAlias("ss.loadScripts")]
- public static void LoadScripts(string[] scriptNames) {
+ public static int SetInterval(string code, int milliseconds) {
+ return 0;
}
- /// <summary>
- /// Loads the specified scripts and invokes the specified callback once they have been
- /// loaded.
- /// </summary>
- /// <param name="scriptNames">The names of scripts that are required and must be loaded.</param>
- /// <param name="callback">A callback to be invoked once the scripts have been loaded.</param>
- [ScriptAlias("ss.loadScripts")]
- public static void LoadScripts(string[] scriptNames, Action callback) {
+ public static int SetInterval(Action callback, int milliseconds) {
+ return 0;
}
- /// <summary>
- /// Loads the specified scripts and invokes the specified callback once they have been
- /// loaded.
- /// </summary>
- /// <param name="scriptNames">The names of scripts that are required and must be loaded.</param>
- /// <param name="callback">A callback to be invoked once the scripts have been loaded.</param>
- /// <param name="context">The object to be passed in into the callback.</param>
- /// <typeparam name="TContext">The type of the context object.</typeparam>
- [ScriptAlias("ss.loadScripts")]
- public static void LoadScripts<TContext>(string[] scriptNames, Action<TContext> callback, TContext context) {
+ public static int SetInterval<T>(Action<T> callback, int milliseconds, T arg) {
+ return 0;
}
- /// <summary>
- /// Registers the specified callback to be invoked when the DOM is ready,
- /// and before any script loading has begun.
- /// </summary>
- /// <param name="callback">The callback to invoke.</param>
- [ScriptAlias("ss.init")]
- public static void OnInit(Action callback) {
+ public static int SetInterval<T1, T2>(Action<T1, T2> callback, int milliseconds, T1 arg1, T2 arg2) {
+ return 0;
}
- /// <summary>
- /// Registers a callback to be invoked once any necessary scripts
- /// have been loaded.
- /// </summary>
- /// <param name="callback">The callback to be invoked.</param>
- [ScriptAlias("ss.ready")]
- public static void OnReady(Action callback) {
+ public static int SetInterval(Delegate d, int milliseconds, params object[] args) {
+ return 0;
}
- /// <summary>
- /// Prompts the user to enter a value.
- /// </summary>
- /// <param name="message">The text of the prompt.</param>
- /// <returns>The value entered by the user.</returns>
- public static string Prompt(string message) {
- return null;
+ public static int SetTimeout(string code, int milliseconds) {
+ return 0;
}
- /// <summary>
- /// Prompts the user to enter a value, along with providing a default
- /// value.
- /// </summary>
- /// <param name="message">The text of the prompt.</param>
- /// <param name="defaultValue">The default value for the prompt.</param>
- /// <returns>The value entered by the user.</returns>
- public static string Prompt(string message, string defaultValue) {
- return null;
+ public static int SetTimeout(Action callback, int milliseconds) {
+ return 0;
}
- /// <summary>
- /// Registers information about a script.
- /// </summary>
- /// <param name="scriptInfo">The information about a script.</param>
- [ScriptAlias("ss.registerScript")]
- public static void RegisterScript(ScriptInfo scriptInfo) {
+ public static int SetTimeout<T>(Action<T> callback, int milliseconds, T arg) {
+ return 0;
+ }
+
+ public static int SetTimeout<T1, T2>(Action<T1, T2> callback, int milliseconds, T1 arg1, T2 arg2) {
+ return 0;
+ }
+
+ public static int SetTimeout(Delegate d, int milliseconds, params object[] args) {
+ return 0;
}
/// <summary>
View
2 src/Core/CoreScript/loader.js
@@ -473,7 +473,7 @@
});
}
- window.ss = {
+ window.loader = {
load: _startup,
loadScripts: loadScripts,
checkScripts: checkScripts,
View
84 src/Core/CoreScript/mscorlib.js
@@ -3,8 +3,8 @@
//!
(function () {
- var globals = {
- version: '0.7.4.0',
+ window.ss = {
+ version: '0.7.6.0',
isUndefined: function (o) {
return (o === undefined);
@@ -22,41 +22,6 @@
return (o !== null) && (o !== undefined);
}
};
-
- var started = false;
- var startCallbacks = [];
-
- function onStartup(cb) {
- startCallbacks ? startCallbacks.push(cb) : setTimeout(cb, 0);
- }
- function startup() {
- if (startCallbacks) {
- var callbacks = startCallbacks;
- startCallbacks = null;
- for (var i = 0, l = callbacks.length; i < l; i++) {
- callbacks[i]();
- }
- }
- }
- if (document.addEventListener) {
- document.readyState == 'complete' ? startup() : document.addEventListener('DOMContentLoaded', startup, false);
- }
- else if (window.attachEvent) {
- window.attachEvent('onload', function () {
- startup();
- });
- }
-
- var ss = window.ss;
- if (!ss) {
- window.ss = ss = {
- init: onStartup,
- ready: onStartup
- };
- }
- for (var n in globals) {
- ss[n] = globals[n];
- }
})();
#include "Extensions\Object.js"
@@ -95,51 +60,6 @@
#include "BCL\EventArgs.js"
-///////////////////////////////////////////////////////////////////////////////
-// XMLHttpRequest and XML parsing helpers
-
-if (!window.XMLHttpRequest) {
- window.XMLHttpRequest = function() {
- var progIDs = [ 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' ];
-
- for (var i = 0; i < progIDs.length; i++) {
- try {
- var xmlHttp = new ActiveXObject(progIDs[i]);
- return xmlHttp;
- }
- catch (ex) {
- }
- }
-
- return null;
- }
-}
-
-ss.parseXml = function(markup) {
- try {
- if (DOMParser) {
- var domParser = new DOMParser();
- return domParser.parseFromString(markup, 'text/xml');
- }
- else {
- var progIDs = [ 'Msxml2.DOMDocument.3.0', 'Msxml2.DOMDocument' ];
-
- for (var i = 0; i < progIDs.length; i++) {
- var xmlDOM = new ActiveXObject(progIDs[i]);
- xmlDOM.async = false;
- xmlDOM.loadXML(markup);
- xmlDOM.setProperty('SelectionLanguage', 'XPath');
-
- return xmlDOM;
- }
- }
- }
- catch (ex) {
- }
-
- return null;
-}
-
#include "BCL\CancelEventArgs.js"
#include "BCL\Tuple.js"
View
99 src/Libraries/Web/Html/Window.cs
@@ -246,18 +246,66 @@ public sealed class Window {
public static void AddEventListener(string eventName, ElementEventListener listener, bool useCapture) {
}
- public static void AttachEvent(string eventName, ElementEventHandler handler) {
+ /// <summary>
+ /// Displays a message box containing the specified message text.
+ /// </summary>
+ /// <param name="message">The text of the message.</param>
+ [ScriptAlias("alert")]
+ public static void Alert(string message) {
+ }
+
+ /// <summary>
+ /// Displays a message box containing the specified value converted
+ /// into a string.
+ /// </summary>
+ /// <param name="b">The boolean to display.</param>
+ [ScriptAlias("alert")]
+ public static void Alert(bool b) {
}
- public static void ClearInterval(int intervalID) {
+ /// <summary>
+ /// Displays a message box containing the specified value converted
+ /// into a string.
+ /// </summary>
+ /// <param name="d">The date to display.</param>
+ [ScriptAlias("alert")]
+ public static void Alert(Date d) {
}
- public static void ClearTimeout(int timeoutID) {
+ /// <summary>
+ /// Displays a message box containing the specified value converted
+ /// into a string.
+ /// </summary>
+ /// <param name="n">The number to display.</param>
+ [ScriptAlias("alert")]
+ public static void Alert(Number n) {
+ }
+
+ /// <summary>
+ /// Displays a message box containing the specified value converted
+ /// into a string.
+ /// </summary>
+ /// <param name="o">The object to display.</param>
+ [ScriptAlias("alert")]
+ public static void Alert(object o) {
+ }
+
+ public static void AttachEvent(string eventName, ElementEventHandler handler) {
}
public static void Close() {
}
+ /// <summary>
+ /// Prompts the user with a yes/no question.
+ /// </summary>
+ /// <param name="message">The text of the question.</param>
+ /// <returns>true if the user chooses yes; false otherwise.</returns>
+ [ScriptAlias("confirm")]
+ public static bool Confirm(string message) {
+ return false;
+ }
+
public static void DetachEvent(string eventName, ElementEventHandler handler) {
}
@@ -288,6 +336,27 @@ public sealed class Window {
}
/// <summary>
+ /// Prompts the user to enter a value.
+ /// </summary>
+ /// <param name="message">The text of the prompt.</param>
+ /// <returns>The value entered by the user.</returns>
+ [ScriptAlias("prompt")]
+ public static string Prompt(string message) {
+ return null;
+ }
+
+ /// <summary>
+ /// Prompts the user to enter a value.
+ /// </summary>
+ /// <param name="message">The text of the prompt.</param>
+ /// <param name="defaultValue">The default value for the prompt.</param>
+ /// <returns>The value entered by the user.</returns>
+ [ScriptAlias("prompt")]
+ public static string Prompt(string message, string defaultValue) {
+ return null;
+ }
+
+ /// <summary>
/// Removes a listener for the specified event.
/// </summary>
/// <param name="eventName">The name of the event such as 'load'.</param>
@@ -313,30 +382,6 @@ public sealed class Window {
public static void ScrollTo(int x, int y) {
}
- public static int SetInterval(string code, int milliseconds) {
- return 0;
- }
-
- public static int SetInterval(Action callback, int milliseconds) {
- return 0;
- }
-
- public static int SetInterval(Delegate d, int milliseconds) {
- return 0;
- }
-
- public static int SetTimeout(string code, int milliseconds) {
- return 0;
- }
-
- public static int SetTimeout(Action callback, int milliseconds) {
- return 0;
- }
-
- public static int SetTimeout(Delegate d, int milliseconds) {
- return 0;
- }
-
public static SqlDatabase OpenDatabase(string name, string version) {
return null;
}
View
67 src/Libraries/Web/Loader.cs
@@ -0,0 +1,67 @@
+// Loader.cs
+// Script#/Libraries/Web
+// This source code is subject to terms and conditions of the Apache License, Version 2.0.
+//
+
+using System.Runtime.CompilerServices;
+
+namespace System {
+
+ [IgnoreNamespace]
+ [Imported]
+ [ScriptName("loader")]
+ public static class Loader {
+
+ /// <summary>
+ /// Loads the specified scripts.
+ /// </summary>
+ /// <param name="scriptNames">The names of scripts that are required and must be loaded.</param>
+ public static void LoadScripts(string[] scriptNames) {
+ }
+
+ /// <summary>
+ /// Loads the specified scripts and invokes the specified callback once they have been
+ /// loaded.
+ /// </summary>
+ /// <param name="scriptNames">The names of scripts that are required and must be loaded.</param>
+ /// <param name="callback">A callback to be invoked once the scripts have been loaded.</param>
+ public static void LoadScripts(string[] scriptNames, Action callback) {
+ }
+
+ /// <summary>
+ /// Loads the specified scripts and invokes the specified callback once they have been
+ /// loaded.
+ /// </summary>
+ /// <param name="scriptNames">The names of scripts that are required and must be loaded.</param>
+ /// <param name="callback">A callback to be invoked once the scripts have been loaded.</param>
+ /// <param name="context">The object to be passed in into the callback.</param>
+ /// <typeparam name="TContext">The type of the context object.</typeparam>
+ public static void LoadScripts<TContext>(string[] scriptNames, Action<TContext> callback, TContext context) {
+ }
+
+ /// <summary>
+ /// Registers the specified callback to be invoked when the DOM is ready,
+ /// and before any script loading has begun.
+ /// </summary>
+ /// <param name="callback">The callback to invoke.</param>
+ [ScriptName("init")]
+ public static void OnInit(Action callback) {
+ }
+
+ /// <summary>
+ /// Registers a callback to be invoked once any necessary scripts
+ /// have been loaded.
+ /// </summary>
+ /// <param name="callback">The callback to be invoked.</param>
+ [ScriptName("ready")]
+ public static void OnReady(Action callback) {
+ }
+
+ /// <summary>
+ /// Registers information about a script.
+ /// </summary>
+ /// <param name="scriptInfo">The information about a script.</param>
+ public static void RegisterScript(ScriptInfo scriptInfo) {
+ }
+ }
+}
View
2 src/Core/CoreLib/ScriptInfo.cs → src/Libraries/Web/ScriptInfo.cs
@@ -1,5 +1,5 @@
// ScriptInfo.cs
-// Script#/Libraries/CoreLib
+// Script#/Libraries/Web
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//
View
2 src/Libraries/Web/Web.csproj
@@ -144,6 +144,8 @@
<Compile Include="..\..\ScriptSharp.cs">
<Link>Properties\ScriptSharp.cs</Link>
</Compile>
+ <Compile Include="Loader.cs" />
+ <Compile Include="ScriptInfo.cs" />
<Compile Include="Xml\XmlAttribute.cs" />
<Compile Include="Xml\XmlDocument.cs" />
<Compile Include="Xml\XmlDocumentParser.cs" />
View
9 src/Libraries/Web/Xml/XmlDocumentParser.cs
@@ -3,17 +3,18 @@
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
//
+using System;
using System.Runtime.CompilerServices;
namespace System.Xml {
[IgnoreNamespace]
[Imported]
- public static class XmlDocumentParser {
+ [ScriptName("DOMParser")]
+ public sealed class XmlDocumentParser {
- [ScriptAlias("ss.parseXml")]
- public static XmlDocument Parse(string markup) {
- return null;
+ public XmlDocument ParseFromString(string markup, string mimeType) {
+ return null;
}
}
}
View
2 src/ZipX/Packages/Runtime.nuspec
@@ -20,5 +20,7 @@
<files>
<file src="..\..\..\bin\Release\mscorlib.js" target="content\Scripts" />
<file src="..\..\..\bin\Release\mscorlib.debug.js" target="content\Scripts" />
+ <file src="..\..\..\bin\Release\ssloader.js" target="content\Scripts" />
+ <file src="..\..\..\bin\Release\ssloader.debug.js" target="content\Scripts" />
</files>
</package>
View
6 tests/CoreLib/TestStartup.htm
@@ -22,11 +22,11 @@ <h2 id="qunit-userAgent"></h2>
sequence.push(c_s1);
}, false);
</script>
- <script type="text/javascript" src="..\..\bin\Debug\mscorlib.debug.js"></script>
+ <script type="text/javascript" src="..\..\bin\Debug\ssloader.debug.js"></script>
<script type="text/javascript">
var bodyAccessible = false;
- ss.ready(function() {
+ loader.ready(function() {
sequence.push(c_s2);
bodyAccessible = document.body != null;
});
@@ -39,7 +39,7 @@ <h2 id="qunit-userAgent"></h2>
QUnit.equal(sequence[0], c_s1, 'Expected DOMContentLoaded event to be first event');
QUnit.equal(sequence[1], c_s2, 'Expected ready event to be second event');
QUnit.equal(bodyAccessible, true, 'Expected to be able to access document.body in ready callback');
- ss.ready(function() {
+ loader.ready(function() {
QUnit.start();
QUnit.equal(document.readyState, 'complete', 'Document.readyState should be "complete"');
});

0 comments on commit 54bae4a

Please sign in to comment.
Something went wrong with that request. Please try again.