Skip to content

Commit

Permalink
Merge pull request Transmogrify-for-Plex#2 from sstrang/feature/toggl…
Browse files Browse the repository at this point in the history
…able-original-movie-titles

Add new configuration option for displaying original movie titles on …
  • Loading branch information
sstrang committed Nov 11, 2015
2 parents a346cd9 + 307eca6 commit 54c40d2
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
9 changes: 9 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ function main() {
utils.debug("rotten_tomatoes_link plugin is disabled");
}

// insert original title
if (settings["original_title"] === "on") {
utils.debug("original_title is enabled");
original_title.init(metadata_xml);
}
else {
utils.debug("original_title is disabled");
}

// create trakt link
if (settings["trakt_movies"] === "on") {
utils.debug("trakt plugin is enabled");
Expand Down
1 change: 1 addition & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"plugins/imdb.js",
"plugins/letterboxd.js",
"plugins/missing_episodes.js",
"plugins/original_title.js",
"plugins/random_picker.js",
"plugins/rotten_tomatoes.js",
"plugins/split_added_deck.js",
Expand Down
12 changes: 12 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
</div>
</div>

<div class="field-row">
<div class="label">Show original titles on movie view:</div>

<div class="field">
<input type="radio" id="original_on" name="original_title" value="on"/>
<label for="original_on">ON</label>

<input type="radio" id="original_off" name="original_title" value="off"/>
<label for="original_off">OFF</label>
</div>
</div>

<div class="field-row">
<div class="label">Trakt link:</div>

Expand Down
5 changes: 5 additions & 0 deletions options.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function saveOptions() {
var rotten_tomatoes_link = document.querySelector("input[name='rotten_tomatoes_link']:checked").value;
var rotten_tomatoes_audience = document.querySelector("input[name='rotten_tomatoes_audience']:checked").value;
var rotten_tomatoes_citizen = document.querySelector("input[name='rotten_tomatoes_citizen']:checked").value;
var original_title = document.querySelector("input[name='original_title']:checked").value;
var trakt_movies = document.querySelector("input[name='trakt_movies']").checked;
var trakt_shows = document.querySelector("input[name='trakt_shows']").checked;
var random_picker = document.querySelector("input[name='random_picker']:checked").value;
Expand All @@ -31,6 +32,7 @@ function saveOptions() {
utils.storage_set("rotten_tomatoes_link", rotten_tomatoes_link);
utils.storage_set("rotten_tomatoes_audience", rotten_tomatoes_audience);
utils.storage_set("rotten_tomatoes_citizen", rotten_tomatoes_citizen);
utils.storage_set("original_title", original_title);
utils.storage_set("missing_episodes", missing_episodes);
utils.storage_set("split_added_deck", split_added_deck);
utils.storage_set("canistreamit", canistreamit);
Expand Down Expand Up @@ -104,6 +106,9 @@ function restoreOptions() {
var rotten_tomatoes_citizen_radio_button = document.getElementById("rotten_tomatoes_citizen_" + results["rotten_tomatoes_citizen"]);
rotten_tomatoes_citizen_radio_button.checked = true;

var original_title_radio_button = document.getElementById("original_" + results["original_title"]);
original_title_radio_button.checked = true;

var trakt_movies_checkbox = document.getElementById("trakt_movies");
if (results["trakt_movies"] === "on") {
trakt_movies_checkbox.checked = true;
Expand Down
46 changes: 46 additions & 0 deletions plugins/original_title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
original_title = {
metadata_xml: null,

init: function(metadata_xml) {
original_title.metadata_xml = metadata_xml;

original_title.addTitle();
},

addTitle: function() {
var original_movie_title = original_title.metadata_xml.getElementsByTagName("MediaContainer")[0].getElementsByTagName("Video")[0].getAttribute("originalTitle");
utils.debug("original_title plugin: Got original movie title - " + original_movie_title);

if (original_movie_title) {
original_title.insertOriginalTitle(original_movie_title);
}
},

insertOriginalTitle: function(original_movie_title) {
var original_title_container = original_title.constructOriginalTitleContainer(original_movie_title);

utils.debug("original_title plugin: Inserting original_title container into page");
document.getElementsByClassName("movie-details-row")[0].appendChild(original_title_container);
},

constructOriginalTitleContainer: function(original_movie_title) {
// build details-title-container
var details_title_container_element = document.createElement("div");
details_title_container_element.setAttribute("class", "details-title-container");
details_title_container_element.setAttribute("id", "original-movie-title");
details_title_container_element.setAttribute("style", "margin-top: -88px");

// build item-title
var item_title_element = document.createElement("h1");
item_title_element.setAttribute("class", "item-title");
item_title_element.setAttribute("style", "color: #999; font-size: 24px");

// build text
var title_text = document.createTextNode(original_movie_title);
item_title_element.appendChild(title_text);

details_title_container_element.appendChild(item_title_element);

return details_title_container_element;
}
}
4 changes: 4 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ utils = {
utils.storage_set("imdb_link", "on");
}

if (!("original_title" in settings)) {
utils.storage_set("original_title", "off");
}

if (!("themoviedb_link" in settings)) {
utils.storage_set("themoviedb_link", "on");
}
Expand Down

0 comments on commit 54c40d2

Please sign in to comment.