Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Partially fix extension not working #13 #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

"icons": { "16": "resources/git-labels-icon-16px.png",
"48": "resources/git-labels-icon-48px.png",
"128": "resources/git-labels-icon-128px.png"
"128": "resources/git-labels-icon-128px.png"
},

"browser_action": {
"default_popup": "src/popup/popup.html"
},

"permissions": [ "https://github.com/*",
"permissions": [ "https://github.com/*",
"http://github.com/*" ],

"content_scripts": [
{
"matches": ["https://github.com/*",
"matches": ["https://github.com/*",
"http://github.com/*" ],

"css": ["libs/semantic/semantic.offline.min.css",
Expand All @@ -42,7 +42,7 @@
"src/uuid-generator/idgenerator.js",
"src/uuid-generator/instanceidgenerator.js",

// Essential Structures
// Essential Structures
"src/label-structures/labelitem.js",
"src/label-structures/groupinfo.js",
"src/label-structures/itemstorage.js",
Expand Down Expand Up @@ -79,8 +79,8 @@
"libs/semantic/resources/jgudjguj.png",
"libs/semantic/resources/wierwurie.png",
"libs/semantic/themes/default/assets/images/flags.png",
"libs/semantic/themes/default/assets/fonts/icons.eot",
"libs/semantic/themes/default/assets/fonts/icons.eot?#iefix",
"libs/semantic/themes/default/assets/fonts/icons.eot",
"libs/semantic/themes/default/assets/fonts/icons.eot?#iefix",
"libs/semantic/themes/default/assets/fonts/icons.svg#icons",
"libs/semantic/themes/default/assets/fonts/icons.ttf",
"libs/semantic/themes/default/assets/fonts/icons.woff",
Expand Down
41 changes: 21 additions & 20 deletions src/page-controllers/existingissuepagecontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var ExistingIssuePageController = function(layoutManager) {
this.sideBarId = "partial-discussion-sidebar";
this.GitLabelNameLocation = ".select-menu-item-text .color-label";
this.GitLabelColorLocation = ".select-menu-item-text .color";
this.GitLabelListItemText = "select-menu-item-text";
this.GitLabelSelectionStatusLocation = ".select-menu-item-text input";
/*
this.storage,
Expand Down Expand Up @@ -115,7 +116,7 @@ ExistingIssuePageController.prototype.handleExternalApplyLabelsEvent = function(

data += ("&" + encodeURIComponent(this.GitLabelFormName) + "=" + encodeURIComponent((item.getFullName())));
}

$.post(postInfo.url, data)
.done(this.handleSuccessfulPostRequest.bind(this))
.fail(this.handleUnsuccessfulPostRequest.bind(this));
Expand Down Expand Up @@ -186,7 +187,7 @@ ExistingIssuePageController.prototype.updateGitFormData = function($parsedRespon
if($newAuthToken.length > 0){
var newAuthTokenValue = $newAuthToken[0].getAttribute("value");
}

return this.replaceGitFormData(newUTF8Value, newMethodValue, newAuthTokenValue);
}

Expand Down Expand Up @@ -233,7 +234,7 @@ ExistingIssuePageController.prototype.processReplyForSideBar = function(reply) {

this.updateGitFormData($reply);

var $newLabelsDisplay = $reply.find(this.GitSelectedLabelsLocation);
var $newLabelsDisplay = $reply.find(this.GitSelectedLabelsLocation);
if($newLabelsDisplay.length <= 0){
return false;
}
Expand Down Expand Up @@ -284,7 +285,7 @@ ExistingIssuePageController.prototype.onUpdatedGitlabelDisplayResponse = functio

this.updateGitFormData($reply);

var $newLabelsDisplay = $reply.find(this.GitSelectedLabelsLocation);
var $newLabelsDisplay = $reply.find(this.GitSelectedLabelsLocation);
if($newLabelsDisplay.length <= 0){
return false;
}
Expand Down Expand Up @@ -351,7 +352,7 @@ ExistingIssuePageController.prototype.recoverLabelsInGitDOM = function(data) {
}

ExistingIssuePageController.prototype.processGETResponse = function(data) {

if(this.layoutManager){
this.recoverLabelsInGitDOM(data);
this.storage = this.getLabelsFromDOM();
Expand Down Expand Up @@ -384,7 +385,7 @@ ExistingIssuePageController.prototype.retrieveLabelsFromGETRequest = function()
}

ExistingIssuePageController.prototype.processInitialGETResponse = function(data, updateType) {

if(this.layoutManager){
this.recoverLabelsInGitDOM(data);
this.storage = this.getLabelsFromDOM();
Expand Down Expand Up @@ -437,22 +438,22 @@ ExistingIssuePageController.prototype.getLabelsFromDOM = function() {

var item = items[i];

var nameNode = item.querySelector(this.GitLabelNameLocation);
if(!nameNode){
let nameNode = item.getElementsByClassName(this.GitLabelListItemText)[0].getElementsByTagName("input")[0];
if(!nameNode) {
continue;
}

var name = nameNode.getAttribute("data-name");
let name = nameNode.getAttribute("data-label-name");
if(!name){
continue;
}

var colorNode = item.querySelector(this.GitLabelColorLocation);
let colorNode = item.getElementsByClassName("float-left")[0];
if(!colorNode){
continue;
}
var color = colorNode.style.backgroundColor;

let color = colorNode.style.backgroundColor;
if(!color){
continue;
}
Expand Down Expand Up @@ -487,20 +488,20 @@ ExistingIssuePageController.prototype.runWithoutPusher = function() {

pusher = document.createElement("div");
pusher.classList.add("pusher");
document.body.prepend(pusher);
document.body.prepend(pusher);

this.bodyObserver = new MutationObserver(processBodyMutations);
this.bodyObserver.observe(document.body, {childList:true});
document.removeEventListener('DOMContentLoaded', this.stopBodyObserver.bind(this));
document.addEventListener('DOMContentLoaded', this.stopBodyObserver.bind(this));

processBodyMutations();

function processBodyMutations() {
var children = document.body.children;
for(var i = 0, sz = children.length; i < sz;){
var child = children[i];
if(child.tagName === "SCRIPT" || child === pusher
if(child.tagName === "SCRIPT" || child === pusher
|| child.classList.contains("git-flash-labels-sidebar")
|| child.classList.contains("git-flash-labels-sidebar-launch-button") ){
++i;
Expand All @@ -519,7 +520,7 @@ ExistingIssuePageController.prototype.processPage = function() {
}

this.bodyObserver = null;

if(!document.body.querySelector(".pusher")){
this.runWithoutPusher();
}
Expand All @@ -540,8 +541,8 @@ ExistingIssuePageController.prototype.partialRun = function(runParams, layoutMan
if(!runParams.a && this.hasPermissionToManageLabels()){
this.layoutManager = layoutManager;
runParams.a = true;
}
}

if(!runParams.a){
if(isEnd) {
this.layoutManager = null;
Expand Down Expand Up @@ -655,7 +656,7 @@ ExistingIssuePageController.prototype.attachGitSideBarObserver = function() {
for(var i = 0; i < mutations.length; ++i){
this.overrideLabelButtonListeners();
this.updateUI(mutations[i]);
}
}
}.bind(this));

this.sideBarObserver.observe(gitSideBar, { childList: true });
Expand Down Expand Up @@ -733,4 +734,4 @@ ExistingIssuePageController.prototype.updateUI = function(mutation) {
}
}
return this.retrieveLabelsFromGETRequest();
}
}
46 changes: 22 additions & 24 deletions src/page-controllers/newissuepagecontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var NewIssuePageController = function() {
this.GitLabelFormName = "issue[labels][]";
this.GitLabelListLocation = ".sidebar-labels .select-menu-modal-holder .select-menu-list";
this.GitLabelListItemClassName = "select-menu-item";
this.GitLabelListItemText = "select-menu-item-text";
this.GitLabelListItemExactLocation = ".select-menu-item";
/*
this.storage,
Expand Down Expand Up @@ -228,33 +229,30 @@ NewIssuePageController.prototype.getLabelsFromDOM = function() {
if(!list){
return null;
}

var labels = list.getElementsByClassName(this.GitLabelListItemClassName);

var labels = list.getElementsByClassName(this.GitLabelListItemClassName);
var storage = new ItemStorage();
for( var i = 0; i < labels.length; ++i ) {

let label = labels[i];
let label = labels[i];

let nameNode = label.querySelector(".color-label");
if(!nameNode){
continue;
}
let nameNode = label.getElementsByClassName(this.GitLabelListItemText)[0].getElementsByTagName("input")[0];
if(!nameNode) {
continue;
}

let itemName = nameNode.getAttribute("data-name");;
if(!itemName){
continue;
}
let itemName = nameNode.getAttribute("data-label-name");

let colorNode = label.querySelector(".color");
if(!colorNode){
continue;
}
let colorNode = label.getElementsByClassName("float-left")[0];
if(!colorNode){
continue;
}

let itemColor = colorNode.style.backgroundColor;
if(!itemColor){
continue;
}

let itemColor = colorNode.style.backgroundColor;
if(!itemColor){
continue;
}

var isItemSelected = label.classList.contains("selected");
storage.addItem(new LabelItem(itemName, itemColor, isItemSelected));
Expand Down Expand Up @@ -301,20 +299,20 @@ NewIssuePageController.prototype.runWithoutPusher = function() {

pusher = document.createElement("div");
pusher.classList.add("pusher");
document.body.prepend(pusher);
document.body.prepend(pusher);

this.bodyObserver = new MutationObserver(processBodyMutations);
this.bodyObserver.observe(document.body, {childList:true});
document.removeEventListener('DOMContentLoaded', this.stopBodyObserver.bind(this));
document.addEventListener('DOMContentLoaded', this.stopBodyObserver.bind(this));

processBodyMutations();

function processBodyMutations() {
var children = document.body.children;
for(var i = 0, sz = children.length; i < sz;){
var child = children[i];
if(child.tagName === "SCRIPT" || child === pusher
if(child.tagName === "SCRIPT" || child === pusher
|| child.classList.contains("git-flash-labels-sidebar")
|| child.classList.contains("git-flash-labels-sidebar-launch-button") ){
++i;
Expand All @@ -333,7 +331,7 @@ NewIssuePageController.prototype.processPage = function() {
}

this.bodyObserver = null;

if(!document.body.querySelector(".pusher")){
this.runWithoutPusher();
}
Expand Down Expand Up @@ -417,4 +415,4 @@ NewIssuePageController.prototype.run = function(layoutManager) {
this.cleanup();
}
}
}
}