├── code_final
├── executor
│ ├── .gitignore
│ ├── requirements.txt
│ ├── Dockerfile
│ ├── executor_server.py
│ └── executor_utils.py
├── readme.txt
├── oj-client1
│ ├── src
│ │ ├── assets
│ │ │ ├── .gitkeep
│ │ │ └── colors.ts
│ │ ├── app
│ │ │ ├── app.component.css
│ │ │ ├── components
│ │ │ │ ├── navbar
│ │ │ │ │ ├── navbar.component.css
│ │ │ │ │ ├── navbar.component.ts
│ │ │ │ │ ├── navbar.component.spec.ts
│ │ │ │ │ └── navbar.component.html
│ │ │ │ ├── new-problem
│ │ │ │ │ ├── new-problem.component.css
│ │ │ │ │ ├── new-problem.component.spec.ts
│ │ │ │ │ ├── new-problem.component.ts
│ │ │ │ │ └── new-problem.component.html
│ │ │ │ ├── problem-detail
│ │ │ │ │ ├── problem-detail.component.css
│ │ │ │ │ ├── problem-detail.component.html
│ │ │ │ │ ├── problem-detail.component.spec.ts
│ │ │ │ │ └── problem-detail.component.ts
│ │ │ │ ├── editor
│ │ │ │ │ ├── editor.component.css
│ │ │ │ │ ├── editor.component.spec.ts
│ │ │ │ │ ├── editor.component.html
│ │ │ │ │ └── editor.component.ts
│ │ │ │ └── problem-list
│ │ │ │ │ ├── problem-list.component.css
│ │ │ │ │ ├── problem-list.component.html
│ │ │ │ │ ├── problem-list.component.spec.ts
│ │ │ │ │ └── problem-list.component.ts
│ │ │ ├── app.component.html
│ │ │ ├── models
│ │ │ │ └── problem.model.ts
│ │ │ ├── app.component.ts
│ │ │ ├── services
│ │ │ │ ├── data.service.spec.ts
│ │ │ │ ├── collaboration.service.spec.ts
│ │ │ │ ├── data.service.ts
│ │ │ │ └── collaboration.service.ts
│ │ │ ├── app.routes.ts
│ │ │ ├── mock-problems.ts
│ │ │ ├── app.component.spec.ts
│ │ │ └── app.module.ts
│ │ ├── environments
│ │ │ ├── environment.prod.ts
│ │ │ └── environment.ts
│ │ ├── styles.css
│ │ ├── favicon.ico
│ │ ├── typings.d.ts
│ │ ├── tsconfig.app.json
│ │ ├── index.html
│ │ ├── tsconfig.spec.json
│ │ ├── main.ts
│ │ ├── test.ts
│ │ └── polyfills.ts
│ ├── e2e
│ │ ├── app.po.ts
│ │ ├── tsconfig.e2e.json
│ │ └── app.e2e-spec.ts
│ ├── .editorconfig
│ ├── tsconfig.json
│ ├── .gitignore
│ ├── protractor.conf.js
│ ├── karma.conf.js
│ ├── README.md
│ ├── package.json
│ ├── .angular-cli.json
│ └── tslint.json
├── oj-server1
│ ├── .gitignore
│ ├── routes
│ │ ├── index.js
│ │ └── rest.js
│ ├── models
│ │ └── problemModel.js
│ ├── package.json
│ ├── modules
│ │ └── redisClient.js
│ ├── server.js
│ └── services
│ │ ├── problemService.js
│ │ └── editorSocketService.js
└── public
│ ├── favicon.ico
│ ├── glyphicons-halflings-regular.448c34a56d699c29117a.woff2
│ ├── glyphicons-halflings-regular.e18bbf611f2a2e43afc0.ttf
│ ├── glyphicons-halflings-regular.f4769f9bdb7466be6508.eot
│ ├── glyphicons-halflings-regular.fa2772327f55d8198301.woff
│ ├── index.html
│ ├── assets
│ └── colors.ts
│ ├── inline.bundle.js.map
│ ├── inline.bundle.js
│ ├── main.bundle.js.map
│ └── main.bundle.js
└── README.md
/code_final/executor/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
--------------------------------------------------------------------------------
/code_final/readme.txt:
--------------------------------------------------------------------------------
1 | week - 01
2 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Collaborative-Online-Judge-System
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/app.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/code_final/oj-server1/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
--------------------------------------------------------------------------------
/code_final/executor/requirements.txt:
--------------------------------------------------------------------------------
1 | Flask
2 | Docker
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/navbar/navbar.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/new-problem/new-problem.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-detail/problem-detail.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/code_final/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnneYang0222/LoveCode/HEAD/code_final/public/favicon.ico
--------------------------------------------------------------------------------
/code_final/oj-client1/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnneYang0222/LoveCode/HEAD/code_final/oj-client1/src/favicon.ico
--------------------------------------------------------------------------------
/code_final/oj-client1/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/code_final/executor/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:16.04
2 | MAINTAINER richkate
3 | RUN apt-get update
4 | RUN apt-get install -y openjdk-8-jdk
5 | RUN apt-get install -y python3
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/models/problem.model.ts:
--------------------------------------------------------------------------------
1 | export class Problem {
2 | id: number;
3 | name: string;
4 | desc: string;
5 | difficulty: string;
6 | }
--------------------------------------------------------------------------------
/code_final/public/glyphicons-halflings-regular.448c34a56d699c29117a.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnneYang0222/LoveCode/HEAD/code_final/public/glyphicons-halflings-regular.448c34a56d699c29117a.woff2
--------------------------------------------------------------------------------
/code_final/public/glyphicons-halflings-regular.e18bbf611f2a2e43afc0.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnneYang0222/LoveCode/HEAD/code_final/public/glyphicons-halflings-regular.e18bbf611f2a2e43afc0.ttf
--------------------------------------------------------------------------------
/code_final/public/glyphicons-halflings-regular.f4769f9bdb7466be6508.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnneYang0222/LoveCode/HEAD/code_final/public/glyphicons-halflings-regular.f4769f9bdb7466be6508.eot
--------------------------------------------------------------------------------
/code_final/public/glyphicons-halflings-regular.fa2772327f55d8198301.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnneYang0222/LoveCode/HEAD/code_final/public/glyphicons-halflings-regular.fa2772327f55d8198301.woff
--------------------------------------------------------------------------------
/code_final/oj-client1/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'app';
10 | }
11 |
--------------------------------------------------------------------------------
/code_final/oj-server1/routes/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 |
4 | const path = require('path');
5 | router.get('/', (req, res) => {
6 | res.sendFile('index.html', {root: path.join(__dirname, '../../public/')});
7 | });
8 |
9 | module.exports = router;
--------------------------------------------------------------------------------
/code_final/oj-client1/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "./",
6 | "module": "es2015",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/code_final/oj-server1/models/problemModel.js:
--------------------------------------------------------------------------------
1 | const mongoose = require('mongoose');
2 | const ProblemSchema = mongoose.Schema({
3 | id: Number,
4 | name: String,
5 | desc: String,
6 | difficulty: String
7 | });
8 | const ProblemModel = mongoose.model('ProblemModel', ProblemSchema);
9 | module.exports = ProblemModel;
--------------------------------------------------------------------------------
/code_final/oj-client1/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/code_final/oj-client1/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "jasminewd2",
11 | "node"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | OjClient1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/code_final/oj-client1/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('oj-client1 App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/navbar/navbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-navbar',
5 | templateUrl: './navbar.component.html',
6 | styleUrls: ['./navbar.component.css']
7 | })
8 | export class NavbarComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.log(err));
13 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-detail/problem-detail.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{problem.id}}. {{problem.name}}
6 |
7 |
8 | {{problem.desc}}
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/services/data.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { DataService } from './data.service';
4 |
5 | describe('DataService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [DataService]
9 | });
10 | });
11 |
12 | it('should be created', inject([DataService], (service: DataService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/code_final/oj-client1/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "moduleResolution": "node",
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es5",
11 | "typeRoots": [
12 | "node_modules/@types"
13 | ],
14 | "lib": [
15 | "es2017",
16 | "dom"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/editor/editor.component.css:
--------------------------------------------------------------------------------
1 | @media screen {
2 | #editor {
3 | height: 600px;
4 | }
5 | .lang-select {
6 | width: 100px;
7 | margin-right: 10px;
8 | }
9 | header .btn {
10 | margin: 0 5px;
11 | }
12 | footer .btn {
13 | margin: 0 5px;
14 | }
15 | .editor-footer, .editor-header {
16 | margin: 10px 0;
17 | }
18 | .cursor {
19 | /*position:absolute;*/
20 | background: rgba(0, 250, 0, 0.5);
21 | z-index: 40;
22 | width: 2px !important;
23 | }
24 | }
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/services/collaboration.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { CollaborationService } from './collaboration.service';
4 |
5 | describe('CollaborationService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [CollaborationService]
9 | });
10 | });
11 |
12 | it('should be created', inject([CollaborationService], (service: CollaborationService) => {
13 | expect(service).toBeTruthy();
14 | }));
15 | });
16 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-list/problem-list.component.css:
--------------------------------------------------------------------------------
1 | .difficulty {
2 | min-width: 65px;
3 | margin-right: 10px;
4 | }
5 | .label.difficulty {
6 | padding-top: 0.6em;
7 | color: #fbfdfa;
8 | font-size: 12px;
9 | }
10 | .title {
11 | font-size: 1.2em;
12 | }
13 | .diff-easy {
14 | background-color: #42ebf4;
15 | }
16 | .diff-medium {
17 | background-color: #92cf5c;
18 | }
19 | .diff-hard {
20 | background-color: #dd0d1e;
21 | }
22 | .diff-super {
23 | background-color: #8d16e2;
24 | }
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-list/problem-list.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/code_final/oj-server1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "oj-server1",
3 | "version": "1.0.0",
4 | "description": "online judge",
5 | "main": "server.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "nodemon server.js",
9 | "haha": "node server.js"
10 | },
11 | "author": "Richkate0222",
12 | "license": "ISC",
13 | "dependencies": {
14 | "body-parser": "^1.18.2",
15 | "express": "^4.16.2",
16 | "node-rest-client": "^3.1.0",
17 | "redis": "^2.8.0",
18 | "socket.io": "^2.0.4"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/code_final/oj-client1/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | testem.log
34 | /typings
35 |
36 | # e2e
37 | /e2e/*.js
38 | /e2e/*.map
39 |
40 | # System Files
41 | .DS_Store
42 | Thumbs.db
43 |
--------------------------------------------------------------------------------
/code_final/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | OjClient1
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/app.routes.ts:
--------------------------------------------------------------------------------
1 | import {Routes, RouterModule} from '@angular/router';
2 | import {ProblemListComponent} from './components/problem-list/problem-list.component';
3 | import {ProblemDetailComponent} from './components/problem-detail/problem-detail.component';
4 |
5 | const routes: Routes = [
6 | {
7 | path: '',
8 | redirectTo: 'problems',
9 | pathMatch: 'full'
10 | },
11 | {
12 | path: 'problems',
13 | component: ProblemListComponent
14 | },
15 | {
16 | path: 'problems/:id',
17 | component: ProblemDetailComponent
18 | },
19 | {
20 | path: '**',
21 | redirectTo: 'problems'
22 | }
23 | ];
24 | export const routing = RouterModule.forRoot(routes);
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/editor/editor.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { EditorComponent } from './editor.component';
4 |
5 | describe('EditorComponent', () => {
6 | let component: EditorComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ EditorComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(EditorComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/navbar/navbar.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NavbarComponent } from './navbar.component';
4 |
5 | describe('NavbarComponent', () => {
6 | let component: NavbarComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ NavbarComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NavbarComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/new-problem/new-problem.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NewProblemComponent } from './new-problem.component';
4 |
5 | describe('NewProblemComponent', () => {
6 | let component: NewProblemComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ NewProblemComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NewProblemComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-list/problem-list.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ProblemListComponent } from './problem-list.component';
4 |
5 | describe('ProblemListComponent', () => {
6 | let component: ProblemListComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ProblemListComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ProblemListComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/code_final/executor/executor_server.py:
--------------------------------------------------------------------------------
1 | import json
2 | from flask import Flask
3 | app = Flask(__name__)
4 | from flask import jsonify
5 | from flask import request
6 | import executor_utils as eu
7 |
8 | @app.route('/')
9 | def hello():
10 | return 'hello world'
11 |
12 | @app.route('/build_and_run', methods=['POST'])
13 | def build_and_run():
14 | data = request.get_json()
15 | if 'code' not in data or 'lang' not in data:
16 | return 'You should provide "code" and "lang"'
17 | code = data['code']
18 | lang = data['lang']
19 | print("API got called with code: %s in %s" % (code, lang))
20 | # return jsonify({'build': 'build jajaja', 'run': 'run from oajsfoaij'})
21 | result = eu.build_and_run(code, lang)
22 | return jsonify(result)
23 |
24 | if __name__ == '__main__':
25 | eu.load_image()
26 | app.run(debug=True)
27 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-detail/problem-detail.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ProblemDetailComponent } from './problem-detail.component';
4 |
5 | describe('ProblemDetailComponent', () => {
6 | let component: ProblemDetailComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ProblemDetailComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ProblemDetailComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/code_final/oj-server1/modules/redisClient.js:
--------------------------------------------------------------------------------
1 | const redis = require('redis');
2 | const client = redis.createClient();
3 |
4 | function set(key, value, callback) {
5 | client.set(key, value, function(err, res) {
6 | if (err) {
7 | console.log(err);
8 | return;
9 | }
10 | callback(res);
11 | });
12 | }
13 |
14 | function get(key, callback) {
15 | client.get(key, function(err, res) {
16 | if (err) {
17 | console.log(err);
18 | return;
19 | }
20 | callback(res);
21 | });
22 | }
23 |
24 | function expire(key, timeInSeconds) {
25 | client.expire(key, timeInSeconds);
26 | }
27 |
28 | function quit() {
29 | client.quit();
30 | }
31 |
32 | module.exports = {
33 | get,
34 | set,
35 | expire,
36 | quit,
37 | redisPrint: redis.print
38 | }
39 |
--------------------------------------------------------------------------------
/code_final/public/assets/colors.ts:
--------------------------------------------------------------------------------
1 | export const COLORS: [string] = [
2 | "#0000ff",
3 | "#a52a2a",
4 | "#00ffff",
5 | "#00008b",
6 | "#008b8b",
7 | "#a9a9a9",
8 | "#006400",
9 | "#bdb76b",
10 | "#8b008b",
11 | "#556b2f",
12 | "#ff8c00",
13 | "#9932cc",
14 | "#8b0000",
15 | "#e9967a",
16 | "#9400d3",
17 | "#ff00ff",
18 | "#ffd700",
19 | "#008000",
20 | "#4b0082",
21 | "#f0e68c",
22 | "#add8e6",
23 | "#e0ffff",
24 | "#90ee90",
25 | "#d3d3d3",
26 | "#ffb6c1",
27 | "#ffffe0",
28 | "#00ff00",
29 | "#ff00ff",
30 | "#800000",
31 | "#000080",
32 | "#808000",
33 | "#ffa500",
34 | "#ffc0cb",
35 | "#800080",
36 | "#800080",
37 | "#ff0000",
38 | "#c0c0c0",
39 | "#ffffff",
40 | "#ffff00"
41 | ];
--------------------------------------------------------------------------------
/code_final/oj-client1/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/assets/colors.ts:
--------------------------------------------------------------------------------
1 | export const COLORS: [string] = [
2 | "#0000ff",
3 | "#a52a2a",
4 | "#00ffff",
5 | "#00008b",
6 | "#008b8b",
7 | "#a9a9a9",
8 | "#006400",
9 | "#bdb76b",
10 | "#8b008b",
11 | "#556b2f",
12 | "#ff8c00",
13 | "#9932cc",
14 | "#8b0000",
15 | "#e9967a",
16 | "#9400d3",
17 | "#ff00ff",
18 | "#ffd700",
19 | "#008000",
20 | "#4b0082",
21 | "#f0e68c",
22 | "#add8e6",
23 | "#e0ffff",
24 | "#90ee90",
25 | "#d3d3d3",
26 | "#ffb6c1",
27 | "#ffffe0",
28 | "#00ff00",
29 | "#ff00ff",
30 | "#800000",
31 | "#000080",
32 | "#808000",
33 | "#ffa500",
34 | "#ffc0cb",
35 | "#800080",
36 | "#800080",
37 | "#ff0000",
38 | "#c0c0c0",
39 | "#ffffff",
40 | "#ffff00"
41 | ];
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-detail/problem-detail.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import {ActivatedRoute, Params} from '@angular/router';
3 | import {Problem} from '../../models/problem.model';
4 | import {DataService} from '../../services/data.service';
5 | @Component({
6 | selector: 'app-problem-detail',
7 | templateUrl: './problem-detail.component.html',
8 | styleUrls: ['./problem-detail.component.css']
9 | })
10 | export class ProblemDetailComponent implements OnInit {
11 | problem: Problem;
12 | constructor(private dataService: DataService, private route: ActivatedRoute) { }
13 |
14 | ngOnInit() {
15 | this.route.params.subscribe(params=>{
16 | //this.problem = this.dataService.getProblem(+params['id']);
17 | this.dataService.getProblem(+params['id'])
18 | .then(problem => this.problem =problem);
19 | });
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/new-problem/new-problem.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import {Problem} from'../../models/problem.model';
3 | import {DataService} from '../../services/data.service';
4 | const DEFAULT_PROBLEM: Problem = Object.freeze({
5 | id: 0,
6 | name: '',
7 | desc: '',
8 | difficulty: 'easy'
9 | });
10 | @Component({
11 | selector: 'app-new-problem',
12 | templateUrl: './new-problem.component.html',
13 | styleUrls: ['./new-problem.component.css']
14 | })
15 | export class NewProblemComponent implements OnInit {
16 | newProblem: Problem = Object.assign({}, DEFAULT_PROBLEM);
17 | difficulties: string[] = ['easy','medium','hard','super'];
18 |
19 | constructor(private dataService: DataService) { }
20 |
21 | ngOnInit() {
22 | }
23 | addProblem(){
24 | this.dataService.addProblem(this.newProblem);
25 | this.newProblem = Object.assign({}, DEFAULT_PROBLEM);
26 | }
27 |
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/mock-problems.ts:
--------------------------------------------------------------------------------
1 | import {Problem} from './models/problem.model';
2 |
3 | export const PROBLEMS: Problem[] = [
4 | {
5 | id: 1,
6 | name: "Two Sum",
7 | desc: 'Given an array of integers, find two numbers such that',
8 | difficulty: "easy",
9 | },
10 | {
11 | id: 2,
12 | name: "three Sum",
13 | desc: 'Given an array of integers, find two numbers such that',
14 | difficulty: "medium",
15 | },
16 | {
17 | id: 3,
18 | name: "Four Sum",
19 | desc: 'Given an array of integers, find two numbers such that',
20 | difficulty: "hard",
21 | },
22 | {
23 | id: 4,
24 | name: "Five Sum",
25 | desc: 'Given an array of integers, find two numbers such that',
26 | difficulty: "super",
27 | },
28 | {
29 | id: 5,
30 | name: "Six Sum",
31 | desc: 'Given an array of integers, find two numbers such that',
32 | difficulty: "easy",
33 | }
34 | ];
--------------------------------------------------------------------------------
/code_final/oj-client1/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 | angularCli: {
23 | environment: 'dev'
24 | },
25 | reporters: ['progress', 'kjhtml'],
26 | port: 9876,
27 | colors: true,
28 | logLevel: config.LOG_INFO,
29 | autoWatch: true,
30 | browsers: ['Chrome'],
31 | singleRun: false
32 | });
33 | };
34 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/problem-list/problem-list.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, OnDestroy } from '@angular/core';
2 | import {Subscription} from 'rxjs/Subscription';
3 | import {Problem} from '../../models/problem.model';
4 | //import {PROBLEMS} from '../../mock-problems';
5 | import {DataService} from '../../services/data.service';
6 |
7 | @Component({
8 | selector: 'app-problem-list',
9 | templateUrl: './problem-list.component.html',
10 | styleUrls: ['./problem-list.component.css']
11 | })
12 | export class ProblemListComponent implements OnInit, OnDestroy {
13 |
14 | problems: Problem[];
15 | subscriptionProblems: Subscription;
16 |
17 | constructor(private dataService: DataService) { }
18 |
19 | ngOnInit() {
20 | this.getProblems();
21 | }
22 | ngOnDestroy(){
23 | this.subscriptionProblems.unsubscribe();
24 | }
25 | getProblems(): void {
26 | //this.problems = this.dataService.getProblems();
27 | this.subscriptionProblems = this.dataService.getProblems()
28 | .subscribe(problems => this.problems = problems);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 | describe('AppComponent', () => {
4 | beforeEach(async(() => {
5 | TestBed.configureTestingModule({
6 | declarations: [
7 | AppComponent
8 | ],
9 | }).compileComponents();
10 | }));
11 | it('should create the app', async(() => {
12 | const fixture = TestBed.createComponent(AppComponent);
13 | const app = fixture.debugElement.componentInstance;
14 | expect(app).toBeTruthy();
15 | }));
16 | it(`should have as title 'app'`, async(() => {
17 | const fixture = TestBed.createComponent(AppComponent);
18 | const app = fixture.debugElement.componentInstance;
19 | expect(app.title).toEqual('app');
20 | }));
21 | it('should render title in a h1 tag', async(() => {
22 | const fixture = TestBed.createComponent(AppComponent);
23 | fixture.detectChanges();
24 | const compiled = fixture.debugElement.nativeElement;
25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
26 | }));
27 | });
28 |
--------------------------------------------------------------------------------
/code_final/oj-client1/README.md:
--------------------------------------------------------------------------------
1 | # OjClient1
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.5.3.
4 |
5 | ## Development server
6 |
7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12 |
13 | ## Build
14 |
15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28 |
--------------------------------------------------------------------------------
/code_final/oj-server1/server.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const app = express();
3 | const path = require('path');
4 | const http = require('http');
5 | const socketIO = require('socket.io');
6 | const io = socketIO();
7 | const editorSocketService = require('./services/editorSocketService')(io);
8 |
9 | // connect mongoDb
10 | const mongoose = require('mongoose');
11 | mongoose.connect('mongodb://user:user@ds125016.mlab.com:25016/cs503-1705test1');
12 |
13 | const restRouter = require('./routes/rest');
14 | const indexRouter = require('./routes/index');
15 |
16 | app.use(express.static(path.join(__dirname, '../public/')));
17 | //app.get('/', (req, res) => res.send('Hello World!'));
18 | app.use('/', indexRouter);
19 | app.use('/api/v1', restRouter);
20 |
21 | app.use((req, res) => {
22 | res.sendFile('index.html', { root: path.join(__dirname, '../public/')});
23 | });
24 | //app.listen(3000, () => console.log('Example app listening on port 3000!'));
25 | const server = http.createServer(app);
26 | io.attach(server);
27 | server.listen(3000);
28 | server.on('listening', onListening);
29 |
30 | function onListening() {
31 | console.log('App listening on port 3000!')
32 | }
--------------------------------------------------------------------------------
/code_final/oj-client1/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare const __karma__: any;
17 | declare const require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () {};
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/new-problem/new-problem.component.html:
--------------------------------------------------------------------------------
1 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import {FormsModule} from '@angular/forms';
4 | import {HttpClientModule} from '@angular/common/http';
5 | //import {HttpModle} from '@angular/http';
6 |
7 | import { routing } from './app.routes';
8 | import {DataService} from './services/data.service';
9 | import { CollaborationService } from './services/collaboration.service';
10 |
11 | import { AppComponent } from './app.component';
12 | import { ProblemListComponent } from './components/problem-list/problem-list.component';
13 | import { ProblemDetailComponent } from './components/problem-detail/problem-detail.component';
14 | import { NewProblemComponent } from './components/new-problem/new-problem.component';
15 | import { NavbarComponent } from './components/navbar/navbar.component';
16 | import { EditorComponent } from './components/editor/editor.component';
17 |
18 |
19 | @NgModule({
20 | declarations: [
21 | AppComponent,
22 | ProblemListComponent,
23 | ProblemDetailComponent,
24 | NewProblemComponent,
25 | NavbarComponent,
26 | EditorComponent
27 | ],
28 | imports: [
29 | BrowserModule,
30 | routing,
31 | FormsModule,
32 | HttpClientModule
33 | ],
34 | providers: [
35 | DataService,
36 | CollaborationService
37 | ],
38 | bootstrap: [AppComponent]
39 | })
40 | export class AppModule { }
41 |
--------------------------------------------------------------------------------
/code_final/oj-client1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "oj-client1",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^5.0.0",
16 | "@angular/common": "^5.0.0",
17 | "@angular/compiler": "^5.0.0",
18 | "@angular/core": "^5.0.0",
19 | "@angular/forms": "^5.0.0",
20 | "@angular/http": "^5.0.0",
21 | "@angular/platform-browser": "^5.0.0",
22 | "@angular/platform-browser-dynamic": "^5.0.0",
23 | "@angular/router": "^5.0.0",
24 | "ace-builds": "^1.2.9",
25 | "bootstrap": "^3.3.7",
26 | "core-js": "^2.4.1",
27 | "jquery": "^3.2.1",
28 | "rxjs": "^5.5.2",
29 | "socket.io": "^2.0.4",
30 | "zone.js": "^0.8.14"
31 | },
32 | "devDependencies": {
33 | "@angular/cli": "1.5.3",
34 | "@angular/compiler-cli": "^5.0.0",
35 | "@angular/language-service": "^5.0.0",
36 | "@types/jasmine": "~2.5.53",
37 | "@types/jasminewd2": "~2.0.2",
38 | "@types/node": "~6.0.60",
39 | "codelyzer": "~3.2.0",
40 | "jasmine-core": "~2.6.2",
41 | "jasmine-spec-reporter": "~4.1.0",
42 | "karma": "~1.7.0",
43 | "karma-chrome-launcher": "~2.1.1",
44 | "karma-cli": "~1.0.1",
45 | "karma-coverage-istanbul-reporter": "^1.2.1",
46 | "karma-jasmine": "~1.1.0",
47 | "karma-jasmine-html-reporter": "^0.2.2",
48 | "protractor": "~5.1.2",
49 | "ts-node": "~3.2.0",
50 | "tslint": "~5.7.0",
51 | "typescript": "~2.4.2"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/code_final/oj-server1/routes/rest.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const router = express.Router();
3 | const problemService = require('../services/problemService');
4 | const bodyParser = require('body-parser');
5 | const jsonParser = bodyParser.json();
6 | const nodeRestClient = require('node-rest-client').Client;
7 | const restClient = new nodeRestClient();
8 |
9 | EXECUTOR_SERVER_URL = 'http://localhost:5000/build_and_run';
10 |
11 | restClient.registerMethod('build_and_run', EXECUTOR_SERVER_URL, 'POST');
12 |
13 | // get problems
14 | router.get('/problems', (req, res) => {
15 | problemService.getProblems()
16 | .then(problems => res.json(problems));
17 | });
18 |
19 | // get problems
20 | router.get('/problems/:id', (req, res) => {
21 | const id = req.params.id;
22 | problemService.getProblem(+id)
23 | .then(problem => res.json(problem));
24 | })
25 | // post problem
26 | router.post('/problems', jsonParser, (req, res) => {
27 | problemService.addProblem(req.body)
28 | .then(problem => {
29 | res.json(problem);
30 | }, (error) => {
31 | res.status(400).send('Problem name already exists!');
32 | });
33 | });
34 | // build and run
35 | router.post('/build_and_run', jsonParser, (req, res) => {
36 | const userCodes = req.body.userCodes;
37 | const lang = req.body.lang;
38 | console.log('lang: ', lang, 'usercode: ', userCodes);
39 |
40 | restClient.methods.build_and_run(
41 | {
42 | data: {code: userCodes, lang: lang},
43 | headers: { 'Content-Type': 'application/json'}
44 | },
45 | (data, response) => {
46 | // build: xxx ; run: xxx
47 | const text = `Build output: ${data['build']}. Execute Output: ${data['run']}`;
48 | data['text'] = text;
49 | res.json(data);
50 | }
51 | );
52 | });
53 | module.exports = router;
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/editor/editor.component.html:
--------------------------------------------------------------------------------
1 |
2 |
37 |
38 |
39 |
40 |
41 | {{output}}
42 |
43 |
44 |
48 |
49 |
--------------------------------------------------------------------------------
/code_final/oj-client1/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "oj-client1"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "../public",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css",
23 | "../node_modules/bootstrap/dist/css/bootstrap.min.css"
24 | ],
25 | "scripts": [
26 | "../node_modules/jquery/dist/jquery.js",
27 | "../node_modules/bootstrap/dist/js/bootstrap.js",
28 | "../node_modules/ace-builds/src-min-noconflict/ace.js",
29 | "../node_modules/ace-builds/src-min-noconflict/theme-eclipse.js",
30 | "../node_modules/ace-builds/src-min-noconflict/mode-java.js",
31 | "../node_modules/ace-builds/src-min-noconflict/mode-python.js",
32 | "../node_modules/socket.io-client/dist/socket.io.js"
33 | ],
34 | "environmentSource": "environments/environment.ts",
35 | "environments": {
36 | "dev": "environments/environment.ts",
37 | "prod": "environments/environment.prod.ts"
38 | }
39 | }
40 | ],
41 | "e2e": {
42 | "protractor": {
43 | "config": "./protractor.conf.js"
44 | }
45 | },
46 | "lint": [
47 | {
48 | "project": "src/tsconfig.app.json",
49 | "exclude": "**/node_modules/**"
50 | },
51 | {
52 | "project": "src/tsconfig.spec.json",
53 | "exclude": "**/node_modules/**"
54 | },
55 | {
56 | "project": "e2e/tsconfig.e2e.json",
57 | "exclude": "**/node_modules/**"
58 | }
59 | ],
60 | "test": {
61 | "karma": {
62 | "config": "./karma.conf.js"
63 | }
64 | },
65 | "defaults": {
66 | "styleExt": "css",
67 | "component": {}
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/services/data.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient, HttpHeaders, HttpResponse} from '@angular/common/http';
3 | import { Observable } from 'rxjs/Rx';
4 | import { BehaviorSubject } from 'rxjs/BehaviorSubject';
5 | import 'rxjs/add/operator/toPromise';
6 |
7 | import { Problem } from '../models/problem.model';
8 | // import { PROBLEMS } from '../mock-problems';
9 | @Injectable()
10 | export class DataService {
11 | // problems: Problem[] = PROBLEMS;
12 | private _problemSource = new BehaviorSubject([]);
13 |
14 | constructor(private httpClient: HttpClient) { }
15 |
16 | getProblems(): Observable {
17 | // return this.problems;
18 | this.httpClient.get('api/v1/problems')
19 | .toPromise()
20 | .then((res: any) => {
21 | this._problemSource.next(res);
22 | })
23 | .catch(this.handleError);
24 | return this._problemSource.asObservable();
25 | }
26 | // values, complete, error
27 | getProblem(id: number): Promise {
28 | // return this.problems.find( (problem) => problem.id === id);
29 | return this.httpClient.get(`api/v1/problems/${id}`)
30 | .toPromise()
31 | .then((res: any) => res)
32 | .catch(this.handleError);
33 | }
34 |
35 | addProblem(problem: Problem) {
36 | // problem.id = this.problems.length + 1;
37 | // this.problems.push(problem);
38 | const options = { headers: new HttpHeaders({ 'Content-Type': 'application/json'})};
39 | return this.httpClient.post('api/v1/problems', problem, options)
40 | .toPromise()
41 | .then((res: any) => {
42 | this.getProblems();
43 | return res;
44 | })
45 | .catch(this.handleError);
46 | }
47 |
48 | buildAndRun(data): Promise {
49 | const options = {headers: new HttpHeaders({ 'Content-Type': 'application/json'})};
50 | return this.httpClient.post('api/v1/build_and_run', data, options)
51 | .toPromise()
52 | .then(res => {
53 | console.log(res);
54 | return res;
55 | })
56 | .catch(this.handleError);
57 | }
58 |
59 | private handleError(error: any): Promise {
60 | return Promise.reject(error.body || error);
61 | }
62 | }
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/services/collaboration.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { COLORS } from '../../assets/colors';
3 |
4 | declare const io: any;
5 | declare const ace: any;
6 | @Injectable()
7 | export class CollaborationService {
8 | clientsInfo: Object = {};
9 | clientNum: number = 0;
10 | collaborationSocket: any;
11 | constructor() { }
12 |
13 | init(editor: any, sessionId: string): void {
14 | this.collaborationSocket = io(window.location.origin, { query: 'sessionId=' + sessionId});
15 |
16 | // this.collaborationSocket.on('message', (message) => {
17 | // console.log('message received from server: ' + message);
18 | // });
19 | this.collaborationSocket.on('change', (delta: string) => {
20 | delta = JSON.parse(delta);
21 | editor.lastAppliedChange = delta;
22 | editor.getSession().getDocument().applyDeltas([delta]);
23 | });
24 |
25 | this.collaborationSocket.on('cursorMove', (cursor: string) => {
26 | console.log('cursor move' + cursor);
27 | const session = editor.getSession();
28 | cursor = JSON.parse(cursor);
29 | const x = cursor['row'];
30 | const y = cursor['column'];
31 | const changeClientId = cursor['socketId'];
32 | console.log(x + ' ' + y + changeClientId);
33 |
34 | if (changeClientId in this.clientsInfo) {
35 | session.removeMarker(this.clientsInfo[changeClientId]['marker']);
36 | } else {
37 | this.clientsInfo[changeClientId] = {};
38 | const css = document.createElement('style');
39 | css.type = 'text/css';
40 | css.innerHTML = `.editor_cursor_${changeClientId}
41 | {
42 | position:absolute;
43 | background:${COLORS[this.clientNum]};
44 | z-index:100;
45 | width:3px !important;
46 | }`;
47 | document.body.appendChild(css);
48 | this.clientNum++;
49 | }
50 | const Range = ace.require('ace/range').Range;
51 | const newMarker = session.addMarker(new Range(x, y, x, y + 1), `editor_cursor_${changeClientId}`, true);
52 | this.clientsInfo[changeClientId]['marker'] = newMarker;
53 | });
54 | }
55 |
56 | change(delta: string): void {
57 | this.collaborationSocket.emit('change', delta);
58 | }
59 |
60 | cursorMove(cursor: string) {
61 | this.collaborationSocket.emit('cursorMove', cursor);
62 | }
63 |
64 | restoreBuffer(): void {
65 | this.collaborationSocket.emit('restoreBuffer');
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/navbar/navbar.component.html:
--------------------------------------------------------------------------------
1 |
2 |
54 |
--------------------------------------------------------------------------------
/code_final/executor/executor_utils.py:
--------------------------------------------------------------------------------
1 | import docker
2 | import os
3 | import shutil
4 | import uuid
5 |
6 | from docker.errors import APIError
7 | from docker.errors import ContainerError
8 | from docker.errors import ImageNotFound
9 |
10 | CURRENT_DIR = os.path.dirname(os.path.relpath(__file__))
11 | IMAGE_NAME = 'richkate/cs503'
12 | client = docker.from_env()
13 |
14 | TEMP_BUILD_DIR = "%s/tmp/" % CURRENT_DIR
15 | CONTAINER_NAME = "%s:latest" % IMAGE_NAME
16 |
17 | SOURCE_FILE_NAMES = {
18 | "java": "Example.java",
19 | "python": "example.py"
20 | }
21 | BINARY_NAMES = {
22 | "java": "Example",
23 | "python": "example.py"
24 | }
25 | BUILD_COMMANDS = {
26 | "java": "javac",
27 | "python": "python3"
28 | }
29 | EXECUTE_COMMANDS = {
30 | "java": "java",
31 | "python": "python3"
32 | }
33 |
34 | def load_image():
35 | try:
36 | client.images.get(IMAGE_NAME)
37 | print("Image exists locally")
38 | except ImageNotFound:
39 | print('image not found locally. lodaing from docker')
40 | client.images.pull(IMAGE_NAME)
41 | except APIError:
42 | print('docker hub go die')
43 | return
44 | print('image loaded')
45 |
46 | def make_dir(dir):
47 | try:
48 | os.mkdir(dir)
49 | except OSError:
50 | print('go die')
51 |
52 | def build_and_run(code, lang):
53 | result = {'build': None, 'run': None, 'error': None}
54 | source_file_parent_dir_name = uuid.uuid4()
55 | source_file_host_dir = "%s/%s" % (TEMP_BUILD_DIR, source_file_parent_dir_name)
56 | source_file_guest_dir = "/test/%s" % (source_file_parent_dir_name)
57 | make_dir(source_file_host_dir)
58 |
59 | with open("%s/%s" %(source_file_host_dir, SOURCE_FILE_NAMES[lang]), 'w') as source_file:
60 | source_file.write(code)
61 | try:
62 | client.containers.run(
63 | image=IMAGE_NAME,
64 | command="%s %s" % (BUILD_COMMANDS[lang], SOURCE_FILE_NAMES[lang]),
65 | volumes={source_file_host_dir: {'bind': source_file_guest_dir, 'mode': 'rw'}},
66 | working_dir=source_file_guest_dir
67 | )
68 | print('source built')
69 | result['build'] = 'OK'
70 | except ContainerError as e:
71 | result['build'] = str(e.stderr, 'utf-8')
72 | shutil.rmtree(source_file_host_dir)
73 | return result
74 | try:
75 | log = client.containers.run(
76 | image=IMAGE_NAME,
77 | command="%s %s" % (EXECUTE_COMMANDS[lang], BINARY_NAMES[lang]),
78 | volumes={source_file_host_dir: {'bind': source_file_guest_dir, 'mode': 'rw'}},
79 | working_dir=source_file_guest_dir
80 | )
81 | log = str(log, 'utf-8')
82 | result['run'] = log
83 | except ContainerError as e:
84 | result['run'] = str(e.stderr, 'utf-8')
85 | shutil.rmtree(source_file_host_dir)
86 | return result
87 | shutil.rmtree(source_file_host_dir)
88 | return result
--------------------------------------------------------------------------------
/code_final/oj-client1/src/app/components/editor/editor.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { ActivatedRoute, Params } from '@angular/router';
3 | import { CollaborationService } from '../../services/collaboration.service';
4 | import { DataService} from '../../services/data.service';
5 | declare const ace: any;
6 | @Component({
7 | selector: 'app-editor',
8 | templateUrl: './editor.component.html',
9 | styleUrls: ['./editor.component.css']
10 | })
11 | export class EditorComponent implements OnInit {
12 | sessionId: string;
13 | languages: string[] = ['Java', 'Python'];
14 | language: string = 'Java';
15 | editor: any;
16 | defaultContent = {
17 | 'Java': `public class Example {
18 | public static void main(String[] args) {
19 | // Type your Java code here
20 | }
21 | }`,
22 | 'Python': `class Solution:
23 | def example():
24 | # Write your Python code here`
25 | };
26 | output: string = '';
27 | constructor(private collaboration: CollaborationService,
28 | private route: ActivatedRoute,
29 | private dataService: DataService) { }
30 |
31 | ngOnInit() {
32 | this.route.params
33 | .subscribe(params => {
34 | this.sessionId = params['id'];
35 | this.initEditor();
36 | this.collaboration.restoreBuffer();
37 | });
38 | }
39 |
40 | initEditor(): void {
41 | this.editor = ace.edit("editor");
42 | this.editor.setTheme("ace/theme/eclipse");
43 | this.resetEditor();
44 | this.editor.$blockScrolling = Infinity;
45 |
46 | // set up collaboration socket
47 | this.collaboration.init(this.editor, this.sessionId);
48 | this.editor.lastAppliedChange = null;
49 |
50 | // register change callback
51 | this.editor.on('change', (e) => {
52 | console.log('editor change: ' + JSON.stringify(e));
53 | if (this.editor.lastAppliedChange != e) {
54 | this.collaboration.change(JSON.stringify(e));
55 | }
56 | });
57 |
58 | this.editor.getSession().getSelection().on('changeCursor', ()=> {
59 | const cursor = this.editor.getSession().getSelection().getCursor();
60 | console.log('curser move log from client' + JSON.stringify(cursor));
61 | this.collaboration.cursorMove(JSON.stringify(cursor));
62 | });
63 | }
64 |
65 | resetEditor(): void {
66 | this.editor.setValue(this.defaultContent[this.language]);
67 | this.editor.getSession().setMode("ace/mode/" + this.language.toLowerCase());
68 | }
69 |
70 | setLanguage(language: string): void {
71 | this.language = language;
72 | this.resetEditor();
73 | }
74 |
75 | submit(): void {
76 | const userCodes = this.editor.getValue();
77 | const data = {
78 | userCodes: userCodes,
79 | lang: this.language.toLocaleLowerCase()
80 | };
81 | //console.log(userCodes);
82 | this.dataService.buildAndRun(data)
83 | .then(res => this.output = res.text);
84 | }
85 |
86 | }
--------------------------------------------------------------------------------
/code_final/oj-client1/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Required to support Web Animations `@angular/platform-browser/animations`.
51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
52 | **/
53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
54 |
55 |
56 |
57 | /***************************************************************************************************
58 | * Zone JS is required by Angular itself.
59 | */
60 | import 'zone.js/dist/zone'; // Included with Angular CLI.
61 |
62 |
63 |
64 | /***************************************************************************************************
65 | * APPLICATION IMPORTS
66 | */
67 |
68 | /**
69 | * Date, currency, decimal and percent pipes.
70 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
71 | */
72 | // import 'intl'; // Run `npm install --save intl`.
73 | /**
74 | * Need to import at least one locale-data with intl.
75 | */
76 | // import 'intl/locale-data/jsonp/en';
77 |
--------------------------------------------------------------------------------
/code_final/oj-server1/services/problemService.js:
--------------------------------------------------------------------------------
1 | //let problems = [
2 | // {
3 | // id: 1,
4 | // name: "Two Sum",
5 | // desc: 'Given an array of integers, find two numbers such that',
6 | // difficulty: "easy",
7 | // },
8 | // {
9 | // id: 2,
10 | // name: "three Sum",
11 | // desc: 'Given an array of integers, find two numbers such that',
12 | // difficulty: "medium",
13 | // },
14 | // {
15 | // id: 3,
16 | // name: "Four Sum",
17 | // desc: 'Given an array of integers, find two numbers such that',
18 | // difficulty: "hard",
19 | // },
20 | // {
21 | // id: 4,
22 | // name: "Five Sum",
23 | // desc: 'Given an array of integers, find two numbers such that',
24 | // difficulty: "super",
25 | // },
26 | // {
27 | // id: 5,
28 | // name: "Six Sum",
29 | // desc: 'Given an array of integers, find two numbers such that',
30 | // difficulty: "easy",
31 | // }
32 | // ];
33 |
34 | const ProblemModel = require('../models/problemModel');
35 |
36 | const getProblems = function(){
37 | // console.log('In the problem service get problems');
38 | // return new Promise((resolve, reject) => {
39 | // resolve(problems);
40 | // });
41 | return new Promise((resolve, reject) => {
42 | ProblemModel.find({}, (err, problems) => {
43 | if(err){
44 | reject(err);
45 | } else {
46 | resolve(problems);
47 | }
48 |
49 | });
50 | });
51 | }
52 |
53 | const getProblem = function(id){
54 | // console.log('In the problem service get problem');
55 | // return new Promise((resolve, reject) => {
56 | // resolve(problems.find(problem => problem.id === id));
57 | // });
58 | return new Promise((resolve, reject) => {
59 | ProblemModel.findOne({id: id}, (err, problem) => {
60 | if(err){
61 | reject(err);
62 | } else {
63 | resolve(problem);
64 | }
65 |
66 | });
67 | });
68 | }
69 |
70 | const addProblem = function(newProblem) {
71 | // return new Promise((resolve, reject) => {
72 | // if (problems.find(problem => problem.name === newProblem.name)) {
73 | // reject('Problem already exists!');
74 | // } else {
75 | // newProblem.id = problems.length + 1;
76 | // problems.push(newProblem);
77 | // resolve(newProblem);
78 | // }
79 | // });
80 | return new Promise((resolve, reject) => {
81 | // check
82 | ProblemModel.findOne({name: newProblem.name}, (err, data) => {
83 | if (data) {
84 | reject('Problem already exists!');
85 | } else {
86 | // save to mongodb
87 | ProblemModel.count({}, (err, count) => {
88 | newProblem.id = count + 1;
89 | const mongoProblem = new ProblemModel(newProblem);
90 | mongoProblem.save();
91 | resolve(mongoProblem);
92 | });
93 | }
94 | });
95 | });
96 | }
97 |
98 | module.exports = {
99 | getProblems, // when the key and value share the same name, we can just use one instaed
100 | getProblem, //getProblem is ok
101 | addProblem
102 | }
103 |
104 |
--------------------------------------------------------------------------------
/code_final/oj-client1/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "eofline": true,
15 | "forin": true,
16 | "import-blacklist": [
17 | true,
18 | "rxjs",
19 | "rxjs/Rx"
20 | ],
21 | "import-spacing": true,
22 | "indent": [
23 | true,
24 | "spaces"
25 | ],
26 | "interface-over-type-literal": true,
27 | "label-position": true,
28 | "max-line-length": [
29 | true,
30 | 140
31 | ],
32 | "member-access": false,
33 | "member-ordering": [
34 | true,
35 | {
36 | "order": [
37 | "static-field",
38 | "instance-field",
39 | "static-method",
40 | "instance-method"
41 | ]
42 | }
43 | ],
44 | "no-arg": true,
45 | "no-bitwise": true,
46 | "no-console": [
47 | true,
48 | "debug",
49 | "info",
50 | "time",
51 | "timeEnd",
52 | "trace"
53 | ],
54 | "no-construct": true,
55 | "no-debugger": true,
56 | "no-duplicate-super": true,
57 | "no-empty": false,
58 | "no-empty-interface": true,
59 | "no-eval": true,
60 | "no-inferrable-types": [
61 | true,
62 | "ignore-params"
63 | ],
64 | "no-misused-new": true,
65 | "no-non-null-assertion": true,
66 | "no-shadowed-variable": true,
67 | "no-string-literal": false,
68 | "no-string-throw": true,
69 | "no-switch-case-fall-through": true,
70 | "no-trailing-whitespace": true,
71 | "no-unnecessary-initializer": true,
72 | "no-unused-expression": true,
73 | "no-use-before-declare": true,
74 | "no-var-keyword": true,
75 | "object-literal-sort-keys": false,
76 | "one-line": [
77 | true,
78 | "check-open-brace",
79 | "check-catch",
80 | "check-else",
81 | "check-whitespace"
82 | ],
83 | "prefer-const": true,
84 | "quotemark": [
85 | true,
86 | "single"
87 | ],
88 | "radix": true,
89 | "semicolon": [
90 | true,
91 | "always"
92 | ],
93 | "triple-equals": [
94 | true,
95 | "allow-null-check"
96 | ],
97 | "typedef-whitespace": [
98 | true,
99 | {
100 | "call-signature": "nospace",
101 | "index-signature": "nospace",
102 | "parameter": "nospace",
103 | "property-declaration": "nospace",
104 | "variable-declaration": "nospace"
105 | }
106 | ],
107 | "typeof-compare": true,
108 | "unified-signatures": true,
109 | "variable-name": false,
110 | "whitespace": [
111 | true,
112 | "check-branch",
113 | "check-decl",
114 | "check-operator",
115 | "check-separator",
116 | "check-type"
117 | ],
118 | "directive-selector": [
119 | true,
120 | "attribute",
121 | "app",
122 | "camelCase"
123 | ],
124 | "component-selector": [
125 | true,
126 | "element",
127 | "app",
128 | "kebab-case"
129 | ],
130 | "use-input-property-decorator": true,
131 | "use-output-property-decorator": true,
132 | "use-host-property-decorator": true,
133 | "no-input-rename": true,
134 | "no-output-rename": true,
135 | "use-life-cycle-interface": true,
136 | "use-pipe-transform-interface": true,
137 | "component-class-suffix": true,
138 | "directive-class-suffix": true,
139 | "invoke-injectable": true
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/code_final/public/inline.bundle.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["webpack/bootstrap a2817cb54bac8930dec1"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAQ,oBAAoB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAY,2BAA2B;AACvC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kDAA0C,WAAW,EAAE;AACvD;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAI;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA,kDAA0C,oBAAoB,WAAW","file":"inline.bundle.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t\"inline\": 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tvar installedChunkData = installedChunks[chunkId];\n \t\tif(installedChunkData === 0) {\n \t\t\treturn new Promise(function(resolve) { resolve(); });\n \t\t}\n\n \t\t// a Promise means \"currently loading\".\n \t\tif(installedChunkData) {\n \t\t\treturn installedChunkData[2];\n \t\t}\n\n \t\t// setup Promise in chunk cache\n \t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\tinstalledChunkData = installedChunks[chunkId] = [resolve, reject];\n \t\t});\n \t\tinstalledChunkData[2] = promise;\n\n \t\t// start chunk loading\n \t\tvar head = document.getElementsByTagName('head')[0];\n \t\tvar script = document.createElement('script');\n \t\tscript.type = 'text/javascript';\n \t\tscript.charset = 'utf-8';\n \t\tscript.async = true;\n \t\tscript.timeout = 120000;\n\n \t\tif (__webpack_require__.nc) {\n \t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t}\n \t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".chunk.js\";\n \t\tvar timeout = setTimeout(onScriptComplete, 120000);\n \t\tscript.onerror = script.onload = onScriptComplete;\n \t\tfunction onScriptComplete() {\n \t\t\t// avoid mem leaks in IE.\n \t\t\tscript.onerror = script.onload = null;\n \t\t\tclearTimeout(timeout);\n \t\t\tvar chunk = installedChunks[chunkId];\n \t\t\tif(chunk !== 0) {\n \t\t\t\tif(chunk) {\n \t\t\t\t\tchunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));\n \t\t\t\t}\n \t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t}\n \t\t};\n \t\thead.appendChild(script);\n\n \t\treturn promise;\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap a2817cb54bac8930dec1"],"sourceRoot":"webpack:///"}
--------------------------------------------------------------------------------
/code_final/oj-server1/services/editorSocketService.js:
--------------------------------------------------------------------------------
1 | const redisClient = require('../modules/redisClient');
2 | const TIMEOUT_IN_SECONDS = 3600;
3 | module.exports = function(io) {
4 | // collaboraiton sessions
5 | const collaborations = {};
6 | // {
7 | // 1: {
8 | // 'participants': [123, 234, 345]
9 | // }
10 | // }
11 | // map from socketId to sessionid
12 | const sessionPath = '/temp_sessions/';
13 | const socketIdToSessionId = {};
14 |
15 | io.on('connection', (socket) => {
16 | // console.log(socket);
17 | // const message = socket.handshake.query['message'];
18 | // console.log(message);
19 |
20 | // io.to(socket.id).emit('message', 'hhahaha from server');
21 | const sessionId = socket.handshake.query['sessionId'];
22 |
23 | socketIdToSessionId[socket.id] = sessionId;
24 |
25 | // if (!(sessionId in collaborations)) {
26 | // collaborations[sessionId] = {
27 | // 'participants': []
28 | // };
29 | // }
30 | // collaborations[sessionId]['participants'].push(socket.id);
31 | if (sessionId in collaborations) {
32 | collaborations[sessionId]['participants'].push(socket.id);
33 | } else {
34 | redisClient.get(sessionPath + '/' + sessionId, data => {
35 | if (data) {
36 | console.log('session terminated perviously, pulling back from redis');
37 | collaborations[sessionId] = {
38 | 'cachaedInstructions': JSON.parse(data),
39 | 'participants': []
40 | };
41 | } else {
42 | console.log('creating new session');
43 | collaborations[sessionId] = {
44 | 'cachaedInstructions': [],
45 | 'participants': []
46 | }
47 | }
48 | collaborations[sessionId]['participants'].push(socket.id);
49 | });
50 | }
51 |
52 |
53 | socket.on('change', delta => {
54 | // const sessionId = socketIdToSessionId[socket.id];
55 | // if (sessionId in collaborations) {
56 | // collaborations[sessionId]['cachaedInstructions'].push(['change', delta, Date.now()]);
57 | // }
58 | // if (sessionId in collaborations) {
59 | // const participants = collaborations[sessionId]['participants'];
60 | // for (let participant of participants) {
61 | // if (socket.id !== participant) {
62 | // io.to(participant).emit('change', delta);
63 | // }
64 | // }
65 | // } else {
66 | // console.error('error');
67 | // }
68 | const sessionId = socketIdToSessionId[socket.id];
69 | if (sessionId in collaborations) {
70 | collaborations[sessionId]['cachaedInstructions'].push(['change', delta, Date.now()]);
71 | }
72 |
73 | forwardEvent(socket.id, 'change', delta);
74 | });
75 |
76 | socket.on('cursorMove', cursor => {
77 | console.log('cursor move for session: ' + socketIdToSessionId[socket.id] + ', socketId' + socket.id);
78 | cursor = JSON.parse(cursor);
79 | cursor['socketId'] = socket.id;
80 | forwardEvent(socket.id, 'cursorMove', JSON.stringify(cursor));
81 | });
82 |
83 | socket.on('restoreBuffer', () => {
84 | const sessionId = socketIdToSessionId[socket.id];
85 | if (sessionId in collaborations) {
86 | const instructions = collaborations[sessionId]['cachaedInstructions'];
87 | for (let instruction of instructions) {
88 | socket.emit(instruction[0], instruction[1]);
89 | }
90 | }
91 | });
92 |
93 | socket.on('disconnect', () => {
94 | const sessionId = socketIdToSessionId[socket.id];
95 | let foundAndRemove = false;
96 | if (sessionId in collaborations) {
97 | const participants = collaborations[sessionId]['participants'];
98 | const index = participants.indexOf(socket.id);
99 | if (index >= 0) {
100 | participants.splice(index, 1);
101 | foundAndRemove = true;
102 | if (participants.length === 0) {
103 | const key = sessionPath + '/' + sessionId;
104 | const value = JSON.stringify(collaborations[sessionId]['cachaedInstructions']);
105 | redisClient.set(key, value, redisClient.redisPrint);
106 | redisClient.expire(key, TIMEOUT_IN_SECONDS);
107 | delete collaborations[sessionId];
108 | }
109 | }
110 | }
111 | if (!foundAndRemove) {
112 | console.error('warning');
113 | }
114 | });
115 | });
116 |
117 | const forwardEvent = function(socketId, eventName, dataString) {
118 | const sessionId = socketIdToSessionId[socketId];
119 | if (sessionId in collaborations) {
120 | const participants = collaborations[sessionId]['participants'];
121 | for(let participant of participants) {
122 | if (socketId != participant) {
123 | io.to(participant).emit(eventName, dataString);
124 | }
125 | }
126 | } else {
127 | console.warn('WARNING');
128 | }
129 | }
130 | }
--------------------------------------------------------------------------------
/code_final/public/inline.bundle.js:
--------------------------------------------------------------------------------
1 | /******/ (function(modules) { // webpackBootstrap
2 | /******/ // install a JSONP callback for chunk loading
3 | /******/ var parentJsonpFunction = window["webpackJsonp"];
4 | /******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
5 | /******/ // add "moreModules" to the modules object,
6 | /******/ // then flag all "chunkIds" as loaded and fire callback
7 | /******/ var moduleId, chunkId, i = 0, resolves = [], result;
8 | /******/ for(;i < chunkIds.length; i++) {
9 | /******/ chunkId = chunkIds[i];
10 | /******/ if(installedChunks[chunkId]) {
11 | /******/ resolves.push(installedChunks[chunkId][0]);
12 | /******/ }
13 | /******/ installedChunks[chunkId] = 0;
14 | /******/ }
15 | /******/ for(moduleId in moreModules) {
16 | /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
17 | /******/ modules[moduleId] = moreModules[moduleId];
18 | /******/ }
19 | /******/ }
20 | /******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
21 | /******/ while(resolves.length) {
22 | /******/ resolves.shift()();
23 | /******/ }
24 | /******/ if(executeModules) {
25 | /******/ for(i=0; i < executeModules.length; i++) {
26 | /******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
27 | /******/ }
28 | /******/ }
29 | /******/ return result;
30 | /******/ };
31 | /******/
32 | /******/ // The module cache
33 | /******/ var installedModules = {};
34 | /******/
35 | /******/ // objects to store loaded and loading chunks
36 | /******/ var installedChunks = {
37 | /******/ "inline": 0
38 | /******/ };
39 | /******/
40 | /******/ // The require function
41 | /******/ function __webpack_require__(moduleId) {
42 | /******/
43 | /******/ // Check if module is in cache
44 | /******/ if(installedModules[moduleId]) {
45 | /******/ return installedModules[moduleId].exports;
46 | /******/ }
47 | /******/ // Create a new module (and put it into the cache)
48 | /******/ var module = installedModules[moduleId] = {
49 | /******/ i: moduleId,
50 | /******/ l: false,
51 | /******/ exports: {}
52 | /******/ };
53 | /******/
54 | /******/ // Execute the module function
55 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
56 | /******/
57 | /******/ // Flag the module as loaded
58 | /******/ module.l = true;
59 | /******/
60 | /******/ // Return the exports of the module
61 | /******/ return module.exports;
62 | /******/ }
63 | /******/
64 | /******/ // This file contains only the entry chunk.
65 | /******/ // The chunk loading function for additional chunks
66 | /******/ __webpack_require__.e = function requireEnsure(chunkId) {
67 | /******/ var installedChunkData = installedChunks[chunkId];
68 | /******/ if(installedChunkData === 0) {
69 | /******/ return new Promise(function(resolve) { resolve(); });
70 | /******/ }
71 | /******/
72 | /******/ // a Promise means "currently loading".
73 | /******/ if(installedChunkData) {
74 | /******/ return installedChunkData[2];
75 | /******/ }
76 | /******/
77 | /******/ // setup Promise in chunk cache
78 | /******/ var promise = new Promise(function(resolve, reject) {
79 | /******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
80 | /******/ });
81 | /******/ installedChunkData[2] = promise;
82 | /******/
83 | /******/ // start chunk loading
84 | /******/ var head = document.getElementsByTagName('head')[0];
85 | /******/ var script = document.createElement('script');
86 | /******/ script.type = 'text/javascript';
87 | /******/ script.charset = 'utf-8';
88 | /******/ script.async = true;
89 | /******/ script.timeout = 120000;
90 | /******/
91 | /******/ if (__webpack_require__.nc) {
92 | /******/ script.setAttribute("nonce", __webpack_require__.nc);
93 | /******/ }
94 | /******/ script.src = __webpack_require__.p + "" + chunkId + ".chunk.js";
95 | /******/ var timeout = setTimeout(onScriptComplete, 120000);
96 | /******/ script.onerror = script.onload = onScriptComplete;
97 | /******/ function onScriptComplete() {
98 | /******/ // avoid mem leaks in IE.
99 | /******/ script.onerror = script.onload = null;
100 | /******/ clearTimeout(timeout);
101 | /******/ var chunk = installedChunks[chunkId];
102 | /******/ if(chunk !== 0) {
103 | /******/ if(chunk) {
104 | /******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
105 | /******/ }
106 | /******/ installedChunks[chunkId] = undefined;
107 | /******/ }
108 | /******/ };
109 | /******/ head.appendChild(script);
110 | /******/
111 | /******/ return promise;
112 | /******/ };
113 | /******/
114 | /******/ // expose the modules object (__webpack_modules__)
115 | /******/ __webpack_require__.m = modules;
116 | /******/
117 | /******/ // expose the module cache
118 | /******/ __webpack_require__.c = installedModules;
119 | /******/
120 | /******/ // define getter function for harmony exports
121 | /******/ __webpack_require__.d = function(exports, name, getter) {
122 | /******/ if(!__webpack_require__.o(exports, name)) {
123 | /******/ Object.defineProperty(exports, name, {
124 | /******/ configurable: false,
125 | /******/ enumerable: true,
126 | /******/ get: getter
127 | /******/ });
128 | /******/ }
129 | /******/ };
130 | /******/
131 | /******/ // getDefaultExport function for compatibility with non-harmony modules
132 | /******/ __webpack_require__.n = function(module) {
133 | /******/ var getter = module && module.__esModule ?
134 | /******/ function getDefault() { return module['default']; } :
135 | /******/ function getModuleExports() { return module; };
136 | /******/ __webpack_require__.d(getter, 'a', getter);
137 | /******/ return getter;
138 | /******/ };
139 | /******/
140 | /******/ // Object.prototype.hasOwnProperty.call
141 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
142 | /******/
143 | /******/ // __webpack_public_path__
144 | /******/ __webpack_require__.p = "";
145 | /******/
146 | /******/ // on error function for async loading
147 | /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
148 | /******/ })
149 | /************************************************************************/
150 | /******/ ([]);
151 | //# sourceMappingURL=inline.bundle.js.map
--------------------------------------------------------------------------------
/code_final/public/main.bundle.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["/home/happy/bittigercs503-1705/week-04/oj-client1/src/$_lazy_route_resource lazy","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.component.css","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.component.html","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.component.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.module.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.routes.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/editor/editor.component.css","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/editor/editor.component.html","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/editor/editor.component.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/navbar/navbar.component.css","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/navbar/navbar.component.html","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/navbar/navbar.component.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/new-problem/new-problem.component.css","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/new-problem/new-problem.component.html","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/new-problem/new-problem.component.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-detail/problem-detail.component.css","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-detail/problem-detail.component.html","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-detail/problem-detail.component.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-list/problem-list.component.css","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-list/problem-list.component.html","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-list/problem-list.component.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/services/collaboration.service.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/app/services/data.service.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/assets/colors.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/environments/environment.ts","/home/happy/bittigercs503-1705/week-04/oj-client1/src/main.ts"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,4CAA4C,WAAW;AACvD;AACA;AACA,yF;;;;;;;ACVA;AACA;;;AAGA;AACA;;AAEA;;;AAGA;AACA,2C;;;;;;;ACXA,6E;;;;;;;;;;;;;;;;ACA0C;AAO1C;IALA;QAME,UAAK,GAAG,KAAK,CAAC;IAChB,CAAC;IAFY,YAAY;QALxB,wEAAS,CAAC;YACT,QAAQ,EAAE,UAAU;;;SAGrB,CAAC;OACW,YAAY,CAExB;IAAD,mBAAC;CAAA;AAFwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPiC;AACjB;AACE;AACW;AACtD,0CAA0C;AAEH;AACa;AACoB;AAEzB;AACyC;AACM;AACT;AACd;AACA;AAwBvE;IAAA;IAAyB,CAAC;IAAb,SAAS;QArBrB,uEAAQ,CAAC;YACR,YAAY,EAAE;gBACZ,oEAAY;gBACZ,6GAAoB;gBACpB,mHAAsB;gBACtB,2GAAmB;gBACnB,6FAAe;gBACf,6FAAe;aAChB;YACD,OAAO,EAAE;gBACP,gFAAa;gBACb,4DAAO;gBACP,mEAAW;gBACX,8EAAgB;aACjB;YACD,SAAS,EAAE;gBACT,2EAAW;gBACX,6FAAoB;aACrB;YACD,SAAS,EAAE,CAAC,oEAAY,CAAC;SAC1B,CAAC;OACW,SAAS,CAAI;IAAD,gBAAC;CAAA;AAAJ;;;;;;;;;;;;;ACvC+B;AACiC;AACM;AAE5F,IAAM,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ACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAC;;;;;;;;;ACxCJ;AAAA,mFAAmF;AACnF,8FAA8F;AAC9F,yEAAyE;AACzE,gFAAgF;AAEzE,IAAM,WAAW,GAAG;IACzB,UAAU,EAAE,KAAK;CAClB,CAAC;;;;;;;;;;;;;;ACP6C;AAC4B;AAE9B;AACY;AAEzD,EAAE,CAAC,CAAC,8EAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3B,+EAAc,EAAE,CAAC;AACnB,CAAC;AAED,yGAAsB,EAAE,CAAC,eAAe,CAAC,kEAAS,CAAC;KAChD,KAAK,CAAC,aAAG,IAAI,cAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAhB,CAAgB,CAAC,CAAC","file":"main.bundle.js","sourcesContent":["function webpackEmptyAsyncContext(req) {\n\t// Here Promise.resolve().then() is used instead of new Promise() to prevent\n\t// uncatched exception popping up in devtools\n\treturn Promise.resolve().then(function() {\n\t\tthrow new Error(\"Cannot find module '\" + req + \"'.\");\n\t});\n}\nwebpackEmptyAsyncContext.keys = function() { return []; };\nwebpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;\nmodule.exports = webpackEmptyAsyncContext;\nwebpackEmptyAsyncContext.id = \"../../../../../src/$$_lazy_route_resource lazy recursive\";\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/$$_lazy_route_resource lazy\n// module id = ../../../../../src/$$_lazy_route_resource lazy recursive\n// module chunks = main","exports = module.exports = require(\"../../node_modules/css-loader/lib/css-base.js\")(false);\n// imports\n\n\n// module\nexports.push([module.id, \"\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.component.css\n// module id = ../../../../../src/app/app.component.css\n// module chunks = main","module.exports = \"\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.component.html\n// module id = ../../../../../src/app/app.component.html\n// module chunks = main","import { Component } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n templateUrl: './app.component.html',\n styleUrls: ['./app.component.css']\n})\nexport class AppComponent {\n title = 'app';\n}\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.component.ts","import { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {HttpClientModule} from '@angular/common/http';\n//import {HttpModle} from '@angular/http';\n\nimport { routing } from './app.routes';\nimport {DataService} from './services/data.service';\nimport { CollaborationService } from './services/collaboration.service';\n\nimport { AppComponent } from './app.component';\nimport { ProblemListComponent } from './components/problem-list/problem-list.component';\nimport { ProblemDetailComponent } from './components/problem-detail/problem-detail.component';\nimport { NewProblemComponent } from './components/new-problem/new-problem.component';\nimport { NavbarComponent } from './components/navbar/navbar.component';\nimport { EditorComponent } from './components/editor/editor.component';\n\n\n@NgModule({\n declarations: [\n AppComponent,\n ProblemListComponent,\n ProblemDetailComponent,\n NewProblemComponent,\n NavbarComponent,\n EditorComponent\n ],\n imports: [\n BrowserModule,\n routing,\n FormsModule,\n HttpClientModule\n ],\n providers: [\n DataService,\n CollaborationService\n ],\n bootstrap: [AppComponent]\n})\nexport class AppModule { }\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.module.ts","import {Routes, RouterModule} from '@angular/router';\nimport {ProblemListComponent} from './components/problem-list/problem-list.component';\nimport {ProblemDetailComponent} from './components/problem-detail/problem-detail.component';\n\nconst routes: Routes = [\n {\n path: '',\n redirectTo: 'problems',\n pathMatch: 'full'\n },\n { \n path: 'problems',\n component: ProblemListComponent\n },\n {\n path: 'problems/:id',\n component: ProblemDetailComponent\n },\n {\n path: '**',\n redirectTo: 'problems'\n }\n];\nexport const routing = RouterModule.forRoot(routes);\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/app.routes.ts","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")(false);\n// imports\n\n\n// module\nexports.push([module.id, \"@media screen {\\n #editor {\\n height: 600px;\\n }\\n .lang-select {\\n width: 100px;\\n margin-right: 10px;\\n }\\n header .btn {\\n margin: 0 5px;\\n }\\n footer .btn {\\n margin: 0 5px;\\n }\\n .editor-footer, .editor-header {\\n margin: 10px 0;\\n }\\n .cursor {\\n /*position:absolute;*/\\n background: rgba(0, 250, 0, 0.5);\\n z-index: 40;\\n width: 2px !important;\\n }\\n }\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/editor/editor.component.css\n// module id = ../../../../../src/app/components/editor/editor.component.css\n// module chunks = main","module.exports = \"\\n \\n \\n
\\n
\\n
\\n {{output}}\\n
\\n
\\n \\n\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/editor/editor.component.html\n// module id = ../../../../../src/app/components/editor/editor.component.html\n// module chunks = main","import { Component, OnInit } from '@angular/core';\nimport { ActivatedRoute, Params } from '@angular/router';\nimport { CollaborationService } from '../../services/collaboration.service';\nimport { DataService} from '../../services/data.service';\ndeclare const ace: any;\n@Component({\n selector: 'app-editor',\n templateUrl: './editor.component.html',\n styleUrls: ['./editor.component.css']\n})\nexport class EditorComponent implements OnInit {\n sessionId: string;\n languages: string[] = ['Java', 'Python'];\n language: string = 'Java';\n editor: any;\n defaultContent = {\n 'Java': `public class Example {\n public static void main(String[] args) {\n // Type your Java code here\n }\n }`,\n 'Python': `class Solution:\n def example():\n # Write your Python code here`\n };\n output: string = '';\n constructor(private collaboration: CollaborationService,\n private route: ActivatedRoute,\n private dataService: DataService) { }\n\n ngOnInit() {\n this.route.params\n .subscribe(params => {\n this.sessionId = params['id'];\n this.initEditor();\n this.collaboration.restoreBuffer();\n });\n }\n\n initEditor(): void {\n this.editor = ace.edit(\"editor\");\n this.editor.setTheme(\"ace/theme/eclipse\");\n this.resetEditor();\n this.editor.$blockScrolling = Infinity;\n\n // set up collaboration socket\n this.collaboration.init(this.editor, this.sessionId);\n this.editor.lastAppliedChange = null;\n\n // register change callback\n this.editor.on('change', (e) => {\n console.log('editor change: ' + JSON.stringify(e));\n if (this.editor.lastAppliedChange != e) {\n this.collaboration.change(JSON.stringify(e));\n }\n });\n\n this.editor.getSession().getSelection().on('changeCursor', ()=> {\n const cursor = this.editor.getSession().getSelection().getCursor();\n console.log('curser move log from client' + JSON.stringify(cursor));\n this.collaboration.cursorMove(JSON.stringify(cursor));\n });\n }\n\n resetEditor(): void {\n this.editor.setValue(this.defaultContent[this.language]);\n this.editor.getSession().setMode(\"ace/mode/\" + this.language.toLowerCase());\n }\n\n setLanguage(language: string): void {\n this.language = language;\n this.resetEditor();\n }\n\n submit(): void {\n const userCodes = this.editor.getValue();\n const data = {\n userCodes: userCodes,\n lang: this.language.toLocaleLowerCase()\n };\n //console.log(userCodes);\n this.dataService.buildAndRun(data)\n .then(res => this.output = res.text);\n }\n\n}\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/editor/editor.component.ts","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")(false);\n// imports\n\n\n// module\nexports.push([module.id, \"\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/navbar/navbar.component.css\n// module id = ../../../../../src/app/components/navbar/navbar.component.css\n// module chunks = main","module.exports = \"\\n
\\n
\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/navbar/navbar.component.html\n// module id = ../../../../../src/app/components/navbar/navbar.component.html\n// module chunks = main","import { Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-navbar',\n templateUrl: './navbar.component.html',\n styleUrls: ['./navbar.component.css']\n})\nexport class NavbarComponent implements OnInit {\n\n constructor() { }\n\n ngOnInit() {\n }\n\n}\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/navbar/navbar.component.ts","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")(false);\n// imports\n\n\n// module\nexports.push([module.id, \"\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/new-problem/new-problem.component.css\n// module id = ../../../../../src/app/components/new-problem/new-problem.component.css\n// module chunks = main","module.exports = \"\\n
\\n
\\n
\\n
\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/new-problem/new-problem.component.html\n// module id = ../../../../../src/app/components/new-problem/new-problem.component.html\n// module chunks = main","import { Component, OnInit } from '@angular/core';\nimport {Problem} from'../../models/problem.model';\nimport {DataService} from '../../services/data.service';\nconst DEFAULT_PROBLEM: Problem = Object.freeze({\n id: 0,\n name: '',\n desc: '',\n difficulty: 'easy'\n});\n@Component({\n selector: 'app-new-problem',\n templateUrl: './new-problem.component.html',\n styleUrls: ['./new-problem.component.css']\n})\nexport class NewProblemComponent implements OnInit {\n newProblem: Problem = Object.assign({}, DEFAULT_PROBLEM);\n difficulties: string[] = ['easy','medium','hard','super'];\n\n constructor(private dataService: DataService) { }\n\n ngOnInit() {\n }\n addProblem(){\n this.dataService.addProblem(this.newProblem);\n this.newProblem = Object.assign({}, DEFAULT_PROBLEM);\n }\n\n}\n\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/new-problem/new-problem.component.ts","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")(false);\n// imports\n\n\n// module\nexports.push([module.id, \"\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-detail/problem-detail.component.css\n// module id = ../../../../../src/app/components/problem-detail/problem-detail.component.css\n// module chunks = main","module.exports = \"\\n
\\n
\\n
\\n {{problem.id}}. {{problem.name}}\\n
\\n
\\n {{problem.desc}}\\n
\\n
\\n\\n
\\n
\\n\\n
\\n\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-detail/problem-detail.component.html\n// module id = ../../../../../src/app/components/problem-detail/problem-detail.component.html\n// module chunks = main","import { Component, OnInit } from '@angular/core';\nimport {ActivatedRoute, Params} from '@angular/router';\nimport {Problem} from '../../models/problem.model';\nimport {DataService} from '../../services/data.service';\n@Component({\n selector: 'app-problem-detail',\n templateUrl: './problem-detail.component.html',\n styleUrls: ['./problem-detail.component.css']\n})\nexport class ProblemDetailComponent implements OnInit {\n problem: Problem;\n constructor(private dataService: DataService, private route: ActivatedRoute) { }\n\n ngOnInit() {\n this.route.params.subscribe(params=>{\n //this.problem = this.dataService.getProblem(+params['id']);\n this.dataService.getProblem(+params['id'])\n .then(problem => this.problem =problem);\n });\n }\n\n}\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-detail/problem-detail.component.ts","exports = module.exports = require(\"../../../../node_modules/css-loader/lib/css-base.js\")(false);\n// imports\n\n\n// module\nexports.push([module.id, \".difficulty {\\n min-width: 65px;\\n margin-right: 10px;\\n}\\n.label.difficulty {\\n padding-top: 0.6em;\\n color: #fbfdfa;\\n font-size: 12px;\\n}\\n.title {\\n font-size: 1.2em;\\n}\\n.diff-easy {\\n background-color: #42ebf4;\\n}\\n.diff-medium {\\n background-color: #92cf5c;\\n}\\n.diff-hard {\\n background-color: #dd0d1e;\\n}\\n.diff-super {\\n background-color: #8d16e2;\\n}\", \"\"]);\n\n// exports\n\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = module.exports.toString();\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-list/problem-list.component.css\n// module id = ../../../../../src/app/components/problem-list/problem-list.component.css\n// module chunks = main","module.exports = \"\"\n\n\n//////////////////\n// WEBPACK FOOTER\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-list/problem-list.component.html\n// module id = ../../../../../src/app/components/problem-list/problem-list.component.html\n// module chunks = main","import { Component, OnInit, OnDestroy } from '@angular/core';\nimport {Subscription} from 'rxjs/Subscription';\nimport {Problem} from '../../models/problem.model';\n//import {PROBLEMS} from '../../mock-problems';\nimport {DataService} from '../../services/data.service';\n\n@Component({\n selector: 'app-problem-list',\n templateUrl: './problem-list.component.html',\n styleUrls: ['./problem-list.component.css']\n})\nexport class ProblemListComponent implements OnInit, OnDestroy {\n\n problems: Problem[];\n subscriptionProblems: Subscription;\n\n constructor(private dataService: DataService) { }\n\n ngOnInit() {\n this.getProblems();\n }\n ngOnDestroy(){\n this.subscriptionProblems.unsubscribe();\n }\n getProblems(): void {\n //this.problems = this.dataService.getProblems();\n this.subscriptionProblems = this.dataService.getProblems()\n .subscribe(problems => this.problems = problems);\n }\n\n}\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/components/problem-list/problem-list.component.ts","import { Injectable } from '@angular/core';\nimport { COLORS } from '../../assets/colors';\n\ndeclare const io: any;\ndeclare const ace: any;\n@Injectable()\nexport class CollaborationService {\n clientsInfo: Object = {};\n clientNum: number = 0;\n collaborationSocket: any;\n constructor() { }\n\n init(editor: any, sessionId: string): void {\n this.collaborationSocket = io(window.location.origin, { query: 'sessionId=' + sessionId});\n\n // this.collaborationSocket.on('message', (message) => {\n // console.log('message received from server: ' + message);\n // });\n this.collaborationSocket.on('change', (delta: string) => {\n delta = JSON.parse(delta);\n editor.lastAppliedChange = delta;\n editor.getSession().getDocument().applyDeltas([delta]);\n });\n\n this.collaborationSocket.on('cursorMove', (cursor: string) => {\n console.log('cursor move' + cursor);\n const session = editor.getSession();\n cursor = JSON.parse(cursor);\n const x = cursor['row'];\n const y = cursor['column'];\n const changeClientId = cursor['socketId'];\n console.log(x + ' ' + y + changeClientId);\n\n if (changeClientId in this.clientsInfo) {\n session.removeMarker(this.clientsInfo[changeClientId]['marker']);\n } else {\n this.clientsInfo[changeClientId] = {};\n const css = document.createElement('style');\n css.type = 'text/css';\n css.innerHTML = `.editor_cursor_${changeClientId}\n { \n position:absolute;\n background:${COLORS[this.clientNum]};\u000b\n z-index:100;\n width:3px !important;\n }`;\u000b\n document.body.appendChild(css);\n this.clientNum++;\n }\n const Range = ace.require('ace/range').Range;\n const newMarker = session.addMarker(new Range(x, y, x, y + 1), `editor_cursor_${changeClientId}`, true);\n this.clientsInfo[changeClientId]['marker'] = newMarker;\n });\n }\n\n change(delta: string): void {\n this.collaborationSocket.emit('change', delta);\n }\n\n cursorMove(cursor: string) {\n this.collaborationSocket.emit('cursorMove', cursor);\n }\n\n restoreBuffer(): void {\n this.collaborationSocket.emit('restoreBuffer');\n }\n \n}\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/services/collaboration.service.ts","import { Injectable } from '@angular/core';\nimport { HttpClient, HttpHeaders, HttpResponse} from '@angular/common/http';\nimport { Observable } from 'rxjs/Rx';\nimport { BehaviorSubject } from 'rxjs/BehaviorSubject';\nimport 'rxjs/add/operator/toPromise';\n\nimport { Problem } from '../models/problem.model';\n// import { PROBLEMS } from '../mock-problems';\n@Injectable()\nexport class DataService {\n // problems: Problem[] = PROBLEMS;\n private _problemSource = new BehaviorSubject([]);\n\n constructor(private httpClient: HttpClient) { }\n\n getProblems(): Observable {\n // return this.problems;\n this.httpClient.get('api/v1/problems')\n .toPromise()\n .then((res: any) => {\n this._problemSource.next(res);\n })\n .catch(this.handleError);\n return this._problemSource.asObservable();\n }\n// values, complete, error\n getProblem(id: number): Promise {\n // return this.problems.find( (problem) => problem.id === id);\n return this.httpClient.get(`api/v1/problems/${id}`)\n .toPromise()\n .then((res: any) => res)\n .catch(this.handleError);\n }\n\n addProblem(problem: Problem) {\n // problem.id = this.problems.length + 1;\n // this.problems.push(problem);\n const options = { headers: new HttpHeaders({ 'Content-Type': 'application/json'})};\n return this.httpClient.post('api/v1/problems', problem, options)\n .toPromise()\n .then((res: any) => {\n this.getProblems();\n return res;\n })\n .catch(this.handleError);\n }\n\n buildAndRun(data): Promise {\n const options = {headers: new HttpHeaders({ 'Content-Type': 'application/json'})};\n return this.httpClient.post('api/v1/build_and_run', data, options)\n .toPromise()\n .then(res => {\n console.log(res);\n return res;\n })\n .catch(this.handleError);\n }\n\n private handleError(error: any): Promise {\n return Promise.reject(error.body || error);\n }\n}\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/app/services/data.service.ts","export const COLORS: [string] = [ \n \"#0000ff\", \n \"#a52a2a\", \n \"#00ffff\", \n \"#00008b\", \n \"#008b8b\", \n \"#a9a9a9\", \n \"#006400\", \n \"#bdb76b\", \n \"#8b008b\", \n \"#556b2f\", \n \"#ff8c00\", \n \"#9932cc\", \n \"#8b0000\", \n \"#e9967a\", \n \"#9400d3\", \n \"#ff00ff\", \n \"#ffd700\", \n \"#008000\", \n \"#4b0082\", \n \"#f0e68c\", \n \"#add8e6\", \n \"#e0ffff\", \n \"#90ee90\", \n \"#d3d3d3\", \n \"#ffb6c1\", \n \"#ffffe0\", \n \"#00ff00\", \n \"#ff00ff\", \n \"#800000\", \n \"#000080\", \n \"#808000\", \n \"#ffa500\", \n \"#ffc0cb\", \n \"#800080\", \n \"#800080\", \n \"#ff0000\", \n \"#c0c0c0\", \n \"#ffffff\", \n \"#ffff00\" \n ];\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/assets/colors.ts","// The file contents for the current environment will overwrite these during build.\n// The build system defaults to the dev environment which uses `environment.ts`, but if you do\n// `ng build --env=prod` then `environment.prod.ts` will be used instead.\n// The list of which env maps to which file can be found in `.angular-cli.json`.\n\nexport const environment = {\n production: false\n};\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/environments/environment.ts","import { enableProdMode } from '@angular/core';\nimport { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\n\nimport { AppModule } from './app/app.module';\nimport { environment } from './environments/environment';\n\nif (environment.production) {\n enableProdMode();\n}\n\nplatformBrowserDynamic().bootstrapModule(AppModule)\n .catch(err => console.log(err));\n\n\n\n// WEBPACK FOOTER //\n// /home/happy/bittigercs503-1705/week-04/oj-client1/src/main.ts"],"sourceRoot":"webpack:///"}
--------------------------------------------------------------------------------
/code_final/public/main.bundle.js:
--------------------------------------------------------------------------------
1 | webpackJsonp(["main"],{
2 |
3 | /***/ "../../../../../src/$$_lazy_route_resource lazy recursive":
4 | /***/ (function(module, exports) {
5 |
6 | function webpackEmptyAsyncContext(req) {
7 | // Here Promise.resolve().then() is used instead of new Promise() to prevent
8 | // uncatched exception popping up in devtools
9 | return Promise.resolve().then(function() {
10 | throw new Error("Cannot find module '" + req + "'.");
11 | });
12 | }
13 | webpackEmptyAsyncContext.keys = function() { return []; };
14 | webpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;
15 | module.exports = webpackEmptyAsyncContext;
16 | webpackEmptyAsyncContext.id = "../../../../../src/$$_lazy_route_resource lazy recursive";
17 |
18 | /***/ }),
19 |
20 | /***/ "../../../../../src/app/app.component.css":
21 | /***/ (function(module, exports, __webpack_require__) {
22 |
23 | exports = module.exports = __webpack_require__("../../../../css-loader/lib/css-base.js")(false);
24 | // imports
25 |
26 |
27 | // module
28 | exports.push([module.i, "", ""]);
29 |
30 | // exports
31 |
32 |
33 | /*** EXPORTS FROM exports-loader ***/
34 | module.exports = module.exports.toString();
35 |
36 | /***/ }),
37 |
38 | /***/ "../../../../../src/app/app.component.html":
39 | /***/ (function(module, exports) {
40 |
41 | module.exports = "\n"
42 |
43 | /***/ }),
44 |
45 | /***/ "../../../../../src/app/app.component.ts":
46 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
47 |
48 | "use strict";
49 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppComponent; });
50 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
51 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
52 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
53 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
54 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
55 | return c > 3 && r && Object.defineProperty(target, key, r), r;
56 | };
57 |
58 | var AppComponent = (function () {
59 | function AppComponent() {
60 | this.title = 'app';
61 | }
62 | AppComponent = __decorate([
63 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
64 | selector: 'app-root',
65 | template: __webpack_require__("../../../../../src/app/app.component.html"),
66 | styles: [__webpack_require__("../../../../../src/app/app.component.css")]
67 | })
68 | ], AppComponent);
69 | return AppComponent;
70 | }());
71 |
72 |
73 |
74 | /***/ }),
75 |
76 | /***/ "../../../../../src/app/app.module.ts":
77 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
78 |
79 | "use strict";
80 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppModule; });
81 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_platform_browser__ = __webpack_require__("../../../platform-browser/esm5/platform-browser.js");
82 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
83 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__angular_forms__ = __webpack_require__("../../../forms/esm5/forms.js");
84 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__angular_common_http__ = __webpack_require__("../../../common/esm5/http.js");
85 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__app_routes__ = __webpack_require__("../../../../../src/app/app.routes.ts");
86 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__services_data_service__ = __webpack_require__("../../../../../src/app/services/data.service.ts");
87 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__services_collaboration_service__ = __webpack_require__("../../../../../src/app/services/collaboration.service.ts");
88 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__app_component__ = __webpack_require__("../../../../../src/app/app.component.ts");
89 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__components_problem_list_problem_list_component__ = __webpack_require__("../../../../../src/app/components/problem-list/problem-list.component.ts");
90 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__components_problem_detail_problem_detail_component__ = __webpack_require__("../../../../../src/app/components/problem-detail/problem-detail.component.ts");
91 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__components_new_problem_new_problem_component__ = __webpack_require__("../../../../../src/app/components/new-problem/new-problem.component.ts");
92 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__components_navbar_navbar_component__ = __webpack_require__("../../../../../src/app/components/navbar/navbar.component.ts");
93 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__components_editor_editor_component__ = __webpack_require__("../../../../../src/app/components/editor/editor.component.ts");
94 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
95 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
96 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
97 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
98 | return c > 3 && r && Object.defineProperty(target, key, r), r;
99 | };
100 |
101 |
102 |
103 |
104 | //import {HttpModle} from '@angular/http';
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | var AppModule = (function () {
115 | function AppModule() {
116 | }
117 | AppModule = __decorate([
118 | Object(__WEBPACK_IMPORTED_MODULE_1__angular_core__["I" /* NgModule */])({
119 | declarations: [
120 | __WEBPACK_IMPORTED_MODULE_7__app_component__["a" /* AppComponent */],
121 | __WEBPACK_IMPORTED_MODULE_8__components_problem_list_problem_list_component__["a" /* ProblemListComponent */],
122 | __WEBPACK_IMPORTED_MODULE_9__components_problem_detail_problem_detail_component__["a" /* ProblemDetailComponent */],
123 | __WEBPACK_IMPORTED_MODULE_10__components_new_problem_new_problem_component__["a" /* NewProblemComponent */],
124 | __WEBPACK_IMPORTED_MODULE_11__components_navbar_navbar_component__["a" /* NavbarComponent */],
125 | __WEBPACK_IMPORTED_MODULE_12__components_editor_editor_component__["a" /* EditorComponent */]
126 | ],
127 | imports: [
128 | __WEBPACK_IMPORTED_MODULE_0__angular_platform_browser__["a" /* BrowserModule */],
129 | __WEBPACK_IMPORTED_MODULE_4__app_routes__["a" /* routing */],
130 | __WEBPACK_IMPORTED_MODULE_2__angular_forms__["a" /* FormsModule */],
131 | __WEBPACK_IMPORTED_MODULE_3__angular_common_http__["b" /* HttpClientModule */]
132 | ],
133 | providers: [
134 | __WEBPACK_IMPORTED_MODULE_5__services_data_service__["a" /* DataService */],
135 | __WEBPACK_IMPORTED_MODULE_6__services_collaboration_service__["a" /* CollaborationService */]
136 | ],
137 | bootstrap: [__WEBPACK_IMPORTED_MODULE_7__app_component__["a" /* AppComponent */]]
138 | })
139 | ], AppModule);
140 | return AppModule;
141 | }());
142 |
143 |
144 |
145 | /***/ }),
146 |
147 | /***/ "../../../../../src/app/app.routes.ts":
148 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
149 |
150 | "use strict";
151 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return routing; });
152 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_router__ = __webpack_require__("../../../router/esm5/router.js");
153 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_problem_list_problem_list_component__ = __webpack_require__("../../../../../src/app/components/problem-list/problem-list.component.ts");
154 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_problem_detail_problem_detail_component__ = __webpack_require__("../../../../../src/app/components/problem-detail/problem-detail.component.ts");
155 |
156 |
157 |
158 | var routes = [
159 | {
160 | path: '',
161 | redirectTo: 'problems',
162 | pathMatch: 'full'
163 | },
164 | {
165 | path: 'problems',
166 | component: __WEBPACK_IMPORTED_MODULE_1__components_problem_list_problem_list_component__["a" /* ProblemListComponent */]
167 | },
168 | {
169 | path: 'problems/:id',
170 | component: __WEBPACK_IMPORTED_MODULE_2__components_problem_detail_problem_detail_component__["a" /* ProblemDetailComponent */]
171 | },
172 | {
173 | path: '**',
174 | redirectTo: 'problems'
175 | }
176 | ];
177 | var routing = __WEBPACK_IMPORTED_MODULE_0__angular_router__["b" /* RouterModule */].forRoot(routes);
178 |
179 |
180 | /***/ }),
181 |
182 | /***/ "../../../../../src/app/components/editor/editor.component.css":
183 | /***/ (function(module, exports, __webpack_require__) {
184 |
185 | exports = module.exports = __webpack_require__("../../../../css-loader/lib/css-base.js")(false);
186 | // imports
187 |
188 |
189 | // module
190 | exports.push([module.i, "@media screen {\n #editor {\n height: 600px;\n }\n .lang-select {\n width: 100px;\n margin-right: 10px;\n }\n header .btn {\n margin: 0 5px;\n }\n footer .btn {\n margin: 0 5px;\n }\n .editor-footer, .editor-header {\n margin: 10px 0;\n }\n .cursor {\n /*position:absolute;*/\n background: rgba(0, 250, 0, 0.5);\n z-index: 40;\n width: 2px !important;\n }\n }", ""]);
191 |
192 | // exports
193 |
194 |
195 | /*** EXPORTS FROM exports-loader ***/
196 | module.exports = module.exports.toString();
197 |
198 | /***/ }),
199 |
200 | /***/ "../../../../../src/app/components/editor/editor.component.html":
201 | /***/ (function(module, exports) {
202 |
203 | module.exports = "\n \n \n
\n
\n
\n {{output}}\n
\n
\n \n\n"
204 |
205 | /***/ }),
206 |
207 | /***/ "../../../../../src/app/components/editor/editor.component.ts":
208 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
209 |
210 | "use strict";
211 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return EditorComponent; });
212 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
213 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_router__ = __webpack_require__("../../../router/esm5/router.js");
214 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__services_collaboration_service__ = __webpack_require__("../../../../../src/app/services/collaboration.service.ts");
215 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__services_data_service__ = __webpack_require__("../../../../../src/app/services/data.service.ts");
216 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
217 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
218 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
219 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
220 | return c > 3 && r && Object.defineProperty(target, key, r), r;
221 | };
222 | var __metadata = (this && this.__metadata) || function (k, v) {
223 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
224 | };
225 |
226 |
227 |
228 |
229 | var EditorComponent = (function () {
230 | function EditorComponent(collaboration, route, dataService) {
231 | this.collaboration = collaboration;
232 | this.route = route;
233 | this.dataService = dataService;
234 | this.languages = ['Java', 'Python'];
235 | this.language = 'Java';
236 | this.defaultContent = {
237 | 'Java': "public class Example {\n public static void main(String[] args) {\n // Type your Java code here\n }\n }",
238 | 'Python': "class Solution:\n def example():\n # Write your Python code here"
239 | };
240 | this.output = '';
241 | }
242 | EditorComponent.prototype.ngOnInit = function () {
243 | var _this = this;
244 | this.route.params
245 | .subscribe(function (params) {
246 | _this.sessionId = params['id'];
247 | _this.initEditor();
248 | _this.collaboration.restoreBuffer();
249 | });
250 | };
251 | EditorComponent.prototype.initEditor = function () {
252 | var _this = this;
253 | this.editor = ace.edit("editor");
254 | this.editor.setTheme("ace/theme/eclipse");
255 | this.resetEditor();
256 | this.editor.$blockScrolling = Infinity;
257 | // set up collaboration socket
258 | this.collaboration.init(this.editor, this.sessionId);
259 | this.editor.lastAppliedChange = null;
260 | // register change callback
261 | this.editor.on('change', function (e) {
262 | console.log('editor change: ' + JSON.stringify(e));
263 | if (_this.editor.lastAppliedChange != e) {
264 | _this.collaboration.change(JSON.stringify(e));
265 | }
266 | });
267 | this.editor.getSession().getSelection().on('changeCursor', function () {
268 | var cursor = _this.editor.getSession().getSelection().getCursor();
269 | console.log('curser move log from client' + JSON.stringify(cursor));
270 | _this.collaboration.cursorMove(JSON.stringify(cursor));
271 | });
272 | };
273 | EditorComponent.prototype.resetEditor = function () {
274 | this.editor.setValue(this.defaultContent[this.language]);
275 | this.editor.getSession().setMode("ace/mode/" + this.language.toLowerCase());
276 | };
277 | EditorComponent.prototype.setLanguage = function (language) {
278 | this.language = language;
279 | this.resetEditor();
280 | };
281 | EditorComponent.prototype.submit = function () {
282 | var _this = this;
283 | var userCodes = this.editor.getValue();
284 | var data = {
285 | userCodes: userCodes,
286 | lang: this.language.toLocaleLowerCase()
287 | };
288 | //console.log(userCodes);
289 | this.dataService.buildAndRun(data)
290 | .then(function (res) { return _this.output = res.text; });
291 | };
292 | EditorComponent = __decorate([
293 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
294 | selector: 'app-editor',
295 | template: __webpack_require__("../../../../../src/app/components/editor/editor.component.html"),
296 | styles: [__webpack_require__("../../../../../src/app/components/editor/editor.component.css")]
297 | }),
298 | __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2__services_collaboration_service__["a" /* CollaborationService */],
299 | __WEBPACK_IMPORTED_MODULE_1__angular_router__["a" /* ActivatedRoute */],
300 | __WEBPACK_IMPORTED_MODULE_3__services_data_service__["a" /* DataService */]])
301 | ], EditorComponent);
302 | return EditorComponent;
303 | }());
304 |
305 |
306 |
307 | /***/ }),
308 |
309 | /***/ "../../../../../src/app/components/navbar/navbar.component.css":
310 | /***/ (function(module, exports, __webpack_require__) {
311 |
312 | exports = module.exports = __webpack_require__("../../../../css-loader/lib/css-base.js")(false);
313 | // imports
314 |
315 |
316 | // module
317 | exports.push([module.i, "", ""]);
318 |
319 | // exports
320 |
321 |
322 | /*** EXPORTS FROM exports-loader ***/
323 | module.exports = module.exports.toString();
324 |
325 | /***/ }),
326 |
327 | /***/ "../../../../../src/app/components/navbar/navbar.component.html":
328 | /***/ (function(module, exports) {
329 |
330 | module.exports = "\n
\n
"
331 |
332 | /***/ }),
333 |
334 | /***/ "../../../../../src/app/components/navbar/navbar.component.ts":
335 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
336 |
337 | "use strict";
338 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NavbarComponent; });
339 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
340 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
341 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
342 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
343 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
344 | return c > 3 && r && Object.defineProperty(target, key, r), r;
345 | };
346 | var __metadata = (this && this.__metadata) || function (k, v) {
347 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
348 | };
349 |
350 | var NavbarComponent = (function () {
351 | function NavbarComponent() {
352 | }
353 | NavbarComponent.prototype.ngOnInit = function () {
354 | };
355 | NavbarComponent = __decorate([
356 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
357 | selector: 'app-navbar',
358 | template: __webpack_require__("../../../../../src/app/components/navbar/navbar.component.html"),
359 | styles: [__webpack_require__("../../../../../src/app/components/navbar/navbar.component.css")]
360 | }),
361 | __metadata("design:paramtypes", [])
362 | ], NavbarComponent);
363 | return NavbarComponent;
364 | }());
365 |
366 |
367 |
368 | /***/ }),
369 |
370 | /***/ "../../../../../src/app/components/new-problem/new-problem.component.css":
371 | /***/ (function(module, exports, __webpack_require__) {
372 |
373 | exports = module.exports = __webpack_require__("../../../../css-loader/lib/css-base.js")(false);
374 | // imports
375 |
376 |
377 | // module
378 | exports.push([module.i, "", ""]);
379 |
380 | // exports
381 |
382 |
383 | /*** EXPORTS FROM exports-loader ***/
384 | module.exports = module.exports.toString();
385 |
386 | /***/ }),
387 |
388 | /***/ "../../../../../src/app/components/new-problem/new-problem.component.html":
389 | /***/ (function(module, exports) {
390 |
391 | module.exports = "\n
\n
\n
\n
\n"
392 |
393 | /***/ }),
394 |
395 | /***/ "../../../../../src/app/components/new-problem/new-problem.component.ts":
396 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
397 |
398 | "use strict";
399 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NewProblemComponent; });
400 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
401 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__services_data_service__ = __webpack_require__("../../../../../src/app/services/data.service.ts");
402 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
403 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
404 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
405 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
406 | return c > 3 && r && Object.defineProperty(target, key, r), r;
407 | };
408 | var __metadata = (this && this.__metadata) || function (k, v) {
409 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
410 | };
411 |
412 |
413 | var DEFAULT_PROBLEM = Object.freeze({
414 | id: 0,
415 | name: '',
416 | desc: '',
417 | difficulty: 'easy'
418 | });
419 | var NewProblemComponent = (function () {
420 | function NewProblemComponent(dataService) {
421 | this.dataService = dataService;
422 | this.newProblem = Object.assign({}, DEFAULT_PROBLEM);
423 | this.difficulties = ['easy', 'medium', 'hard', 'super'];
424 | }
425 | NewProblemComponent.prototype.ngOnInit = function () {
426 | };
427 | NewProblemComponent.prototype.addProblem = function () {
428 | this.dataService.addProblem(this.newProblem);
429 | this.newProblem = Object.assign({}, DEFAULT_PROBLEM);
430 | };
431 | NewProblemComponent = __decorate([
432 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
433 | selector: 'app-new-problem',
434 | template: __webpack_require__("../../../../../src/app/components/new-problem/new-problem.component.html"),
435 | styles: [__webpack_require__("../../../../../src/app/components/new-problem/new-problem.component.css")]
436 | }),
437 | __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1__services_data_service__["a" /* DataService */]])
438 | ], NewProblemComponent);
439 | return NewProblemComponent;
440 | }());
441 |
442 |
443 |
444 | /***/ }),
445 |
446 | /***/ "../../../../../src/app/components/problem-detail/problem-detail.component.css":
447 | /***/ (function(module, exports, __webpack_require__) {
448 |
449 | exports = module.exports = __webpack_require__("../../../../css-loader/lib/css-base.js")(false);
450 | // imports
451 |
452 |
453 | // module
454 | exports.push([module.i, "", ""]);
455 |
456 | // exports
457 |
458 |
459 | /*** EXPORTS FROM exports-loader ***/
460 | module.exports = module.exports.toString();
461 |
462 | /***/ }),
463 |
464 | /***/ "../../../../../src/app/components/problem-detail/problem-detail.component.html":
465 | /***/ (function(module, exports) {
466 |
467 | module.exports = "\n
\n
\n
\n {{problem.id}}. {{problem.name}}\n
\n
\n {{problem.desc}}\n
\n
\n\n
\n
\n\n
\n"
468 |
469 | /***/ }),
470 |
471 | /***/ "../../../../../src/app/components/problem-detail/problem-detail.component.ts":
472 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
473 |
474 | "use strict";
475 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ProblemDetailComponent; });
476 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
477 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_router__ = __webpack_require__("../../../router/esm5/router.js");
478 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__services_data_service__ = __webpack_require__("../../../../../src/app/services/data.service.ts");
479 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
480 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
481 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
482 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
483 | return c > 3 && r && Object.defineProperty(target, key, r), r;
484 | };
485 | var __metadata = (this && this.__metadata) || function (k, v) {
486 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
487 | };
488 |
489 |
490 |
491 | var ProblemDetailComponent = (function () {
492 | function ProblemDetailComponent(dataService, route) {
493 | this.dataService = dataService;
494 | this.route = route;
495 | }
496 | ProblemDetailComponent.prototype.ngOnInit = function () {
497 | var _this = this;
498 | this.route.params.subscribe(function (params) {
499 | //this.problem = this.dataService.getProblem(+params['id']);
500 | _this.dataService.getProblem(+params['id'])
501 | .then(function (problem) { return _this.problem = problem; });
502 | });
503 | };
504 | ProblemDetailComponent = __decorate([
505 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
506 | selector: 'app-problem-detail',
507 | template: __webpack_require__("../../../../../src/app/components/problem-detail/problem-detail.component.html"),
508 | styles: [__webpack_require__("../../../../../src/app/components/problem-detail/problem-detail.component.css")]
509 | }),
510 | __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2__services_data_service__["a" /* DataService */], __WEBPACK_IMPORTED_MODULE_1__angular_router__["a" /* ActivatedRoute */]])
511 | ], ProblemDetailComponent);
512 | return ProblemDetailComponent;
513 | }());
514 |
515 |
516 |
517 | /***/ }),
518 |
519 | /***/ "../../../../../src/app/components/problem-list/problem-list.component.css":
520 | /***/ (function(module, exports, __webpack_require__) {
521 |
522 | exports = module.exports = __webpack_require__("../../../../css-loader/lib/css-base.js")(false);
523 | // imports
524 |
525 |
526 | // module
527 | exports.push([module.i, ".difficulty {\n min-width: 65px;\n margin-right: 10px;\n}\n.label.difficulty {\n padding-top: 0.6em;\n color: #fbfdfa;\n font-size: 12px;\n}\n.title {\n font-size: 1.2em;\n}\n.diff-easy {\n background-color: #42ebf4;\n}\n.diff-medium {\n background-color: #92cf5c;\n}\n.diff-hard {\n background-color: #dd0d1e;\n}\n.diff-super {\n background-color: #8d16e2;\n}", ""]);
528 |
529 | // exports
530 |
531 |
532 | /*** EXPORTS FROM exports-loader ***/
533 | module.exports = module.exports.toString();
534 |
535 | /***/ }),
536 |
537 | /***/ "../../../../../src/app/components/problem-list/problem-list.component.html":
538 | /***/ (function(module, exports) {
539 |
540 | module.exports = ""
541 |
542 | /***/ }),
543 |
544 | /***/ "../../../../../src/app/components/problem-list/problem-list.component.ts":
545 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
546 |
547 | "use strict";
548 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ProblemListComponent; });
549 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
550 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__services_data_service__ = __webpack_require__("../../../../../src/app/services/data.service.ts");
551 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
552 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
553 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
554 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
555 | return c > 3 && r && Object.defineProperty(target, key, r), r;
556 | };
557 | var __metadata = (this && this.__metadata) || function (k, v) {
558 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
559 | };
560 |
561 | //import {PROBLEMS} from '../../mock-problems';
562 |
563 | var ProblemListComponent = (function () {
564 | function ProblemListComponent(dataService) {
565 | this.dataService = dataService;
566 | }
567 | ProblemListComponent.prototype.ngOnInit = function () {
568 | this.getProblems();
569 | };
570 | ProblemListComponent.prototype.ngOnDestroy = function () {
571 | this.subscriptionProblems.unsubscribe();
572 | };
573 | ProblemListComponent.prototype.getProblems = function () {
574 | var _this = this;
575 | //this.problems = this.dataService.getProblems();
576 | this.subscriptionProblems = this.dataService.getProblems()
577 | .subscribe(function (problems) { return _this.problems = problems; });
578 | };
579 | ProblemListComponent = __decorate([
580 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["n" /* Component */])({
581 | selector: 'app-problem-list',
582 | template: __webpack_require__("../../../../../src/app/components/problem-list/problem-list.component.html"),
583 | styles: [__webpack_require__("../../../../../src/app/components/problem-list/problem-list.component.css")]
584 | }),
585 | __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1__services_data_service__["a" /* DataService */]])
586 | ], ProblemListComponent);
587 | return ProblemListComponent;
588 | }());
589 |
590 |
591 |
592 | /***/ }),
593 |
594 | /***/ "../../../../../src/app/services/collaboration.service.ts":
595 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
596 |
597 | "use strict";
598 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CollaborationService; });
599 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
600 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__assets_colors__ = __webpack_require__("../../../../../src/assets/colors.ts");
601 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
602 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
603 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
604 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
605 | return c > 3 && r && Object.defineProperty(target, key, r), r;
606 | };
607 | var __metadata = (this && this.__metadata) || function (k, v) {
608 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
609 | };
610 |
611 |
612 | var CollaborationService = (function () {
613 | function CollaborationService() {
614 | this.clientsInfo = {};
615 | this.clientNum = 0;
616 | }
617 | CollaborationService.prototype.init = function (editor, sessionId) {
618 | var _this = this;
619 | this.collaborationSocket = io(window.location.origin, { query: 'sessionId=' + sessionId });
620 | // this.collaborationSocket.on('message', (message) => {
621 | // console.log('message received from server: ' + message);
622 | // });
623 | this.collaborationSocket.on('change', function (delta) {
624 | delta = JSON.parse(delta);
625 | editor.lastAppliedChange = delta;
626 | editor.getSession().getDocument().applyDeltas([delta]);
627 | });
628 | this.collaborationSocket.on('cursorMove', function (cursor) {
629 | console.log('cursor move' + cursor);
630 | var session = editor.getSession();
631 | cursor = JSON.parse(cursor);
632 | var x = cursor['row'];
633 | var y = cursor['column'];
634 | var changeClientId = cursor['socketId'];
635 | console.log(x + ' ' + y + changeClientId);
636 | if (changeClientId in _this.clientsInfo) {
637 | session.removeMarker(_this.clientsInfo[changeClientId]['marker']);
638 | }
639 | else {
640 | _this.clientsInfo[changeClientId] = {};
641 | var css = document.createElement('style');
642 | css.type = 'text/css';
643 | css.innerHTML = ".editor_cursor_" + changeClientId + "\n { \n position:absolute;\n background:" + __WEBPACK_IMPORTED_MODULE_1__assets_colors__["a" /* COLORS */][_this.clientNum] + ";\v\n z-index:100;\n width:3px !important;\n }";
644 | document.body.appendChild(css);
645 | _this.clientNum++;
646 | }
647 | var Range = ace.require('ace/range').Range;
648 | var newMarker = session.addMarker(new Range(x, y, x, y + 1), "editor_cursor_" + changeClientId, true);
649 | _this.clientsInfo[changeClientId]['marker'] = newMarker;
650 | });
651 | };
652 | CollaborationService.prototype.change = function (delta) {
653 | this.collaborationSocket.emit('change', delta);
654 | };
655 | CollaborationService.prototype.cursorMove = function (cursor) {
656 | this.collaborationSocket.emit('cursorMove', cursor);
657 | };
658 | CollaborationService.prototype.restoreBuffer = function () {
659 | this.collaborationSocket.emit('restoreBuffer');
660 | };
661 | CollaborationService = __decorate([
662 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Injectable */])(),
663 | __metadata("design:paramtypes", [])
664 | ], CollaborationService);
665 | return CollaborationService;
666 | }());
667 |
668 |
669 |
670 | /***/ }),
671 |
672 | /***/ "../../../../../src/app/services/data.service.ts":
673 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
674 |
675 | "use strict";
676 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DataService; });
677 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
678 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_common_http__ = __webpack_require__("../../../common/esm5/http.js");
679 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rxjs_BehaviorSubject__ = __webpack_require__("../../../../rxjs/_esm5/BehaviorSubject.js");
680 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rxjs_add_operator_toPromise__ = __webpack_require__("../../../../rxjs/_esm5/add/operator/toPromise.js");
681 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rxjs_add_operator_toPromise___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_rxjs_add_operator_toPromise__);
682 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
683 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
684 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
685 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
686 | return c > 3 && r && Object.defineProperty(target, key, r), r;
687 | };
688 | var __metadata = (this && this.__metadata) || function (k, v) {
689 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
690 | };
691 |
692 |
693 |
694 |
695 | // import { PROBLEMS } from '../mock-problems';
696 | var DataService = (function () {
697 | function DataService(httpClient) {
698 | this.httpClient = httpClient;
699 | // problems: Problem[] = PROBLEMS;
700 | this._problemSource = new __WEBPACK_IMPORTED_MODULE_2_rxjs_BehaviorSubject__["a" /* BehaviorSubject */]([]);
701 | }
702 | DataService.prototype.getProblems = function () {
703 | var _this = this;
704 | // return this.problems;
705 | this.httpClient.get('api/v1/problems')
706 | .toPromise()
707 | .then(function (res) {
708 | _this._problemSource.next(res);
709 | })
710 | .catch(this.handleError);
711 | return this._problemSource.asObservable();
712 | };
713 | // values, complete, error
714 | DataService.prototype.getProblem = function (id) {
715 | // return this.problems.find( (problem) => problem.id === id);
716 | return this.httpClient.get("api/v1/problems/" + id)
717 | .toPromise()
718 | .then(function (res) { return res; })
719 | .catch(this.handleError);
720 | };
721 | DataService.prototype.addProblem = function (problem) {
722 | var _this = this;
723 | // problem.id = this.problems.length + 1;
724 | // this.problems.push(problem);
725 | var options = { headers: new __WEBPACK_IMPORTED_MODULE_1__angular_common_http__["c" /* HttpHeaders */]({ 'Content-Type': 'application/json' }) };
726 | return this.httpClient.post('api/v1/problems', problem, options)
727 | .toPromise()
728 | .then(function (res) {
729 | _this.getProblems();
730 | return res;
731 | })
732 | .catch(this.handleError);
733 | };
734 | DataService.prototype.buildAndRun = function (data) {
735 | var options = { headers: new __WEBPACK_IMPORTED_MODULE_1__angular_common_http__["c" /* HttpHeaders */]({ 'Content-Type': 'application/json' }) };
736 | return this.httpClient.post('api/v1/build_and_run', data, options)
737 | .toPromise()
738 | .then(function (res) {
739 | console.log(res);
740 | return res;
741 | })
742 | .catch(this.handleError);
743 | };
744 | DataService.prototype.handleError = function (error) {
745 | return Promise.reject(error.body || error);
746 | };
747 | DataService = __decorate([
748 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["A" /* Injectable */])(),
749 | __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1__angular_common_http__["a" /* HttpClient */]])
750 | ], DataService);
751 | return DataService;
752 | }());
753 |
754 |
755 |
756 | /***/ }),
757 |
758 | /***/ "../../../../../src/assets/colors.ts":
759 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
760 |
761 | "use strict";
762 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return COLORS; });
763 | var COLORS = [
764 | "#0000ff",
765 | "#a52a2a",
766 | "#00ffff",
767 | "#00008b",
768 | "#008b8b",
769 | "#a9a9a9",
770 | "#006400",
771 | "#bdb76b",
772 | "#8b008b",
773 | "#556b2f",
774 | "#ff8c00",
775 | "#9932cc",
776 | "#8b0000",
777 | "#e9967a",
778 | "#9400d3",
779 | "#ff00ff",
780 | "#ffd700",
781 | "#008000",
782 | "#4b0082",
783 | "#f0e68c",
784 | "#add8e6",
785 | "#e0ffff",
786 | "#90ee90",
787 | "#d3d3d3",
788 | "#ffb6c1",
789 | "#ffffe0",
790 | "#00ff00",
791 | "#ff00ff",
792 | "#800000",
793 | "#000080",
794 | "#808000",
795 | "#ffa500",
796 | "#ffc0cb",
797 | "#800080",
798 | "#800080",
799 | "#ff0000",
800 | "#c0c0c0",
801 | "#ffffff",
802 | "#ffff00"
803 | ];
804 |
805 |
806 | /***/ }),
807 |
808 | /***/ "../../../../../src/environments/environment.ts":
809 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
810 |
811 | "use strict";
812 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return environment; });
813 | // The file contents for the current environment will overwrite these during build.
814 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
815 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
816 | // The list of which env maps to which file can be found in `.angular-cli.json`.
817 | var environment = {
818 | production: false
819 | };
820 |
821 |
822 | /***/ }),
823 |
824 | /***/ "../../../../../src/main.ts":
825 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
826 |
827 | "use strict";
828 | Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
829 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__("../../../core/esm5/core.js");
830 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_platform_browser_dynamic__ = __webpack_require__("../../../platform-browser-dynamic/esm5/platform-browser-dynamic.js");
831 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__app_app_module__ = __webpack_require__("../../../../../src/app/app.module.ts");
832 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__environments_environment__ = __webpack_require__("../../../../../src/environments/environment.ts");
833 |
834 |
835 |
836 |
837 | if (__WEBPACK_IMPORTED_MODULE_3__environments_environment__["a" /* environment */].production) {
838 | Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_13" /* enableProdMode */])();
839 | }
840 | Object(__WEBPACK_IMPORTED_MODULE_1__angular_platform_browser_dynamic__["a" /* platformBrowserDynamic */])().bootstrapModule(__WEBPACK_IMPORTED_MODULE_2__app_app_module__["a" /* AppModule */])
841 | .catch(function (err) { return console.log(err); });
842 |
843 |
844 | /***/ }),
845 |
846 | /***/ 0:
847 | /***/ (function(module, exports, __webpack_require__) {
848 |
849 | module.exports = __webpack_require__("../../../../../src/main.ts");
850 |
851 |
852 | /***/ })
853 |
854 | },[0]);
855 | //# sourceMappingURL=main.bundle.js.map
--------------------------------------------------------------------------------