Merge lp:~lenasysimpl1/lenasys/GammaBear into lp:lenasys

Proposed by Victor Nagy
Status: Merged
Merged at revision: 25
Proposed branch: lp:~lenasysimpl1/lenasys/GammaBear
Merge into: lp:lenasys
Diff against target: 1309 lines (+512/-403)
18 files modified
DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js (+235/-0)
DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php (+2/-243)
Widget Library/sliderdemo.html (+2/-12)
Widget Library/sliders.css (+2/-0)
Widget Library/sliders.js (+44/-23)
codeigniter/application/controllers/admin.php (+11/-11)
codeigniter/application/controllers/codeviewer.php (+18/-6)
codeigniter/application/models/admin/admin_model.php (+89/-23)
codeigniter/application/models/codeviewer/codeviewer_model.php (+45/-50)
codeigniter/application/views/admin/add_example.php (+2/-0)
codeigniter/application/views/admin/add_page.php (+0/-2)
codeigniter/application/views/admin/index.php (+3/-3)
codeigniter/application/views/admin/manage_course.php (+3/-3)
codeigniter/application/views/admin/manage_example.php (+2/-2)
codeigniter/application/views/admin/manage_page.php (+13/-14)
codeigniter/application/views/codeviewer/codeviewer.php (+19/-0)
codeigniter/css/adminstyle.css (+4/-0)
codeigniter/js/script.js (+18/-11)
To merge this branch: bzr merge lp:~lenasysimpl1/lenasys/GammaBear
Reviewer Review Type Date Requested Status
Gustav Hartvigsson Approve
Review via email: mp+158660@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gustav Hartvigsson (gustav-hartvigsson) wrote :

