Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/contentedit.html
blob: a439b428a92109c986fd89641f130142ed89ab1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html>
<head>
<title>Siyavula Content Editor</title>
<link rel="stylesheet" href="content/karma/css/global.css" type="text/css"/>
<script type="text/javascript" src="tinymce/jquery.js"></script>
<script type="text/javascript" src="tinymce/jquery.tinymce.js"></script>
<script type="text/javascript" src="tinymce/tiny_mce.js"></script>
<script type="text/javascript">

host = 'http://localhost:8008/'
url = window.location+'';
parts = url.split('?');
parts.shift();
temp = parts[0];
items = temp.split('/');
items.pop();
items.shift();
items.shift();
items.shift();
openfolder = items.join('/')+'/';
openfile = openfolder + 'source.txt';
tinyMCE.init({
    mode : "textareas",
    theme : "advanced",
    theme_advanced_toolbar_location : 'top',
    theme_advanced_toolbar_align : 'left',
    theme_advanced_resizing : 'true',
    editor_selector:"mceAdvanced",
    relative_urls : 'true',
    document_base_url : host + openfolder,
    content_css: host + 'content/karma/css/global.css',
    width: "1200",
    height: "4000"
});

$(document).ready(function(){
  var ed = tinyMCE.get('cntnt');
  $('#editreturn')
      .bind('click', function(){window.location = host + openfolder + 'index.html'})
  $('#cntnt').load(host + 'cgi-bin/fetchFile.py',
    {'openfile':openfile},
    function(responseTxt, status, xhr){
      $('#cntnt').text(responseTxt);
  });
});

function ajaxSave() {
  var ed = tinyMCE.get('cntnt');
  ed.setProgressState(1); // Show progress
  $('#cntnt').load(host+'cgi-bin/saveFile.py', 
    {'openfile':openfile, 'content':ed.getContent()}, 
      function(responseText, status, xhr){
    ed.setProgressState(0);
  });
};

function toggleEditor(id) {
  if (!tinyMCE.get(id)){
    tinyMCE.execCommand('mceAddControl', false, id);
  }else{
    tinyMCE.execCommand('mceRemoveControl', false, id);
  };
};

</script>
</head>
<body style='height: 4000'>
        <div id="header">
            <div class="topbtn_left">
                <div title="Back" id="editreturn" class="linkBack"></div>
            </div>
            <div class='lesson_title'>
              <img src='content/karma/image/title_block_lt.png' class='title_img'>
              Content Editor
              <img src='content/karma/image/title_block_rt.png' class='title_img'>
            </div>
            <div class="topbtn_right">
              <div title="Quit" id = 'linkQuit' class='linkQuit'>Quit</div>
            </div>
            <div class='topbtn_right'>
              <a href="javascript:ajaxSave();">save</a>
            </div>
            <div class='topbtn_right'>
              <a href="javascript:toggleEditor('cntnt');">web/html</a>
            </div>
        </div>
<div id='content'>
  <textarea id="cntnt" name='cntnt' class='mceAdvanced'> 
  </textarea>
</div>
</body>
</html>