summaryrefslogtreecommitdiff
path: root/wikipedia/views/js/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'wikipedia/views/js/main.js')
-rw-r--r--wikipedia/views/js/main.js64
1 files changed, 25 insertions, 39 deletions
diff --git a/wikipedia/views/js/main.js b/wikipedia/views/js/main.js
index bd76576..531d7fa 100644
--- a/wikipedia/views/js/main.js
+++ b/wikipedia/views/js/main.js
@@ -10,63 +10,49 @@ Endless.Wikipedia = Endless.Wikipedia || {};
$body = $("body"),
$image = $(".image"),
$main = $("#main"),
- $main_wrapper_home = $("#main-wrapper-home"),
- $main_results = $("#main-results"),
- $main_wrapper = $("#main-wrapper"),
$main_content = $("#main-content"),
$inside_content = $("#inside-content"),
$header_content = $("#header-content"),
- $main_wrapper_middle = $("#main-wrapper-middle"),
$wiki_content = $("#wiki_content"),
lang = "pt",
- _resultPageView = function(pageHtml, titlePage, resultError) {
- if (resultError === false) {
- $inside_content.html(pageHtml);
- $header_content.html('<h1>' + titlePage + '</h1>');
- $('#inside-content').prepend('<hr class="hr-title">');
-
- $('#inside-content [src^="//"]').each(function() {
- var parent = $(this).parent();
- if($(this).is("img")){
- var url = $(this).attr("src");
- var theSplit = url.split("/");
- var filename = theSplit[theSplit.length - 2];
- if(filename.length == 2){
- filename = theSplit[theSplit.length - 1];
- }
- var newSrc = "article_images/" + encodeURI(filename)
- if(newSrc.substring(newSrc.length - 4) == ".svg"){
- newSrc += ".png";
- }
- $(this).attr('src', newSrc);
+ _resultPageView = function(image_path) {
+ $('#inside-content [src^="//"]').each(function() {
+ var parent = $(this).parent();
+ if($(this).is("img")){
+ var url = $(this).attr("src");
+ var theSplit = url.split("/");
+ var filename = theSplit[theSplit.length - 2];
+ if(filename.length == 2){
+ filename = theSplit[theSplit.length - 1];
+ }
+ var newSrc = image_path + encodeURI(filename)
+ if(newSrc.substring(newSrc.length - 4) == ".svg"){
+ newSrc += ".png";
}
-
- });
- }
+ $(this).attr('src', newSrc);
+ }
+ });
+ // May need this back at some point
+ // $('link[rel=stylesheet]').each(function(){
+ // var src = $(this).attr("href");
+ // console.log(asset_path + src);
+ // $(this).attr("href", asset_path + "/" + src);
+ // });
},
wresize = function() {
- $main_wrapper_home.height($(window).height());
- $main_results.height($(window).height());
- $main_wrapper.height($(window).height());
- $main_content.height($(window).height() - $("#header-top").outerHeight());
+ $main_content.height($(window).height());
$inside_content.height($main_content.outerHeight() - ($("#header-content").outerHeight() + 15));
- $main_wrapper_home.css("background-size", "100% " + $(window).height() + "px");
- $main_results.css("background-size", "100% " + $(window).height() + "px");
}
return {
init: function() {
$(document).hide();
- $(window).resize(wresize);
- var content = $('#wiki_content').html();
- var title = $('#wiki_content').attr('name');
- _resultPageView(content, title, false);
- $('#wiki_content').remove();
+ var image_path = $inside_content.attr('image_path');
+ _resultPageView(image_path);
wresize();
$(document).show();
-
},
wresize: wresize
};