<commit_before><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">


    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleAnimator.js" charset="utf-8"></script>
    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleButton.js" charset="utf-8"></script>
    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleInfoButton.js" charset="utf-8"></script>
    <link rel="stylesheet" href="main.css">

	<script type="text/javascript" src="js/conf.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/storage.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/hogan.min.js.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/urls.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/utils.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/xhr.js" charset="utf-8"></script>

    <script type="text/javascript" src="Parts/parts.js" charset="utf-8"></script>
    <script type="text/javascript" src="localizedStrings.js" charset="utf-8"></script>
    <script type="text/javascript" src="main.js" charset="utf-8"></script>

	<script type="text/html" id="mainList">
		{{#json}}
			{{^mensaName}}
				<li class="divider">{{header}}</li>
			{{/mensaName}}
			{{#mensaName}}
				<li id="listRowTemplate" apple-template="true" class="listRowTemplate_template" style="">
					<div id="rowLabel" apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children rowLabel_template" apple-text-overflow="ellipsis">{{dish}}</div>
				</li>
			{{/mensaName}}	
		{{/json}}
	</script>
		
<!--
					<li>
						<h2>{{dish}}</h2>

						<p class="price">{{studPrice}}€</p>
						<p>{{name}}</p>
					</li>
-->

    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleScrollbar.js" charset="utf-8"></script>
    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleScrollArea.js" charset="utf-8"></script>
</head>
<body onload="load();" apple-part="com.apple.Dashcode.part.StackLayout">
    <div id="front">
        <img id="frontImg" src="Parts/Images/front.png" alt="" apple-locked="true" apple-part="com.apple.Dashcode.part.frontimage" apple-style="image-theme: 1; image-shape: 3; image-opacity: 1.00; image-top-color: 1.0000,1.0000,1.0000; image-bottom-color: 0.6154,0.6154,0.6154; image-radius: 12,12,12,12; image-border: 1; image-border-color: 0.5294,0.5294,0.5294; image-border-width: 1; shine-strength: 0.9; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 1; shadow-blur: 9.00; shadow-offset: -1.00,-6.00; shadow-color: 0.0000,0.0000,0.0000,0.3333;">
        <div class="apple-no-children" id="info" apple-part="com.apple.Dashcode.part.infobutton" apple-default-image-visibility="hidden"></div>
        <div id="topRectangleShape" apple-part="com.apple.Dashcode.part.toprectangleshape" class="apple-no-children" apple-style="image-theme: 1; image-shape: 9; image-button-type: 3; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.6154,0.6154,0.6154,1; image-radius: 12,12,-1,-1; image-border: 1; image-border-color: 0.5294,0.5294,0.5294,1; image-border-width: 1; shine-strength: 0.90; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 0;"></div>
        <div apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children" id="helloText" apple-group="text" apple-default-image-visibility="hidden" apple-style="part-height-dependent: true;"></div>
        <div id="scrollArea" apple-part="com.apple.Dashcode.part.scrollarea" apple-group="scrollArea">
            <div id="content" class="content" apple-group="scrollArea" style="position: absolute; left: 0px; top: 0px; right: 22px; bottom: 0px; overflow-x: hidden; overflow-y: hidden; ">
                <ul id="list" apple-part="com.apple.Dashcode.part.widgetList" class="">
                    <li id="listRowTemplate" apple-template="true" class="listRowTemplate_template" style="">
                        <div id="rowLabel" apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children rowLabel_template" apple-text-overflow="ellipsis"></div>
                    </li>
                </ul>
            </div></div>
        <div id="popup" apple-part="com.apple.Dashcode.part.roundedpopupbutton" class="apple-no-children" apple-style="image-theme: 1; image-shape: 3; image-button-type: 1; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.6154,0.6154,0.6154,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0.5294,0.5294,0.5294,1; image-border-width: 1; shine-strength: 0.90; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 0;"></div>
        <div id="popup1" apple-part="com.apple.Dashcode.part.roundedpopupbutton" class="apple-no-children" apple-style="image-theme: 1; image-shape: 3; image-button-type: 1; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.6154,0.6154,0.6154,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0.5294,0.5294,0.5294,1; image-border-width: 1; shine-strength: 0.90; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 0;"></div>
    </div>
    <div id="back">
		<NAME>
        <img id="backImg" src="Parts/Images/back.png" alt="" apple-locked="true" apple-part="com.apple.Dashcode.part.backimage" apple-style=" image-radius: 12,12,12,12; image-border: 1; image-border-color: 0.1500,0.1500,0.1500; image-border-width: 3; shadow-include-shadow: 1; shadow-blur: 9.00; shadow-offset: -1.00,-6.00; shadow-color: 0.0000,0.0000,0.0000,0.3333;">
        <img src="Images/DevelopedWith.png" alt="Created with Dashcode" id="backDevelopedWith">
        <div id="done" class="apple-no-children" apple-part="com.apple.Dashcode.part.glassbutton"></div>
    </div>
</body>
</html><commit_msg>MacOS Dashboard-Widget: Scripte erstmal inline<commit_after><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">


    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleAnimator.js" charset="utf-8"></script>
    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleButton.js" charset="utf-8"></script>
    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleInfoButton.js" charset="utf-8"></script>
    <link rel="stylesheet" href="main.css">

<script type="text/javascript">

/**
* @preserve Copyright 2012 Twitter, Inc.
* @license http://www.apache.org/licenses/LICENSE-2.0.txt
*/
var HoganTemplate=function(){function a(a){this.text=a}function h(a){return a=String(a===null?"":a),g.test(a)?a.replace(b,"&amp;").replace(c,"&lt;").replace(d,"&gt;").replace(e,"&#39;").replace(f,"&quot;"):a}a.prototype={r:function(a,b,c){return""},v:h,render:function(b,c,d){return this.r(b,c,d)},rp:function(a,b,c,d){var e=c[a];return e?e.r(b,c,d):""},rs:function(a,b,c){var d="",e=a[a.length-1];if(!i(e))return d=c(a,b);for(var f=0;f<e.length;f++)a.push(e[f]),d+=c(a,b),a.pop();return d},s:function(a,b,c,d,e,f,g){var h;return i(a)&&a.length===0?!1:(!d&&typeof a=="function"&&(a=this.ls(a,b,c,e,f,g)),h=a===""||!!a,!d&&h&&b&&b.push(typeof a=="object"?a:b[b.length-1]),h)},d:function(a,b,c,d){var e=a.split("."),f=this.f(e[0],b,c,d),g=null;if(a==="."&&i(b[b.length-2]))return b[b.length-1];for(var h=1;h<e.length;h++)f&&typeof f=="object"&&e[h]in f?(g=f,f=f[e[h]]):f="";return d&&!f?!1:(!d&&typeof f=="function"&&(b.push(g),f=this.lv(f,b,c),b.pop()),f)},f:function(a,b,c,d){var e=!1,f=null,g=!1;for(var h=b.length-1;h>=0;h--){f=b[h];if(f&&typeof f=="object"&&a in f){e=f[a],g=!0;break}}return g?(!d&&typeof e=="function"&&(e=this.lv(e,b,c)),e):d?!1:""},ho:function(a,b,c,d,e){var f=a.call(b,d,function(a){return Hogan.compile(a,{delimiters:e}).render(b,c)}),g=Hogan.compile(f.toString(),{delimiters:e}).render(b,c);return this.b=g,!1},b:"",ls:function(a,b,c,d,e,f){var g=b[b.length-1],h=a.call(g);return a.length>0?this.ho(a,g,c,this.text.substring(d,e),f):typeof h=="function"?this.ho(h,g,c,this.text.substring(d,e),f):h},lv:function(a,b,c){var d=b[b.length-1];return Hogan.compile(a.call(d).toString()).render(d,c)}};var b=/&/g,c=/</g,d=/>/g,e=/\'/g,f=/\"/g,g=/[&<>\"\']/,i=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"};return a}(),Hogan=function(){function g(b,c){function u(){n.length>0&&(o.push(new String(n)),n="")}function v(){var b=!0;for(var c=r;c<o.length;c++){b=o[c].tag&&f[o[c].tag]<f._v||!o[c].tag&&o[c].match(a)===null;if(!b)return!1}return b}function w(a,b){u();if(a&&v())for(var c=r,d;c<o.length;c++)o[c].tag||((d=o[c+1])&&d.tag==">"&&(d.indent=o[c].toString()),o.splice(c,1));else b||o.push({tag:"\n"});p=!1,r=o.length}function x(a,b){var c="="+t,d=a.indexOf(c,b),e=h(a.substring(a.indexOf("=",b)+1,d)).split(" ");return s=e[0],t=e[1],d+c.length-1}var d=b.length,e=0,g=1,j=2,k=e,l=null,m=null,n="",o=[],p=!1,q=0,r=0,s="{{",t="}}";c&&(c=c.split(" "),s=c[0],t=c[1]);for(q=0;q<d;q++)k==e?i(s,b,q)?(--q,u(),k=g):b.charAt(q)=="\n"?w(p):n+=b.charAt(q):k==g?(q+=s.length-1,m=f[b.charAt(q+1)],l=m?b.charAt(q+1):"_v",l=="="?(q=x(b,q),k=e):(m&&q++,k=j),p=q):i(t,b,q)?(o.push({tag:l,n:h(n),otag:s,ctag:t,i:l=="/"?p-t.length:q+s.length}),n="",q+=t.length-1,k=e,l=="{"&&q++):n+=b.charAt(q);return w(p,!0),o}function h(a){return a.trim?a.trim():a.replace(/^\s*|\s*$/g,"")}function i(a,b,c){if(b.charAt(c)!=a.charAt(0))return!1;for(var d=1,e=a.length;d<e;d++)if(b.charAt(c+d)!=a.charAt(d))return!1;return!0}function j(a,b,c,d){var e=[],f=null,g=null;while(a.length>0){g=a.shift();if(g.tag=="#"||g.tag=="^"||k(g,d))c.push(g),g.nodes=j(a,g.tag,c,d),e.push(g);else{if(g.tag=="/"){if(c.length===0)throw new Error("Closing tag without opener: /"+g.n);f=c.pop();if(g.n!=f.n&&!l(g.n,f.n,d))throw new Error("Nesting error: "+f.n+" vs. "+g.n);return f.end=g.i,e}e.push(g)}}if(c.length>0)throw new Error("missing closing tag: "+c.pop().n);return e}function k(a,b){for(var c=0,d=b.length;c<d;c++)if(b[c].o==a.n)return a.tag="#",!0}function l(a,b,c){for(var d=0,e=c.length;d<e;d++)if(c[d].c==a&&c[d].o==b)return!0}function m(a,b,c){var d='i = i || "";var c = [cx];var b = i + "";var _ = this;'+p(a)+"return b;";if(c.asString)return"function(cx,p,i){"+d+";}";var e=new HoganTemplate(b);return e.r=new Function("cx","p","i",d),e}function n(a){return a.replace(e,"\\\\").replace(b,'\\"').replace(c,"\\n").replace(d,"\\r")}function o(a){return~a.indexOf(".")?"d":"f"}function p(a){var b="";for(var c=0,d=a.length;c<d;c++){var e=a[c].tag;e=="#"?b+=q(a[c].nodes,a[c].n,o(a[c].n),a[c].i,a[c].end,a[c].otag+" "+a[c].ctag):e=="^"?b+=r(a[c].nodes,a[c].n,o(a[c].n)):e=="<"||e==">"?b+=s(a[c]):e=="{"||e=="&"?b+=t(a[c].n,o(a[c].n)):e=="\n"?b+=v('"\\n"'+(a.length-1==c?"":" + i")):e=="_v"?b+=u(a[c].n,o(a[c].n)):e===undefined&&(b+=v('"'+n(a[c])+'"'))}return b}function q(a,b,c,d,e,f){return"if(_.s(_."+c+'("'+n(b)+'",c,p,1),'+"c,p,0,"+d+","+e+', "'+f+'")){'+"b += _.rs(c,p,"+'function(c,p){ var b = "";'+p(a)+"return b;});c.pop();}"+'else{b += _.b; _.b = ""};'}function r(a,b,c){return"if (!_.s(_."+c+'("'+n(b)+'",c,p,1),c,p,1,0,0,"")){'+p(a)+"};"}function s(a){return'b += _.rp("'+n(a.n)+'",c[c.length - 1],p,"'+(a.indent||"")+'");'}function t(a,b){return"b += (_."+b+'("'+n(a)+'",c,p,0));'}function u(a,b){return"b += (_.v(_."+b+'("'+n(a)+'",c,p,0)));'}function v(a){return"b += "+a+";"}var a=/\S/,b=/\"/g,c=/\n/g,d=/\r/g,e=/\\/g,f={"#":1,"^":2,"/":3,"!":4,">":5,"<":6,"=":7,_v:8,"{":9,"&":10};return{scan:g,parse:function(a,b){return b=b||{},j(a,"",[],b.sectionTags||[])},cache:{},compile:function(a,b){b=b||{};var c=this.cache[a];return c?c:(c=m(this.parse(g(a,b.delimiters),b),a,b),this.cache[a]=c)}}}();typeof module!="undefined"&&module.exports?(module.exports=Hogan,module.exports.Template=HoganTemplate):typeof define=="function"&&define.amd?define(function(){return Hogan}):typeof exports!="undefined"&&(exports.Hogan=Hogan,exports.HoganTemplate=HoganTemplate)
</script>

<script type="text/javascript">
/*
 * URLs speichern und lesen
 *
 */
(function(){
	conf = {
		getSavedURLs : function(){
			if(this.isConfigured()){
				try{
					var urls = JSON.parse(localStorage.getItem("urls"));
					return urls.length > 0 ? urls : this.getURLs();
				} catch(e){
					return this.getURLs();
				}
			} else {
				return this.getURLs();
			}
		},
		getURLs : function(){
			var array = [], item;
			for(item in urls.mensenWeek) array.push(item);
			return array;
		},
		setURLs : function(urls){
			return localStorage.setItem("urls", JSON.stringify(urls));
		},
		isConfigured : function(urls){
			try{
				return typeof localStorage.getItem("urls") === "string";
			} catch(e){
				return false;
			}
		},
		getMensaInfo : function(){
			var json = [];
			var a = this.getURLs();
			var b = this.getSavedURLs();
			for(i=0; i < a.length; i++){
				json.push({
					"name"   : a[i],
					"active" : b.indexOf(a[i]) != -1
				});
			}
			return json;
		}
	};
})();




/*
 * abstrahiert den Zugriff auf AJAX bzw. lokalen Speicher
 *
 * @TODO:
 * - nächste Woche
 * - globale finden und entfernen
 * - reload neue urls
 * 
 */
 
(function(){ // its a trap!
	storage = {
		weekMenu         : [], // Cache
		filteredWeekMenu : [], // Cache
		lock : [],
		loadedMensen : {},
		menuCallbackQueue : [],
		filters : [],
		filterByMensa : function(item){
			return item.mensaName === args.mensa;
		},
		filterByName : function(item){
			return item.name === args.name;
		},
		filterByDate : function(item){
			return item.date === args.date;
		},
		filter : function(callback){
			this.getWeekMenu(function(){
				var i;
				//copy weekMenu to filteredWeekMenu
				storage.filteredWeekMenu = [];
				for(i=0; i < storage.weekMenu.length; i++){
					storage.filteredWeekMenu.push(storage.weekMenu[i]);
				}
				// filter filteredWeekMenu
				for(i=0; i < storage.filters.length; i++){
					// ? args
					args = storage.filters[i].args;
					storage.filteredWeekMenu = storage.filteredWeekMenu.filter(storage.filters[i].fkt);
				}
				callback(storage.filteredWeekMenu);
			});
		},

		getSortedSegmented : function(callback){
			this.filter(function(json){
				var sorted = json.sort(function(a, b){
					var mensaNameWeight = 0,
					    dateWeight = 0,
					    nameA = a.mensaName.toLowerCase(),
						nameB = b.mensaName.toLowerCase(),
					    dateA = a.date.toLowerCase(),
						dateB = b.date.toLowerCase()
					if (nameA < nameB){
						mensaNameWeight = -10;
					} else if (nameA > nameB) {
						mensaNameWeight =  10;
					}
					if (dateA < dateB){
						dateWeight = -100;
					} else if (dateA > dateB) {
						dateWeight =  100;
					}

					return mensaNameWeight + dateWeight;
				});

				var isDateFilterSet = storage.filters.filter(function(item){
					return item.fkt === storage.filterByDate;
				}).length !== 0;

				var isMensaFilterSet = storage.filters.filter(function(item){
					return item.fkt === storage.filterByMensa;
				}).length !== 0;
			
				var segmented = [], mensaName = "", date = "", i;
				for(i=0; i<sorted.length; i++){
					if(date != sorted[i].date && !isDateFilterSet){
						segmented.push({header:sorted[i].date, type: "header"});
					}
					if(mensaName != sorted[i].mensaName && !isMensaFilterSet){
						segmented.push({header:sorted[i].mensaName, type: "header"});
					}
					sorted[i].type = "item";
					segmented.push(sorted[i]);
					mensaName = sorted[i].mensaName;
					date = sorted[i].date;
				}

				callback(segmented);
			});
		},

		/*
		 * Find and delete Data of urls that are not saved
		 */
		cleanData : function(){
			var validUrls = conf.getSavedURLs();
			this.weekMenu = this.weekMenu.filter(function(item){
				return validUrls.indexOf(item.mensaName) !== -1;
			});
			this.filteredWeekMenu = this.filteredWeekMenu.filter(function(item){
				return validUrls.indexOf(item.mensaName) !== -1;
			});
			
			// cleanup loadedMensen
			for(var mensa in this.loadedMensen){
				this.loadedMensen[mensa] = this.weekMenu.filter(function(item){
					return mensa === item.mensaName;
				}).length > 0
			}

			// unset MensaFilter
			this.unsetMensaFilter();
		},
		
		/*
		 * 
		 * @param function                        !: callback kann mehrfach aufgerufen werden
		 * @return void
		 */
		// @TODO: cleanup vars & documentation
		getWeekMenu : function(callback){
			if(callback) { this.menuCallbackQueue.push(callback);}
			mensenArr = conf.getSavedURLs();
			for(var m = 0; m<mensenArr.length; m++){
				mensa = mensenArr[m];
				if(!this.loadedMensen[mensa] && typeof this.lock[mensa] === "undefined"){
					// lock execution of callback queue to prevent race conditions
					this.lock[mensa] = true;

					// get current Week from date
					var now = new Date();
					var week = now.getWeek();

					// load and parse URL with correct week number
					if(typeof debug !== "undefined" && debug){
						url = urls.mock[mensa].replace(/{{week}}/, week);
					} else {
						url = urls.mensenWeek[mensa].replace(/{{week}}/, week);
					}

					// Trigger AJAX-Call
					xhr.get(url, function(resp, additional_args){
//						console.log("sucess!: " + resp);
						var tds, trs, dish, dishName, date, dateString, obj;
						var tempDiv = document.createElement('div');

						tempDiv.innerHTML = resp.replace(/<img(.|\s)*?\>/g, '').replace(/<script(.|\s)*?\/script>/g, '');

//						console.log(additional_args.mensaName);
						try{
							trs = tempDiv.getElementsByTagName("table")[1].getElementsByTagName("tr");
						} catch(e){
							console.log(resp);
							return;
						}
						// extract and parse date field
						var datefield = trs[0].getElementsByTagName("td")[0].innerText;
						germanStartdate = datefield.split("-")[0].trim();
						germanStartdateArr = germanStartdate.split(".");
						startdate = new Date(germanStartdateArr[2],(germanStartdateArr[1]-1),germanStartdateArr[0]);

						for (var j=2; j<trs.length; j++){ // erste beiden überspringen
							try{
								tds = trs[j].getElementsByTagName("td");
							} catch(e){
								console.log(e);
								continue;
							}

							// Parse Dishname
							dishName = tds[0].innerText.replace(/\s+$/, "").replace(/^\s+/, ""); //trim
							dishName = dishName.replace(/_+$/, ""); //remove trailing underscore

							// Parse dish
							for (var i = 1; i<=5; i++){
								try{
									p = tds[i].getElementsByTagName("p");
								} catch(e){
									console.log(e);
									continue;
								}
						
								for (var k=0; k<p.length; k++){
									// Extract Price
									price = p[k].getElementsByClassName("fliesstextklorange")[0].innerHTML.replace("€","").replace(" ","").split("/");
									studPrice = price[0].replace(/[^0-9,]/g,"");
									normalPrice = price[1].replace(/[^0-9,]/g,"");

									// Parse out dish
									p[k].removeChild(p[k].getElementsByClassName("fliesstextklorange")[0]); // remove price
									dish = p[k].innerText;
									dish = dish.replace(/&nbsp;/g, "").replace(/\s+$/, "").replace(/^\s+/, ""); //trim
									dish = dish.replace(/\(([0-9]+,?)*\)/g, ""); //Zusatzstoffe entfernen


									// Figure out date
									date = new Date(startdate.valueOf() + (i-1) * 24 * 60 * 60 * 1000);
									dateString = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();

									if(dish !== ""){
										storage.weekMenu.push({
											mensaName   : additional_args.mensaName,
											name        : dishName,
											dish        : dish,
											studPrice   : studPrice,
											normalPrice : normalPrice,
											date        : dateString
										});
									}
								}
							}
						}

						// mark as cached
						storage.loadedMensen[additional_args.mensaName] = true;

						// release lock
						delete storage.lock[additional_args.mensaName];
						
						// try to run callbacks
						storage.runMenuCallbacks();
						
					}, function(resp, additional_args){
						console.log("xhr error");

						// release lock
						delete storage.lock[additional_args.mensaName];
						
						// try to run callbacks
						storage.runMenuCallbacks();
					},
					{
						mensaName : mensa
					}
					);
				}
			}
			
			this.runMenuCallbacks();
		},

		runMenuCallbacks : function(){
			// only execute callback queue if all locks are released
			if(isEmpty(this.lock)){
				while (this.menuCallbackQueue.length>0){
					fkt = this.menuCallbackQueue.pop();
					fkt(this.filteredWeekMenu);
				}
				return true;
			} else {
				return false;
			}
		},

		/*
		* list all Types
		*/
		getTypes : function(callback){
			this.getWeekMenu(function(){
				var type, types = {}, typesArr = [];
				for (var i=0; i<storage.weekMenu.length; i++){
					types[storage.weekMenu[i].name] = storage.weekMenu[i].name
				}
				
				for(type in types){
					typesArr.push(type); 
				}
				callback(typesArr);
			});
		},

		/*
		* list all MensaNames
		*/
		getMensen : function(callback){
			console.log("storage.getMensen is depreciated, use conf.getSavedURLs or conf.getMensaInfo");
			callback(conf.getSavedURLs());
		},
		/*
		* list all dates
		*/
		getAvailableDates: function(callback){
			this.getWeekMenu(function(){
				var date, dates = {}, datesArr = [];
				for (var i=0; i<storage.weekMenu.length; i++){
					dates[storage.weekMenu[i].date] = storage.weekMenu[i].date
				}
				
				for(date in dates){
					datesArr.push(date); 
				}
				callback(datesArr.sort());
			});
		},

		getMenuByDate : function(date, callback){
			console.log("getMenuByDate is depreciated");
			this.getWeekMenu(function(){
				storage.filters = [{fkt:storage.filterByDate,args:{date:date}}];
				storage.filter(callback);
			});
		},

		/*
		* get dishes by dish type
		*/
		getByType : function(type, callback){
			console.log("getByType is depreciated")
			this.getWeekMenu(function(){
				storage.filters = [{fkt:storage.filterByType,args:{type:type}}];
				storage.filter(callback);
			});
		},

		/*
		* get dishes by mensa name
		*/
		getByMensa : function(mensa, callback){
			console.log("getByMensa is depreciated "+ mensa);
			this.getWeekMenu(function(){
				storage.filters = [{fkt:storage.filterByMensa,args:{mensa:mensa}}];
				storage.filter(callback);
			});
		},

		/*
		* 
		*/
		setMensaFilter : function(mensa){
			this.unsetMensaFilter();
			storage.filters.push({fkt:storage.filterByMensa,args:{mensa:mensa}});
		},
		/*
		* 
		*/
		unsetMensaFilter : function(){
			storage.filters = storage.filters.filter(function(item){
				return item.fkt !== storage.filterByMensa;
			});
		},

		/*
		* 
		*/
		setNameFilter : function(name){
			this.unsetNameFilter();
			storage.filters.push({fkt:storage.filterByName,args:{name:name}});
		},
		/*
		* 
		*/
		unsetNameFilter : function(){
			storage.filters = storage.filters.filter(function(item){
				return item.fkt !== storage.filterByName;
			});
		},
		
		/*
		* 
		*/
		setDateFilter : function(date){
			this.unsetDateFilter();
			this.filters.push({fkt:this.filterByDate,args:{date:date}});
		},
		/*
		* 
		*/
		unsetDateFilter : function(){
			this.filters = this.filters.filter(function(item){
				return item.fkt !== storage.filterByDate;
			});
		},
		
		/*
		* 
		*/
		unsetFilters : function(){
			this.filters = [];
		},
	}
})();


/* 
 * Mehr oder minder statische Konfigurationsdatei für URLs
 * 
 */
(function(){
	urls = {
		mensen : {
//			"Armgartstraße"         : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Armgartstraße",
//			"Bergedorf"             : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Bergedorf",
//			"<NAME>"          : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Berliner Tor",
//			"<NAME>" : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Bistro Averhoffstraße",
//			"<NAME>"    : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Botanischer Garten",
//			"<NAME>"  : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Café Alexanderstraße",
//			"Finkenau"              : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Finkenau",
//			"Stellingen"            : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Stellingen",
//			"Harburg"               : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Harburg",
			"WIWI"                  : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Campus", 
			"Philo"                 : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Philosophenturm",
			"Geo"                   : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Geomatikum",
			"Schweinemensa"         : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Studierendenhaus"
//			"Physik"                : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Caf%C3%A9%20Jungiusstra%C3%9Fe",
//			"<NAME>"              : "http://www.studierendenwerk-hamburg.de/essen/tag_bls.php?haus=Bucerius%20Law%20School"
//			"Bucerius Law School"   : "http://www.studierendenwerk-hamburg.de/essen/tag.php?haus=Bucerius Law School",
		},
		
		mensenWeek : {
			"Armgartstrasse"         : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Armgartstra%DFe&kw={{week}}",
			"Bergedorf"             : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Bergedorf&kw={{week}}",
			"<NAME>"          : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Berliner Tor&kw={{week}}",
			"<NAME>asse" : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Bistro Averhoffstraße&kw={{week}}",
			"<NAME>"    : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Botanischer Garten&kw={{week}}",
			"<NAME>"  : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Café Alexanderstraße&kw={{week}}",
			"Finkenau"              : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Finkenau&kw={{week}}",
			"Stellingen"            : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Stellingen&kw={{week}}",
			"Harburg"               : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Harburg&kw={{week}}",
			"WIWI"                  : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Campus&kw={{week}}",
			"Philo"                 : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Philosophenturm&kw={{week}}",
			"Geo"                   : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Geomatikum&kw={{week}}",
			"Schweinemensa"         : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Studierendenhaus&kw={{week}}",
			"Physik"                : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=Caf%C3%A9%20Jungiusstra%C3%9Fe&kw={{week}}",
			"Bucerius Law School"   : "http://www.studierendenwerk-hamburg.de/essen/woche_bls.php?haus=Bucerius Law School&kw={{week}}",// "FH Buzze"
			"City Nord"             : "http://www.studierendenwerk-hamburg.de/essen/woche.php?haus=City%20Nord&kw={{week}}"
		},

		mock: {
			"Armgartstrasse"         : "mock/armgardtstrasse.html",
			"Bergedorf"             : "mock/bergedorf.html",
			"<NAME>"          : "mock/berlinertor.html",
			"<NAME>" : "mock/averhoffstrasse.html",
			"<NAME>"    : "mock/botanischergarten.html",
			"<NAME>"  : "mock/alexanderstrasse.html",
			"Finkenau"              : "mock/finkenau.html",
			"Stellingen"            : "mock/stellingen.html",
			"Harburg"               : "mock/harburg.html",
			"WIWI"                  : "mock/campus.html",
			"Philo"                 : "mock/philosophenturm.html",
			"Geo"                   : "mock/geomatikum.html",
			"Schweinemensa"         : "mock/studierendenhaus.html",
			"Physik"                : "mock/jungiusstrasse.html",
			"Bucerius Law School"   : "mock/buzze.html",// "FH Buzze"
			"City Nord"             : "mock/citynord.html"
		}

	}
})();



// http://syn.ac/tech/19/get-the-weeknumber-with-javascript/
Date.prototype.getWeek = function() {
	var determinedate = new Date();
	determinedate.setFullYear(this.getFullYear(), this.getMonth(), this.getDate());
	var D = determinedate.getDay();
	if(D == 0) D = 7;
	determinedate.setDate(determinedate.getDate() + (4 - D));
	var YN = determinedate.getFullYear();
	var ZBDoCY = Math.floor((determinedate.getTime() - new Date(YN, 0, 1, -6)) / 86400000);
	var WN = 1 + Math.floor(ZBDoCY / 7);
	return WN;
}

 function isEmpty(obj) {
    for(var prop in obj) {
        if(obj.hasOwnProperty(prop))
            return false;
    }

    return true;
}
//http://james.padolsey.com/javascript/deep-copying-of-objects-and-arrays/
function deepCopy(o) {
    var copy = o,k;
 
    if (o && typeof o === 'object') {
        copy = Object.prototype.toString.call(o) === '[object Array]' ? [] : {};
        for (k in o) {
            copy[k] = deepCopy(o[k]);
        }
    }
 
    return copy;
}

/*
 * 
 */
function dateToString(isoDate){
	var isoDateArr = isoDate.split("-");
	var date = new Date(isoDateArr[0], isoDateArr[1]-1, isoDateArr[2]);

	var dayNames = ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Sonnabend"];
	var now = new Date();
	if(date.getDate() === now.getDate()){
		dayString = "Heute";
	} else if(date.getDate() === now.getDate()-1){
		dayString = "Gestern";
	} else if(date.getDate() === now.getDate()+1){
		dayString = "Morgen";
	} else {
		dayString = dayNames[date.getDay()];
	}
	return dayString;
}

/*
 * Stellt ein primitives XMLHttpRequest-Interface zur Verfügung
 *
 * */

(function(){
	xhr = {
		get : function(url, success, error, additional_args){
			var xhr = new XMLHttpRequest();
			xhr.open('GET', url, true);
			xhr.onreadystatechange = function () {
				if (xhr.readyState === 4) {
					if(xhr.status === 200){
						success(xhr.responseText, additional_args);
					} else if (xhr.status === 0) {
						success(xhr.responseText, additional_args);
					} else if(typeof error === "function"){
						error(xhr.responseText, additional_args);
					}
				}
			};
			xhr.send(null);
		},
		getJSON : function(url, success, error){
			this.get(url, function(resp){
				success(JSON.parse(resp));
			}, error);
		},
		putJSON : function(url, json, success, error){
			var xhr = new XMLHttpRequest();
			xhr.open('PUT', url, true);
			xhr.onreadystatechange = function () {
				if (xhr.readyState === 4) {
					if(xhr.status === 200){
						success(xhr.responseText);
					}
					else if(typeof error === "function"){
						error(xhr.responseText);
					}
				}
			};
			xhr.setRequestHeader("Content-Type", "application/json");
			xhr.send(JSON.stringify(json));
		}
	};
})();



</script>


	<script type="text/javascript" src="js/conf.js"></script>
	<script type="text/javascript" src="js/storage.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/hogan.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/urls.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/utils.js" charset="utf-8"></script>
	<script type="text/javascript" src="js/xhr.js" charset="utf-8"></script>

    <script type="text/javascript" src="Parts/parts.js" charset="utf-8"></script>
    <script type="text/javascript" src="localizedStrings.js" charset="utf-8"></script>
    <script type="text/javascript" src="main.js" charset="utf-8"></script>

	<script type="text/html" id="mainList">
		{{#json}}
			{{^mensaName}}
				<li class="divider">{{header}}</li>
			{{/mensaName}}
			{{#mensaName}}
				<li id="listRowTemplate" apple-template="true" class="listRowTemplate_template" style="">
					<div id="rowLabel" apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children rowLabel_template" apple-text-overflow="ellipsis">{{dish}}</div>
				</li>
			{{/mensaName}}	
		{{/json}}
	</script>
		
<!--
					<li>
						<h2>{{dish}}</h2>

						<p class="price">{{studPrice}}€</p>
						<p>{{name}}</p>
					</li>
-->

    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleScrollbar.js" charset="utf-8"></script>
    <script type="text/javascript" src="file:///System/Library/WidgetResources/AppleClasses/AppleScrollArea.js" charset="utf-8"></script>
</head>
<body onload="load();" apple-part="com.apple.Dashcode.part.StackLayout">
    <div id="front">
        <img id="frontImg" src="Parts/Images/front.png" alt="" apple-locked="true" apple-part="com.apple.Dashcode.part.frontimage" apple-style="image-theme: 1; image-shape: 3; image-opacity: 1.00; image-top-color: 1.0000,1.0000,1.0000; image-bottom-color: 0.6154,0.6154,0.6154; image-radius: 12,12,12,12; image-border: 1; image-border-color: 0.5294,0.5294,0.5294; image-border-width: 1; shine-strength: 0.9; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 1; shadow-blur: 9.00; shadow-offset: -1.00,-6.00; shadow-color: 0.0000,0.0000,0.0000,0.3333;">
        <div class="apple-no-children" id="info" apple-part="com.apple.Dashcode.part.infobutton" apple-default-image-visibility="hidden"></div>
        <div id="topRectangleShape" apple-part="com.apple.Dashcode.part.toprectangleshape" class="apple-no-children" apple-style="image-theme: 1; image-shape: 9; image-button-type: 3; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.6154,0.6154,0.6154,1; image-radius: 12,12,-1,-1; image-border: 1; image-border-color: 0.5294,0.5294,0.5294,1; image-border-width: 1; shine-strength: 0.90; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 0;"></div>
        <div apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children" id="helloText" apple-group="text" apple-default-image-visibility="hidden" apple-style="part-height-dependent: true;"></div>
        <div id="scrollArea" apple-part="com.apple.Dashcode.part.scrollarea" apple-group="scrollArea">
            <div id="content" class="content" apple-group="scrollArea" style="position: absolute; left: 0px; top: 0px; right: 22px; bottom: 0px; overflow-x: hidden; overflow-y: hidden; ">
                <ul id="list" apple-part="com.apple.Dashcode.part.widgetList" class="">
                    <li id="listRowTemplate" apple-template="true" class="listRowTemplate_template" style="">
                        <div id="rowLabel" apple-part="com.apple.Dashcode.part.text" class="apple-text apple-no-children rowLabel_template" apple-text-overflow="ellipsis"></div>
                    </li>
                </ul>
            </div></div>
        <div id="popup" apple-part="com.apple.Dashcode.part.roundedpopupbutton" class="apple-no-children" apple-style="image-theme: 1; image-shape: 3; image-button-type: 1; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.6154,0.6154,0.6154,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0.5294,0.5294,0.5294,1; image-border-width: 1; shine-strength: 0.90; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 0;"></div>
        <div id="popup1" apple-part="com.apple.Dashcode.part.roundedpopupbutton" class="apple-no-children" apple-style="image-theme: 1; image-shape: 3; image-button-type: 1; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.6154,0.6154,0.6154,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0.5294,0.5294,0.5294,1; image-border-width: 1; shine-strength: 0.90; shine-alpha-level: 0.67; shine-height: 0.50; glass-arc-height: 0.06; shadow-include-shadow: 0;"></div>
    </div>
    <div id="back">
        <img id="backImg" src="Parts/Images/back.png" alt="" apple-locked="true" apple-part="com.apple.Dashcode.part.backimage" apple-style=" image-radius: 12,12,12,12; image-border: 1; image-border-color: 0.1500,0.1500,0.1500; image-border-width: 3; shadow-include-shadow: 1; shadow-blur: 9.00; shadow-offset: -1.00,-6.00; shadow-color: 0.0000,0.0000,0.0000,0.3333;">
        <img src="Images/DevelopedWith.png" alt="Created with Dashcode" id="backDevelopedWith">
        <div id="done" class="apple-no-children" apple-part="com.apple.Dashcode.part.glassbutton"></div>
    </div>
</body>
</html>
{'fraction_non_alphanumeric': 0.21839301405975395, 'fraction_numerical': 0.0257579086115993, 'mean_word_length': 3.733168702885365, 'pattern_counts': {'":': 12, '<': 215, '<?xml version=': 0, '>': 204, 'https://': 0, 'lorem ipsum': 0, 'www.': 35, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1557177', 'n_tokens_mistral': 16017, 'n_tokens_neox': 13798, 'n_words': 1850}