~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/browser/editor.js

  • Committer: William Grant
  • Date: 2008-07-07 01:57:58 UTC
  • mfrom: (unknown (missing))
  • Revision ID: wgrant@ugrad.unimelb.edu.au-20080707015758-k812ycn5bp6ijopz
Merge another bit of killall-editarea - automatic filetype detection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
        text.toString())
65
65
    div.appendChild(txt_elem);
66
66
    txt_elem.setAttribute("id", "editbox");
67
 
    txt_elem.className = "codepress python";
 
67
    language = language_from_mime(current_file.type)
 
68
 
 
69
    // Assume plaintext if no type can be determined.
 
70
    txt_elem.className = "codepress " + (language ? language : 'text');
68
71
    txt_elem.setAttribute("onchange", "edit_text()");
69
72
    /* TODO: Make CSS height: 100% work */
70
73
    txt_elem.setAttribute("rows", "35");
78
81
                                 disable_save_if_safe(); };
79
82
}
80
83
 
 
84
function language_from_mime(mime)
 
85
{
 
86
    return {'text/x-python': 'python',
 
87
            'application/javascript': 'javascript',
 
88
            'text/css': 'css',
 
89
            'text/plain': 'text',
 
90
            'text/html': 'html',
 
91
            'application/xhtml+xml': 'html'}[mime];
 
92
}