I saw Nagy code.
I can not disapprove this.
:3

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js'
2--- DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js 1970-01-01 00:00:00 +0000
3+++ DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.js 2013-04-12 15:59:33 +0000
4@@ -0,0 +1,235 @@
5+var account="<?php echo $accountname ?>";
6+var duggaNr="<?php echo $duggaNr ?>";
7+var courseName="<?php echo $courseName ?>";
8+var courseOccasion="<?php echo $courseOccasion ?>";
9+
10+$(document).ready(function() {
11+ fetchQuiz();
12+ fetchQuizObject("ObjDesc");
13+});
14+
15+/* login, courseName, courseOccasion, quizNr */
16+function fetchQuiz(){
17+ console.log("post fetchQuiz ");
18+ $.post("../quizAjax/getQuiz.php",
19+ {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr },
20+ fetchQuizCallBack,
21+ "json"
22+ );
23+}
24+
25+function fetchQuizCallBack(data){
26+ console.log(data);
27+ if (typeof data.Error != 'undefined') {
28+ $("#result").append("<br/><h3>Error:"+data.Error+"</h3>");
29+ } else {
30+ $("#result").append("<br/>Dugga nr:"+data.quizNr);
31+ $("#result").append("<br/>Kursnamn:"+data.quizCourseName);
32+ $("#result").append("<br/>Lista över dugga-objekt:"+data.quizObjectIDs);
33+ $("#result").append("<br/>Data:"+data.quizData);
34+ }
35+}
36+
37+/* Evaluate the submited answer
38+ * (Alternativly, it just saves it if the dugga does not correct it self. )
39+ */
40+function checkAnswer(submitstr){
41+ $.post("../quizAjax/answerQuiz.php",
42+ {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, quizAnswer: submitstr},
43+ checkAnswerCallBack,
44+ "json"
45+ );
46+}
47+
48+function checkAnswerCallBack(data){
49+ console.log("checkAnswerCallBack:");
50+ console.log(data);
51+ if (typeof data.Error != 'undefined') {
52+ $("#result").append("<br/><h3>Error:"+data.Error+"</h3>");
53+ } else {
54+ for (var key in data) {
55+ $("#result").append("<br />"+data[key]);
56+ }
57+ }
58+}
59+
60+/* Get a dugga object (object id's are fetched from the list with object ids which comes with the dugga)
61+ * Parameters: (POST) objectID, courseName, courseOccasion, quizNr, loginName
62+ */
63+function fetchQuizObject(objectName){
64+ console.log("post fetchQuizObject");
65+ $.post("../quizAjax/getQuizObject.php",
66+ {objectID: objectName, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, loginName: account},
67+ fetchQuizObjectCallBack,
68+ "json"
69+ );
70+}
71+
72+function fetchQuizObjectCallBack(data){
73+ if (typeof data.Error != 'undefined') {
74+ $("#result").append("<br/><h3>Error:"+data.Error+"</h3>");
75+ } else {
76+ $("#result").append(data.objectData);
77+ }
78+}
79+
80+function newbutton() {
81+ var funclist;
82+ var oplist;
83+
84+ funclist = document.getElementById('function');
85+ oplist = document.getElementById('operations');
86+
87+ oplist.innerHTML+="<option value='"+funclist.options[funclist.selectedIndex].value+"'>"+funclist.options[funclist.selectedIndex].text+"</option>";
88+}
89+
90+function deletebutton() {
91+ var elSel = document.getElementById('operations');
92+ var i=0;
93+ for (i = elSel.length-1; i >= 0; i--) {
94+ if (elSel.options[i].selected) {
95+ elSel.remove(i);
96+ }
97+ }
98+}
99+
100+function moveupbutton() {
101+ var elSel = document.getElementById('operations');
102+ var ind=elSel.selectedIndex;
103+ var val;
104+ var tex;
105+
106+ if( elSel.selectedIndex>0) {
107+
108+ val=elSel.options[ind].value;
109+ tex=elSel.options[ind].text;
110+
111+ elSel.options[ind].value=elSel.options[ind-1].value;
112+ elSel.options[ind].text=elSel.options[ind-1].text;
113+
114+ elSel.options[ind-1].value=val;
115+ tex=elSel.options[ind-1].text=tex;
116+
117+ elSel.selectedIndex--;
118+ }
119+}
120+
121+function movedownbutton() {
122+ var elSel = document.getElementById('operations');
123+ var ind=elSel.selectedIndex;
124+ var val;
125+ var tex;
126+
127+ if(elSel.selectedIndex < elSel.length-1){
128+
129+ val=elSel.options[ind].value;
130+ tex=elSel.options[ind].text;
131+
132+ elSel.options[ind].value=elSel.options[ind+1].value;
133+ elSel.options[ind].text=elSel.options[ind+1].text;
134+
135+ elSel.options[ind+1].value=val;
136+ tex=elSel.options[ind+1].text=tex;
137+
138+ elSel.selectedIndex++;
139+ }
140+}
141+
142+function submbutton() {
143+ var submitstr="";
144+
145+ var elSel = document.getElementById('operations');
146+ var i=0;
147+
148+ for (i=elSel.length-1; i >= 0;i--) {
149+ submitstr+=elSel.options[i].value;
150+ }
151+
152+ alert(submitstr);
153+ checkAnswer(submitstr);
154+}
155+
156+function handler_mouseup() {
157+ clickstate=0;
158+}
159+
160+function handler_mousedown() {
161+ clickstate=1;
162+}
163+
164+function handler_mousemove (cx,cy) {
165+// Make use of cx and cy... right now no use as this app does not use clicks
166+}
167+
168+var v=0;
169+
170+function foo() {
171+ acanvas.width = acanvas.width;
172+
173+ v+=0.1;
174+
175+ context.translate(300,300);
176+ context.save();
177+
178+ var elSel = document.getElementById('operations');
179+ var i=0;
180+ for (i=0;i<=elSel.length-1;i++) {
181+ if (elSel.options[i].value == "T1") {
182+ context.translate(100,0);
183+ }
184+ if (elSel.options[i].value == "T2") {
185+ context.translate(150,0);
186+ }
187+ if (elSel.options[i].value == "T3") {
188+ context.translate(200,0);
189+ }
190+ if (elSel.options[i].value == "RP") {
191+ context.rotate(v);
192+ }
193+ if (elSel.options[i].value == "RN") {
194+ context.rotate(-v);
195+ }
196+ if (elSel.options[i].value == "S1") {
197+ context.scale(0.25,0.25);
198+ }
199+ if (elSel.options[i].value == "S2") {
200+ context.scale(0.5,0.5);
201+ }
202+ if (elSel.options[i].value == "S3") {
203+ context.scale(0.75,0.75);
204+ }
205+ if (elSel.options[i].value == "S4") {
206+ context.scale(1.5,1.5);
207+ }
208+ if (elSel.options[i].value == "D1") {
209+ drawball(0,0,40,30,10,"#f84",45.0,22.5);
210+ }
211+ if (elSel.options[i].value == "D2") {
212+ drawball(0,0,40,30,10,"#4f8",45.0,22.5);
213+ }
214+ if (elSel.options[i].value == "D3") {
215+ drawball(0,0,40,30,10,"#84f",45.0,22.5);
216+ }
217+ }
218+
219+ // Must count saves
220+ // Restore equal amount of times
221+
222+ /*
223+ context.beginPath();
224+ drawcircle(40,'#f0f');
225+
226+ context.lineWidth = 0.5;
227+
228+ context.moveTo(0,0);
229+ context.rect(0,0,30,30);
230+
231+ context.stroke();
232+ */
233+ context.restore();
234+ context.globalAlpha = 0.5
235+ context.rotate(-v*0.6);
236+ drawsun();
237+
238+ setTimeout("foo();",100);
239+}
240\ No newline at end of file
241
242=== modified file 'DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php'
243--- DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php 2013-04-04 11:30:02 +0000
244+++ DuggaSys/duggor/Dugga 3 Datorgrafik - Transformationer/johan_dugga_datorgrafik_1_transforms.php 2013-04-12 15:59:33 +0000
245@@ -9,250 +9,9 @@
246 <html>
247 <head>
248 <meta charset="UTF-8"/>
249- <script type="text/javascript" src="../../../../js/jquery.js"></script>
250- <script lang='Javascript'>
251- var account="<?php echo $accountname ?>";
252- var duggaNr="<?php echo $duggaNr ?>";
253- var courseName="<?php echo $courseName ?>";
254- var courseOccasion="<?php echo $courseOccasion ?>";
255-
256- $(document).ready(function() {
257- fetchQuiz();
258- fetchQuizObject("ObjDesc");
259- });
260-
261- //login, courseName, courseOccasion, quizNr
262- function fetchQuiz(){
263- console.log("post fetchQuiz ");
264- $.post("../quizAjax/getQuiz.php",
265- {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr },
266- fetchQuizCallBack,
267- "json"
268- );
269- }
270-
271- function fetchQuizCallBack(data){
272- console.log(data);
273- if (typeof data.Error != 'undefined') {
274- $("#result").append("<br/><h3>Error:"+data.Error+"</h3>");
275- } else {
276- $("#result").append("<br/>Dugga nr:"+data.quizNr);
277- $("#result").append("<br/>Kursnamn:"+data.quizCourseName);
278- $("#result").append("<br/>Lista över dugga-objekt:"+data.quizObjectIDs);
279- $("#result").append("<br/>Data:"+data.quizData);
280- }
281- }
282-
283- //Kontrollera om inskickat svar är rätt (alternativt bara spara det om duggan inte rättas automatiskt)
284- function checkAnswer(submitstr){
285- $.post("../quizAjax/answerQuiz.php",
286- {loginName: account, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, quizAnswer: submitstr},
287- checkAnswerCallBack,
288- "json"
289- );
290- }
291-
292- function checkAnswerCallBack(data){
293- console.log("checkAnswerCallBack:");
294- console.log(data);
295- if (typeof data.Error != 'undefined') {
296- $("#result").append("<br/><h3>Error:"+data.Error+"</h3>");
297- } else {
298- for (var key in data) {
299- $("#result").append("<br />"+data[key]);
300- }
301- }
302- }
303-
304- //Hämta ett dugga objekt (objekt id:n hämtas från listan med objekt id:n som kommer med duggan)
305- //////Parameters: (POST) objectID, courseName, courseOccasion, quizNr, loginName
306- function fetchQuizObject(objectName){
307- console.log("post fetchQuizObject");
308- $.post("../quizAjax/getQuizObject.php",
309- {objectID: objectName, courseName: courseName, courseOccasion: courseOccasion, quizNr: duggaNr, loginName: account},
310- fetchQuizObjectCallBack,
311- "json"
312- );
313- }
314-
315- function fetchQuizObjectCallBack(data){
316- if (typeof data.Error != 'undefined') {
317- $("#result").append("<br/><h3>Error:"+data.Error+"</h3>");
318- } else {
319- $("#result").append(data.objectData);
320- }
321- }
322- </script>
323-
324+ <script type="text/javascript" src="../../../../js/jquery.js"></script>
325 <script type="text/javascript" src="../../../../js/dugga.js"></script>
326-
327- <script lang='Javascript'>
328-
329- function newbutton()
330- {
331- var funclist;
332- var oplist;
333-
334- funclist=document.getElementById('function');
335- oplist=document.getElementById('operations');
336-
337- oplist.innerHTML+="<option value='"+funclist.options[funclist.selectedIndex].value+"'>"+funclist.options[funclist.selectedIndex].text+"</option>";
338-
339- }
340-
341- function deletebutton()
342- {
343- var elSel = document.getElementById('operations');
344- var i=0;
345- for (i=elSel.length-1;i>=0;i--) {
346- if (elSel.options[i].selected) {
347- elSel.remove(i);
348- }
349- }
350- }
351-
352- function moveupbutton()
353- {
354- var elSel = document.getElementById('operations');
355- var ind=elSel.selectedIndex;
356- var val;
357- var tex;
358-
359- if(elSel.selectedIndex>0){
360-
361- val=elSel.options[ind].value;
362- tex=elSel.options[ind].text;
363-
364- elSel.options[ind].value=elSel.options[ind-1].value;
365- elSel.options[ind].text=elSel.options[ind-1].text;
366-
367- elSel.options[ind-1].value=val;
368- tex=elSel.options[ind-1].text=tex;
369-
370- elSel.selectedIndex--;
371- }
372- }
373-
374- function movedownbutton()
375- {
376- var elSel = document.getElementById('operations');
377- var ind=elSel.selectedIndex;
378- var val;
379- var tex;
380-
381- if(elSel.selectedIndex<elSel.length-1){
382-
383- val=elSel.options[ind].value;
384- tex=elSel.options[ind].text;
385-
386- elSel.options[ind].value=elSel.options[ind+1].value;
387- elSel.options[ind].text=elSel.options[ind+1].text;
388-
389- elSel.options[ind+1].value=val;
390- tex=elSel.options[ind+1].text=tex;
391-
392- elSel.selectedIndex++;
393- }
394-
395- }
396-
397- function submbutton()
398- {
399- var submitstr="";
400-
401- var elSel = document.getElementById('operations');
402- var i=0;
403-
404- for (i=elSel.length-1;i>=0;i--) {
405- submitstr+=elSel.options[i].value;
406- }
407-
408- alert(submitstr);
409- checkAnswer(submitstr);
410- }
411-
412- function handler_mouseup()
413- {
414- clickstate=0;
415- }
416-
417- function handler_mousedown()
418- {
419- clickstate=1;
420- }
421-
422- function handler_mousemove (cx,cy)
423- {
424- // Make use of cx and cy... right now no use as this app does not use clicks
425- }
426-
427- var v=0;
428-
429- function foo()
430- {
431- acanvas.width = acanvas.width;
432-
433- v+=0.1;
434-
435- context.translate(300,300);
436- context.save();
437-
438- var elSel = document.getElementById('operations');
439- var i=0;
440- for (i=0;i<=elSel.length-1;i++) {
441- if(elSel.options[i].value=="T1"){
442- context.translate(100,0);
443- }if(elSel.options[i].value=="T2"){
444- context.translate(150,0);
445- }if(elSel.options[i].value=="T3"){
446- context.translate(200,0);
447- }if(elSel.options[i].value=="RP"){
448- context.rotate(v);
449- }if(elSel.options[i].value=="RN"){
450- context.rotate(-v);
451- }if(elSel.options[i].value=="S1"){
452- context.scale(0.25,0.25);
453- }if(elSel.options[i].value=="S2"){
454- context.scale(0.5,0.5);
455- }if(elSel.options[i].value=="S3"){
456- context.scale(0.75,0.75);
457- }if(elSel.options[i].value=="S4"){
458- context.scale(1.5,1.5);
459- }if(elSel.options[i].value=="D1"){
460- drawball(0,0,40,30,10,"#f84",45.0,22.5);
461- }if(elSel.options[i].value=="D2"){
462- drawball(0,0,40,30,10,"#4f8",45.0,22.5);
463- }if(elSel.options[i].value=="D3"){
464- drawball(0,0,40,30,10,"#84f",45.0,22.5);
465- }
466- }
467-
468-
469-
470- // Must count saves
471- // Restore equal amount of times
472-
473-/*
474- context.beginPath();
475- drawcircle(40,'#f0f');
476-
477- context.lineWidth = 0.5;
478-
479- context.moveTo(0,0);
480- context.rect(0,0,30,30);
481-
482- context.stroke();
483-*/
484- context.restore();
485- context.globalAlpha = 0.5
486- context.rotate(-v*0.6);
487- drawsun();
488-
489- setTimeout("foo();",100);
490-
491- }
492-
493- </script>
494+ <script type="text/javascript" src="johan_dugga_datorgrafik_1_transforms.js"></script>
495
496 </head>
497 <body onload="setupcanvas();">
498
499=== modified file 'Widget Library/sliderdemo.html'
500--- Widget Library/sliderdemo.html 2013-04-03 14:29:36 +0000
501+++ Widget Library/sliderdemo.html 2013-04-12 15:59:33 +0000
502@@ -3,19 +3,9 @@
503 <head>
504 <title>Slider Demo</title>
505 <link rel="stylesheet" type="text/css" media="screen" href="sliders.css">
506+ <script type="text/javascript" src="../etc/PIE/PIE.js"></script>
507+ <script type="text/javascript" src="../js/jquery.js"></script>
508 <script type="text/javascript" src="sliders.js"></script>
509- <script>
510- function createDemoSliders() {
511- str = "";
512- str += makePanel(250, 200);
513- str += makeLabel("Slider");
514- str += makeSlider("slider", 1, 2, 7, 4.5, 160, 5);
515- str += makeLabel("Binary");
516- str += makeBinary("binary", 0);
517- str += makePanelEnd();
518- document.getElementById("container").innerHTML = str;
519- }
520- </script>
521 </head>
522 <body onload="createDemoSliders();" onmousedown="mbPress(event);" onmouseup="mbRelease(event);">
523 <div id="container">
524
525=== modified file 'Widget Library/sliders.css'
526--- Widget Library/sliders.css 2013-04-03 14:29:36 +0000
527+++ Widget Library/sliders.css 2013-04-12 15:59:33 +0000
528@@ -9,6 +9,7 @@
529 font-family: Arial;
530 background-color: #d0d0d4;
531 background: linear-gradient(to bottom, #f0f0e8 0%, #e8e8e8 1%, #b8b8b0 17%);
532+ -pie-background: linear-gradient(top, #f0f0e8 0%, #e8e8e8 1%, #b8b8b0 17%);
533 border-radius: 10px;
534 padding:6px;
535 }
536@@ -79,4 +80,5 @@
537 border-width: 1px;
538 box-shadow: 2px 2px 2px #444;
539 background: linear-gradient(to bottom, #fff 0%,#e0e0d8 60%);
540+ -pie-background: linear-gradient(top, #fff 0%,#e0e0d8 60%);
541 }
542\ No newline at end of file
543
544=== modified file 'Widget Library/sliders.js'
545--- Widget Library/sliders.js 2013-04-03 14:29:36 +0000
546+++ Widget Library/sliders.js 2013-04-12 15:59:33 +0000
547@@ -4,13 +4,34 @@
548
549 */
550
551+// Fixes css3 for IE
552+function attachPIE() {
553+ $('*').each(function() {
554+ PIE.attach(this);
555+ });
556+}
557+
558+// Creates a demo
559+function createDemoSliders() {
560+ str = "";
561+ str += makePanel(250, 200);
562+ str += makeLabel("Slider");
563+ str += makeSlider("slider", 1, 2, 7, 4.5, 160, 5);
564+ str += makeLabel("Binary");
565+ str += makeBinary("binary", 0);
566+ str += makePanelEnd();
567+ document.getElementById("container").innerHTML = str;
568+ attachPIE();
569+
570+}
571+
572 // Recursive Pos of div in document - should work in most browsers
573 function findPos(obj) {
574 var curLeft = curTop = 0;
575- if(obj.offsetParent) {
576+ if (obj.offsetParent) {
577 curLeft = obj.offsetLeft
578 curTop = obj.offsetTop
579- while(obj = obj.offsetParent) {
580+ while (obj = obj.offsetParent) {
581 curLeft += obj.offsetLeft
582 curTop += obj.offsetTop
583 }
584@@ -29,7 +50,7 @@
585
586 function readSlider(sliderId) {
587 var value = parseFloat(document.getElementById(sliderId + "box").value);
588- if(isNaN(value)) {
589+ if (isNaN(value)) {
590 value = 0.0;
591 }
592 return value;
593@@ -37,7 +58,7 @@
594
595 function readBinary(binaryId) {
596 lf = document.getElementById(binaryId + "marker").style.left;
597- if(lf == "2px") {
598+ if (lf == "2px") {
599 return 0;
600 } else {
601 return 1;
602@@ -52,7 +73,7 @@
603
604 // The idea is to have a few functions like this one and minimum javascript intervention
605 function updateBinary(event, binaryId) {
606- if(mb) {
607+ if (mb) {
608 coords = findPos(event.currentTarget);
609 coords.x = event.clientX - coords.x;
610 coords.y = event.clientY - coords.y;
611@@ -68,24 +89,24 @@
612
613 // The idea is to have a few functions like this one and minimum javascript intervention
614 function updateSlider(event, kind, min, max, length, sliderId, boxId) {
615- if(mb) {
616+ if (mb) {
617 coords = findPos(event.currentTarget);
618 coords.x = event.clientX - coords.x;
619 coords.y = event.clientY - coords.y;
620 cx = coords.x / length;
621 sd = max - min;
622 value = min + (sd * cx);
623- if(value > max) value = max;
624- if(kind == 0) {
625+ if (value > max) value = max;
626+ if (kind == 0) {
627 value = Math.round(value);
628 }
629- if(kind == 1) {
630+ if (kind == 1) {
631 value = Math.round(value * 10.0) / 10.0;
632 }
633- if(kind == 2) {
634+ if (kind == 2) {
635 value = Math.round(value * 100.0) / 100.0;
636 }
637- if(kind == 3) {
638+ if (kind == 3) {
639 value = Math.round(value * 1000.0) / 1000.0;
640 }
641 document.getElementById(boxId).value = value;
642@@ -94,10 +115,10 @@
643 }
644
645 function sliderPosition(value, min, max, length) {
646- if(value < min) {
647+ if (value < min) {
648 value = min;
649 }
650- if(value > max) {
651+ if (value > max) {
652 value = max;
653 }
654 pos = Math.round(((value - min) / (max - min)) * length);
655@@ -106,25 +127,25 @@
656
657 function changeSlider(value, sliderId, kind, min, max, length) {
658 value = parseFloat(value);
659- if(isNaN(value)) {
660+ if (isNaN(value)) {
661 value = 0.0;
662 }
663- if(value < min) {
664+ if (value < min) {
665 value = min;
666 }
667- if(value > max) {
668+ if (value > max) {
669 value = max;
670 }
671- if(kind == 0) {
672+ if (kind == 0) {
673 value = Math.round(value);
674 }
675- if(kind == 1) {
676+ if (kind == 1) {
677 value = Math.round(value * 10.0) / 10.0;
678 }
679- if(kind == 2) {
680+ if (kind == 2) {
681 value = Math.round(value * 100.0) / 100.0;
682 }
683- if(kind == 3) {
684+ if (kind == 3) {
685 value = Math.round(value * 1000.0) / 1000.0;
686 }
687 pos = sliderPosition(value, min, max, length);
688@@ -158,10 +179,10 @@
689 function makeSlider(sliderId, kind, minValue, maxValue, midValue, sliderWidth, defaultValue) {
690 s = "";
691 defaultPosition = sliderPosition(defaultValue, minValue, maxValue, sliderWidth);
692- if(defaultValue < minValue) {
693+ if (defaultValue < minValue) {
694 defaultValue = minValue;
695 }
696- if(defaultValue > maxValue) {
697+ if (defaultValue > maxValue) {
698 defaultValue = maxValue;
699 }
700 s += "<input id='" + sliderId + "box' value='" + defaultValue + "' type='text' class='sliderBox' onBlur='changeSlider(this.value,\"" + sliderId + "\"," + kind + "," + minValue + "," + maxValue + "," + sliderWidth + ");'>";
701@@ -178,7 +199,7 @@
702
703 function makeBinary(binaryId, defaultValue) {
704 s = "";
705- if(defaultValue == 1) {
706+ if (defaultValue == 1) {
707 defaultPosition = 20;
708 defaultColor = "#ddd";
709 } else {
710
711=== modified file 'codeigniter/application/controllers/admin.php'
712--- codeigniter/application/controllers/admin.php 2013-04-11 13:59:06 +0000
713+++ codeigniter/application/controllers/admin.php 2013-04-12 15:59:33 +0000
714@@ -2,7 +2,10 @@
715
716 class Admin extends CI_Controller {
717
718-
719+ /*
720+ * This is the index function. It will be the one called if you do not specify a
721+ * function in the url, example: /admin/
722+ */
723 public function index() {
724 $this->load->model('admin/Admin_model');
725 $courses = $this->Admin_model->getCourses();
726@@ -38,7 +41,7 @@
727 $this->load->view('admin/add_example', array("cid" => $cid));
728 } else {
729 $this->load->model('admin/Admin_model');
730- $this->Admin_model->addExample($_POST['cid'], $_POST['example']);
731+ $this->Admin_model->addExample($_POST['cid'], $_POST['example'], $_POST['description']);
732 redirect("admin/");
733 }
734 }
735@@ -58,7 +61,7 @@
736 $this->load->view('admin/add_page', array("cid" => $cid, "example" => $example));
737 } else {
738 $this->load->model('admin/Admin_model');
739- $this->Admin_model->addPage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation']);
740+ $this->Admin_model->addPage($_POST['cid'], $_POST['example'],$_POST['page']);
741 redirect("admin/");
742 }
743 }
744@@ -69,19 +72,16 @@
745
746 $this->load->model('codeviewer/Codeviewer_model');
747
748- $files = $this->Codeviewer_model->getFiles($cid, $example,$page);
749- $editorHTML = "";
750- foreach ($files as $file) {
751- $editorHTML .= $this->Codeviewer_model->showFile($file, "html");
752- }
753+
754+ $editorHTML = $this->Codeviewer_model->getCode($cid, $example, $page);
755
756- $doc = $this->Codeviewer_model->getDoc($cid, $example, $page);
757+ //$doc = $this->Codeviewer_model->getDoc($cid, $example, $page);
758
759 $this->load->view('admin/header', array("editors" => $editorHTML, "title" => "Manage page - ".$page." - ".$example." - ".$cid));
760- $this->load->view('admin/manage_page', array("cid" => $cid, "example" => $example, "page" => $page, "documentation" => $doc));
761+ $this->load->view('admin/manage_page', array("cid" => $cid, "example" => $example, "page" => $page /*,"documentation" => $doc*/));
762 } else {
763 $this->load->model('admin/Admin_model');
764- $this->Admin_model->updatePage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation']);
765+ $this->Admin_model->updatePage($_POST['cid'], $_POST['example'],$_POST['page'], $_POST['documentation'], $_POST['files']);
766 redirect("admin/");
767 }
768 }
769
770=== modified file 'codeigniter/application/controllers/codeviewer.php'
771--- codeigniter/application/controllers/codeviewer.php 2013-04-10 15:49:32 +0000
772+++ codeigniter/application/controllers/codeviewer.php 2013-04-12 15:59:33 +0000
773@@ -1,18 +1,30 @@
774 <?php
775-
776+/**
777+* This is a controller. It links the views related to the codeviewer together with the model, which holds
778+* the logic.
779+*
780+* Function names equals path. Example: codeviewer/show in the url calls the function show in the controller
781+* codeviewer (this file below).
782+*
783+* The params after the url equals the input arguments of the function. Function show() has 3 arguments
784+* and therefore requires 3 arguments to be given in the url, like so: codeviewer/show/courseid/exampleid/pageid
785+*/
786 class Codeviewer extends CI_Controller {
787
788+ /**
789+ * This shows the codeviewer page
790+ */
791 public function show($course, $example, $page){
792 $this->load->model('codeviewer/Codeviewer_model');
793
794- $files = $this->Codeviewer_model->getFiles($course, $example,$page);
795- $editorHTML = "";
796- foreach ($files as $file) {
797- $editorHTML .= $this->Codeviewer_model->showFile($file, "html");
798- }
799+ $editorHTML = $this->Codeviewer_model->getCode($course, $example, $page);
800
801 $doc = $this->Codeviewer_model->getDoc($course, $example, $page);
802
803+ // This loads the view. It's stored in application/views/codeviewer/codeviewer.php
804+ // Do note that application/views should not be in the first argument of view()
805+ // The second argument is data to be shown in the view. "editors" => "test" would
806+ // generate an $editors variable in the view containing "test"
807 $this->load->view('codeviewer/codeviewer', array("editors" => $editorHTML, "documentation" => $doc));
808 }
809 }
810\ No newline at end of file
811
812=== modified file 'codeigniter/application/models/admin/admin_model.php'
813--- codeigniter/application/models/admin/admin_model.php 2013-04-11 13:59:06 +0000
814+++ codeigniter/application/models/admin/admin_model.php 2013-04-12 15:59:33 +0000
815@@ -1,4 +1,11 @@
816 <?php
817+/**
818+* This is a model. It holds the logic.
819+* It's loaded like this in the controllers: $this->load->model("path/to/model");
820+* This specific model is: $this->load->model("admin/admin_model")
821+*
822+* This model is the logic behind the admin panel. It let's you manage courses, pages etc
823+*/
824 class Admin_model extends CI_Model {
825
826 function __construct() {
827@@ -12,9 +19,9 @@
828
829 function addCourse($cid, $name){
830 $data = array(
831- 'cid' => $cid ,
832- 'name' => $name
833- );
834+ 'courseID' => $cid ,
835+ 'courseName' => $name
836+ );
837
838 $this->db->insert('courses', $data);
839 mkdir("../courses/".$cid);
840@@ -22,15 +29,16 @@
841 }
842
843 function getExamples($cid) {
844- $query = $this->db->get_where('examples', array("cid" => $cid));
845+ $query = $this->db->get_where('examples', array("Courses_courseID" => $cid));
846 return $query->result();
847 }
848
849- function addExample($cid, $example){
850+ function addExample($cid, $example, $description){
851 $data = array(
852- 'cid' => $cid ,
853- 'example' => $example
854- );
855+ 'Courses_courseID' => $cid ,
856+ 'Name' => $example,
857+ 'description' => $description
858+ );
859
860 $this->db->insert('examples', $data);
861 mkdir("../courses/".$cid."/".$example);
862@@ -38,32 +46,90 @@
863 }
864
865 function getPages($cid, $example) {
866- $query = $this->db->get_where('pages', array("cid" => $cid, "example" => $example));
867+ $query = $this->db->get_where('pages', array("Examples_Courses_courseID" => $cid, "Examples_Name" => $example));
868 return $query->result();
869 }
870
871- function addPage($cid, $example, $page, $documentation){
872+ function addPage($cid, $example, $page){
873 $data = array(
874- 'cid' => $cid ,
875- 'example' => $example,
876- 'page' => $page ,
877- 'documentation' => $documentation
878- );
879+ 'Examples_Courses_courseID' => $cid ,
880+ 'Examples_Name' => $example,
881+ 'name' => $page
882+ );
883
884 $this->db->insert('pages', $data);
885 mkdir("../courses/".$cid."/".$example."/".$page);
886
887+ $data = array(
888+ 'fileName' => $cid."/".$example."/".$page."/documentation",
889+ 'language' => $file->lang,
890+ 'fileType' => $file->type,
891+ 'dataBlob' => $output
892+ );
893+
894+ $this->db->insert('files', $data);
895+
896+ $data = array(
897+ 'Files_fileName' => $cid."/".$example."/".$page."/documentation" ,
898+ 'Pages_name' => $page,
899+ 'Pages_Examples_Name' => $example,
900+ 'Pages_Examples_Courses_courseID' => $cid
901+ );
902+
903+ $this->db->insert('pagesfiles', $data);
904+
905 }
906
907- function updatePage($cid, $example, $page, $documentation){
908+ function updatePage($cid, $example, $page, $documentation, $files){
909+
910+ $filearr = json_decode($files);
911+
912+ foreach ($filearr as $file) {
913+ $output = "";
914+ $handle = @fopen("../courses/".$cid."/".$example."/".$page."/".$file->filename, "r");
915+ if ($handle) {
916+
917+ while (($buffer = fgets($handle, 4096)) !== false) {
918+
919+ $buffer = str_replace("&", "&amp;", $buffer);
920+ $buffer = str_replace("<", "&lt;", $buffer);
921+ $buffer = str_replace(">", "&gt;", $buffer);
922+
923+ $output .= $buffer;
924+ }
925+ if (!feof($handle)) {
926+ $output .= "Error: unexpected fgets() fail\n";
927+ }
928+ fclose($handle);
929+ }
930+
931+ $data = array(
932+ 'fileName' => $file->filename ,
933+ 'language' => $file->lang,
934+ 'fileType' => $file->type,
935+ 'dataBlob' => $output
936+ );
937+
938+ $this->db->insert('files', $data);
939+
940+ $data = array(
941+ 'Files_fileName' => $file->filename ,
942+ 'Pages_name' => $page,
943+ 'Pages_Examples_Name' => $example,
944+ 'Pages_Examples_Courses_courseID' => $cid
945+ );
946+
947+ $this->db->insert('pagesfiles', $data);
948+ }
949+
950 $data = array(
951- 'documentation' => $documentation
952- );
953-
954- $this->db->where('cid', $cid);
955- $this->db->where('example', $example);
956- $this->db->where('page', $page);
957- $this->db->update('pages', $data);
958+ 'dataBlob' => $documentation
959+ );
960+
961+ $this->db->where("fileName",$cid."/".$example."/".$page."/"."documentation" );
962+ $this->db->update('files', $data);
963+
964+
965 }
966
967 function uploadFile($files, $cid, $example, $page){
968
969=== modified file 'codeigniter/application/models/codeviewer/codeviewer_model.php'
970--- codeigniter/application/models/codeviewer/codeviewer_model.php 2013-04-10 15:49:32 +0000
971+++ codeigniter/application/models/codeviewer/codeviewer_model.php 2013-04-12 15:59:33 +0000
972@@ -5,66 +5,61 @@
973 $this->load->database();
974 }
975
976- function showFile($filename, $lang, $interestingrows = array()) {
977+ function getCode($cid, $example, $page) {
978+
979+ $this->db->from('files');
980+ $this->db->join("pagesfiles", "pagesfiles.Files_fileName = files.fileName");
981+ $this->db->where("pagesfiles.Pages_name", $page);
982+ $this->db->where("pagesfiles.Pages_Examples_Name", $example);
983+ $this->db->where("pagesfiles.Pages_Examples_Courses_courseID", $cid);
984+ $this->db->not_like("pagesfiles.Files_fileName", $cid."/".$example."/".$page."/"."documentation");
985+
986+ $query = $this->db->get();
987 $output = "";
988- $output .= '<div class="editorinfo">'.$lang.'&nbsp;&nbsp;&nbsp;&nbsp;'.$filename.'</div>';
989- $output .= '<div id="ace_'.str_replace(".", "", $filename).'" class="ace">';
990- $handle = @fopen($filename, "r");
991- if ($handle) {
992-
993- while (($buffer = fgets($handle, 4096)) !== false) {
994-
995- $buffer = str_replace("&", "&amp;", $buffer);
996- $buffer = str_replace("<", "&lt;", $buffer);
997- $buffer = str_replace(">", "&gt;", $buffer);
998-
999- $output .= $buffer;
1000- }
1001- if (!feof($handle)) {
1002- $output .= "Error: unexpected fgets() fail\n";
1003- }
1004- fclose($handle);
1005- }
1006- $output .= '</div>';
1007-
1008- $output .= '<script type="text/javascript">
1009- var Range = require("ace/range").Range;
1010- var editor = ace.edit("ace_'.str_replace(".", "", $filename).'");
1011- editor.setTheme("ace/theme/merbivore");
1012- editor.getSession().setMode("ace/mode/'.$lang.'");
1013- editor.setReadOnly(true);
1014- editor.setShowPrintMargin(false);
1015- editor.setDisplayIndentGuides(false);
1016- editor.setHighlightSelectedWord(true);
1017- lines = editor.getSession().getLength();
1018- $("#ace_'.str_replace(".", "", $filename).'").height(Math.min(500,lines*16));
1019- aceeditors.push("ace_'.str_replace(".", "", $filename).'");';
1020- for($i = 0; $i < count($interestingrows); $i++) {
1021+ foreach ($query->result() as $row) {
1022+ $output .= '<div class="editorinfo">'.$row->language.'&nbsp;&nbsp;&nbsp;&nbsp;'.$row->fileName.'</div>';
1023+ $output .= '<div id="ace_'.str_replace(".", "", $row->fileName).'" class="ace">';
1024+ $output .= $row->dataBlob;
1025+ $output .= '</div>';
1026+
1027+ $output .= '<script type="text/javascript">
1028+ var Range = require("ace/range").Range;
1029+ var editor = ace.edit("ace_'.str_replace(".", "", $row->fileName).'");
1030+ editor.setTheme("ace/theme/merbivore");
1031+ editor.getSession().setMode("ace/mode/'.$row->language.'");
1032+ editor.setReadOnly(true);
1033+ editor.setShowPrintMargin(false);
1034+ editor.setDisplayIndentGuides(false);
1035+ editor.setHighlightSelectedWord(true);
1036+ lines = editor.getSession().getLength();
1037+ $("#ace_'.str_replace(".", "", $row->fileName).'").height(Math.min(500,lines*16));
1038+ aceeditors.push("ace_'.str_replace(".", "", $row->fileName).'");';
1039+
1040+ /*
1041+ for($i = 0; $i < count($interestingrows); $i++) {
1042 $output .= 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
1043 .$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
1044+ }
1045+ */
1046+ $output .= '</script>';
1047+
1048 }
1049- $output .= '</script>';
1050
1051 return $output;
1052 }
1053
1054- function getFiles($course, $example, $page){
1055- $files = array();
1056- if ($handle = opendir("../courses/".$course."/". $example."/".$page."/")) {
1057- while (false !== ($entry = readdir($handle))) {
1058- if($entry == "." || $entry == "..") continue;
1059- $files[] = "../courses/".$course."/". $example."/".$page."/".$entry;
1060- }
1061- }
1062-
1063- return $files;
1064- }
1065-
1066 function getDoc($cid, $example, $page){
1067- $this->db->select('documentation');
1068- $query = $this->db->get_where('pages', array('cid' => $cid, 'example' => $example, 'page' => $page));
1069+ $this->db->select('dataBlob');
1070+ $this->db->from('files');
1071+ $this->db->join("pagesfiles", "pagesfiles.Files_fileName = files.fileName");
1072+ $this->db->where("pagesfiles.Pages_name", $page);
1073+ $this->db->where("pagesfiles.Pages_Examples_Name", $example);
1074+ $this->db->where("pagesfiles.Pages_Examples_Courses_courseID", $cid);
1075+ $this->db->where("pagesfiles.Files_fileName", $cid."/".$example."/".$page."/"."documentation");
1076+
1077+ $query = $this->db->get();
1078 $result = $query->result();
1079- return $result[0]->documentation;
1080+ return $result[0]->dataBlob;
1081 }
1082
1083 }
1084
1085=== modified file 'codeigniter/application/views/admin/add_example.php'
1086--- codeigniter/application/views/admin/add_example.php 2013-04-11 13:59:06 +0000
1087+++ codeigniter/application/views/admin/add_example.php 2013-04-12 15:59:33 +0000
1088@@ -31,6 +31,8 @@
1089 echo form_open(base_url().'admin/addexample');
1090 echo form_label('Example name', 'example');
1091 echo form_input(array('name' => 'example', 'required' => 'required'));
1092+ echo form_label('Description', 'description');
1093+ echo form_input(array('name' => 'description', 'required' => 'required'));
1094 echo form_hidden('cid',$cid);
1095 echo "<br>";
1096 echo form_submit(array('name' => 'submit', 'value' => 'Add example', "class" => "btn btn-primary"));
1097
1098=== modified file 'codeigniter/application/views/admin/add_page.php'
1099--- codeigniter/application/views/admin/add_page.php 2013-04-11 13:59:06 +0000
1100+++ codeigniter/application/views/admin/add_page.php 2013-04-12 15:59:33 +0000
1101@@ -31,8 +31,6 @@
1102 echo form_open(base_url().'admin/addpage');
1103 echo form_label('Page name', 'page');
1104 echo form_input(array('name' => 'page', 'required' => 'required'));
1105- echo form_label('Documentation', 'documentation');
1106- echo form_input(array('name' => 'documentation', 'required' => 'required'));
1107 echo form_hidden('cid',$cid);
1108 echo form_hidden('example',$example);
1109 echo "<br>";
1110
1111=== modified file 'codeigniter/application/views/admin/index.php'
1112--- codeigniter/application/views/admin/index.php 2013-04-11 13:59:06 +0000
1113+++ codeigniter/application/views/admin/index.php 2013-04-12 15:59:33 +0000
1114@@ -47,9 +47,9 @@
1115 foreach ($courses as $item):
1116 ?>
1117 <tr>
1118- <td><?php echo $item->cid ?></td>
1119- <td><?php echo $item->name ?></td>
1120- <td><button class="btn btn-primary" onClick="window.location.href='<?php echo base_url();?>admin/managecourse/<?php echo $item->cid ?>'"><i class="icon-cog icon-white"></i> Manage</button></td>
1121+ <td><?php echo $item->courseID ?></td>
1122+ <td><?php echo $item->courseName ?></td>
1123+ <td><button class="btn btn-primary" onClick="window.location.href='<?php echo base_url();?>admin/managecourse/<?php echo $item->courseID?>'"><i class="icon-cog icon-white"></i> Manage</button></td>
1124 </tr>
1125 <?php endforeach;?>
1126 </tbody>
1127
1128=== modified file 'codeigniter/application/views/admin/manage_course.php'
1129--- codeigniter/application/views/admin/manage_course.php 2013-04-11 13:59:06 +0000
1130+++ codeigniter/application/views/admin/manage_course.php 2013-04-12 15:59:33 +0000
1131@@ -33,7 +33,7 @@
1132 <div class="span9">
1133
1134 <div class="span9" id="content">
1135- <h2>Manage example - <?php echo $cid ?></h2>
1136+ <h2>Manage course - <?php echo $cid ?></h2>
1137 <table class="table table-striped">
1138 <thead>
1139 <tr>
1140@@ -46,8 +46,8 @@
1141 foreach ($examples as $item):
1142 ?>
1143 <tr>
1144- <td><?php echo $item->example ?></td>
1145- <td><button class="btn btn-primary" onClick="window.location.href='<?php echo base_url();?>admin/manageexample/<?php echo $item->cid ?>/<?php echo $item->example ?>'"><i class="icon-cog icon-white"></i> Manage</button></td>
1146+ <td><?php echo $item->Name ?></td>
1147+ <td><button class="btn btn-primary" onClick="window.location.href='<?php echo base_url();?>admin/manageexample/<?php echo $cid ?>/<?php echo $item->Name ?>'"><i class="icon-cog icon-white"></i> Manage</button></td>
1148 </tr>
1149 <?php endforeach;?>
1150 </tbody>
1151
1152=== modified file 'codeigniter/application/views/admin/manage_example.php'
1153--- codeigniter/application/views/admin/manage_example.php 2013-04-11 13:59:06 +0000
1154+++ codeigniter/application/views/admin/manage_example.php 2013-04-12 15:59:33 +0000
1155@@ -46,8 +46,8 @@
1156 foreach ($pages as $item):
1157 ?>
1158 <tr>
1159- <td><?php echo $item->page ?></td>
1160- <td><button class="btn btn-primary" onClick="window.location.href='<?php echo base_url();?>admin/managepage/<?php echo $item->cid ?>/<?php echo $item->example ?>/<?php echo $item->page ?>'"><i class="icon-cog icon-white"></i> Manage</button></td>
1161+ <td><?php echo $item->name ?></td>
1162+ <td><button class="btn btn-primary" onClick="window.location.href='<?php echo base_url();?>admin/managepage/<?php echo $cid ?>/<?php echo $example ?>/<?php echo $item->name ?>'"><i class="icon-cog icon-white"></i> Manage</button></td>
1163 </tr>
1164 <?php endforeach;?>
1165 </tbody>
1166
1167=== modified file 'codeigniter/application/views/admin/manage_page.php'
1168--- codeigniter/application/views/admin/manage_page.php 2013-04-11 13:59:06 +0000
1169+++ codeigniter/application/views/admin/manage_page.php 2013-04-12 15:59:33 +0000
1170@@ -16,32 +16,31 @@
1171
1172
1173 <h3>Managing page - <?php echo $page?> </h3>
1174+
1175
1176+ <div id="dropbox">
1177+ <span class="message"><i>Drop files here to upload</i></span>
1178+
1179+ <div class="progressHolder">
1180+ <div class="progress"></div>
1181+ </div>
1182+ </div>
1183+ <div id="filelist">
1184+ </div>
1185 <?php
1186
1187 echo form_open(base_url().'admin/managepage');
1188 echo form_label('Documentation', 'documentation');
1189- echo form_textarea(array('name' => 'documentation', 'class' => 'ckeditor', 'required' => 'required', 'value' => $documentation));
1190+ echo form_textarea(array('name' => 'documentation', 'class' => 'ckeditor'/*, 'value' => $documentation*/));
1191 echo form_hidden('cid',$cid);
1192 echo form_hidden('example',$example);
1193 echo form_hidden('page',$page);
1194+ echo form_hidden('files');
1195 echo "<br>";
1196- echo form_submit(array('name' => 'submit', 'value' => 'Add page', "class" => "btn btn-primary"));
1197+ echo form_submit(array('name' => 'submit', 'value' => 'Update page', "class" => "btn btn-primary"));
1198 echo form_close();
1199
1200 ?>
1201-
1202- <div id="dropbox">
1203- <span class="message"><i>Drop files here to upload</i></span>
1204-
1205- <div class="progressHolder">
1206- <div class="progress"></div>
1207- </div>
1208- </div>
1209- <div id="filelist">
1210- <ul id="flist">
1211- </ul>
1212- </div>
1213
1214 </div>
1215 <div class="span6">
1216
1217=== modified file 'codeigniter/application/views/codeviewer/codeviewer.php'
1218--- codeigniter/application/views/codeviewer/codeviewer.php 2013-04-11 13:59:06 +0000
1219+++ codeigniter/application/views/codeviewer/codeviewer.php 2013-04-12 15:59:33 +0000
1220@@ -1,5 +1,24 @@
1221 <!DOCTYPE html>
1222 <html>
1223+<!--
1224+ Created by
1225+____ __ ____ _______ ______ __ __ _______ __ __ __ __
1226+\ \ / \ / / | ____|| _ \ | | | | / _____/_ | /_ | | | | |
1227+ \ \/ \/ / | |__ | |_) | | | | | | | __ | | | | | |__| |
1228+ \ / | __| | _ < | | | | | | |_ | | | | | | __ |
1229+ \ /\ / | |____ | |_) | | `--' | | |__| | | | | | | | | |
1230+ \__/ \__/ |_______||______/ \______/ \______| |_| |_| |__| |__|
1231+
1232+ _______ ____ ____ ______ __ __ __ __
1233+| \ \ \ / / | _ \ /_ | /_ | | | | |
1234+| .--. | \ \/ / | |_) | | | | | | |__| |
1235+| | | | \ / | ___/ | | | | | __ |
1236+| '--' | \ / | | | | | | | | | |
1237+|_______/ \__/ | _| |_| |_| |__| |__|
1238+
1239+ Spring 2013
1240+
1241+ -->
1242 <head>
1243 <script src="<?php echo base_url();?>js/ace/ace.js" type="text/javascript" charset="utf-8"></script>
1244 <script src="<?php echo base_url();?>js/jquery-1.8.0.min.js" type="text/javascript" charset="utf-8"></script>
1245
1246=== modified file 'codeigniter/css/adminstyle.css'
1247--- codeigniter/css/adminstyle.css 2013-04-11 13:59:06 +0000
1248+++ codeigniter/css/adminstyle.css 2013-04-12 15:59:33 +0000
1249@@ -174,4 +174,8 @@
1250 opacity: 0.5;
1251 position: absolute;
1252 z-index: 4;
1253+}
1254+
1255+.file {
1256+ background-color: #ccc;
1257 }
1258\ No newline at end of file
1259
1260=== modified file 'codeigniter/js/script.js'
1261--- codeigniter/js/script.js 2013-04-10 15:49:32 +0000
1262+++ codeigniter/js/script.js 2013-04-12 15:59:33 +0000
1263@@ -1,13 +1,4 @@
1264 $(function(){
1265- var $_GET = {};
1266-
1267- document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
1268- function decode(s) {
1269- return decodeURIComponent(s.split("+").join(" "));
1270- }
1271-
1272- $_GET[decode(arguments[1])] = decode(arguments[2]);
1273- });
1274
1275 var dropbox = $('#dropbox'),
1276 message = $('.message', dropbox);
1277@@ -20,7 +11,14 @@
1278
1279 uploadFinished:function(i,file,response){
1280 $('.progress').addClass('done');
1281- $('#flist').append("<li>"+file.name+"</li>")
1282+ html = "";
1283+ html += '<div class="file">';
1284+ html += "<strong>"+file.name+"</strong>";
1285+ html += '<input type="hidden" value="'+file.name+'">';
1286+ html += '<label>Language</label><input type="text" name="'+file.name.replace(/\s/g,"")+'_lang" onChange="fileupdated()">';
1287+ html += '<label>Type</label><input type="text" name="'+file.name.replace(/\s/g,"")+'_type" onChange="fileupdated()">';
1288+ html += "</div>";
1289+ $('#filelist').append(html);
1290
1291 },
1292
1293@@ -54,4 +52,13 @@
1294 message.html(msg);
1295 }
1296
1297-});
1298\ No newline at end of file
1299+});
1300+
1301+function fileupdated(){
1302+ var fileinfo = [];
1303+ $('.file').each(function() {
1304+ inputs = $(this).find("input");
1305+ fileinfo.push({"filename":inputs.get(0).value, "lang": inputs.get(1).value, "type": inputs.get(2).value});
1306+ });
1307+ $("input[name='files']").val(JSON.stringify(fileinfo));
1308+}
1309\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: