From 22aaa7476e385c88a3e7ff16a4536ca1595b5332 Mon Sep 17 00:00:00 2001 From: larsholm Date: Thu, 10 Sep 2015 17:43:33 +0200 Subject: [PATCH] First --- SQuery.sln | 22 +++++ SQuery/Index.html | 82 ++++++++++++++++++ SQuery/Properties/AssemblyInfo.cs | 35 ++++++++ SQuery/SQuery.csproj | 124 +++++++++++++++++++++++++++ SQuery/SQuery.js | 138 ++++++++++++++++++++++++++++++ SQuery/Web.Debug.config | 30 +++++++ SQuery/Web.Release.config | 31 +++++++ SQuery/Web.config | 21 +++++ SQuery/packages.config | 5 ++ 9 files changed, 488 insertions(+) create mode 100644 SQuery.sln create mode 100644 SQuery/Index.html create mode 100644 SQuery/Properties/AssemblyInfo.cs create mode 100644 SQuery/SQuery.csproj create mode 100644 SQuery/SQuery.js create mode 100644 SQuery/Web.Debug.config create mode 100644 SQuery/Web.Release.config create mode 100644 SQuery/Web.config create mode 100644 SQuery/packages.config diff --git a/SQuery.sln b/SQuery.sln new file mode 100644 index 0000000..4ace89e --- /dev/null +++ b/SQuery.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQuery", "SQuery\SQuery.csproj", "{02C831D1-4606-4FFD-B703-FCFB1BBF0B70}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {02C831D1-4606-4FFD-B703-FCFB1BBF0B70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {02C831D1-4606-4FFD-B703-FCFB1BBF0B70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {02C831D1-4606-4FFD-B703-FCFB1BBF0B70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {02C831D1-4606-4FFD-B703-FCFB1BBF0B70}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SQuery/Index.html b/SQuery/Index.html new file mode 100644 index 0000000..084648f --- /dev/null +++ b/SQuery/Index.html @@ -0,0 +1,82 @@ + + + + + + + + +
Lorem ipsum
+

Some untouched text

+
dolor sit amet
+ +

This should not be shown

+

Some undeleted text

+

This should not be shown

+
+ +
Lorem ipsum
+ + + + diff --git a/SQuery/Properties/AssemblyInfo.cs b/SQuery/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..213ac50 --- /dev/null +++ b/SQuery/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SQuery")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SQuery")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("02c831d1-4606-4ffd-b703-fcfb1bbf0b70")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SQuery/SQuery.csproj b/SQuery/SQuery.csproj new file mode 100644 index 0000000..143aa28 --- /dev/null +++ b/SQuery/SQuery.csproj @@ -0,0 +1,124 @@ + + + + + + + Debug + AnyCPU + + + 2.0 + {02C831D1-4606-4FFD-B703-FCFB1BBF0B70} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + SQuery + SQuery + v4.5.2 + true + + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + True + + + + + + + + + + + + + + + + + + + + + + + Web.config + + + Web.config + + + + + + + + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 14235 + / + http://localhost:14235/ + False + False + + + False + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/SQuery/SQuery.js b/SQuery/SQuery.js new file mode 100644 index 0000000..0d7cf3c --- /dev/null +++ b/SQuery/SQuery.js @@ -0,0 +1,138 @@ +/* SQuery : A small "JQuery" immitation */ + +S = (function createSQuery() { + var EP = Element.prototype, + CP = CSSStyleDeclaration.prototype; + var aDOMFunc = [EP.removeAttribute, EP.setAttribute, CP.removeProperty, CP.setProperty]; + + function set(bStyle, sProp, sVal) { + var bSet = Boolean(sVal), + fAction = aDOMFunc[bSet | bStyle << 1], + aArgs = [].slice.call(arguments, 1, bSet ? 3 : 2), + aNodeList = bStyle ? this.cssNodes : this.nodes; + + if (bSet && bStyle) { + aArgs.push(''); + } + for ( + var nItem = 0, nLen = this.nodes.length; + nItem < nLen; + fAction.apply(aNodeList[nItem++], aArgs)); + this.follow = set.caller; + return this; + } + + function get(bStyle, sProp) { + var fAction = (bStyle ? CP.getPropertyValue : EP.getAttribute), + aNodeList = bStyle ? this.cssNodes : this.nodes; + return fAction.call(aNodeList[0], sProp); + } + + function styles(sProp, sVal) { + return (arguments.length === 1 ? get.call(this, true, sProp) : set.call(this, true, sProp, sVal)); + }; + function attributes(sProp, sVal) { + return (arguments.length === 1 ? get.call(this, false, sProp) : set.call(this, false, sProp, sVal)); + }; + function getSelectors() { + return this.selectors; + }; + function getNodes() { + return this.nodes; + }; + function forEach(callback) { + [].forEach.call(this.nodes, callback); + return this; + }; + function setHTML(html) { + return forEach.call(this, function (e) { + e.innerHTML = html + }); + }; + function setClick(callback) { + return forEach.call(this, function (e) { + e.onclick = callback + }); + }; + function setOnchange(callback) { + return forEach.call(this, function (e) { + e.onchange = (function (el) { + el.srcElement = (el.srcElement || el.target); + callback(el) + }).bind(e); + }); + }; + function removeNode() { + return forEach.call(this, function (e) { + e.parentNode.removeChild(e) + }); + }; + function appendNode(n) { + return forEach.call(this, function (e) { + if ([].toString.call(n) === "[object Function]") { + [].forEach.call(n.nodes, e.appendChild); + } + else + e.appendChild(n) + }); + }; + function doAjax(method, url, data, successHandler, errorHandler) { + var xhr = typeof XMLHttpRequest != 'undefined' ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); + var hasResponseType = 'responseType' in xhr; + xhr.open(method, url, true); + xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + if (hasResponseType) + xhr.responseType = 'json'; + xhr.onreadystatechange = function () { + var status = xhr.status, + data; + if (xhr.readyState == 4) { + if (status.toString().indexOf("2") === 0) { + successHandler && successHandler(hasResponseType ? xhr.response : JSON.parse(xhr.responseText)); + } else { + errorHandler && errorHandler(status); + } + } + }; + xhr.send(data); + }; + + var s = (function (sSelectors) { + + if ([].toString.call(sSelectors) === "[object Function]") + sSelectors = sSelectors(); + + var sQuery = new Function('return arguments.callee.follow.apply(arguments.callee, arguments)'); + //"internal" + sQuery.selectors = sSelectors; + + if (/<[a-z][\s\S]*>/i.test(sSelectors)) { //looks like xhtml + var parser = new DOMParser(); + sQuery.nodes = parser.parseFromString(sSelectors, "text/xml").childNodes; + } else { + sQuery.nodes = document.querySelectorAll(sSelectors); + } + sQuery.cssNodes = [].map.call(sQuery.nodes, function (oInlineCSS) { + return oInlineCSS.style; + }); + sQuery.follow = getNodes; + //"external" + sQuery.attr = attributes; + sQuery.css = styles; + sQuery.toString = getSelectors; + sQuery.valueOf = getNodes; + sQuery.each = forEach; + sQuery.html = setHTML; + sQuery.click = setClick; + sQuery.change = setOnchange; + sQuery.show = styles.bind(sQuery, "display", "block"); + sQuery.hide = styles.bind(sQuery, "display", "none"); + sQuery.remove = removeNode; + sQuery.append = appendNode; + return sQuery; + }); + + s.ajax = doAjax; + + return s; +})(); \ No newline at end of file diff --git a/SQuery/Web.Debug.config b/SQuery/Web.Debug.config new file mode 100644 index 0000000..2e302f9 --- /dev/null +++ b/SQuery/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/SQuery/Web.Release.config b/SQuery/Web.Release.config new file mode 100644 index 0000000..c358444 --- /dev/null +++ b/SQuery/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/SQuery/Web.config b/SQuery/Web.config new file mode 100644 index 0000000..b976e20 --- /dev/null +++ b/SQuery/Web.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SQuery/packages.config b/SQuery/packages.config new file mode 100644 index 0000000..a34b4ed --- /dev/null +++ b/SQuery/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file