~writkirb/novacut/scripttest

« back to all changes in this revision

Viewing changes to ui/userwebscript/screenplay.js

  • Committer: Jonathan Kirby
  • Date: 2012-09-08 22:00:34 UTC
  • mfrom: (290.1.13 scripttest)
  • Revision ID: writkirb@yahoo.com-20120908220034-3csyrkh02jxny4tg
?

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    session.subscribe(doc._id, this.on_change, this);
53
53
    this.session = session;
54
54
    this.element = $el('div', {'class': 'scene', 'id': doc._id});
 
55
<<<<<<< TREE
55
56
    this.element.style.width = '302px';
56
57
    this.element.style.height = '32px';
57
58
    this.element.style.backgroundColor = 'ae8';
58
59
 
 
60
=======
 
61
//    this.element.style.width = '302px';
 
62
//    this.element.style.height = '32px';
 
63
//    this.element.style.backgroundColor = 'ae8';
 
64
>>>>>>> MERGE-SOURCE
59
65
    
60
66
    this.heading = new Heading(session, session.get_doc(doc['heading']));
61
 
        this.action = new Action(session, session.get_doc(doc['action']))
 
67
        //this.action = new Action(session, session.get_doc(doc['action']))
62
68
    this.element.appendChild(this.heading.element);
 
69
    
 
70
    console.log(doc.blocks.length);
 
71
    
 
72
    for(i = 0; i < doc['blocks'].length; i++){
 
73
        console.log(doc['blocks'][i]);
 
74
        current_doc = session.get_doc(doc['blocks'][i])
 
75
        if (current_doc['type'] = 'action') {
 
76
            this.new_block = new Action(session, current_doc);
 
77
            this.element.appendChild(this.new_block.element);
 
78
        }
 
79
        else {
 
80
        
 
81
        }
 
82
        
 
83
    }
63
84
 
64
85
 
65
86
 
106
127
    this.element.onkeypress = function(e){
107
128
        console.log(e);
108
129
        if (e.keyCode == 13) {
 
130
            console.log(self.element.parentNode);
 
131
            parent = self.element.parentNode;
 
132
            parent_doc = session.get_doc(parent.id);
 
133
            i = 0;
 
134
            found = false;
 
135
            if (parent_doc.heading == self.element.id) {
 
136
                found = true;
 
137
            }
 
138
            if (!found) {
 
139
                for(i = 1; i <= (parent_doc.blocks.length); i++) {
 
140
                    if (parent_doc.blocks[i-1] == self.element.id) {
 
141
                        found = true;
 
142
                        break;
 
143
                    }
 
144
                }
 
145
            }
 
146
            
 
147
            if (found) {
 
148
                action_doc = {}
 
149
                action_doc['type'] = 'action';
 
150
                action_doc['text'] = '';
 
151
                db.save(action_doc); 
 
152
                console.log(parent_doc['blocks']);
 
153
 
 
154
                try{
 
155
                    parent_doc['blocks'].splice(i,0, action_doc['_id']);
 
156
                }
 
157
                catch (exeption) {
 
158
                    parent_doc.blocks = [action_doc['_id']];
 
159
                }
 
160
 
 
161
                
 
162
                db.save(parent_doc);
 
163
                
 
164
                console.log(parent_doc);
 
165
                action = new Action(session, session.get_doc(parent_doc.blocks[i]));
 
166
                try {
 
167
                    parent.insertBefore(action.element, self.element.nextSibling);
 
168
                }
 
169
                catch (exception) {
 
170
                    parent.appendChild(action.element);
 
171
                }
 
172
                action.element.focus();
 
173
            }
 
174
            
109
175
            return false;
110
176
        }
111
177
    }