%Teilweise Erzeugt mit dem LaTeX-Generator: http://latex.sehnot.de

%Schriftgröße, Layout, Papierformat, Art des Dokumentes
\documentclass[10pt,oneside,a4paper]{scrartcl}

%Einstellungen der Seitenränder
\usepackage[left=2cm,right=2cm,top=1.5cm,bottom=1.5cm,includeheadfoot]{geometry}

%neue Rechtschreibung
\usepackage[ngerman]{babel}

%Umlaute ermöglichen
\usepackage[utf8]{inputenc}

%Gesamtseitenzahl
\usepackage{lastpage}

% Kopf- und Fußzeile
\usepackage[automark]{scrpage2}

%Quellcode-Listings
\usepackage{listings}

%Hyperlinks
\usepackage{hyperref}

\usepackage{listings}
\usepackage{color}
\definecolor{lightgray}{rgb}{.9,.9,.9}
\definecolor{darkgray}{rgb}{.4,.4,.4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}

\lstdefinelanguage{JavaScript}{
  keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
  keywordstyle=\color{blue}\bfseries,
  ndkeywords={class, export, boolean, throw, implements, import, this},
  ndkeywordstyle=\color{darkgray}\bfseries,
  identifierstyle=\color{black},
  sensitive=false,
  comment=[l]{//},
  morecomment=[s]{/*}{*/},
  commentstyle=\color{purple}\ttfamily,
  stringstyle=\color{red}\ttfamily,
  morestring=[b]',
  morestring=[b]"
}

\lstset{
   language=JavaScript,
   backgroundcolor=\color{lightgray},
   extendedchars=true,
   basicstyle=\footnotesize\ttfamily,
   showstringspaces=false,
   showspaces=false,   
   tabsize=2,
   breaklines=true,
   showtabs=false,
   captionpos=b
}

%Kopfzeile
\ihead{JavaScript}
\chead{}
\ohead{http://kohnlehome.de/html/javascript.pdf}
\setheadsepline{0.5pt}

%Fußzeile
\setfootsepline{0.5pt}
\ifoot{Franz Kohnle}
\cfoot{Seite \thepage\ von  \pageref{LastPage}}
\ofoot{\today}

\pagestyle{scrheadings}

\begin{document}

% Überschrift 
\begin{center}
\LARGE % Schriftgröße
\bfseries % Fettdruck
\sffamily % Serifenlose Schrift
JavaScript
\end{center}


\section{Einbinden in (X)HTML}
\subsection{Im Quellcode (z.B. head)}
\lstset{language=html}
\begin{lstlisting}[]
<script type="text/javascript">
   ...
</script>
\end{lstlisting}

\subsection{In extra Datei}
\lstset{language=html}
\begin{lstlisting}[]
<script src="datei.js" type="text/javascript" />
\end{lstlisting}

\section{Ausgabe}
\lstset{language=JavaScript}
\begin{lstlisting}[]
document.write("Text");
\end{lstlisting}

\section{Kommentare}
\begin{lstlisting}[]
// ...
/* ... */
\end{lstlisting}


\section{Strict Mode}
\begin{lstlisting}[]
"use strict";
\end{lstlisting}


\section{Variablen}
\subsection{Deklaration}
\begin{lstlisting}[]
var a = true;
var b = 1.23;
var c = "Text";
\end{lstlisting}


\subsection{Typ ermitteln}
\begin{lstlisting}[]
typeof(variable); // undefined, number, boolean, string, object
\end{lstlisting}





\section{Operatoren}
\subsection{arithmetisch}
\begin{lstlisting}[]
+ - * / %
\end{lstlisting}

\subsection{Zuweisung}
\begin{lstlisting}[]
= += -= *= /= %=
\end{lstlisting}

\subsection{Inkrement, Dekrement}
\begin{lstlisting}[]
++ --
\end{lstlisting}

\subsection{Vergleich}
\begin{lstlisting}[]
< <= > >= == !=
\end{lstlisting}

\subsection{logisch}
\begin{lstlisting}[]
&&  ||  !
\end{lstlisting}

\subsection{Textverkettung}
\begin{lstlisting}[]
"Text" + text
\end{lstlisting}




\section{Verzweigungen}
\subsection{if}
\begin{lstlisting}[]
if(bedingung){
    ...
} else {
    ...
}
\end{lstlisting}

\subsection{switch}
\begin{lstlisting}[]
switch(variable){
    case wert1:
        ...
        break;
    case wert2:
        ...
        break;
    default:
        ...
}
\end{lstlisting}

\section{Schleifen}
\subsection{do}
\begin{lstlisting}[]
do{
    ...
}while(bedingung);  
\end{lstlisting}

\subsection{while}
\begin{lstlisting}[]
while(bedingung){
    ...
}  
\end{lstlisting}

\subsection{for}
\begin{lstlisting}[]
for(var i=0; i<5; i++){
    ...
}  
\end{lstlisting}




\section{Funktionen}
\subsection{Definition}
\begin{lstlisting}[]
function name(par1, par2){
    ...
    return rueck;
}  
\end{lstlisting}

\subsection{Aufruf}
\begin{lstlisting}[]
rueck = name(arg1, arg2);  
\end{lstlisting}



\end{document}
