Commit 4d098c6b authored by Thomas Lechauve's avatar Thomas Lechauve

Fix last commit

Forgot to add modified files
parent 94b89ec8
......@@ -4,15 +4,11 @@ app = Flask(__name__)
@app.route('/')
def index():
return "index"
@app.route('/test-mobile')
def test():
return render_template('test-mobile.html')
return render_template("slapos.html")
@app.route('/request', methods=["POST", "GET"])
def request():
response = make_response("HELLO", 409)
response = make_response("HELLO", 408)
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = '*'
return response
......
......@@ -3,20 +3,34 @@
<head>
<link rel="stylesheet" href="static/css/qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="static/js/modernizr-2.5.3.js"></script>
<script type="text/javascript" src="static/js/qunit.js"></script>
<script type="text/javascript" src="static/js/sinon-1.3.2.js"></script>
<script type="text/javascript" src="static/js/sinon-qunit-1.0.0.js"></script>
<script type="text/javascript" src="static/js/sinon-server-1.3.2.js"></script>
<script type="text/javascript" src="static/js/slapOs.js"></script>
<script type="text/javascript" src="static/js/test.js"></script>
<title>Test Slapos</title>
</head>
<body>
<div class="container">
<h1 id="qunit-header">QUnit SlapOs tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</div>
<section>
<article>
<center>
<form id="connect">
<label for="login">Test on a real server :</label>
<input type="text" id="login" name="login" placeholder="Server url" spellcheck="false" required autofocus="autofocus"/>
<input type="submit" id="submit" value="Go!"/>
</form>
</center>
<div class="container">
<h1 id="qunit-header">QUnit SlapOs tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</div>
</article>
</section>
</body>
\ No newline at end of file
......@@ -7420,6 +7420,7 @@ jQuery.extend({
if ( state === 2 ) {
if ( !responseHeaders ) {
responseHeaders = {};
console.log(responseHeadersString);
while( ( match = rheaders.exec( responseHeadersString ) ) ) {
responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
}
......@@ -7483,7 +7484,6 @@ jQuery.extend({
response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
lastModified,
etag;
// If successful, handle type chaining
if ( status >= 200 && status < 300 || status === 304 ) {
......
(function(window, $) {
;(function($, window, document, undefined) {
var SlapOs = function(elem, options){
this.elem = elem;
this.$elem = $(elem);
......@@ -7,25 +7,52 @@
};
SlapOs.prototype = {
host: '',
defaults: {
host: ''
},
init: function(){
this.config = $.extends({}, this.defaults, this.options, this.metadata);
this.config = $.extend({}, this.defaults, this.options, this.metadata);
this.store = Modernizr.localstorage ? this.lStore : this.cStore;
this.store('host', this.config.host);
return this;
},
/* Local storage method */
lStore: function(name, value){
if(Modernizr.localstorage)
return value == undefined ? window.localStorage[name] : window.localStorage[name] = value;
return false;
},
/* Cookie storage method */
cStore: function(name, value){
if(value != undefined){
document.cookie = name+"="+value+";domain="+window.location.hostname+";path="+window.location.pathname;
}else{
var i,x,y, cookies = document.cookie.split(';');
for(i=0; i<cookies.length; i++){
x = cookies[i].substr(0, cookies[i].indexOf('='));
y = cookies[i].substr(cookies[i].indexOf('=')+1);
x=x.replace(/^\s+|\s+$/g,"");
if(x == name) return unescape(y);
}
}
},
request: function(type, url, callback, data){
data = data || '';
return $.ajax({
url: this.host+url,
$.ajax({
url: this.config.host+url,
dataType: 'json',
data: data,
context: this.$elem,
type: type,
statusCode: {
409: function(){console.log('Status Code : 409')},
},
success: function(data){ callback(data); }
});
}).done(callback).fail(this.failCallback);
},
failCallback: function(jqXHR, textStatus){
//console.log(jqXHR);
},
newInstance: function(data, callback){
......@@ -84,4 +111,5 @@
};
window.SlapOs = SlapOs;
})(window, jQuery);
\ No newline at end of file
})(jQuery, window , document);
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment