Back to index

plone3  3.1.7
Public Member Functions
kss.core.plugins.core.demo.typewriter.KSSTypewriterDemo Class Reference
Inheritance diagram for kss.core.plugins.core.demo.typewriter.KSSTypewriterDemo:
Inheritance graph
[legend]
Collaboration diagram for kss.core.plugins.core.demo.typewriter.KSSTypewriterDemo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def displayedKeys
def setCurrentLesson
def loadInitialPattern
def getLessons
def getLessonTitles
def keydown
def keyup
def mousedown
def mouseup

Detailed Description

Definition at line 22 of file typewriter.py.


Member Function Documentation

Definition at line 24 of file typewriter.py.

00024 
00025     def displayedKeys(self):
00026         keys = [
00027             [113, 119, 101, 114, 116, 122, 117, 105, 111, 112],
00028             [97, 115, 100, 102, 103, 104, 106, 107, 108],
00029             [121, 120, 99, 118, 98, 110, 109],
00030             [32]
00031         ]
00032         return keys
    

Definition at line 50 of file typewriter.py.

00050 
00051     def getLessons(self):
00052         lessons = {
00053             'Lesson 1'      : 'This is our first lesson at the SnowSprint',
00054             'Lesson 2'      : 'KSS is a generic javascript AJAX framework',
00055         }
00056         return lessons

Here is the caller graph for this function:

Definition at line 57 of file typewriter.py.

00057 
00058     def getLessonTitles(self):
00059         titles = self.getLessons().keys()
00060         titles.sort()
00061         return titles
00062 
    

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file typewriter.py.

00063 
00064     def keydown(self, keycode):
00065         keycode = int(keycode)
00066         if keycode == 16:
00067             self.getCommandSet('core').addClass('div#key_16', 'active')
00068             for key in range(97, 97+26):
00069                 self.getCommandSet('core').replaceInnerHTML('div#key_%s' % key, chr(key).upper())
00070         elif keycode in range(97, 97+26) + range(65, 65+26) + [32]:
00071             smallKeycode = keycode
00072             if keycode in range(65, 65+26):
00073                 smallKeycode += 32
00074             self.getCommandSet('core').addClass('div#key_%s' % smallKeycode, 'active')
00075             currentText = self.request.SESSION['typewriter']
00076             if len(currentText)>0 and currentText[0]==chr(keycode):
00077                 currentText = currentText[1:]
00078                 self.request.SESSION['typewriter'] = currentText
00079                 if len(currentText)==0:
00080                     currentText = 'please select another lesson'
00081                     self.getCommandSet('core').removeClass('input.lesson', 'active')
00082                 self.getCommandSet('core').replaceInnerHTML('div#pattern', currentText.replace(' ', ' '))
00083         return self.render()

Here is the caller graph for this function:

Definition at line 84 of file typewriter.py.

00084 
00085     def keyup(self, keycode):
00086         keycode = int(keycode)
00087         if keycode == 16:
00088             for key in range(97, 97+26):
00089                 self.getCommandSet('core').replaceInnerHTML('div#key_%s' % key, chr(key))
00090             self.getCommandSet('core').removeClass('div#key_16', 'active')
00091         elif keycode in range(97, 97+26) + range(65, 65+26) + [32]:
00092             smallKeycode = keycode
00093             if keycode in range(65, 65+26):
00094                 smallKeycode += 32
00095             self.getCommandSet('core').removeClass('div#key_%s' % smallKeycode, 'active')
00096         return self.render()

Here is the caller graph for this function:

Definition at line 43 of file typewriter.py.

00043 
00044     def loadInitialPattern(self):
00045         lessonText = self.getLessons()[self.getLessonTitles()[0]]
00046         self.request.SESSION['typewriter'] = lessonText
00047         return lessonText
00048 
00049 

Here is the call graph for this function:

Definition at line 97 of file typewriter.py.

00097 
00098     def mousedown(self, content):
00099         if content.strip()=='Shift':
00100             if self.request.SESSION.get('typewriter_shift', False):
00101                 self.request.SESSION['typewriter_shift'] = False
00102                 return self.keyup(16)
00103             else:
00104                 self.request.SESSION['typewriter_shift'] = True
00105                 return self.keydown(16)
00106         try:
00107             keycode = ord(content.strip())
00108         except:
00109             keycode = 32
00110         return self.keydown(keycode)

Here is the call graph for this function:

def kss.core.plugins.core.demo.typewriter.KSSTypewriterDemo.mouseup (   self,
  content,
  fieldValue 
)

Definition at line 111 of file typewriter.py.

00111 
00112     def mouseup(self, content, fieldValue):
00113         if content.strip()=='Shift':
00114             return self.render()
00115         try:
00116             keycode = ord(content.strip())
00117         except:
00118             keycode = 32
00119             content = ' '
00120         if self.request.SESSION.get('typewriter_shift', False):
00121             self.keyup(16)
00122         if keycode in range(97, 97+26) + range(65, 65+26) + [32]:
00123             self.getCommandSet('core').setAttribute('input#field', 'value', fieldValue + content)
00124             self.getCommandSet('core').focus('input#field')
00125         return self.keyup(keycode)

Definition at line 33 of file typewriter.py.

00033 
00034     def setCurrentLesson(self, title):
00035         text = self.getLessons()[title].strip()
00036         self.request.SESSION['typewriter'] = text
00037         self.getCommandSet('core').replaceInnerHTML('div#pattern', text)
00038         self.getCommandSet('core').setAttribute('input#field', 'value', '')
00039         self.getCommandSet('core').removeClass('input.lesson', 'active')
00040         self.getCommandSet('core').addClass('input#lesson_%s' % self.getLessonTitles().index(title), 'active')
00041         return self.render()
00042 


The documentation for this class was generated from the following file: