Skip to content

Commit c87d423

Browse files
committed
Ide editor added
1 parent 2dc8cc9 commit c87d423

6 files changed

Lines changed: 100 additions & 7 deletions

File tree

codecamp-front/.angular-cli.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626

2727
"../node_modules/popper.js/dist/umd/popper.min.js",
2828
"../node_modules/jquery/dist/jquery.min.js",
29-
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
29+
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
30+
"../node_modules/ace-builds/src-min/ace.js",
31+
"../node_modules/ace-builds/src-min/mode-c_cpp.js",
32+
"../node_modules/ace-builds/src-min/mode-python.js",
33+
"../node_modules/ace-builds/src-min/mode-java.js"
3034
],
3135
"environmentSource": "environments/environment.ts",
3236
"environments": {

codecamp-front/package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codecamp-front/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"bootstrap": "^4.0.0-beta.2",
2828
"core-js": "^2.4.1",
2929
"jquery": "^3.3.1",
30+
"ng2-ace-editor": "^0.3.4",
3031
"popper.js": "^1.12.9",
3132
"rxjs": "^5.5.6",
3233
"zone.js": "^0.8.19"

codecamp-front/src/app/app.module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RouterModule, Routes} from '@angular/router';
44
import { ReactiveFormsModule} from '@angular/forms';
55
import { AppRoutingModule } from './app-routing.module';
66
import {FormControl, FormGroup} from '@angular/forms';
7-
7+
import {AceEditorModule} from 'ng2-ace-editor';
88
import { AppComponent } from './app.component';
99
import { NavbarComponent } from './components/navbar/navbar.component';
1010
import { LoginComponent } from './components/login/login.component';
@@ -41,7 +41,8 @@ import { ProblemsComponent } from './components/problems/problems.component';
4141
BrowserModule,
4242
HttpModule,
4343
ReactiveFormsModule,
44-
AppRoutingModule
44+
AppRoutingModule,
45+
AceEditorModule
4546
],
4647
providers: [ AuthService],
4748
bootstrap: [AppComponent]

codecamp-front/src/app/components/ide/ide.component.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@
22
<div class="row">
33
<div class="col-md-12">
44
<h1 class="display-4">Online IDE</h1>
5-
<textarea name="" id="" cols="105" rows="28" ></textarea>
5+
<article>
6+
<h5>Select language</h5>
7+
<select (change)="selectLanguage($event)">
8+
<option value="c_cpp">C</option>
9+
<option value="c_cpp">C++</option>
10+
<option value="java">Java</option>
11+
<option value="python">Python</option>
12+
</select>
13+
</article>
14+
15+
<div ace-editor id="" cols="105" rows="28"
16+
[text]="content"
17+
class="aceEditorDirective"
18+
mode="{{selectedLanguage}}"
19+
style="height:500px;"></div>
20+
21+
622
<div class="row">
723
<div class="col-md-8">
824
<label class="file-upload">Upload File
@@ -18,7 +34,7 @@ <h1 class="display-4">Online IDE</h1>
1834
Check me out
1935
</label>
2036
</div>
21-
37+
2238
</div>
2339
</div>
2440
</div>

codecamp-front/src/app/components/ide/ide.component.ts

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, ViewChild } from '@angular/core';
22

33
@Component({
44
selector: 'app-ide',
@@ -7,7 +7,51 @@ import { Component, OnInit } from '@angular/core';
77
})
88
export class IdeComponent implements OnInit {
99

10-
constructor() { }
10+
11+
selectedLanguage: String = 'c_cpp';
12+
content: string;
13+
selectLanguage(event: any) {
14+
this.selectedLanguage = event.target.value;
15+
if(this.selectedLanguage === 'c_cpp') { this.content =
16+
`#include<stdio.h>
17+
18+
int main()
19+
{
20+
21+
printf("Welcome To CodeCamp");
22+
23+
}
24+
`} else if(this.selectedLanguage === 'java'){this.content =
25+
`import java.util.*;
26+
27+
public class CodeCamp {
28+
29+
public static void main(String[] args) {
30+
31+
System.out.println("Welcome To Code Camp");
32+
33+
}
34+
35+
}
36+
`
37+
} else {
38+
this.content = `print("Welcome To CodeCamp")`
39+
}
40+
41+
}
42+
43+
constructor() {
44+
this.content =
45+
`#include<stdio.h>
46+
47+
int main()
48+
{
49+
50+
printf("Welcome To CodeCamp");
51+
52+
}
53+
`
54+
}
1155

1256
ngOnInit() {
1357
}

0 commit comments

Comments
 (0)