mirror of
https://github.com/jcreek/phldnhack.git
synced 2026-07-12 18:43:43 +00:00
test
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<script type="text/ractive" id="home"><div class="row">
|
||||
<script type="text/ractive" id="parent"><div class="row">
|
||||
<div class="col s12 m6 offset-m3">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
Ractive.components.home = Ractive.extend({
|
||||
template:'#home'
|
||||
Ractive.components.student = Ractive.extend({
|
||||
template:'#student'
|
||||
});
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script>
|
||||
|
||||
<script src='index.js'></script>
|
||||
<script src='/index.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/ractive" id="home"><div class="row">
|
||||
<script type="text/ractive" id="parent"><div class="row">
|
||||
<div class="col s12 m6 offset-m3">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
Ractive.components.home = Ractive.extend({
|
||||
template:'#home'
|
||||
Ractive.components.student = Ractive.extend({
|
||||
template:'#student'
|
||||
});
|
||||
|
||||
|
||||
$.getJSON('/sample', function(res){
|
||||
$.getJSON('/data/'+location.pathname.split('/').slice(3).join('/'), function(res){
|
||||
|
||||
var ractive = new Ractive.components.home({
|
||||
var ractive = new Ractive.components[location.pathname.split('/')[2]]({
|
||||
el:'#load',
|
||||
data:res
|
||||
});
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
@@include('components.js')
|
||||
Ractive.components.home = Ractive.extend({
|
||||
template:'#home'
|
||||
});
|
||||
|
||||
|
||||
$.getJSON('/sample', function(res){
|
||||
|
||||
var ractive = new Ractive.components.home({
|
||||
var ractive = new Ractive.components[location.pathname.split('/')[1]]({
|
||||
el:'#load',
|
||||
data:res
|
||||
});
|
||||
+1
-1
@@ -7,7 +7,7 @@ $(document).ready(function(){
|
||||
|
||||
$.getJSON('/sample', function(res){
|
||||
|
||||
var ractive = new Ractive.components.home({
|
||||
var ractive = new Ractive.components[location.pathname.split('/')[1]]({
|
||||
el:'#load',
|
||||
data:res
|
||||
});
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Ractive.components.home = Ractive.extend({
|
||||
template:'#home'
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
Ractive.components.student = Ractive.extend({
|
||||
template:'#student'
|
||||
});
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script>
|
||||
|
||||
<script src='index.js'></script>
|
||||
<script src='/index.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
@@include('components.js')
|
||||
|
||||
$.getJSON('/data/'+location.pathname.split('/').slice(3).join('/'), function(res){
|
||||
|
||||
var ractive = new Ractive.components[location.pathname.split('/')[2]]({
|
||||
el:'#load',
|
||||
data:res
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//Code below here
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RCard</title>
|
||||
<script src='http://cdn.ractivejs.org/latest/ractive.js'></script>
|
||||
<script src='https://code.jquery.com/jquery-2.1.4.min.js'></script>
|
||||
|
||||
<!-- Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/css/materialize.min.css">
|
||||
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script>
|
||||
|
||||
<script src='index.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@include('components.html')
|
||||
|
||||
<div id='load'></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,20 +0,0 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
@@include('components.js')
|
||||
|
||||
$.getJSON('/sample', function(res){
|
||||
|
||||
var ractive = new Ractive.components.home({
|
||||
el:'#load',
|
||||
data:res
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
//Code below here
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
+25
-2
@@ -3,8 +3,12 @@ var express = require('express');
|
||||
var app = express();
|
||||
app.use(express.static('../build'))
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.send(fs.readFileSync('../build/index.html'));
|
||||
var mongojs = require('mongojs');
|
||||
|
||||
var db = mongojs('test', ['class', 'student']);
|
||||
|
||||
app.get('/view/:viewType/:dataType/:id', function(req, res){
|
||||
res.send(fs.readFileSync('../build/index.html', 'utf8'));
|
||||
});
|
||||
|
||||
app.get('/sample', function(req, res){
|
||||
@@ -14,5 +18,24 @@ app.get('/sample', function(req, res){
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/data/:type/:id', function(req, res){
|
||||
if(req.params.type === 'class') {
|
||||
db.class.findOne({_id: mongojs.ObjectId(req.params.id)}, function(err, classDoc){
|
||||
if(err)
|
||||
throw new Error('Error finding class');
|
||||
db.student.find({class:req.params.id}, function(err, students){
|
||||
res.send({
|
||||
class:classDoc,
|
||||
students:students
|
||||
});
|
||||
});
|
||||
});
|
||||
} else if(req.params.type === 'student') {
|
||||
db.student.find({_id:mongojs.ObjectId(req.params.id)}, function(err, student){
|
||||
res.send(student);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
app.listen(1337);
|
||||
|
||||
Reference in New Issue
Block a user