Skip to content

Commit

Permalink
Samples added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ihnat committed May 27, 2015
1 parent 38d37d4 commit f943919
Show file tree
Hide file tree
Showing 22 changed files with 587 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Task_1.js"></script>
<script src="Task_2.js"></script>
<script src="Task_3.js"></script>
<script src="Task_4.js"></script>
<script src="Task_5.js"></script>
<script src="Task_6.js"></script>
<script src="Task_9.js"></script>
<script src="Task_10.js"></script>
<script src="Task_11.js"></script>
<script src="main.js"></script>

<title></title>
</head>
<body>

</body>
</html>
35 changes: 35 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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("TestWeb")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestWeb")]
[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("6a0eaf82-aa4e-4e78-a6f6-5f35e124d0f0")]

// 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")]
3 changes: 2 additions & 1 deletion ReadMe.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
JavaScript Samples
JavaScript Samples
Task 7 and 8 in main.js
10 changes: 10 additions & 0 deletions Task_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var partialFunction = function (func) {

var argsArray = Array.prototype.slice.call(arguments, 1);
return function () {
return func.apply(this, argsArray.concat(Array.prototype.slice.call(arguments)));
}
}
var testFunction = function (x, y, z) {
return Math.sqrt(x * x + y * y + z * z);
}
6 changes: 6 additions & 0 deletions Task_10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function initLazyFunction(func) {
var requireArguments = Array.prototype.slice.call(arguments, 1);
return function () {
return func.apply(this, requireArguments);
}
}
16 changes: 16 additions & 0 deletions Task_11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var memoizationCreatorFunction = function (func) {
var me = this;
if(!me.cache){
me.cache = [];
}
var index = me.cache.length;
//use array element for each call cause functions can be anonymous (without names for key value)
me.cache.push({});
var returnFunction = function (arg) {
if (!me.cache[index][arg]) {
me.cache[index][arg] = func(arg);
}
return me.cache[index][arg];
};
return returnFunction;
}
23 changes: 23 additions & 0 deletions Task_2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var curryFunction = function (func) {

var argsArray = [];
var maxSize = func.length;
return function (argument) {
argsArray.push(argument);
if (maxSize == argsArray.length) {
return func.apply(this, argsArray);
}
else {
return arguments.callee;
}
}
}
var testFunctionLine = function (x) {
return x;
}
var testFunctionSquare = function (x, y) {
return Math.sqrt(x * x + y * y);
}
var testFunctionCube = function (x, y, z) {
return Math.sqrt(x * x + y * y + z * z);
}
10 changes: 10 additions & 0 deletions Task_3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var linearFoldFunction = function (array, callback, initialValue) {
var previousValue = initialValue ? initialValue : 0;
for (var i = 0; i < array.length; i++) {
previousValue = callback(previousValue, array[i], i, array);
}
return previousValue;
}
var foldingFunctionCallback = function (previousValue, currentValue, index, array) {
return (currentValue * currentValue) - previousValue * index;
}
17 changes: 17 additions & 0 deletions Task_4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var linearUnfoldFunction = function (callback, initialState) {
var resultArray = [];
var callbackResult = callback(initialState);
while (callbackResult !== false) {
resultArray.push(callbackResult.element);
callbackResult = callback(callbackResult.state);
}
return resultArray;
}
var unfoldingFunctionCallback = function (currentValue) {
if (currentValue > 10)
return false;
return {
state: currentValue + 1,
element: currentValue * currentValue
}
}
11 changes: 11 additions & 0 deletions Task_5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var mapFunction = function (callback, array) {
var resultArray = [];
for (var key in array) {
resultArray.push(callback(array[key]));
}
return resultArray;

}
var mapFunctionCallback = function (value) {
return value * value;
}
10 changes: 10 additions & 0 deletions Task_6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var filterFunction = function (callback, array) {
var resultArray = [];
for (var key in array) {
callback(array[key]) && resultArray.push(array[key]);
}
return resultArray;
}
var filterFunctionCallback = function (value) {
return value % 2;
}
15 changes: 15 additions & 0 deletions Task_9.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var firstFilterFunction = function (callback, array) {
for (var key in array) {
if (callback(array[key])) {
return array[key];
}
}
return null;

}
var firstFilterFunctionCallback = function (value) {
if (value === 3)
return true;
else
return false;
}
116 changes: 116 additions & 0 deletions TestWeb.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BFE837ED-11D3-405F-A400-0C8CE78829A1}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestWeb</RootNamespace>
<AssemblyName>TestWeb</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Index.html" />
<Content Include="main.js" />
<Content Include="Task_1.js" />
<Content Include="Task_10.js" />
<Content Include="Task_11.js" />
<Content Include="Task_2.js" />
<Content Include="Task_3.js" />
<Content Include="Task_4.js" />
<Content Include="Task_5.js" />
<Content Include="Task_6.js" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>2615</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:2615/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
30 changes: 30 additions & 0 deletions Web.Debug.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
31 changes: 31 additions & 0 deletions Web.Release.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your web.config file.
Note that because there is only one customErrors section under the
<system.web> node, there is no need to use the "xdt:Locator" attribute.
<customErrors defaultRedirect="GenericError.htm"
mode="RemoteOnly" xdt:Transform="Replace">
<error statusCode="500" redirect="InternalError.htm"/>
</customErrors>
-->
</system.web>
</configuration>
11 changes: 11 additions & 0 deletions Web.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
</configuration>
Loading

0 comments on commit f943919

Please sign in to comment.